documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698
  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 `muted` to video, if specified
  35263. */
  35264. muted?: boolean;
  35265. /**
  35266. * Applies `loop` to video, if specified
  35267. */
  35268. loop?: boolean;
  35269. /**
  35270. * Automatically updates internal texture from video at every frame in the render loop
  35271. */
  35272. autoUpdateTexture: boolean;
  35273. /**
  35274. * Image src displayed during the video loading or until the user interacts with the video.
  35275. */
  35276. poster?: string;
  35277. }
  35278. /**
  35279. * If you want to display a video in your scene, this is the special texture for that.
  35280. * This special texture works similar to other textures, with the exception of a few parameters.
  35281. * @see https://doc.babylonjs.com/how_to/video_texture
  35282. */
  35283. export class VideoTexture extends Texture {
  35284. /**
  35285. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35286. */
  35287. readonly autoUpdateTexture: boolean;
  35288. /**
  35289. * The video instance used by the texture internally
  35290. */
  35291. readonly video: HTMLVideoElement;
  35292. private _onUserActionRequestedObservable;
  35293. /**
  35294. * Event triggerd when a dom action is required by the user to play the video.
  35295. * This happens due to recent changes in browser policies preventing video to auto start.
  35296. */
  35297. get onUserActionRequestedObservable(): Observable<Texture>;
  35298. private _generateMipMaps;
  35299. private _stillImageCaptured;
  35300. private _displayingPosterTexture;
  35301. private _settings;
  35302. private _createInternalTextureOnEvent;
  35303. private _frameId;
  35304. private _currentSrc;
  35305. /**
  35306. * Creates a video texture.
  35307. * If you want to display a video in your scene, this is the special texture for that.
  35308. * This special texture works similar to other textures, with the exception of a few parameters.
  35309. * @see https://doc.babylonjs.com/how_to/video_texture
  35310. * @param name optional name, will detect from video source, if not defined
  35311. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35312. * @param scene is obviously the current scene.
  35313. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35314. * @param invertY is false by default but can be used to invert video on Y axis
  35315. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35316. * @param settings allows finer control over video usage
  35317. */
  35318. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35319. private _getName;
  35320. private _getVideo;
  35321. private _createInternalTexture;
  35322. private reset;
  35323. /**
  35324. * @hidden Internal method to initiate `update`.
  35325. */
  35326. _rebuild(): void;
  35327. /**
  35328. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35329. */
  35330. update(): void;
  35331. /**
  35332. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35333. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35334. */
  35335. updateTexture(isVisible: boolean): void;
  35336. protected _updateInternalTexture: () => void;
  35337. /**
  35338. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35339. * @param url New url.
  35340. */
  35341. updateURL(url: string): void;
  35342. /**
  35343. * Clones the texture.
  35344. * @returns the cloned texture
  35345. */
  35346. clone(): VideoTexture;
  35347. /**
  35348. * Dispose the texture and release its associated resources.
  35349. */
  35350. dispose(): void;
  35351. /**
  35352. * Creates a video texture straight from a stream.
  35353. * @param scene Define the scene the texture should be created in
  35354. * @param stream Define the stream the texture should be created from
  35355. * @returns The created video texture as a promise
  35356. */
  35357. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35358. /**
  35359. * Creates a video texture straight from your WebCam video feed.
  35360. * @param scene Define the scene the texture should be created in
  35361. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35362. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35363. * @returns The created video texture as a promise
  35364. */
  35365. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35366. minWidth: number;
  35367. maxWidth: number;
  35368. minHeight: number;
  35369. maxHeight: number;
  35370. deviceId: string;
  35371. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35372. /**
  35373. * Creates a video texture straight from your WebCam video feed.
  35374. * @param scene Define the scene the texture should be created in
  35375. * @param onReady Define a callback to triggered once the texture will be ready
  35376. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35377. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35378. */
  35379. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35380. minWidth: number;
  35381. maxWidth: number;
  35382. minHeight: number;
  35383. maxHeight: number;
  35384. deviceId: string;
  35385. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35386. }
  35387. }
  35388. declare module BABYLON {
  35389. /**
  35390. * Defines the interface used by objects working like Scene
  35391. * @hidden
  35392. */
  35393. export interface ISceneLike {
  35394. _addPendingData(data: any): void;
  35395. _removePendingData(data: any): void;
  35396. offlineProvider: IOfflineProvider;
  35397. }
  35398. /**
  35399. * Information about the current host
  35400. */
  35401. export interface HostInformation {
  35402. /**
  35403. * Defines if the current host is a mobile
  35404. */
  35405. isMobile: boolean;
  35406. }
  35407. /** Interface defining initialization parameters for Engine class */
  35408. export interface EngineOptions extends WebGLContextAttributes {
  35409. /**
  35410. * Defines if the engine should no exceed a specified device ratio
  35411. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35412. */
  35413. limitDeviceRatio?: number;
  35414. /**
  35415. * Defines if webvr should be enabled automatically
  35416. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35417. */
  35418. autoEnableWebVR?: boolean;
  35419. /**
  35420. * Defines if webgl2 should be turned off even if supported
  35421. * @see https://doc.babylonjs.com/features/webgl2
  35422. */
  35423. disableWebGL2Support?: boolean;
  35424. /**
  35425. * Defines if webaudio should be initialized as well
  35426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35427. */
  35428. audioEngine?: boolean;
  35429. /**
  35430. * Defines if animations should run using a deterministic lock step
  35431. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35432. */
  35433. deterministicLockstep?: boolean;
  35434. /** Defines the maximum steps to use with deterministic lock step mode */
  35435. lockstepMaxSteps?: number;
  35436. /** Defines the seconds between each deterministic lock step */
  35437. timeStep?: number;
  35438. /**
  35439. * Defines that engine should ignore context lost events
  35440. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35441. */
  35442. doNotHandleContextLost?: boolean;
  35443. /**
  35444. * Defines that engine should ignore modifying touch action attribute and style
  35445. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35446. */
  35447. doNotHandleTouchAction?: boolean;
  35448. /**
  35449. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35450. */
  35451. useHighPrecisionFloats?: boolean;
  35452. /**
  35453. * Make the canvas XR Compatible for XR sessions
  35454. */
  35455. xrCompatible?: boolean;
  35456. /**
  35457. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35458. */
  35459. useHighPrecisionMatrix?: boolean;
  35460. /**
  35461. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  35462. */
  35463. failIfMajorPerformanceCaveat?: boolean;
  35464. }
  35465. /**
  35466. * The base engine class (root of all engines)
  35467. */
  35468. export class ThinEngine {
  35469. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35470. static ExceptionList: ({
  35471. key: string;
  35472. capture: string;
  35473. captureConstraint: number;
  35474. targets: string[];
  35475. } | {
  35476. key: string;
  35477. capture: null;
  35478. captureConstraint: null;
  35479. targets: string[];
  35480. })[];
  35481. /** @hidden */
  35482. static _TextureLoaders: IInternalTextureLoader[];
  35483. /**
  35484. * Returns the current npm package of the sdk
  35485. */
  35486. static get NpmPackage(): string;
  35487. /**
  35488. * Returns the current version of the framework
  35489. */
  35490. static get Version(): string;
  35491. /**
  35492. * Returns a string describing the current engine
  35493. */
  35494. get description(): string;
  35495. /**
  35496. * Gets or sets the epsilon value used by collision engine
  35497. */
  35498. static CollisionsEpsilon: number;
  35499. /**
  35500. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35501. */
  35502. static get ShadersRepository(): string;
  35503. static set ShadersRepository(value: string);
  35504. /** @hidden */
  35505. _shaderProcessor: IShaderProcessor;
  35506. /**
  35507. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35508. */
  35509. forcePOTTextures: boolean;
  35510. /**
  35511. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35512. */
  35513. isFullscreen: boolean;
  35514. /**
  35515. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35516. */
  35517. cullBackFaces: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35520. */
  35521. renderEvenInBackground: boolean;
  35522. /**
  35523. * Gets or sets a boolean indicating that cache can be kept between frames
  35524. */
  35525. preventCacheWipeBetweenFrames: boolean;
  35526. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35527. validateShaderPrograms: boolean;
  35528. /**
  35529. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35530. * This can provide greater z depth for distant objects.
  35531. */
  35532. useReverseDepthBuffer: boolean;
  35533. /**
  35534. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35535. */
  35536. disableUniformBuffers: boolean;
  35537. /** @hidden */
  35538. _uniformBuffers: UniformBuffer[];
  35539. /**
  35540. * Gets a boolean indicating that the engine supports uniform buffers
  35541. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35542. */
  35543. get supportsUniformBuffers(): boolean;
  35544. /** @hidden */
  35545. _gl: WebGLRenderingContext;
  35546. /** @hidden */
  35547. _webGLVersion: number;
  35548. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35549. protected _windowIsBackground: boolean;
  35550. protected _creationOptions: EngineOptions;
  35551. protected _highPrecisionShadersAllowed: boolean;
  35552. /** @hidden */
  35553. get _shouldUseHighPrecisionShader(): boolean;
  35554. /**
  35555. * Gets a boolean indicating that only power of 2 textures are supported
  35556. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35557. */
  35558. get needPOTTextures(): boolean;
  35559. /** @hidden */
  35560. _badOS: boolean;
  35561. /** @hidden */
  35562. _badDesktopOS: boolean;
  35563. private _hardwareScalingLevel;
  35564. /** @hidden */
  35565. _caps: EngineCapabilities;
  35566. private _isStencilEnable;
  35567. private _glVersion;
  35568. private _glRenderer;
  35569. private _glVendor;
  35570. /** @hidden */
  35571. _videoTextureSupported: boolean;
  35572. protected _renderingQueueLaunched: boolean;
  35573. protected _activeRenderLoops: (() => void)[];
  35574. /**
  35575. * Observable signaled when a context lost event is raised
  35576. */
  35577. onContextLostObservable: Observable<ThinEngine>;
  35578. /**
  35579. * Observable signaled when a context restored event is raised
  35580. */
  35581. onContextRestoredObservable: Observable<ThinEngine>;
  35582. private _onContextLost;
  35583. private _onContextRestored;
  35584. protected _contextWasLost: boolean;
  35585. /** @hidden */
  35586. _doNotHandleContextLost: boolean;
  35587. /**
  35588. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35590. */
  35591. get doNotHandleContextLost(): boolean;
  35592. set doNotHandleContextLost(value: boolean);
  35593. /**
  35594. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35595. */
  35596. disableVertexArrayObjects: boolean;
  35597. /** @hidden */
  35598. protected _colorWrite: boolean;
  35599. /** @hidden */
  35600. protected _colorWriteChanged: boolean;
  35601. /** @hidden */
  35602. protected _depthCullingState: DepthCullingState;
  35603. /** @hidden */
  35604. protected _stencilState: StencilState;
  35605. /** @hidden */
  35606. _alphaState: AlphaState;
  35607. /** @hidden */
  35608. _alphaMode: number;
  35609. /** @hidden */
  35610. _alphaEquation: number;
  35611. /** @hidden */
  35612. _internalTexturesCache: InternalTexture[];
  35613. /** @hidden */
  35614. protected _activeChannel: number;
  35615. private _currentTextureChannel;
  35616. /** @hidden */
  35617. protected _boundTexturesCache: {
  35618. [key: string]: Nullable<InternalTexture>;
  35619. };
  35620. /** @hidden */
  35621. protected _currentEffect: Nullable<Effect>;
  35622. /** @hidden */
  35623. protected _currentProgram: Nullable<WebGLProgram>;
  35624. private _compiledEffects;
  35625. private _vertexAttribArraysEnabled;
  35626. /** @hidden */
  35627. protected _cachedViewport: Nullable<IViewportLike>;
  35628. private _cachedVertexArrayObject;
  35629. /** @hidden */
  35630. protected _cachedVertexBuffers: any;
  35631. /** @hidden */
  35632. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35633. /** @hidden */
  35634. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35635. /** @hidden */
  35636. _currentRenderTarget: Nullable<InternalTexture>;
  35637. private _uintIndicesCurrentlySet;
  35638. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35639. /** @hidden */
  35640. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35641. /** @hidden */
  35642. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35643. private _currentBufferPointers;
  35644. private _currentInstanceLocations;
  35645. private _currentInstanceBuffers;
  35646. private _textureUnits;
  35647. /** @hidden */
  35648. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35649. /** @hidden */
  35650. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35651. /** @hidden */
  35652. _boundRenderFunction: any;
  35653. private _vaoRecordInProgress;
  35654. private _mustWipeVertexAttributes;
  35655. private _emptyTexture;
  35656. private _emptyCubeTexture;
  35657. private _emptyTexture3D;
  35658. private _emptyTexture2DArray;
  35659. /** @hidden */
  35660. _frameHandler: number;
  35661. private _nextFreeTextureSlots;
  35662. private _maxSimultaneousTextures;
  35663. private _activeRequests;
  35664. /** @hidden */
  35665. _transformTextureUrl: Nullable<(url: string) => string>;
  35666. /**
  35667. * Gets information about the current host
  35668. */
  35669. hostInformation: HostInformation;
  35670. protected get _supportsHardwareTextureRescaling(): boolean;
  35671. private _framebufferDimensionsObject;
  35672. /**
  35673. * sets the object from which width and height will be taken from when getting render width and height
  35674. * Will fallback to the gl object
  35675. * @param dimensions the framebuffer width and height that will be used.
  35676. */
  35677. set framebufferDimensionsObject(dimensions: Nullable<{
  35678. framebufferWidth: number;
  35679. framebufferHeight: number;
  35680. }>);
  35681. /**
  35682. * Gets the current viewport
  35683. */
  35684. get currentViewport(): Nullable<IViewportLike>;
  35685. /**
  35686. * Gets the default empty texture
  35687. */
  35688. get emptyTexture(): InternalTexture;
  35689. /**
  35690. * Gets the default empty 3D texture
  35691. */
  35692. get emptyTexture3D(): InternalTexture;
  35693. /**
  35694. * Gets the default empty 2D array texture
  35695. */
  35696. get emptyTexture2DArray(): InternalTexture;
  35697. /**
  35698. * Gets the default empty cube texture
  35699. */
  35700. get emptyCubeTexture(): InternalTexture;
  35701. /**
  35702. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35703. */
  35704. readonly premultipliedAlpha: boolean;
  35705. /**
  35706. * Observable event triggered before each texture is initialized
  35707. */
  35708. onBeforeTextureInitObservable: Observable<Texture>;
  35709. /**
  35710. * Creates a new engine
  35711. * @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
  35712. * @param antialias defines enable antialiasing (default: false)
  35713. * @param options defines further options to be sent to the getContext() function
  35714. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35715. */
  35716. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35717. private _rebuildInternalTextures;
  35718. private _rebuildEffects;
  35719. /**
  35720. * Gets a boolean indicating if all created effects are ready
  35721. * @returns true if all effects are ready
  35722. */
  35723. areAllEffectsReady(): boolean;
  35724. protected _rebuildBuffers(): void;
  35725. protected _initGLContext(): void;
  35726. /**
  35727. * Gets version of the current webGL context
  35728. */
  35729. get webGLVersion(): number;
  35730. /**
  35731. * Gets a string identifying the name of the class
  35732. * @returns "Engine" string
  35733. */
  35734. getClassName(): string;
  35735. /**
  35736. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35737. */
  35738. get isStencilEnable(): boolean;
  35739. /** @hidden */
  35740. _prepareWorkingCanvas(): void;
  35741. /**
  35742. * Reset the texture cache to empty state
  35743. */
  35744. resetTextureCache(): void;
  35745. /**
  35746. * Gets an object containing information about the current webGL context
  35747. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35748. */
  35749. getGlInfo(): {
  35750. vendor: string;
  35751. renderer: string;
  35752. version: string;
  35753. };
  35754. /**
  35755. * Defines the hardware scaling level.
  35756. * By default the hardware scaling level is computed from the window device ratio.
  35757. * 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.
  35758. * @param level defines the level to use
  35759. */
  35760. setHardwareScalingLevel(level: number): void;
  35761. /**
  35762. * Gets the current hardware scaling level.
  35763. * By default the hardware scaling level is computed from the window device ratio.
  35764. * 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.
  35765. * @returns a number indicating the current hardware scaling level
  35766. */
  35767. getHardwareScalingLevel(): number;
  35768. /**
  35769. * Gets the list of loaded textures
  35770. * @returns an array containing all loaded textures
  35771. */
  35772. getLoadedTexturesCache(): InternalTexture[];
  35773. /**
  35774. * Gets the object containing all engine capabilities
  35775. * @returns the EngineCapabilities object
  35776. */
  35777. getCaps(): EngineCapabilities;
  35778. /**
  35779. * stop executing a render loop function and remove it from the execution array
  35780. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35781. */
  35782. stopRenderLoop(renderFunction?: () => void): void;
  35783. /** @hidden */
  35784. _renderLoop(): void;
  35785. /**
  35786. * Gets the HTML canvas attached with the current webGL context
  35787. * @returns a HTML canvas
  35788. */
  35789. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35790. /**
  35791. * Gets host window
  35792. * @returns the host window object
  35793. */
  35794. getHostWindow(): Nullable<Window>;
  35795. /**
  35796. * Gets the current render width
  35797. * @param useScreen defines if screen size must be used (or the current render target if any)
  35798. * @returns a number defining the current render width
  35799. */
  35800. getRenderWidth(useScreen?: boolean): number;
  35801. /**
  35802. * Gets the current render height
  35803. * @param useScreen defines if screen size must be used (or the current render target if any)
  35804. * @returns a number defining the current render height
  35805. */
  35806. getRenderHeight(useScreen?: boolean): number;
  35807. /**
  35808. * Can be used to override the current requestAnimationFrame requester.
  35809. * @hidden
  35810. */
  35811. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35812. /**
  35813. * Register and execute a render loop. The engine can have more than one render function
  35814. * @param renderFunction defines the function to continuously execute
  35815. */
  35816. runRenderLoop(renderFunction: () => void): void;
  35817. /**
  35818. * Clear the current render buffer or the current render target (if any is set up)
  35819. * @param color defines the color to use
  35820. * @param backBuffer defines if the back buffer must be cleared
  35821. * @param depth defines if the depth buffer must be cleared
  35822. * @param stencil defines if the stencil buffer must be cleared
  35823. */
  35824. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35825. private _viewportCached;
  35826. /** @hidden */
  35827. _viewport(x: number, y: number, width: number, height: number): void;
  35828. /**
  35829. * Set the WebGL's viewport
  35830. * @param viewport defines the viewport element to be used
  35831. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35832. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35833. */
  35834. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35835. /**
  35836. * Begin a new frame
  35837. */
  35838. beginFrame(): void;
  35839. /**
  35840. * Enf the current frame
  35841. */
  35842. endFrame(): void;
  35843. /**
  35844. * Resize the view according to the canvas' size
  35845. */
  35846. resize(): void;
  35847. /**
  35848. * Force a specific size of the canvas
  35849. * @param width defines the new canvas' width
  35850. * @param height defines the new canvas' height
  35851. * @returns true if the size was changed
  35852. */
  35853. setSize(width: number, height: number): boolean;
  35854. /**
  35855. * Binds the frame buffer to the specified texture.
  35856. * @param texture The texture to render to or null for the default canvas
  35857. * @param faceIndex The face of the texture to render to in case of cube texture
  35858. * @param requiredWidth The width of the target to render to
  35859. * @param requiredHeight The height of the target to render to
  35860. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35861. * @param lodLevel defines the lod level to bind to the frame buffer
  35862. * @param layer defines the 2d array index to bind to frame buffer to
  35863. */
  35864. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35865. /** @hidden */
  35866. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35867. /**
  35868. * Unbind the current render target texture from the webGL context
  35869. * @param texture defines the render target texture to unbind
  35870. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35871. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35872. */
  35873. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35874. /**
  35875. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35876. */
  35877. flushFramebuffer(): void;
  35878. /**
  35879. * Unbind the current render target and bind the default framebuffer
  35880. */
  35881. restoreDefaultFramebuffer(): void;
  35882. /** @hidden */
  35883. protected _resetVertexBufferBinding(): void;
  35884. /**
  35885. * Creates a vertex buffer
  35886. * @param data the data for the vertex buffer
  35887. * @returns the new WebGL static buffer
  35888. */
  35889. createVertexBuffer(data: DataArray): DataBuffer;
  35890. private _createVertexBuffer;
  35891. /**
  35892. * Creates a dynamic vertex buffer
  35893. * @param data the data for the dynamic vertex buffer
  35894. * @returns the new WebGL dynamic buffer
  35895. */
  35896. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35897. protected _resetIndexBufferBinding(): void;
  35898. /**
  35899. * Creates a new index buffer
  35900. * @param indices defines the content of the index buffer
  35901. * @param updatable defines if the index buffer must be updatable
  35902. * @returns a new webGL buffer
  35903. */
  35904. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35905. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35906. /**
  35907. * Bind a webGL buffer to the webGL context
  35908. * @param buffer defines the buffer to bind
  35909. */
  35910. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35911. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35912. private bindBuffer;
  35913. /**
  35914. * update the bound buffer with the given data
  35915. * @param data defines the data to update
  35916. */
  35917. updateArrayBuffer(data: Float32Array): void;
  35918. private _vertexAttribPointer;
  35919. /** @hidden */
  35920. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35921. private _bindVertexBuffersAttributes;
  35922. /**
  35923. * Records a vertex array object
  35924. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35925. * @param vertexBuffers defines the list of vertex buffers to store
  35926. * @param indexBuffer defines the index buffer to store
  35927. * @param effect defines the effect to store
  35928. * @returns the new vertex array object
  35929. */
  35930. recordVertexArrayObject(vertexBuffers: {
  35931. [key: string]: VertexBuffer;
  35932. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35933. /**
  35934. * Bind a specific vertex array object
  35935. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35936. * @param vertexArrayObject defines the vertex array object to bind
  35937. * @param indexBuffer defines the index buffer to bind
  35938. */
  35939. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35940. /**
  35941. * Bind webGl buffers directly to the webGL context
  35942. * @param vertexBuffer defines the vertex buffer to bind
  35943. * @param indexBuffer defines the index buffer to bind
  35944. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35945. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35946. * @param effect defines the effect associated with the vertex buffer
  35947. */
  35948. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35949. private _unbindVertexArrayObject;
  35950. /**
  35951. * Bind a list of vertex buffers to the webGL context
  35952. * @param vertexBuffers defines the list of vertex buffers to bind
  35953. * @param indexBuffer defines the index buffer to bind
  35954. * @param effect defines the effect associated with the vertex buffers
  35955. */
  35956. bindBuffers(vertexBuffers: {
  35957. [key: string]: Nullable<VertexBuffer>;
  35958. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35959. /**
  35960. * Unbind all instance attributes
  35961. */
  35962. unbindInstanceAttributes(): void;
  35963. /**
  35964. * Release and free the memory of a vertex array object
  35965. * @param vao defines the vertex array object to delete
  35966. */
  35967. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35968. /** @hidden */
  35969. _releaseBuffer(buffer: DataBuffer): boolean;
  35970. protected _deleteBuffer(buffer: DataBuffer): void;
  35971. /**
  35972. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35973. * @param instancesBuffer defines the webGL buffer to update and bind
  35974. * @param data defines the data to store in the buffer
  35975. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35976. */
  35977. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35978. /**
  35979. * Bind the content of a webGL buffer used with instantiation
  35980. * @param instancesBuffer defines the webGL buffer to bind
  35981. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35982. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35983. */
  35984. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35985. /**
  35986. * Disable the instance attribute corresponding to the name in parameter
  35987. * @param name defines the name of the attribute to disable
  35988. */
  35989. disableInstanceAttributeByName(name: string): void;
  35990. /**
  35991. * Disable the instance attribute corresponding to the location in parameter
  35992. * @param attributeLocation defines the attribute location of the attribute to disable
  35993. */
  35994. disableInstanceAttribute(attributeLocation: number): void;
  35995. /**
  35996. * Disable the attribute corresponding to the location in parameter
  35997. * @param attributeLocation defines the attribute location of the attribute to disable
  35998. */
  35999. disableAttributeByIndex(attributeLocation: number): void;
  36000. /**
  36001. * Send a draw order
  36002. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36003. * @param indexStart defines the starting index
  36004. * @param indexCount defines the number of index to draw
  36005. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36006. */
  36007. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36008. /**
  36009. * Draw a list of points
  36010. * @param verticesStart defines the index of first vertex to draw
  36011. * @param verticesCount defines the count of vertices to draw
  36012. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36013. */
  36014. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36015. /**
  36016. * Draw a list of unindexed primitives
  36017. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36018. * @param verticesStart defines the index of first vertex to draw
  36019. * @param verticesCount defines the count of vertices to draw
  36020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36021. */
  36022. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36023. /**
  36024. * Draw a list of indexed primitives
  36025. * @param fillMode defines the primitive to use
  36026. * @param indexStart defines the starting index
  36027. * @param indexCount defines the number of index to draw
  36028. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36029. */
  36030. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36031. /**
  36032. * Draw a list of unindexed primitives
  36033. * @param fillMode defines the primitive to use
  36034. * @param verticesStart defines the index of first vertex to draw
  36035. * @param verticesCount defines the count of vertices to draw
  36036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36037. */
  36038. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36039. private _drawMode;
  36040. /** @hidden */
  36041. protected _reportDrawCall(): void;
  36042. /** @hidden */
  36043. _releaseEffect(effect: Effect): void;
  36044. /** @hidden */
  36045. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36046. /**
  36047. * Create a new effect (used to store vertex/fragment shaders)
  36048. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36049. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36050. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36051. * @param samplers defines an array of string used to represent textures
  36052. * @param defines defines the string containing the defines to use to compile the shaders
  36053. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36054. * @param onCompiled defines a function to call when the effect creation is successful
  36055. * @param onError defines a function to call when the effect creation has failed
  36056. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36057. * @returns the new Effect
  36058. */
  36059. 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;
  36060. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36061. private _compileShader;
  36062. private _compileRawShader;
  36063. /** @hidden */
  36064. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36065. /**
  36066. * Directly creates a webGL program
  36067. * @param pipelineContext defines the pipeline context to attach to
  36068. * @param vertexCode defines the vertex shader code to use
  36069. * @param fragmentCode defines the fragment shader code to use
  36070. * @param context defines the webGL context to use (if not set, the current one will be used)
  36071. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36072. * @returns the new webGL program
  36073. */
  36074. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36075. /**
  36076. * Creates a webGL program
  36077. * @param pipelineContext defines the pipeline context to attach to
  36078. * @param vertexCode defines the vertex shader code to use
  36079. * @param fragmentCode defines the fragment shader code to use
  36080. * @param defines defines the string containing the defines to use to compile the shaders
  36081. * @param context defines the webGL context to use (if not set, the current one will be used)
  36082. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36083. * @returns the new webGL program
  36084. */
  36085. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36086. /**
  36087. * Creates a new pipeline context
  36088. * @returns the new pipeline
  36089. */
  36090. createPipelineContext(): IPipelineContext;
  36091. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36092. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36093. /** @hidden */
  36094. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36095. /** @hidden */
  36096. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36097. /** @hidden */
  36098. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36099. /**
  36100. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36101. * @param pipelineContext defines the pipeline context to use
  36102. * @param uniformsNames defines the list of uniform names
  36103. * @returns an array of webGL uniform locations
  36104. */
  36105. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36106. /**
  36107. * Gets the lsit of active attributes for a given webGL program
  36108. * @param pipelineContext defines the pipeline context to use
  36109. * @param attributesNames defines the list of attribute names to get
  36110. * @returns an array of indices indicating the offset of each attribute
  36111. */
  36112. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36113. /**
  36114. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36115. * @param effect defines the effect to activate
  36116. */
  36117. enableEffect(effect: Nullable<Effect>): void;
  36118. /**
  36119. * Set the value of an uniform to a number (int)
  36120. * @param uniform defines the webGL uniform location where to store the value
  36121. * @param value defines the int number to store
  36122. * @returns true if the value was set
  36123. */
  36124. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36125. /**
  36126. * Set the value of an uniform to an array of int32
  36127. * @param uniform defines the webGL uniform location where to store the value
  36128. * @param array defines the array of int32 to store
  36129. * @returns true if the value was set
  36130. */
  36131. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36132. /**
  36133. * Set the value of an uniform to an array of int32 (stored as vec2)
  36134. * @param uniform defines the webGL uniform location where to store the value
  36135. * @param array defines the array of int32 to store
  36136. * @returns true if the value was set
  36137. */
  36138. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36139. /**
  36140. * Set the value of an uniform to an array of int32 (stored as vec3)
  36141. * @param uniform defines the webGL uniform location where to store the value
  36142. * @param array defines the array of int32 to store
  36143. * @returns true if the value was set
  36144. */
  36145. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36146. /**
  36147. * Set the value of an uniform to an array of int32 (stored as vec4)
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param array defines the array of int32 to store
  36150. * @returns true if the value was set
  36151. */
  36152. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36153. /**
  36154. * Set the value of an uniform to an array of number
  36155. * @param uniform defines the webGL uniform location where to store the value
  36156. * @param array defines the array of number to store
  36157. * @returns true if the value was set
  36158. */
  36159. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36160. /**
  36161. * Set the value of an uniform to an array of number (stored as vec2)
  36162. * @param uniform defines the webGL uniform location where to store the value
  36163. * @param array defines the array of number to store
  36164. * @returns true if the value was set
  36165. */
  36166. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36167. /**
  36168. * Set the value of an uniform to an array of number (stored as vec3)
  36169. * @param uniform defines the webGL uniform location where to store the value
  36170. * @param array defines the array of number to store
  36171. * @returns true if the value was set
  36172. */
  36173. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36174. /**
  36175. * Set the value of an uniform to an array of number (stored as vec4)
  36176. * @param uniform defines the webGL uniform location where to store the value
  36177. * @param array defines the array of number to store
  36178. * @returns true if the value was set
  36179. */
  36180. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36181. /**
  36182. * Set the value of an uniform to an array of float32 (stored as matrices)
  36183. * @param uniform defines the webGL uniform location where to store the value
  36184. * @param matrices defines the array of float32 to store
  36185. * @returns true if the value was set
  36186. */
  36187. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36188. /**
  36189. * Set the value of an uniform to a matrix (3x3)
  36190. * @param uniform defines the webGL uniform location where to store the value
  36191. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36192. * @returns true if the value was set
  36193. */
  36194. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36195. /**
  36196. * Set the value of an uniform to a matrix (2x2)
  36197. * @param uniform defines the webGL uniform location where to store the value
  36198. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36199. * @returns true if the value was set
  36200. */
  36201. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36202. /**
  36203. * Set the value of an uniform to a number (float)
  36204. * @param uniform defines the webGL uniform location where to store the value
  36205. * @param value defines the float number to store
  36206. * @returns true if the value was transfered
  36207. */
  36208. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36209. /**
  36210. * Set the value of an uniform to a vec2
  36211. * @param uniform defines the webGL uniform location where to store the value
  36212. * @param x defines the 1st component of the value
  36213. * @param y defines the 2nd component of the value
  36214. * @returns true if the value was set
  36215. */
  36216. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36217. /**
  36218. * Set the value of an uniform to a vec3
  36219. * @param uniform defines the webGL uniform location where to store the value
  36220. * @param x defines the 1st component of the value
  36221. * @param y defines the 2nd component of the value
  36222. * @param z defines the 3rd component of the value
  36223. * @returns true if the value was set
  36224. */
  36225. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36226. /**
  36227. * Set the value of an uniform to a vec4
  36228. * @param uniform defines the webGL uniform location where to store the value
  36229. * @param x defines the 1st component of the value
  36230. * @param y defines the 2nd component of the value
  36231. * @param z defines the 3rd component of the value
  36232. * @param w defines the 4th component of the value
  36233. * @returns true if the value was set
  36234. */
  36235. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36236. /**
  36237. * Apply all cached states (depth, culling, stencil and alpha)
  36238. */
  36239. applyStates(): void;
  36240. /**
  36241. * Enable or disable color writing
  36242. * @param enable defines the state to set
  36243. */
  36244. setColorWrite(enable: boolean): void;
  36245. /**
  36246. * Gets a boolean indicating if color writing is enabled
  36247. * @returns the current color writing state
  36248. */
  36249. getColorWrite(): boolean;
  36250. /**
  36251. * Gets the depth culling state manager
  36252. */
  36253. get depthCullingState(): DepthCullingState;
  36254. /**
  36255. * Gets the alpha state manager
  36256. */
  36257. get alphaState(): AlphaState;
  36258. /**
  36259. * Gets the stencil state manager
  36260. */
  36261. get stencilState(): StencilState;
  36262. /**
  36263. * Clears the list of texture accessible through engine.
  36264. * This can help preventing texture load conflict due to name collision.
  36265. */
  36266. clearInternalTexturesCache(): void;
  36267. /**
  36268. * Force the entire cache to be cleared
  36269. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36270. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36271. */
  36272. wipeCaches(bruteForce?: boolean): void;
  36273. /** @hidden */
  36274. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36275. min: number;
  36276. mag: number;
  36277. };
  36278. /** @hidden */
  36279. _createTexture(): WebGLTexture;
  36280. /**
  36281. * Usually called from Texture.ts.
  36282. * Passed information to create a WebGLTexture
  36283. * @param url defines a value which contains one of the following:
  36284. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36285. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36286. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36287. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36288. * @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)
  36289. * @param scene needed for loading to the correct scene
  36290. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36291. * @param onLoad optional callback to be called upon successful completion
  36292. * @param onError optional callback to be called upon failure
  36293. * @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
  36294. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36295. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36296. * @param forcedExtension defines the extension to use to pick the right loader
  36297. * @param mimeType defines an optional mime type
  36298. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36299. */
  36300. 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;
  36301. /**
  36302. * Loads an image as an HTMLImageElement.
  36303. * @param input url string, ArrayBuffer, or Blob to load
  36304. * @param onLoad callback called when the image successfully loads
  36305. * @param onError callback called when the image fails to load
  36306. * @param offlineProvider offline provider for caching
  36307. * @param mimeType optional mime type
  36308. * @returns the HTMLImageElement of the loaded image
  36309. * @hidden
  36310. */
  36311. 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>;
  36312. /**
  36313. * @hidden
  36314. */
  36315. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36316. private _unpackFlipYCached;
  36317. /**
  36318. * In case you are sharing the context with other applications, it might
  36319. * be interested to not cache the unpack flip y state to ensure a consistent
  36320. * value would be set.
  36321. */
  36322. enableUnpackFlipYCached: boolean;
  36323. /** @hidden */
  36324. _unpackFlipY(value: boolean): void;
  36325. /** @hidden */
  36326. _getUnpackAlignement(): number;
  36327. private _getTextureTarget;
  36328. /**
  36329. * Update the sampling mode of a given texture
  36330. * @param samplingMode defines the required sampling mode
  36331. * @param texture defines the texture to update
  36332. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36333. */
  36334. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36335. /**
  36336. * Update the sampling mode of a given texture
  36337. * @param texture defines the texture to update
  36338. * @param wrapU defines the texture wrap mode of the u coordinates
  36339. * @param wrapV defines the texture wrap mode of the v coordinates
  36340. * @param wrapR defines the texture wrap mode of the r coordinates
  36341. */
  36342. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36343. /** @hidden */
  36344. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36345. width: number;
  36346. height: number;
  36347. layers?: number;
  36348. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36349. /** @hidden */
  36350. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36351. /** @hidden */
  36352. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36353. /**
  36354. * Update a portion of an internal texture
  36355. * @param texture defines the texture to update
  36356. * @param imageData defines the data to store into the texture
  36357. * @param xOffset defines the x coordinates of the update rectangle
  36358. * @param yOffset defines the y coordinates of the update rectangle
  36359. * @param width defines the width of the update rectangle
  36360. * @param height defines the height of the update rectangle
  36361. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36362. * @param lod defines the lod level to update (0 by default)
  36363. */
  36364. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36365. /** @hidden */
  36366. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36367. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36368. private _prepareWebGLTexture;
  36369. /** @hidden */
  36370. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36371. private _getDepthStencilBuffer;
  36372. /** @hidden */
  36373. _releaseFramebufferObjects(texture: InternalTexture): void;
  36374. /** @hidden */
  36375. _releaseTexture(texture: InternalTexture): void;
  36376. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36377. protected _setProgram(program: WebGLProgram): void;
  36378. protected _boundUniforms: {
  36379. [key: number]: WebGLUniformLocation;
  36380. };
  36381. /**
  36382. * Binds an effect to the webGL context
  36383. * @param effect defines the effect to bind
  36384. */
  36385. bindSamplers(effect: Effect): void;
  36386. private _activateCurrentTexture;
  36387. /** @hidden */
  36388. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36389. /** @hidden */
  36390. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36391. /**
  36392. * Unbind all textures from the webGL context
  36393. */
  36394. unbindAllTextures(): void;
  36395. /**
  36396. * Sets a texture to the according uniform.
  36397. * @param channel The texture channel
  36398. * @param uniform The uniform to set
  36399. * @param texture The texture to apply
  36400. */
  36401. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36402. private _bindSamplerUniformToChannel;
  36403. private _getTextureWrapMode;
  36404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36405. /**
  36406. * Sets an array of texture to the webGL context
  36407. * @param channel defines the channel where the texture array must be set
  36408. * @param uniform defines the associated uniform location
  36409. * @param textures defines the array of textures to bind
  36410. */
  36411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36412. /** @hidden */
  36413. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36414. private _setTextureParameterFloat;
  36415. private _setTextureParameterInteger;
  36416. /**
  36417. * Unbind all vertex attributes from the webGL context
  36418. */
  36419. unbindAllAttributes(): void;
  36420. /**
  36421. * 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
  36422. */
  36423. releaseEffects(): void;
  36424. /**
  36425. * Dispose and release all associated resources
  36426. */
  36427. dispose(): void;
  36428. /**
  36429. * Attach a new callback raised when context lost event is fired
  36430. * @param callback defines the callback to call
  36431. */
  36432. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36433. /**
  36434. * Attach a new callback raised when context restored event is fired
  36435. * @param callback defines the callback to call
  36436. */
  36437. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36438. /**
  36439. * Get the current error code of the webGL context
  36440. * @returns the error code
  36441. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36442. */
  36443. getError(): number;
  36444. private _canRenderToFloatFramebuffer;
  36445. private _canRenderToHalfFloatFramebuffer;
  36446. private _canRenderToFramebuffer;
  36447. /** @hidden */
  36448. _getWebGLTextureType(type: number): number;
  36449. /** @hidden */
  36450. _getInternalFormat(format: number): number;
  36451. /** @hidden */
  36452. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36453. /** @hidden */
  36454. _getRGBAMultiSampleBufferFormat(type: number): number;
  36455. /** @hidden */
  36456. _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;
  36457. /**
  36458. * Loads a file from a url
  36459. * @param url url to load
  36460. * @param onSuccess callback called when the file successfully loads
  36461. * @param onProgress callback called while file is loading (if the server supports this mode)
  36462. * @param offlineProvider defines the offline provider for caching
  36463. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36464. * @param onError callback called when the file fails to load
  36465. * @returns a file request object
  36466. * @hidden
  36467. */
  36468. 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;
  36469. /**
  36470. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36471. * @param x defines the x coordinate of the rectangle where pixels must be read
  36472. * @param y defines the y coordinate of the rectangle where pixels must be read
  36473. * @param width defines the width of the rectangle where pixels must be read
  36474. * @param height defines the height of the rectangle where pixels must be read
  36475. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36476. * @returns a Uint8Array containing RGBA colors
  36477. */
  36478. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36479. private static _IsSupported;
  36480. private static _HasMajorPerformanceCaveat;
  36481. /**
  36482. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36483. */
  36484. static get IsSupported(): boolean;
  36485. /**
  36486. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36487. * @returns true if the engine can be created
  36488. * @ignorenaming
  36489. */
  36490. static isSupported(): boolean;
  36491. /**
  36492. * 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)
  36493. */
  36494. static get HasMajorPerformanceCaveat(): boolean;
  36495. /**
  36496. * Find the next highest power of two.
  36497. * @param x Number to start search from.
  36498. * @return Next highest power of two.
  36499. */
  36500. static CeilingPOT(x: number): number;
  36501. /**
  36502. * Find the next lowest power of two.
  36503. * @param x Number to start search from.
  36504. * @return Next lowest power of two.
  36505. */
  36506. static FloorPOT(x: number): number;
  36507. /**
  36508. * Find the nearest power of two.
  36509. * @param x Number to start search from.
  36510. * @return Next nearest power of two.
  36511. */
  36512. static NearestPOT(x: number): number;
  36513. /**
  36514. * Get the closest exponent of two
  36515. * @param value defines the value to approximate
  36516. * @param max defines the maximum value to return
  36517. * @param mode defines how to define the closest value
  36518. * @returns closest exponent of two of the given value
  36519. */
  36520. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36521. /**
  36522. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36523. * @param func - the function to be called
  36524. * @param requester - the object that will request the next frame. Falls back to window.
  36525. * @returns frame number
  36526. */
  36527. static QueueNewFrame(func: () => void, requester?: any): number;
  36528. /**
  36529. * Gets host document
  36530. * @returns the host document object
  36531. */
  36532. getHostDocument(): Nullable<Document>;
  36533. }
  36534. }
  36535. declare module BABYLON {
  36536. /**
  36537. * Class representing spherical harmonics coefficients to the 3rd degree
  36538. */
  36539. export class SphericalHarmonics {
  36540. /**
  36541. * Defines whether or not the harmonics have been prescaled for rendering.
  36542. */
  36543. preScaled: boolean;
  36544. /**
  36545. * The l0,0 coefficients of the spherical harmonics
  36546. */
  36547. l00: Vector3;
  36548. /**
  36549. * The l1,-1 coefficients of the spherical harmonics
  36550. */
  36551. l1_1: Vector3;
  36552. /**
  36553. * The l1,0 coefficients of the spherical harmonics
  36554. */
  36555. l10: Vector3;
  36556. /**
  36557. * The l1,1 coefficients of the spherical harmonics
  36558. */
  36559. l11: Vector3;
  36560. /**
  36561. * The l2,-2 coefficients of the spherical harmonics
  36562. */
  36563. l2_2: Vector3;
  36564. /**
  36565. * The l2,-1 coefficients of the spherical harmonics
  36566. */
  36567. l2_1: Vector3;
  36568. /**
  36569. * The l2,0 coefficients of the spherical harmonics
  36570. */
  36571. l20: Vector3;
  36572. /**
  36573. * The l2,1 coefficients of the spherical harmonics
  36574. */
  36575. l21: Vector3;
  36576. /**
  36577. * The l2,2 coefficients of the spherical harmonics
  36578. */
  36579. l22: Vector3;
  36580. /**
  36581. * Adds a light to the spherical harmonics
  36582. * @param direction the direction of the light
  36583. * @param color the color of the light
  36584. * @param deltaSolidAngle the delta solid angle of the light
  36585. */
  36586. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36587. /**
  36588. * Scales the spherical harmonics by the given amount
  36589. * @param scale the amount to scale
  36590. */
  36591. scaleInPlace(scale: number): void;
  36592. /**
  36593. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36594. *
  36595. * ```
  36596. * E_lm = A_l * L_lm
  36597. * ```
  36598. *
  36599. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36600. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36601. * the scaling factors are given in equation 9.
  36602. */
  36603. convertIncidentRadianceToIrradiance(): void;
  36604. /**
  36605. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36606. *
  36607. * ```
  36608. * L = (1/pi) * E * rho
  36609. * ```
  36610. *
  36611. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36612. */
  36613. convertIrradianceToLambertianRadiance(): void;
  36614. /**
  36615. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36616. * required operations at run time.
  36617. *
  36618. * This is simply done by scaling back the SH with Ylm constants parameter.
  36619. * The trigonometric part being applied by the shader at run time.
  36620. */
  36621. preScaleForRendering(): void;
  36622. /**
  36623. * Constructs a spherical harmonics from an array.
  36624. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36625. * @returns the spherical harmonics
  36626. */
  36627. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36628. /**
  36629. * Gets the spherical harmonics from polynomial
  36630. * @param polynomial the spherical polynomial
  36631. * @returns the spherical harmonics
  36632. */
  36633. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36634. }
  36635. /**
  36636. * Class representing spherical polynomial coefficients to the 3rd degree
  36637. */
  36638. export class SphericalPolynomial {
  36639. private _harmonics;
  36640. /**
  36641. * The spherical harmonics used to create the polynomials.
  36642. */
  36643. get preScaledHarmonics(): SphericalHarmonics;
  36644. /**
  36645. * The x coefficients of the spherical polynomial
  36646. */
  36647. x: Vector3;
  36648. /**
  36649. * The y coefficients of the spherical polynomial
  36650. */
  36651. y: Vector3;
  36652. /**
  36653. * The z coefficients of the spherical polynomial
  36654. */
  36655. z: Vector3;
  36656. /**
  36657. * The xx coefficients of the spherical polynomial
  36658. */
  36659. xx: Vector3;
  36660. /**
  36661. * The yy coefficients of the spherical polynomial
  36662. */
  36663. yy: Vector3;
  36664. /**
  36665. * The zz coefficients of the spherical polynomial
  36666. */
  36667. zz: Vector3;
  36668. /**
  36669. * The xy coefficients of the spherical polynomial
  36670. */
  36671. xy: Vector3;
  36672. /**
  36673. * The yz coefficients of the spherical polynomial
  36674. */
  36675. yz: Vector3;
  36676. /**
  36677. * The zx coefficients of the spherical polynomial
  36678. */
  36679. zx: Vector3;
  36680. /**
  36681. * Adds an ambient color to the spherical polynomial
  36682. * @param color the color to add
  36683. */
  36684. addAmbient(color: Color3): void;
  36685. /**
  36686. * Scales the spherical polynomial by the given amount
  36687. * @param scale the amount to scale
  36688. */
  36689. scaleInPlace(scale: number): void;
  36690. /**
  36691. * Gets the spherical polynomial from harmonics
  36692. * @param harmonics the spherical harmonics
  36693. * @returns the spherical polynomial
  36694. */
  36695. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36696. /**
  36697. * Constructs a spherical polynomial from an array.
  36698. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36699. * @returns the spherical polynomial
  36700. */
  36701. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36702. }
  36703. }
  36704. declare module BABYLON {
  36705. /**
  36706. * Defines the source of the internal texture
  36707. */
  36708. export enum InternalTextureSource {
  36709. /**
  36710. * The source of the texture data is unknown
  36711. */
  36712. Unknown = 0,
  36713. /**
  36714. * Texture data comes from an URL
  36715. */
  36716. Url = 1,
  36717. /**
  36718. * Texture data is only used for temporary storage
  36719. */
  36720. Temp = 2,
  36721. /**
  36722. * Texture data comes from raw data (ArrayBuffer)
  36723. */
  36724. Raw = 3,
  36725. /**
  36726. * Texture content is dynamic (video or dynamic texture)
  36727. */
  36728. Dynamic = 4,
  36729. /**
  36730. * Texture content is generated by rendering to it
  36731. */
  36732. RenderTarget = 5,
  36733. /**
  36734. * Texture content is part of a multi render target process
  36735. */
  36736. MultiRenderTarget = 6,
  36737. /**
  36738. * Texture data comes from a cube data file
  36739. */
  36740. Cube = 7,
  36741. /**
  36742. * Texture data comes from a raw cube data
  36743. */
  36744. CubeRaw = 8,
  36745. /**
  36746. * Texture data come from a prefiltered cube data file
  36747. */
  36748. CubePrefiltered = 9,
  36749. /**
  36750. * Texture content is raw 3D data
  36751. */
  36752. Raw3D = 10,
  36753. /**
  36754. * Texture content is raw 2D array data
  36755. */
  36756. Raw2DArray = 11,
  36757. /**
  36758. * Texture content is a depth texture
  36759. */
  36760. Depth = 12,
  36761. /**
  36762. * Texture data comes from a raw cube data encoded with RGBD
  36763. */
  36764. CubeRawRGBD = 13
  36765. }
  36766. /**
  36767. * Class used to store data associated with WebGL texture data for the engine
  36768. * This class should not be used directly
  36769. */
  36770. export class InternalTexture {
  36771. /** @hidden */
  36772. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36773. /**
  36774. * Defines if the texture is ready
  36775. */
  36776. isReady: boolean;
  36777. /**
  36778. * Defines if the texture is a cube texture
  36779. */
  36780. isCube: boolean;
  36781. /**
  36782. * Defines if the texture contains 3D data
  36783. */
  36784. is3D: boolean;
  36785. /**
  36786. * Defines if the texture contains 2D array data
  36787. */
  36788. is2DArray: boolean;
  36789. /**
  36790. * Defines if the texture contains multiview data
  36791. */
  36792. isMultiview: boolean;
  36793. /**
  36794. * Gets the URL used to load this texture
  36795. */
  36796. url: string;
  36797. /**
  36798. * Gets the sampling mode of the texture
  36799. */
  36800. samplingMode: number;
  36801. /**
  36802. * Gets a boolean indicating if the texture needs mipmaps generation
  36803. */
  36804. generateMipMaps: boolean;
  36805. /**
  36806. * Gets the number of samples used by the texture (WebGL2+ only)
  36807. */
  36808. samples: number;
  36809. /**
  36810. * Gets the type of the texture (int, float...)
  36811. */
  36812. type: number;
  36813. /**
  36814. * Gets the format of the texture (RGB, RGBA...)
  36815. */
  36816. format: number;
  36817. /**
  36818. * Observable called when the texture is loaded
  36819. */
  36820. onLoadedObservable: Observable<InternalTexture>;
  36821. /**
  36822. * Gets the width of the texture
  36823. */
  36824. width: number;
  36825. /**
  36826. * Gets the height of the texture
  36827. */
  36828. height: number;
  36829. /**
  36830. * Gets the depth of the texture
  36831. */
  36832. depth: number;
  36833. /**
  36834. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36835. */
  36836. baseWidth: number;
  36837. /**
  36838. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36839. */
  36840. baseHeight: number;
  36841. /**
  36842. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36843. */
  36844. baseDepth: number;
  36845. /**
  36846. * Gets a boolean indicating if the texture is inverted on Y axis
  36847. */
  36848. invertY: boolean;
  36849. /** @hidden */
  36850. _invertVScale: boolean;
  36851. /** @hidden */
  36852. _associatedChannel: number;
  36853. /** @hidden */
  36854. _source: InternalTextureSource;
  36855. /** @hidden */
  36856. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36857. /** @hidden */
  36858. _bufferView: Nullable<ArrayBufferView>;
  36859. /** @hidden */
  36860. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36861. /** @hidden */
  36862. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36863. /** @hidden */
  36864. _size: number;
  36865. /** @hidden */
  36866. _extension: string;
  36867. /** @hidden */
  36868. _files: Nullable<string[]>;
  36869. /** @hidden */
  36870. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36871. /** @hidden */
  36872. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36873. /** @hidden */
  36874. _framebuffer: Nullable<WebGLFramebuffer>;
  36875. /** @hidden */
  36876. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36877. /** @hidden */
  36878. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36879. /** @hidden */
  36880. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36881. /** @hidden */
  36882. _attachments: Nullable<number[]>;
  36883. /** @hidden */
  36884. _textureArray: Nullable<InternalTexture[]>;
  36885. /** @hidden */
  36886. _cachedCoordinatesMode: Nullable<number>;
  36887. /** @hidden */
  36888. _cachedWrapU: Nullable<number>;
  36889. /** @hidden */
  36890. _cachedWrapV: Nullable<number>;
  36891. /** @hidden */
  36892. _cachedWrapR: Nullable<number>;
  36893. /** @hidden */
  36894. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36895. /** @hidden */
  36896. _isDisabled: boolean;
  36897. /** @hidden */
  36898. _compression: Nullable<string>;
  36899. /** @hidden */
  36900. _generateStencilBuffer: boolean;
  36901. /** @hidden */
  36902. _generateDepthBuffer: boolean;
  36903. /** @hidden */
  36904. _comparisonFunction: number;
  36905. /** @hidden */
  36906. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36907. /** @hidden */
  36908. _lodGenerationScale: number;
  36909. /** @hidden */
  36910. _lodGenerationOffset: number;
  36911. /** @hidden */
  36912. _depthStencilTexture: Nullable<InternalTexture>;
  36913. /** @hidden */
  36914. _colorTextureArray: Nullable<WebGLTexture>;
  36915. /** @hidden */
  36916. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36917. /** @hidden */
  36918. _lodTextureHigh: Nullable<BaseTexture>;
  36919. /** @hidden */
  36920. _lodTextureMid: Nullable<BaseTexture>;
  36921. /** @hidden */
  36922. _lodTextureLow: Nullable<BaseTexture>;
  36923. /** @hidden */
  36924. _isRGBD: boolean;
  36925. /** @hidden */
  36926. _linearSpecularLOD: boolean;
  36927. /** @hidden */
  36928. _irradianceTexture: Nullable<BaseTexture>;
  36929. /** @hidden */
  36930. _webGLTexture: Nullable<WebGLTexture>;
  36931. /** @hidden */
  36932. _references: number;
  36933. /** @hidden */
  36934. _gammaSpace: Nullable<boolean>;
  36935. private _engine;
  36936. /**
  36937. * Gets the Engine the texture belongs to.
  36938. * @returns The babylon engine
  36939. */
  36940. getEngine(): ThinEngine;
  36941. /**
  36942. * Gets the data source type of the texture
  36943. */
  36944. get source(): InternalTextureSource;
  36945. /**
  36946. * Creates a new InternalTexture
  36947. * @param engine defines the engine to use
  36948. * @param source defines the type of data that will be used
  36949. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36950. */
  36951. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36952. /**
  36953. * Increments the number of references (ie. the number of Texture that point to it)
  36954. */
  36955. incrementReferences(): void;
  36956. /**
  36957. * Change the size of the texture (not the size of the content)
  36958. * @param width defines the new width
  36959. * @param height defines the new height
  36960. * @param depth defines the new depth (1 by default)
  36961. */
  36962. updateSize(width: int, height: int, depth?: int): void;
  36963. /** @hidden */
  36964. _rebuild(): void;
  36965. /** @hidden */
  36966. _swapAndDie(target: InternalTexture): void;
  36967. /**
  36968. * Dispose the current allocated resources
  36969. */
  36970. dispose(): void;
  36971. }
  36972. }
  36973. declare module BABYLON {
  36974. /**
  36975. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36976. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36977. */
  36978. export class Analyser {
  36979. /**
  36980. * Gets or sets the smoothing
  36981. * @ignorenaming
  36982. */
  36983. SMOOTHING: number;
  36984. /**
  36985. * Gets or sets the FFT table size
  36986. * @ignorenaming
  36987. */
  36988. FFT_SIZE: number;
  36989. /**
  36990. * Gets or sets the bar graph amplitude
  36991. * @ignorenaming
  36992. */
  36993. BARGRAPHAMPLITUDE: number;
  36994. /**
  36995. * Gets or sets the position of the debug canvas
  36996. * @ignorenaming
  36997. */
  36998. DEBUGCANVASPOS: {
  36999. x: number;
  37000. y: number;
  37001. };
  37002. /**
  37003. * Gets or sets the debug canvas size
  37004. * @ignorenaming
  37005. */
  37006. DEBUGCANVASSIZE: {
  37007. width: number;
  37008. height: number;
  37009. };
  37010. private _byteFreqs;
  37011. private _byteTime;
  37012. private _floatFreqs;
  37013. private _webAudioAnalyser;
  37014. private _debugCanvas;
  37015. private _debugCanvasContext;
  37016. private _scene;
  37017. private _registerFunc;
  37018. private _audioEngine;
  37019. /**
  37020. * Creates a new analyser
  37021. * @param scene defines hosting scene
  37022. */
  37023. constructor(scene: Scene);
  37024. /**
  37025. * Get the number of data values you will have to play with for the visualization
  37026. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37027. * @returns a number
  37028. */
  37029. getFrequencyBinCount(): number;
  37030. /**
  37031. * Gets the current frequency data as a byte array
  37032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37033. * @returns a Uint8Array
  37034. */
  37035. getByteFrequencyData(): Uint8Array;
  37036. /**
  37037. * Gets the current waveform as a byte array
  37038. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37039. * @returns a Uint8Array
  37040. */
  37041. getByteTimeDomainData(): Uint8Array;
  37042. /**
  37043. * Gets the current frequency data as a float array
  37044. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37045. * @returns a Float32Array
  37046. */
  37047. getFloatFrequencyData(): Float32Array;
  37048. /**
  37049. * Renders the debug canvas
  37050. */
  37051. drawDebugCanvas(): void;
  37052. /**
  37053. * Stops rendering the debug canvas and removes it
  37054. */
  37055. stopDebugCanvas(): void;
  37056. /**
  37057. * Connects two audio nodes
  37058. * @param inputAudioNode defines first node to connect
  37059. * @param outputAudioNode defines second node to connect
  37060. */
  37061. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37062. /**
  37063. * Releases all associated resources
  37064. */
  37065. dispose(): void;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. /**
  37070. * This represents an audio engine and it is responsible
  37071. * to play, synchronize and analyse sounds throughout the application.
  37072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37073. */
  37074. export interface IAudioEngine extends IDisposable {
  37075. /**
  37076. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37077. */
  37078. readonly canUseWebAudio: boolean;
  37079. /**
  37080. * Gets the current AudioContext if available.
  37081. */
  37082. readonly audioContext: Nullable<AudioContext>;
  37083. /**
  37084. * The master gain node defines the global audio volume of your audio engine.
  37085. */
  37086. readonly masterGain: GainNode;
  37087. /**
  37088. * Gets whether or not mp3 are supported by your browser.
  37089. */
  37090. readonly isMP3supported: boolean;
  37091. /**
  37092. * Gets whether or not ogg are supported by your browser.
  37093. */
  37094. readonly isOGGsupported: boolean;
  37095. /**
  37096. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37097. * @ignoreNaming
  37098. */
  37099. WarnedWebAudioUnsupported: boolean;
  37100. /**
  37101. * Defines if the audio engine relies on a custom unlocked button.
  37102. * In this case, the embedded button will not be displayed.
  37103. */
  37104. useCustomUnlockedButton: boolean;
  37105. /**
  37106. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37107. */
  37108. readonly unlocked: boolean;
  37109. /**
  37110. * Event raised when audio has been unlocked on the browser.
  37111. */
  37112. onAudioUnlockedObservable: Observable<AudioEngine>;
  37113. /**
  37114. * Event raised when audio has been locked on the browser.
  37115. */
  37116. onAudioLockedObservable: Observable<AudioEngine>;
  37117. /**
  37118. * Flags the audio engine in Locked state.
  37119. * This happens due to new browser policies preventing audio to autoplay.
  37120. */
  37121. lock(): void;
  37122. /**
  37123. * Unlocks the audio engine once a user action has been done on the dom.
  37124. * This is helpful to resume play once browser policies have been satisfied.
  37125. */
  37126. unlock(): void;
  37127. /**
  37128. * Gets the global volume sets on the master gain.
  37129. * @returns the global volume if set or -1 otherwise
  37130. */
  37131. getGlobalVolume(): number;
  37132. /**
  37133. * Sets the global volume of your experience (sets on the master gain).
  37134. * @param newVolume Defines the new global volume of the application
  37135. */
  37136. setGlobalVolume(newVolume: number): void;
  37137. /**
  37138. * Connect the audio engine to an audio analyser allowing some amazing
  37139. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37141. * @param analyser The analyser to connect to the engine
  37142. */
  37143. connectToAnalyser(analyser: Analyser): void;
  37144. }
  37145. /**
  37146. * This represents the default audio engine used in babylon.
  37147. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37149. */
  37150. export class AudioEngine implements IAudioEngine {
  37151. private _audioContext;
  37152. private _audioContextInitialized;
  37153. private _muteButton;
  37154. private _hostElement;
  37155. /**
  37156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37157. */
  37158. canUseWebAudio: boolean;
  37159. /**
  37160. * The master gain node defines the global audio volume of your audio engine.
  37161. */
  37162. masterGain: GainNode;
  37163. /**
  37164. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37165. * @ignoreNaming
  37166. */
  37167. WarnedWebAudioUnsupported: boolean;
  37168. /**
  37169. * Gets whether or not mp3 are supported by your browser.
  37170. */
  37171. isMP3supported: boolean;
  37172. /**
  37173. * Gets whether or not ogg are supported by your browser.
  37174. */
  37175. isOGGsupported: boolean;
  37176. /**
  37177. * Gets whether audio has been unlocked on the device.
  37178. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37179. * a user interaction has happened.
  37180. */
  37181. unlocked: boolean;
  37182. /**
  37183. * Defines if the audio engine relies on a custom unlocked button.
  37184. * In this case, the embedded button will not be displayed.
  37185. */
  37186. useCustomUnlockedButton: boolean;
  37187. /**
  37188. * Event raised when audio has been unlocked on the browser.
  37189. */
  37190. onAudioUnlockedObservable: Observable<AudioEngine>;
  37191. /**
  37192. * Event raised when audio has been locked on the browser.
  37193. */
  37194. onAudioLockedObservable: Observable<AudioEngine>;
  37195. /**
  37196. * Gets the current AudioContext if available.
  37197. */
  37198. get audioContext(): Nullable<AudioContext>;
  37199. private _connectedAnalyser;
  37200. /**
  37201. * Instantiates a new audio engine.
  37202. *
  37203. * There should be only one per page as some browsers restrict the number
  37204. * of audio contexts you can create.
  37205. * @param hostElement defines the host element where to display the mute icon if necessary
  37206. */
  37207. constructor(hostElement?: Nullable<HTMLElement>);
  37208. /**
  37209. * Flags the audio engine in Locked state.
  37210. * This happens due to new browser policies preventing audio to autoplay.
  37211. */
  37212. lock(): void;
  37213. /**
  37214. * Unlocks the audio engine once a user action has been done on the dom.
  37215. * This is helpful to resume play once browser policies have been satisfied.
  37216. */
  37217. unlock(): void;
  37218. private _resumeAudioContext;
  37219. private _initializeAudioContext;
  37220. private _tryToRun;
  37221. private _triggerRunningState;
  37222. private _triggerSuspendedState;
  37223. private _displayMuteButton;
  37224. private _moveButtonToTopLeft;
  37225. private _onResize;
  37226. private _hideMuteButton;
  37227. /**
  37228. * Destroy and release the resources associated with the audio ccontext.
  37229. */
  37230. dispose(): void;
  37231. /**
  37232. * Gets the global volume sets on the master gain.
  37233. * @returns the global volume if set or -1 otherwise
  37234. */
  37235. getGlobalVolume(): number;
  37236. /**
  37237. * Sets the global volume of your experience (sets on the master gain).
  37238. * @param newVolume Defines the new global volume of the application
  37239. */
  37240. setGlobalVolume(newVolume: number): void;
  37241. /**
  37242. * Connect the audio engine to an audio analyser allowing some amazing
  37243. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37245. * @param analyser The analyser to connect to the engine
  37246. */
  37247. connectToAnalyser(analyser: Analyser): void;
  37248. }
  37249. }
  37250. declare module BABYLON {
  37251. /**
  37252. * Interface used to present a loading screen while loading a scene
  37253. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37254. */
  37255. export interface ILoadingScreen {
  37256. /**
  37257. * Function called to display the loading screen
  37258. */
  37259. displayLoadingUI: () => void;
  37260. /**
  37261. * Function called to hide the loading screen
  37262. */
  37263. hideLoadingUI: () => void;
  37264. /**
  37265. * Gets or sets the color to use for the background
  37266. */
  37267. loadingUIBackgroundColor: string;
  37268. /**
  37269. * Gets or sets the text to display while loading
  37270. */
  37271. loadingUIText: string;
  37272. }
  37273. /**
  37274. * Class used for the default loading screen
  37275. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37276. */
  37277. export class DefaultLoadingScreen implements ILoadingScreen {
  37278. private _renderingCanvas;
  37279. private _loadingText;
  37280. private _loadingDivBackgroundColor;
  37281. private _loadingDiv;
  37282. private _loadingTextDiv;
  37283. /** Gets or sets the logo url to use for the default loading screen */
  37284. static DefaultLogoUrl: string;
  37285. /** Gets or sets the spinner url to use for the default loading screen */
  37286. static DefaultSpinnerUrl: string;
  37287. /**
  37288. * Creates a new default loading screen
  37289. * @param _renderingCanvas defines the canvas used to render the scene
  37290. * @param _loadingText defines the default text to display
  37291. * @param _loadingDivBackgroundColor defines the default background color
  37292. */
  37293. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37294. /**
  37295. * Function called to display the loading screen
  37296. */
  37297. displayLoadingUI(): void;
  37298. /**
  37299. * Function called to hide the loading screen
  37300. */
  37301. hideLoadingUI(): void;
  37302. /**
  37303. * Gets or sets the text to display while loading
  37304. */
  37305. set loadingUIText(text: string);
  37306. get loadingUIText(): string;
  37307. /**
  37308. * Gets or sets the color to use for the background
  37309. */
  37310. get loadingUIBackgroundColor(): string;
  37311. set loadingUIBackgroundColor(color: string);
  37312. private _resizeLoadingUI;
  37313. }
  37314. }
  37315. declare module BABYLON {
  37316. /**
  37317. * Interface for any object that can request an animation frame
  37318. */
  37319. export interface ICustomAnimationFrameRequester {
  37320. /**
  37321. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37322. */
  37323. renderFunction?: Function;
  37324. /**
  37325. * Called to request the next frame to render to
  37326. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37327. */
  37328. requestAnimationFrame: Function;
  37329. /**
  37330. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37331. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37332. */
  37333. requestID?: number;
  37334. }
  37335. }
  37336. declare module BABYLON {
  37337. /**
  37338. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37339. */
  37340. export class PerformanceMonitor {
  37341. private _enabled;
  37342. private _rollingFrameTime;
  37343. private _lastFrameTimeMs;
  37344. /**
  37345. * constructor
  37346. * @param frameSampleSize The number of samples required to saturate the sliding window
  37347. */
  37348. constructor(frameSampleSize?: number);
  37349. /**
  37350. * Samples current frame
  37351. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37352. */
  37353. sampleFrame(timeMs?: number): void;
  37354. /**
  37355. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37356. */
  37357. get averageFrameTime(): number;
  37358. /**
  37359. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37360. */
  37361. get averageFrameTimeVariance(): number;
  37362. /**
  37363. * Returns the frame time of the most recent frame
  37364. */
  37365. get instantaneousFrameTime(): number;
  37366. /**
  37367. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37368. */
  37369. get averageFPS(): number;
  37370. /**
  37371. * Returns the average framerate in frames per second using the most recent frame time
  37372. */
  37373. get instantaneousFPS(): number;
  37374. /**
  37375. * Returns true if enough samples have been taken to completely fill the sliding window
  37376. */
  37377. get isSaturated(): boolean;
  37378. /**
  37379. * Enables contributions to the sliding window sample set
  37380. */
  37381. enable(): void;
  37382. /**
  37383. * Disables contributions to the sliding window sample set
  37384. * Samples will not be interpolated over the disabled period
  37385. */
  37386. disable(): void;
  37387. /**
  37388. * Returns true if sampling is enabled
  37389. */
  37390. get isEnabled(): boolean;
  37391. /**
  37392. * Resets performance monitor
  37393. */
  37394. reset(): void;
  37395. }
  37396. /**
  37397. * RollingAverage
  37398. *
  37399. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37400. */
  37401. export class RollingAverage {
  37402. /**
  37403. * Current average
  37404. */
  37405. average: number;
  37406. /**
  37407. * Current variance
  37408. */
  37409. variance: number;
  37410. protected _samples: Array<number>;
  37411. protected _sampleCount: number;
  37412. protected _pos: number;
  37413. protected _m2: number;
  37414. /**
  37415. * constructor
  37416. * @param length The number of samples required to saturate the sliding window
  37417. */
  37418. constructor(length: number);
  37419. /**
  37420. * Adds a sample to the sample set
  37421. * @param v The sample value
  37422. */
  37423. add(v: number): void;
  37424. /**
  37425. * Returns previously added values or null if outside of history or outside the sliding window domain
  37426. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37427. * @return Value previously recorded with add() or null if outside of range
  37428. */
  37429. history(i: number): number;
  37430. /**
  37431. * Returns true if enough samples have been taken to completely fill the sliding window
  37432. * @return true if sample-set saturated
  37433. */
  37434. isSaturated(): boolean;
  37435. /**
  37436. * Resets the rolling average (equivalent to 0 samples taken so far)
  37437. */
  37438. reset(): void;
  37439. /**
  37440. * Wraps a value around the sample range boundaries
  37441. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37442. * @return Wrapped position in sample range
  37443. */
  37444. protected _wrapPosition(i: number): number;
  37445. }
  37446. }
  37447. declare module BABYLON {
  37448. /**
  37449. * This class is used to track a performance counter which is number based.
  37450. * The user has access to many properties which give statistics of different nature.
  37451. *
  37452. * The implementer can track two kinds of Performance Counter: time and count.
  37453. * 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.
  37454. * 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.
  37455. */
  37456. export class PerfCounter {
  37457. /**
  37458. * Gets or sets a global boolean to turn on and off all the counters
  37459. */
  37460. static Enabled: boolean;
  37461. /**
  37462. * Returns the smallest value ever
  37463. */
  37464. get min(): number;
  37465. /**
  37466. * Returns the biggest value ever
  37467. */
  37468. get max(): number;
  37469. /**
  37470. * Returns the average value since the performance counter is running
  37471. */
  37472. get average(): number;
  37473. /**
  37474. * Returns the average value of the last second the counter was monitored
  37475. */
  37476. get lastSecAverage(): number;
  37477. /**
  37478. * Returns the current value
  37479. */
  37480. get current(): number;
  37481. /**
  37482. * Gets the accumulated total
  37483. */
  37484. get total(): number;
  37485. /**
  37486. * Gets the total value count
  37487. */
  37488. get count(): number;
  37489. /**
  37490. * Creates a new counter
  37491. */
  37492. constructor();
  37493. /**
  37494. * Call this method to start monitoring a new frame.
  37495. * 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.
  37496. */
  37497. fetchNewFrame(): void;
  37498. /**
  37499. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37500. * @param newCount the count value to add to the monitored count
  37501. * @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.
  37502. */
  37503. addCount(newCount: number, fetchResult: boolean): void;
  37504. /**
  37505. * Start monitoring this performance counter
  37506. */
  37507. beginMonitoring(): void;
  37508. /**
  37509. * Compute the time lapsed since the previous beginMonitoring() call.
  37510. * @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
  37511. */
  37512. endMonitoring(newFrame?: boolean): void;
  37513. private _fetchResult;
  37514. private _startMonitoringTime;
  37515. private _min;
  37516. private _max;
  37517. private _average;
  37518. private _current;
  37519. private _totalValueCount;
  37520. private _totalAccumulated;
  37521. private _lastSecAverage;
  37522. private _lastSecAccumulated;
  37523. private _lastSecTime;
  37524. private _lastSecValueCount;
  37525. }
  37526. }
  37527. declare module BABYLON {
  37528. interface ThinEngine {
  37529. /** @hidden */
  37530. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37531. }
  37532. }
  37533. declare module BABYLON {
  37534. /**
  37535. * Defines the interface used by display changed events
  37536. */
  37537. export interface IDisplayChangedEventArgs {
  37538. /** Gets the vrDisplay object (if any) */
  37539. vrDisplay: Nullable<any>;
  37540. /** Gets a boolean indicating if webVR is supported */
  37541. vrSupported: boolean;
  37542. }
  37543. /**
  37544. * Defines the interface used by objects containing a viewport (like a camera)
  37545. */
  37546. interface IViewportOwnerLike {
  37547. /**
  37548. * Gets or sets the viewport
  37549. */
  37550. viewport: IViewportLike;
  37551. }
  37552. /**
  37553. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37554. */
  37555. export class Engine extends ThinEngine {
  37556. /** Defines that alpha blending is disabled */
  37557. static readonly ALPHA_DISABLE: number;
  37558. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37559. static readonly ALPHA_ADD: number;
  37560. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37561. static readonly ALPHA_COMBINE: number;
  37562. /** Defines that alpha blending to DEST - SRC * DEST */
  37563. static readonly ALPHA_SUBTRACT: number;
  37564. /** Defines that alpha blending to SRC * DEST */
  37565. static readonly ALPHA_MULTIPLY: number;
  37566. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37567. static readonly ALPHA_MAXIMIZED: number;
  37568. /** Defines that alpha blending to SRC + DEST */
  37569. static readonly ALPHA_ONEONE: number;
  37570. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37571. static readonly ALPHA_PREMULTIPLIED: number;
  37572. /**
  37573. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37574. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37575. */
  37576. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37577. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37578. static readonly ALPHA_INTERPOLATE: number;
  37579. /**
  37580. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37581. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37582. */
  37583. static readonly ALPHA_SCREENMODE: number;
  37584. /** Defines that the ressource is not delayed*/
  37585. static readonly DELAYLOADSTATE_NONE: number;
  37586. /** Defines that the ressource was successfully delay loaded */
  37587. static readonly DELAYLOADSTATE_LOADED: number;
  37588. /** Defines that the ressource is currently delay loading */
  37589. static readonly DELAYLOADSTATE_LOADING: number;
  37590. /** Defines that the ressource is delayed and has not started loading */
  37591. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37592. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37593. static readonly NEVER: number;
  37594. /** 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 */
  37595. static readonly ALWAYS: number;
  37596. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37597. static readonly LESS: number;
  37598. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37599. static readonly EQUAL: number;
  37600. /** 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 */
  37601. static readonly LEQUAL: number;
  37602. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37603. static readonly GREATER: number;
  37604. /** 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 */
  37605. static readonly GEQUAL: number;
  37606. /** 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 */
  37607. static readonly NOTEQUAL: number;
  37608. /** Passed to stencilOperation to specify that stencil value must be kept */
  37609. static readonly KEEP: number;
  37610. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37611. static readonly REPLACE: number;
  37612. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37613. static readonly INCR: number;
  37614. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37615. static readonly DECR: number;
  37616. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37617. static readonly INVERT: number;
  37618. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37619. static readonly INCR_WRAP: number;
  37620. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37621. static readonly DECR_WRAP: number;
  37622. /** Texture is not repeating outside of 0..1 UVs */
  37623. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37624. /** Texture is repeating outside of 0..1 UVs */
  37625. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37626. /** Texture is repeating and mirrored */
  37627. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37628. /** ALPHA */
  37629. static readonly TEXTUREFORMAT_ALPHA: number;
  37630. /** LUMINANCE */
  37631. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37632. /** LUMINANCE_ALPHA */
  37633. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37634. /** RGB */
  37635. static readonly TEXTUREFORMAT_RGB: number;
  37636. /** RGBA */
  37637. static readonly TEXTUREFORMAT_RGBA: number;
  37638. /** RED */
  37639. static readonly TEXTUREFORMAT_RED: number;
  37640. /** RED (2nd reference) */
  37641. static readonly TEXTUREFORMAT_R: number;
  37642. /** RG */
  37643. static readonly TEXTUREFORMAT_RG: number;
  37644. /** RED_INTEGER */
  37645. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37646. /** RED_INTEGER (2nd reference) */
  37647. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37648. /** RG_INTEGER */
  37649. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37650. /** RGB_INTEGER */
  37651. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37652. /** RGBA_INTEGER */
  37653. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37654. /** UNSIGNED_BYTE */
  37655. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37656. /** UNSIGNED_BYTE (2nd reference) */
  37657. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37658. /** FLOAT */
  37659. static readonly TEXTURETYPE_FLOAT: number;
  37660. /** HALF_FLOAT */
  37661. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37662. /** BYTE */
  37663. static readonly TEXTURETYPE_BYTE: number;
  37664. /** SHORT */
  37665. static readonly TEXTURETYPE_SHORT: number;
  37666. /** UNSIGNED_SHORT */
  37667. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37668. /** INT */
  37669. static readonly TEXTURETYPE_INT: number;
  37670. /** UNSIGNED_INT */
  37671. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37672. /** UNSIGNED_SHORT_4_4_4_4 */
  37673. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37674. /** UNSIGNED_SHORT_5_5_5_1 */
  37675. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37676. /** UNSIGNED_SHORT_5_6_5 */
  37677. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37678. /** UNSIGNED_INT_2_10_10_10_REV */
  37679. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37680. /** UNSIGNED_INT_24_8 */
  37681. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37682. /** UNSIGNED_INT_10F_11F_11F_REV */
  37683. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37684. /** UNSIGNED_INT_5_9_9_9_REV */
  37685. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37686. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37687. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37688. /** nearest is mag = nearest and min = nearest and mip = linear */
  37689. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37690. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37691. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37692. /** Trilinear is mag = linear and min = linear and mip = linear */
  37693. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37694. /** nearest is mag = nearest and min = nearest and mip = linear */
  37695. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37696. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37697. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37698. /** Trilinear is mag = linear and min = linear and mip = linear */
  37699. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37700. /** mag = nearest and min = nearest and mip = nearest */
  37701. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37702. /** mag = nearest and min = linear and mip = nearest */
  37703. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37704. /** mag = nearest and min = linear and mip = linear */
  37705. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37706. /** mag = nearest and min = linear and mip = none */
  37707. static readonly TEXTURE_NEAREST_LINEAR: number;
  37708. /** mag = nearest and min = nearest and mip = none */
  37709. static readonly TEXTURE_NEAREST_NEAREST: number;
  37710. /** mag = linear and min = nearest and mip = nearest */
  37711. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37712. /** mag = linear and min = nearest and mip = linear */
  37713. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37714. /** mag = linear and min = linear and mip = none */
  37715. static readonly TEXTURE_LINEAR_LINEAR: number;
  37716. /** mag = linear and min = nearest and mip = none */
  37717. static readonly TEXTURE_LINEAR_NEAREST: number;
  37718. /** Explicit coordinates mode */
  37719. static readonly TEXTURE_EXPLICIT_MODE: number;
  37720. /** Spherical coordinates mode */
  37721. static readonly TEXTURE_SPHERICAL_MODE: number;
  37722. /** Planar coordinates mode */
  37723. static readonly TEXTURE_PLANAR_MODE: number;
  37724. /** Cubic coordinates mode */
  37725. static readonly TEXTURE_CUBIC_MODE: number;
  37726. /** Projection coordinates mode */
  37727. static readonly TEXTURE_PROJECTION_MODE: number;
  37728. /** Skybox coordinates mode */
  37729. static readonly TEXTURE_SKYBOX_MODE: number;
  37730. /** Inverse Cubic coordinates mode */
  37731. static readonly TEXTURE_INVCUBIC_MODE: number;
  37732. /** Equirectangular coordinates mode */
  37733. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37734. /** Equirectangular Fixed coordinates mode */
  37735. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37736. /** Equirectangular Fixed Mirrored coordinates mode */
  37737. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37738. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37739. static readonly SCALEMODE_FLOOR: number;
  37740. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37741. static readonly SCALEMODE_NEAREST: number;
  37742. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37743. static readonly SCALEMODE_CEILING: number;
  37744. /**
  37745. * Returns the current npm package of the sdk
  37746. */
  37747. static get NpmPackage(): string;
  37748. /**
  37749. * Returns the current version of the framework
  37750. */
  37751. static get Version(): string;
  37752. /** Gets the list of created engines */
  37753. static get Instances(): Engine[];
  37754. /**
  37755. * Gets the latest created engine
  37756. */
  37757. static get LastCreatedEngine(): Nullable<Engine>;
  37758. /**
  37759. * Gets the latest created scene
  37760. */
  37761. static get LastCreatedScene(): Nullable<Scene>;
  37762. /**
  37763. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37764. * @param flag defines which part of the materials must be marked as dirty
  37765. * @param predicate defines a predicate used to filter which materials should be affected
  37766. */
  37767. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37768. /**
  37769. * Method called to create the default loading screen.
  37770. * This can be overriden in your own app.
  37771. * @param canvas The rendering canvas element
  37772. * @returns The loading screen
  37773. */
  37774. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37775. /**
  37776. * Method called to create the default rescale post process on each engine.
  37777. */
  37778. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37779. /**
  37780. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37781. **/
  37782. enableOfflineSupport: boolean;
  37783. /**
  37784. * 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)
  37785. **/
  37786. disableManifestCheck: boolean;
  37787. /**
  37788. * Gets the list of created scenes
  37789. */
  37790. scenes: Scene[];
  37791. /**
  37792. * Event raised when a new scene is created
  37793. */
  37794. onNewSceneAddedObservable: Observable<Scene>;
  37795. /**
  37796. * Gets the list of created postprocesses
  37797. */
  37798. postProcesses: PostProcess[];
  37799. /**
  37800. * Gets a boolean indicating if the pointer is currently locked
  37801. */
  37802. isPointerLock: boolean;
  37803. /**
  37804. * Observable event triggered each time the rendering canvas is resized
  37805. */
  37806. onResizeObservable: Observable<Engine>;
  37807. /**
  37808. * Observable event triggered each time the canvas loses focus
  37809. */
  37810. onCanvasBlurObservable: Observable<Engine>;
  37811. /**
  37812. * Observable event triggered each time the canvas gains focus
  37813. */
  37814. onCanvasFocusObservable: Observable<Engine>;
  37815. /**
  37816. * Observable event triggered each time the canvas receives pointerout event
  37817. */
  37818. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37819. /**
  37820. * Observable raised when the engine begins a new frame
  37821. */
  37822. onBeginFrameObservable: Observable<Engine>;
  37823. /**
  37824. * If set, will be used to request the next animation frame for the render loop
  37825. */
  37826. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37827. /**
  37828. * Observable raised when the engine ends the current frame
  37829. */
  37830. onEndFrameObservable: Observable<Engine>;
  37831. /**
  37832. * Observable raised when the engine is about to compile a shader
  37833. */
  37834. onBeforeShaderCompilationObservable: Observable<Engine>;
  37835. /**
  37836. * Observable raised when the engine has jsut compiled a shader
  37837. */
  37838. onAfterShaderCompilationObservable: Observable<Engine>;
  37839. /**
  37840. * Gets the audio engine
  37841. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37842. * @ignorenaming
  37843. */
  37844. static audioEngine: IAudioEngine;
  37845. /**
  37846. * Default AudioEngine factory responsible of creating the Audio Engine.
  37847. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37848. */
  37849. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37850. /**
  37851. * Default offline support factory responsible of creating a tool used to store data locally.
  37852. * By default, this will create a Database object if the workload has been embedded.
  37853. */
  37854. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37855. private _loadingScreen;
  37856. private _pointerLockRequested;
  37857. private _rescalePostProcess;
  37858. private _deterministicLockstep;
  37859. private _lockstepMaxSteps;
  37860. private _timeStep;
  37861. protected get _supportsHardwareTextureRescaling(): boolean;
  37862. private _fps;
  37863. private _deltaTime;
  37864. /** @hidden */
  37865. _drawCalls: PerfCounter;
  37866. /** 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 */
  37867. canvasTabIndex: number;
  37868. /**
  37869. * Turn this value on if you want to pause FPS computation when in background
  37870. */
  37871. disablePerformanceMonitorInBackground: boolean;
  37872. private _performanceMonitor;
  37873. /**
  37874. * Gets the performance monitor attached to this engine
  37875. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37876. */
  37877. get performanceMonitor(): PerformanceMonitor;
  37878. private _onFocus;
  37879. private _onBlur;
  37880. private _onCanvasPointerOut;
  37881. private _onCanvasBlur;
  37882. private _onCanvasFocus;
  37883. private _onFullscreenChange;
  37884. private _onPointerLockChange;
  37885. /**
  37886. * Gets the HTML element used to attach event listeners
  37887. * @returns a HTML element
  37888. */
  37889. getInputElement(): Nullable<HTMLElement>;
  37890. /**
  37891. * Creates a new engine
  37892. * @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
  37893. * @param antialias defines enable antialiasing (default: false)
  37894. * @param options defines further options to be sent to the getContext() function
  37895. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37896. */
  37897. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37898. /**
  37899. * Gets current aspect ratio
  37900. * @param viewportOwner defines the camera to use to get the aspect ratio
  37901. * @param useScreen defines if screen size must be used (or the current render target if any)
  37902. * @returns a number defining the aspect ratio
  37903. */
  37904. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37905. /**
  37906. * Gets current screen aspect ratio
  37907. * @returns a number defining the aspect ratio
  37908. */
  37909. getScreenAspectRatio(): number;
  37910. /**
  37911. * Gets the client rect of the HTML canvas attached with the current webGL context
  37912. * @returns a client rectanglee
  37913. */
  37914. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37915. /**
  37916. * Gets the client rect of the HTML element used for events
  37917. * @returns a client rectanglee
  37918. */
  37919. getInputElementClientRect(): Nullable<ClientRect>;
  37920. /**
  37921. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37922. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37923. * @returns true if engine is in deterministic lock step mode
  37924. */
  37925. isDeterministicLockStep(): boolean;
  37926. /**
  37927. * Gets the max steps when engine is running in deterministic lock step
  37928. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37929. * @returns the max steps
  37930. */
  37931. getLockstepMaxSteps(): number;
  37932. /**
  37933. * Returns the time in ms between steps when using deterministic lock step.
  37934. * @returns time step in (ms)
  37935. */
  37936. getTimeStep(): number;
  37937. /**
  37938. * Force the mipmap generation for the given render target texture
  37939. * @param texture defines the render target texture to use
  37940. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37941. */
  37942. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37943. /** States */
  37944. /**
  37945. * Set various states to the webGL context
  37946. * @param culling defines backface culling state
  37947. * @param zOffset defines the value to apply to zOffset (0 by default)
  37948. * @param force defines if states must be applied even if cache is up to date
  37949. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37950. */
  37951. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37952. /**
  37953. * Set the z offset to apply to current rendering
  37954. * @param value defines the offset to apply
  37955. */
  37956. setZOffset(value: number): void;
  37957. /**
  37958. * Gets the current value of the zOffset
  37959. * @returns the current zOffset state
  37960. */
  37961. getZOffset(): number;
  37962. /**
  37963. * Enable or disable depth buffering
  37964. * @param enable defines the state to set
  37965. */
  37966. setDepthBuffer(enable: boolean): void;
  37967. /**
  37968. * Gets a boolean indicating if depth writing is enabled
  37969. * @returns the current depth writing state
  37970. */
  37971. getDepthWrite(): boolean;
  37972. /**
  37973. * Enable or disable depth writing
  37974. * @param enable defines the state to set
  37975. */
  37976. setDepthWrite(enable: boolean): void;
  37977. /**
  37978. * Gets a boolean indicating if stencil buffer is enabled
  37979. * @returns the current stencil buffer state
  37980. */
  37981. getStencilBuffer(): boolean;
  37982. /**
  37983. * Enable or disable the stencil buffer
  37984. * @param enable defines if the stencil buffer must be enabled or disabled
  37985. */
  37986. setStencilBuffer(enable: boolean): void;
  37987. /**
  37988. * Gets the current stencil mask
  37989. * @returns a number defining the new stencil mask to use
  37990. */
  37991. getStencilMask(): number;
  37992. /**
  37993. * Sets the current stencil mask
  37994. * @param mask defines the new stencil mask to use
  37995. */
  37996. setStencilMask(mask: number): void;
  37997. /**
  37998. * Gets the current stencil function
  37999. * @returns a number defining the stencil function to use
  38000. */
  38001. getStencilFunction(): number;
  38002. /**
  38003. * Gets the current stencil reference value
  38004. * @returns a number defining the stencil reference value to use
  38005. */
  38006. getStencilFunctionReference(): number;
  38007. /**
  38008. * Gets the current stencil mask
  38009. * @returns a number defining the stencil mask to use
  38010. */
  38011. getStencilFunctionMask(): number;
  38012. /**
  38013. * Sets the current stencil function
  38014. * @param stencilFunc defines the new stencil function to use
  38015. */
  38016. setStencilFunction(stencilFunc: number): void;
  38017. /**
  38018. * Sets the current stencil reference
  38019. * @param reference defines the new stencil reference to use
  38020. */
  38021. setStencilFunctionReference(reference: number): void;
  38022. /**
  38023. * Sets the current stencil mask
  38024. * @param mask defines the new stencil mask to use
  38025. */
  38026. setStencilFunctionMask(mask: number): void;
  38027. /**
  38028. * Gets the current stencil operation when stencil fails
  38029. * @returns a number defining stencil operation to use when stencil fails
  38030. */
  38031. getStencilOperationFail(): number;
  38032. /**
  38033. * Gets the current stencil operation when depth fails
  38034. * @returns a number defining stencil operation to use when depth fails
  38035. */
  38036. getStencilOperationDepthFail(): number;
  38037. /**
  38038. * Gets the current stencil operation when stencil passes
  38039. * @returns a number defining stencil operation to use when stencil passes
  38040. */
  38041. getStencilOperationPass(): number;
  38042. /**
  38043. * Sets the stencil operation to use when stencil fails
  38044. * @param operation defines the stencil operation to use when stencil fails
  38045. */
  38046. setStencilOperationFail(operation: number): void;
  38047. /**
  38048. * Sets the stencil operation to use when depth fails
  38049. * @param operation defines the stencil operation to use when depth fails
  38050. */
  38051. setStencilOperationDepthFail(operation: number): void;
  38052. /**
  38053. * Sets the stencil operation to use when stencil passes
  38054. * @param operation defines the stencil operation to use when stencil passes
  38055. */
  38056. setStencilOperationPass(operation: number): void;
  38057. /**
  38058. * Sets a boolean indicating if the dithering state is enabled or disabled
  38059. * @param value defines the dithering state
  38060. */
  38061. setDitheringState(value: boolean): void;
  38062. /**
  38063. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38064. * @param value defines the rasterizer state
  38065. */
  38066. setRasterizerState(value: boolean): void;
  38067. /**
  38068. * Gets the current depth function
  38069. * @returns a number defining the depth function
  38070. */
  38071. getDepthFunction(): Nullable<number>;
  38072. /**
  38073. * Sets the current depth function
  38074. * @param depthFunc defines the function to use
  38075. */
  38076. setDepthFunction(depthFunc: number): void;
  38077. /**
  38078. * Sets the current depth function to GREATER
  38079. */
  38080. setDepthFunctionToGreater(): void;
  38081. /**
  38082. * Sets the current depth function to GEQUAL
  38083. */
  38084. setDepthFunctionToGreaterOrEqual(): void;
  38085. /**
  38086. * Sets the current depth function to LESS
  38087. */
  38088. setDepthFunctionToLess(): void;
  38089. /**
  38090. * Sets the current depth function to LEQUAL
  38091. */
  38092. setDepthFunctionToLessOrEqual(): void;
  38093. private _cachedStencilBuffer;
  38094. private _cachedStencilFunction;
  38095. private _cachedStencilMask;
  38096. private _cachedStencilOperationPass;
  38097. private _cachedStencilOperationFail;
  38098. private _cachedStencilOperationDepthFail;
  38099. private _cachedStencilReference;
  38100. /**
  38101. * Caches the the state of the stencil buffer
  38102. */
  38103. cacheStencilState(): void;
  38104. /**
  38105. * Restores the state of the stencil buffer
  38106. */
  38107. restoreStencilState(): void;
  38108. /**
  38109. * Directly set the WebGL Viewport
  38110. * @param x defines the x coordinate of the viewport (in screen space)
  38111. * @param y defines the y coordinate of the viewport (in screen space)
  38112. * @param width defines the width of the viewport (in screen space)
  38113. * @param height defines the height of the viewport (in screen space)
  38114. * @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
  38115. */
  38116. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38117. /**
  38118. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38119. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38120. * @param y defines the y-coordinate of the corner of the clear rectangle
  38121. * @param width defines the width of the clear rectangle
  38122. * @param height defines the height of the clear rectangle
  38123. * @param clearColor defines the clear color
  38124. */
  38125. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38126. /**
  38127. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38128. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38129. * @param y defines the y-coordinate of the corner of the clear rectangle
  38130. * @param width defines the width of the clear rectangle
  38131. * @param height defines the height of the clear rectangle
  38132. */
  38133. enableScissor(x: number, y: number, width: number, height: number): void;
  38134. /**
  38135. * Disable previously set scissor test rectangle
  38136. */
  38137. disableScissor(): void;
  38138. protected _reportDrawCall(): void;
  38139. /**
  38140. * Initializes a webVR display and starts listening to display change events
  38141. * The onVRDisplayChangedObservable will be notified upon these changes
  38142. * @returns The onVRDisplayChangedObservable
  38143. */
  38144. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38145. /** @hidden */
  38146. _prepareVRComponent(): void;
  38147. /** @hidden */
  38148. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38149. /** @hidden */
  38150. _submitVRFrame(): void;
  38151. /**
  38152. * Call this function to leave webVR mode
  38153. * Will do nothing if webVR is not supported or if there is no webVR device
  38154. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38155. */
  38156. disableVR(): void;
  38157. /**
  38158. * Gets a boolean indicating that the system is in VR mode and is presenting
  38159. * @returns true if VR mode is engaged
  38160. */
  38161. isVRPresenting(): boolean;
  38162. /** @hidden */
  38163. _requestVRFrame(): void;
  38164. /** @hidden */
  38165. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38166. /**
  38167. * Gets the source code of the vertex shader associated with a specific webGL program
  38168. * @param program defines the program to use
  38169. * @returns a string containing the source code of the vertex shader associated with the program
  38170. */
  38171. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38172. /**
  38173. * Gets the source code of the fragment shader associated with a specific webGL program
  38174. * @param program defines the program to use
  38175. * @returns a string containing the source code of the fragment shader associated with the program
  38176. */
  38177. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38178. /**
  38179. * Sets a depth stencil texture from a render target to the according uniform.
  38180. * @param channel The texture channel
  38181. * @param uniform The uniform to set
  38182. * @param texture The render target texture containing the depth stencil texture to apply
  38183. */
  38184. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38185. /**
  38186. * Sets a texture to the webGL context from a postprocess
  38187. * @param channel defines the channel to use
  38188. * @param postProcess defines the source postprocess
  38189. */
  38190. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38191. /**
  38192. * Binds the output of the passed in post process to the texture channel specified
  38193. * @param channel The channel the texture should be bound to
  38194. * @param postProcess The post process which's output should be bound
  38195. */
  38196. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38197. protected _rebuildBuffers(): void;
  38198. /** @hidden */
  38199. _renderFrame(): void;
  38200. _renderLoop(): void;
  38201. /** @hidden */
  38202. _renderViews(): boolean;
  38203. /**
  38204. * Toggle full screen mode
  38205. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38206. */
  38207. switchFullscreen(requestPointerLock: boolean): void;
  38208. /**
  38209. * Enters full screen mode
  38210. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38211. */
  38212. enterFullscreen(requestPointerLock: boolean): void;
  38213. /**
  38214. * Exits full screen mode
  38215. */
  38216. exitFullscreen(): void;
  38217. /**
  38218. * Enters Pointerlock mode
  38219. */
  38220. enterPointerlock(): void;
  38221. /**
  38222. * Exits Pointerlock mode
  38223. */
  38224. exitPointerlock(): void;
  38225. /**
  38226. * Begin a new frame
  38227. */
  38228. beginFrame(): void;
  38229. /**
  38230. * Enf the current frame
  38231. */
  38232. endFrame(): void;
  38233. resize(): void;
  38234. /**
  38235. * Force a specific size of the canvas
  38236. * @param width defines the new canvas' width
  38237. * @param height defines the new canvas' height
  38238. * @returns true if the size was changed
  38239. */
  38240. setSize(width: number, height: number): boolean;
  38241. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38242. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38243. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38244. _releaseTexture(texture: InternalTexture): void;
  38245. /**
  38246. * @hidden
  38247. * Rescales a texture
  38248. * @param source input texutre
  38249. * @param destination destination texture
  38250. * @param scene scene to use to render the resize
  38251. * @param internalFormat format to use when resizing
  38252. * @param onComplete callback to be called when resize has completed
  38253. */
  38254. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38255. /**
  38256. * Gets the current framerate
  38257. * @returns a number representing the framerate
  38258. */
  38259. getFps(): number;
  38260. /**
  38261. * Gets the time spent between current and previous frame
  38262. * @returns a number representing the delta time in ms
  38263. */
  38264. getDeltaTime(): number;
  38265. private _measureFps;
  38266. /** @hidden */
  38267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38268. /**
  38269. * Updates the sample count of a render target texture
  38270. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38271. * @param texture defines the texture to update
  38272. * @param samples defines the sample count to set
  38273. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38274. */
  38275. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38276. /**
  38277. * Updates a depth texture Comparison Mode and Function.
  38278. * If the comparison Function is equal to 0, the mode will be set to none.
  38279. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38280. * @param texture The texture to set the comparison function for
  38281. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38282. */
  38283. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38284. /**
  38285. * Creates a webGL buffer to use with instanciation
  38286. * @param capacity defines the size of the buffer
  38287. * @returns the webGL buffer
  38288. */
  38289. createInstancesBuffer(capacity: number): DataBuffer;
  38290. /**
  38291. * Delete a webGL buffer used with instanciation
  38292. * @param buffer defines the webGL buffer to delete
  38293. */
  38294. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38295. private _clientWaitAsync;
  38296. /** @hidden */
  38297. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38298. dispose(): void;
  38299. private _disableTouchAction;
  38300. /**
  38301. * Display the loading screen
  38302. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38303. */
  38304. displayLoadingUI(): void;
  38305. /**
  38306. * Hide the loading screen
  38307. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38308. */
  38309. hideLoadingUI(): void;
  38310. /**
  38311. * Gets the current loading screen object
  38312. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38313. */
  38314. get loadingScreen(): ILoadingScreen;
  38315. /**
  38316. * Sets the current loading screen object
  38317. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38318. */
  38319. set loadingScreen(loadingScreen: ILoadingScreen);
  38320. /**
  38321. * Sets the current loading screen text
  38322. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38323. */
  38324. set loadingUIText(text: string);
  38325. /**
  38326. * Sets the current loading screen background color
  38327. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38328. */
  38329. set loadingUIBackgroundColor(color: string);
  38330. /** Pointerlock and fullscreen */
  38331. /**
  38332. * Ask the browser to promote the current element to pointerlock mode
  38333. * @param element defines the DOM element to promote
  38334. */
  38335. static _RequestPointerlock(element: HTMLElement): void;
  38336. /**
  38337. * Asks the browser to exit pointerlock mode
  38338. */
  38339. static _ExitPointerlock(): void;
  38340. /**
  38341. * Ask the browser to promote the current element to fullscreen rendering mode
  38342. * @param element defines the DOM element to promote
  38343. */
  38344. static _RequestFullscreen(element: HTMLElement): void;
  38345. /**
  38346. * Asks the browser to exit fullscreen mode
  38347. */
  38348. static _ExitFullscreen(): void;
  38349. }
  38350. }
  38351. declare module BABYLON {
  38352. /**
  38353. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38354. * during the life time of the application.
  38355. */
  38356. export class EngineStore {
  38357. /** Gets the list of created engines */
  38358. static Instances: Engine[];
  38359. /** @hidden */
  38360. static _LastCreatedScene: Nullable<Scene>;
  38361. /**
  38362. * Gets the latest created engine
  38363. */
  38364. static get LastCreatedEngine(): Nullable<Engine>;
  38365. /**
  38366. * Gets the latest created scene
  38367. */
  38368. static get LastCreatedScene(): Nullable<Scene>;
  38369. /**
  38370. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38371. * @ignorenaming
  38372. */
  38373. static UseFallbackTexture: boolean;
  38374. /**
  38375. * Texture content used if a texture cannot loaded
  38376. * @ignorenaming
  38377. */
  38378. static FallbackTexture: string;
  38379. }
  38380. }
  38381. declare module BABYLON {
  38382. /**
  38383. * Helper class that provides a small promise polyfill
  38384. */
  38385. export class PromisePolyfill {
  38386. /**
  38387. * Static function used to check if the polyfill is required
  38388. * If this is the case then the function will inject the polyfill to window.Promise
  38389. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38390. */
  38391. static Apply(force?: boolean): void;
  38392. }
  38393. }
  38394. declare module BABYLON {
  38395. /**
  38396. * Interface for screenshot methods with describe argument called `size` as object with options
  38397. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38398. */
  38399. export interface IScreenshotSize {
  38400. /**
  38401. * number in pixels for canvas height
  38402. */
  38403. height?: number;
  38404. /**
  38405. * multiplier allowing render at a higher or lower resolution
  38406. * If value is defined then height and width will be ignored and taken from camera
  38407. */
  38408. precision?: number;
  38409. /**
  38410. * number in pixels for canvas width
  38411. */
  38412. width?: number;
  38413. }
  38414. }
  38415. declare module BABYLON {
  38416. interface IColor4Like {
  38417. r: float;
  38418. g: float;
  38419. b: float;
  38420. a: float;
  38421. }
  38422. /**
  38423. * Class containing a set of static utilities functions
  38424. */
  38425. export class Tools {
  38426. /**
  38427. * Gets or sets the base URL to use to load assets
  38428. */
  38429. static get BaseUrl(): string;
  38430. static set BaseUrl(value: string);
  38431. /**
  38432. * Enable/Disable Custom HTTP Request Headers globally.
  38433. * default = false
  38434. * @see CustomRequestHeaders
  38435. */
  38436. static UseCustomRequestHeaders: boolean;
  38437. /**
  38438. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38439. * i.e. when loading files, where the server/service expects an Authorization header
  38440. */
  38441. static CustomRequestHeaders: {
  38442. [key: string]: string;
  38443. };
  38444. /**
  38445. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38446. */
  38447. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38448. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38449. /**
  38450. * Default behaviour for cors in the application.
  38451. * It can be a string if the expected behavior is identical in the entire app.
  38452. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38453. */
  38454. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38455. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38456. /**
  38457. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38458. * @ignorenaming
  38459. */
  38460. static get UseFallbackTexture(): boolean;
  38461. static set UseFallbackTexture(value: boolean);
  38462. /**
  38463. * Use this object to register external classes like custom textures or material
  38464. * to allow the laoders to instantiate them
  38465. */
  38466. static get RegisteredExternalClasses(): {
  38467. [key: string]: Object;
  38468. };
  38469. static set RegisteredExternalClasses(classes: {
  38470. [key: string]: Object;
  38471. });
  38472. /**
  38473. * Texture content used if a texture cannot loaded
  38474. * @ignorenaming
  38475. */
  38476. static get fallbackTexture(): string;
  38477. static set fallbackTexture(value: string);
  38478. /**
  38479. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38480. * @param u defines the coordinate on X axis
  38481. * @param v defines the coordinate on Y axis
  38482. * @param width defines the width of the source data
  38483. * @param height defines the height of the source data
  38484. * @param pixels defines the source byte array
  38485. * @param color defines the output color
  38486. */
  38487. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38488. /**
  38489. * Interpolates between a and b via alpha
  38490. * @param a The lower value (returned when alpha = 0)
  38491. * @param b The upper value (returned when alpha = 1)
  38492. * @param alpha The interpolation-factor
  38493. * @return The mixed value
  38494. */
  38495. static Mix(a: number, b: number, alpha: number): number;
  38496. /**
  38497. * Tries to instantiate a new object from a given class name
  38498. * @param className defines the class name to instantiate
  38499. * @returns the new object or null if the system was not able to do the instantiation
  38500. */
  38501. static Instantiate(className: string): any;
  38502. /**
  38503. * Provides a slice function that will work even on IE
  38504. * @param data defines the array to slice
  38505. * @param start defines the start of the data (optional)
  38506. * @param end defines the end of the data (optional)
  38507. * @returns the new sliced array
  38508. */
  38509. static Slice<T>(data: T, start?: number, end?: number): T;
  38510. /**
  38511. * Polyfill for setImmediate
  38512. * @param action defines the action to execute after the current execution block
  38513. */
  38514. static SetImmediate(action: () => void): void;
  38515. /**
  38516. * Function indicating if a number is an exponent of 2
  38517. * @param value defines the value to test
  38518. * @returns true if the value is an exponent of 2
  38519. */
  38520. static IsExponentOfTwo(value: number): boolean;
  38521. private static _tmpFloatArray;
  38522. /**
  38523. * Returns the nearest 32-bit single precision float representation of a Number
  38524. * @param value A Number. If the parameter is of a different type, it will get converted
  38525. * to a number or to NaN if it cannot be converted
  38526. * @returns number
  38527. */
  38528. static FloatRound(value: number): number;
  38529. /**
  38530. * Extracts the filename from a path
  38531. * @param path defines the path to use
  38532. * @returns the filename
  38533. */
  38534. static GetFilename(path: string): string;
  38535. /**
  38536. * Extracts the "folder" part of a path (everything before the filename).
  38537. * @param uri The URI to extract the info from
  38538. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38539. * @returns The "folder" part of the path
  38540. */
  38541. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38542. /**
  38543. * Extracts text content from a DOM element hierarchy
  38544. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38545. */
  38546. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38547. /**
  38548. * Convert an angle in radians to degrees
  38549. * @param angle defines the angle to convert
  38550. * @returns the angle in degrees
  38551. */
  38552. static ToDegrees(angle: number): number;
  38553. /**
  38554. * Convert an angle in degrees to radians
  38555. * @param angle defines the angle to convert
  38556. * @returns the angle in radians
  38557. */
  38558. static ToRadians(angle: number): number;
  38559. /**
  38560. * Returns an array if obj is not an array
  38561. * @param obj defines the object to evaluate as an array
  38562. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38563. * @returns either obj directly if obj is an array or a new array containing obj
  38564. */
  38565. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38566. /**
  38567. * Gets the pointer prefix to use
  38568. * @param engine defines the engine we are finding the prefix for
  38569. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38570. */
  38571. static GetPointerPrefix(engine: Engine): string;
  38572. /**
  38573. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38574. * @param url define the url we are trying
  38575. * @param element define the dom element where to configure the cors policy
  38576. */
  38577. static SetCorsBehavior(url: string | string[], element: {
  38578. crossOrigin: string | null;
  38579. }): void;
  38580. /**
  38581. * Removes unwanted characters from an url
  38582. * @param url defines the url to clean
  38583. * @returns the cleaned url
  38584. */
  38585. static CleanUrl(url: string): string;
  38586. /**
  38587. * Gets or sets a function used to pre-process url before using them to load assets
  38588. */
  38589. static get PreprocessUrl(): (url: string) => string;
  38590. static set PreprocessUrl(processor: (url: string) => string);
  38591. /**
  38592. * Loads an image as an HTMLImageElement.
  38593. * @param input url string, ArrayBuffer, or Blob to load
  38594. * @param onLoad callback called when the image successfully loads
  38595. * @param onError callback called when the image fails to load
  38596. * @param offlineProvider offline provider for caching
  38597. * @param mimeType optional mime type
  38598. * @returns the HTMLImageElement of the loaded image
  38599. */
  38600. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38601. /**
  38602. * Loads a file from a url
  38603. * @param url url string, ArrayBuffer, or Blob to load
  38604. * @param onSuccess callback called when the file successfully loads
  38605. * @param onProgress callback called while file is loading (if the server supports this mode)
  38606. * @param offlineProvider defines the offline provider for caching
  38607. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38608. * @param onError callback called when the file fails to load
  38609. * @returns a file request object
  38610. */
  38611. 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;
  38612. /**
  38613. * Loads a file from a url
  38614. * @param url the file url to load
  38615. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38616. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38617. */
  38618. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38619. /**
  38620. * Load a script (identified by an url). When the url returns, the
  38621. * content of this file is added into a new script element, attached to the DOM (body element)
  38622. * @param scriptUrl defines the url of the script to laod
  38623. * @param onSuccess defines the callback called when the script is loaded
  38624. * @param onError defines the callback to call if an error occurs
  38625. * @param scriptId defines the id of the script element
  38626. */
  38627. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38628. /**
  38629. * Load an asynchronous script (identified by an url). When the url returns, the
  38630. * content of this file is added into a new script element, attached to the DOM (body element)
  38631. * @param scriptUrl defines the url of the script to laod
  38632. * @param scriptId defines the id of the script element
  38633. * @returns a promise request object
  38634. */
  38635. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38636. /**
  38637. * Loads a file from a blob
  38638. * @param fileToLoad defines the blob to use
  38639. * @param callback defines the callback to call when data is loaded
  38640. * @param progressCallback defines the callback to call during loading process
  38641. * @returns a file request object
  38642. */
  38643. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38644. /**
  38645. * Reads a file from a File object
  38646. * @param file defines the file to load
  38647. * @param onSuccess defines the callback to call when data is loaded
  38648. * @param onProgress defines the callback to call during loading process
  38649. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38650. * @param onError defines the callback to call when an error occurs
  38651. * @returns a file request object
  38652. */
  38653. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38654. /**
  38655. * Creates a data url from a given string content
  38656. * @param content defines the content to convert
  38657. * @returns the new data url link
  38658. */
  38659. static FileAsURL(content: string): string;
  38660. /**
  38661. * Format the given number to a specific decimal format
  38662. * @param value defines the number to format
  38663. * @param decimals defines the number of decimals to use
  38664. * @returns the formatted string
  38665. */
  38666. static Format(value: number, decimals?: number): string;
  38667. /**
  38668. * Tries to copy an object by duplicating every property
  38669. * @param source defines the source object
  38670. * @param destination defines the target object
  38671. * @param doNotCopyList defines a list of properties to avoid
  38672. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38673. */
  38674. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38675. /**
  38676. * Gets a boolean indicating if the given object has no own property
  38677. * @param obj defines the object to test
  38678. * @returns true if object has no own property
  38679. */
  38680. static IsEmpty(obj: any): boolean;
  38681. /**
  38682. * Function used to register events at window level
  38683. * @param windowElement defines the Window object to use
  38684. * @param events defines the events to register
  38685. */
  38686. static RegisterTopRootEvents(windowElement: Window, events: {
  38687. name: string;
  38688. handler: Nullable<(e: FocusEvent) => any>;
  38689. }[]): void;
  38690. /**
  38691. * Function used to unregister events from window level
  38692. * @param windowElement defines the Window object to use
  38693. * @param events defines the events to unregister
  38694. */
  38695. static UnregisterTopRootEvents(windowElement: Window, events: {
  38696. name: string;
  38697. handler: Nullable<(e: FocusEvent) => any>;
  38698. }[]): void;
  38699. /**
  38700. * @ignore
  38701. */
  38702. static _ScreenshotCanvas: HTMLCanvasElement;
  38703. /**
  38704. * Dumps the current bound framebuffer
  38705. * @param width defines the rendering width
  38706. * @param height defines the rendering height
  38707. * @param engine defines the hosting engine
  38708. * @param successCallback defines the callback triggered once the data are available
  38709. * @param mimeType defines the mime type of the result
  38710. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38711. */
  38712. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38713. /**
  38714. * Converts the canvas data to blob.
  38715. * This acts as a polyfill for browsers not supporting the to blob function.
  38716. * @param canvas Defines the canvas to extract the data from
  38717. * @param successCallback Defines the callback triggered once the data are available
  38718. * @param mimeType Defines the mime type of the result
  38719. */
  38720. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38721. /**
  38722. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38723. * @param successCallback defines the callback triggered once the data are available
  38724. * @param mimeType defines the mime type of the result
  38725. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38726. */
  38727. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38728. /**
  38729. * Downloads a blob in the browser
  38730. * @param blob defines the blob to download
  38731. * @param fileName defines the name of the downloaded file
  38732. */
  38733. static Download(blob: Blob, fileName: string): void;
  38734. /**
  38735. * Captures a screenshot of the current rendering
  38736. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38737. * @param engine defines the rendering engine
  38738. * @param camera defines the source camera
  38739. * @param size This parameter can be set to a single number or to an object with the
  38740. * following (optional) properties: precision, width, height. If a single number is passed,
  38741. * it will be used for both width and height. If an object is passed, the screenshot size
  38742. * will be derived from the parameters. The precision property is a multiplier allowing
  38743. * rendering at a higher or lower resolution
  38744. * @param successCallback defines the callback receives a single parameter which contains the
  38745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38746. * src parameter of an <img> to display it
  38747. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38748. * Check your browser for supported MIME types
  38749. */
  38750. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38751. /**
  38752. * Captures a screenshot of the current rendering
  38753. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38754. * @param engine defines the rendering engine
  38755. * @param camera defines the source camera
  38756. * @param size This parameter can be set to a single number or to an object with the
  38757. * following (optional) properties: precision, width, height. If a single number is passed,
  38758. * it will be used for both width and height. If an object is passed, the screenshot size
  38759. * will be derived from the parameters. The precision property is a multiplier allowing
  38760. * rendering at a higher or lower resolution
  38761. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38762. * Check your browser for supported MIME types
  38763. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38764. * to the src parameter of an <img> to display it
  38765. */
  38766. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38767. /**
  38768. * Generates an image screenshot from the specified camera.
  38769. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38770. * @param engine The engine to use for rendering
  38771. * @param camera The camera to use for rendering
  38772. * @param size This parameter can be set to a single number or to an object with the
  38773. * following (optional) properties: precision, width, height. If a single number is passed,
  38774. * it will be used for both width and height. If an object is passed, the screenshot size
  38775. * will be derived from the parameters. The precision property is a multiplier allowing
  38776. * rendering at a higher or lower resolution
  38777. * @param successCallback The callback receives a single parameter which contains the
  38778. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38779. * src parameter of an <img> to display it
  38780. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38781. * Check your browser for supported MIME types
  38782. * @param samples Texture samples (default: 1)
  38783. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38784. * @param fileName A name for for the downloaded file.
  38785. */
  38786. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38787. /**
  38788. * Generates an image screenshot from the specified camera.
  38789. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38790. * @param engine The engine to use for rendering
  38791. * @param camera The camera to use for rendering
  38792. * @param size This parameter can be set to a single number or to an object with the
  38793. * following (optional) properties: precision, width, height. If a single number is passed,
  38794. * it will be used for both width and height. If an object is passed, the screenshot size
  38795. * will be derived from the parameters. The precision property is a multiplier allowing
  38796. * rendering at a higher or lower resolution
  38797. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38798. * Check your browser for supported MIME types
  38799. * @param samples Texture samples (default: 1)
  38800. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38801. * @param fileName A name for for the downloaded file.
  38802. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38803. * to the src parameter of an <img> to display it
  38804. */
  38805. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38806. /**
  38807. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38808. * Be aware Math.random() could cause collisions, but:
  38809. * "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"
  38810. * @returns a pseudo random id
  38811. */
  38812. static RandomId(): string;
  38813. /**
  38814. * Test if the given uri is a base64 string
  38815. * @param uri The uri to test
  38816. * @return True if the uri is a base64 string or false otherwise
  38817. */
  38818. static IsBase64(uri: string): boolean;
  38819. /**
  38820. * Decode the given base64 uri.
  38821. * @param uri The uri to decode
  38822. * @return The decoded base64 data.
  38823. */
  38824. static DecodeBase64(uri: string): ArrayBuffer;
  38825. /**
  38826. * Gets the absolute url.
  38827. * @param url the input url
  38828. * @return the absolute url
  38829. */
  38830. static GetAbsoluteUrl(url: string): string;
  38831. /**
  38832. * No log
  38833. */
  38834. static readonly NoneLogLevel: number;
  38835. /**
  38836. * Only message logs
  38837. */
  38838. static readonly MessageLogLevel: number;
  38839. /**
  38840. * Only warning logs
  38841. */
  38842. static readonly WarningLogLevel: number;
  38843. /**
  38844. * Only error logs
  38845. */
  38846. static readonly ErrorLogLevel: number;
  38847. /**
  38848. * All logs
  38849. */
  38850. static readonly AllLogLevel: number;
  38851. /**
  38852. * Gets a value indicating the number of loading errors
  38853. * @ignorenaming
  38854. */
  38855. static get errorsCount(): number;
  38856. /**
  38857. * Callback called when a new log is added
  38858. */
  38859. static OnNewCacheEntry: (entry: string) => void;
  38860. /**
  38861. * Log a message to the console
  38862. * @param message defines the message to log
  38863. */
  38864. static Log(message: string): void;
  38865. /**
  38866. * Write a warning message to the console
  38867. * @param message defines the message to log
  38868. */
  38869. static Warn(message: string): void;
  38870. /**
  38871. * Write an error message to the console
  38872. * @param message defines the message to log
  38873. */
  38874. static Error(message: string): void;
  38875. /**
  38876. * Gets current log cache (list of logs)
  38877. */
  38878. static get LogCache(): string;
  38879. /**
  38880. * Clears the log cache
  38881. */
  38882. static ClearLogCache(): void;
  38883. /**
  38884. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38885. */
  38886. static set LogLevels(level: number);
  38887. /**
  38888. * Checks if the window object exists
  38889. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38890. */
  38891. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38892. /**
  38893. * No performance log
  38894. */
  38895. static readonly PerformanceNoneLogLevel: number;
  38896. /**
  38897. * Use user marks to log performance
  38898. */
  38899. static readonly PerformanceUserMarkLogLevel: number;
  38900. /**
  38901. * Log performance to the console
  38902. */
  38903. static readonly PerformanceConsoleLogLevel: number;
  38904. private static _performance;
  38905. /**
  38906. * Sets the current performance log level
  38907. */
  38908. static set PerformanceLogLevel(level: number);
  38909. private static _StartPerformanceCounterDisabled;
  38910. private static _EndPerformanceCounterDisabled;
  38911. private static _StartUserMark;
  38912. private static _EndUserMark;
  38913. private static _StartPerformanceConsole;
  38914. private static _EndPerformanceConsole;
  38915. /**
  38916. * Starts a performance counter
  38917. */
  38918. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38919. /**
  38920. * Ends a specific performance coutner
  38921. */
  38922. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38923. /**
  38924. * Gets either window.performance.now() if supported or Date.now() else
  38925. */
  38926. static get Now(): number;
  38927. /**
  38928. * This method will return the name of the class used to create the instance of the given object.
  38929. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38930. * @param object the object to get the class name from
  38931. * @param isType defines if the object is actually a type
  38932. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38933. */
  38934. static GetClassName(object: any, isType?: boolean): string;
  38935. /**
  38936. * Gets the first element of an array satisfying a given predicate
  38937. * @param array defines the array to browse
  38938. * @param predicate defines the predicate to use
  38939. * @returns null if not found or the element
  38940. */
  38941. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38942. /**
  38943. * This method will return the name of the full name of the class, including its owning module (if any).
  38944. * 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).
  38945. * @param object the object to get the class name from
  38946. * @param isType defines if the object is actually a type
  38947. * @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.
  38948. * @ignorenaming
  38949. */
  38950. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38951. /**
  38952. * Returns a promise that resolves after the given amount of time.
  38953. * @param delay Number of milliseconds to delay
  38954. * @returns Promise that resolves after the given amount of time
  38955. */
  38956. static DelayAsync(delay: number): Promise<void>;
  38957. /**
  38958. * Utility function to detect if the current user agent is Safari
  38959. * @returns whether or not the current user agent is safari
  38960. */
  38961. static IsSafari(): boolean;
  38962. }
  38963. /**
  38964. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38965. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38966. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38967. * @param name The name of the class, case should be preserved
  38968. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38969. */
  38970. export function className(name: string, module?: string): (target: Object) => void;
  38971. /**
  38972. * An implementation of a loop for asynchronous functions.
  38973. */
  38974. export class AsyncLoop {
  38975. /**
  38976. * Defines the number of iterations for the loop
  38977. */
  38978. iterations: number;
  38979. /**
  38980. * Defines the current index of the loop.
  38981. */
  38982. index: number;
  38983. private _done;
  38984. private _fn;
  38985. private _successCallback;
  38986. /**
  38987. * Constructor.
  38988. * @param iterations the number of iterations.
  38989. * @param func the function to run each iteration
  38990. * @param successCallback the callback that will be called upon succesful execution
  38991. * @param offset starting offset.
  38992. */
  38993. constructor(
  38994. /**
  38995. * Defines the number of iterations for the loop
  38996. */
  38997. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38998. /**
  38999. * Execute the next iteration. Must be called after the last iteration was finished.
  39000. */
  39001. executeNext(): void;
  39002. /**
  39003. * Break the loop and run the success callback.
  39004. */
  39005. breakLoop(): void;
  39006. /**
  39007. * Create and run an async loop.
  39008. * @param iterations the number of iterations.
  39009. * @param fn the function to run each iteration
  39010. * @param successCallback the callback that will be called upon succesful execution
  39011. * @param offset starting offset.
  39012. * @returns the created async loop object
  39013. */
  39014. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39015. /**
  39016. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39017. * @param iterations total number of iterations
  39018. * @param syncedIterations number of synchronous iterations in each async iteration.
  39019. * @param fn the function to call each iteration.
  39020. * @param callback a success call back that will be called when iterating stops.
  39021. * @param breakFunction a break condition (optional)
  39022. * @param timeout timeout settings for the setTimeout function. default - 0.
  39023. * @returns the created async loop object
  39024. */
  39025. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39026. }
  39027. }
  39028. declare module BABYLON {
  39029. /**
  39030. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39031. * The underlying implementation relies on an associative array to ensure the best performances.
  39032. * The value can be anything including 'null' but except 'undefined'
  39033. */
  39034. export class StringDictionary<T> {
  39035. /**
  39036. * This will clear this dictionary and copy the content from the 'source' one.
  39037. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39038. * @param source the dictionary to take the content from and copy to this dictionary
  39039. */
  39040. copyFrom(source: StringDictionary<T>): void;
  39041. /**
  39042. * Get a value based from its key
  39043. * @param key the given key to get the matching value from
  39044. * @return the value if found, otherwise undefined is returned
  39045. */
  39046. get(key: string): T | undefined;
  39047. /**
  39048. * Get a value from its key or add it if it doesn't exist.
  39049. * This method will ensure you that a given key/data will be present in the dictionary.
  39050. * @param key the given key to get the matching value from
  39051. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39052. * The factory will only be invoked if there's no data for the given key.
  39053. * @return the value corresponding to the key.
  39054. */
  39055. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39056. /**
  39057. * Get a value from its key if present in the dictionary otherwise add it
  39058. * @param key the key to get the value from
  39059. * @param val if there's no such key/value pair in the dictionary add it with this value
  39060. * @return the value corresponding to the key
  39061. */
  39062. getOrAdd(key: string, val: T): T;
  39063. /**
  39064. * Check if there's a given key in the dictionary
  39065. * @param key the key to check for
  39066. * @return true if the key is present, false otherwise
  39067. */
  39068. contains(key: string): boolean;
  39069. /**
  39070. * Add a new key and its corresponding value
  39071. * @param key the key to add
  39072. * @param value the value corresponding to the key
  39073. * @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
  39074. */
  39075. add(key: string, value: T): boolean;
  39076. /**
  39077. * Update a specific value associated to a key
  39078. * @param key defines the key to use
  39079. * @param value defines the value to store
  39080. * @returns true if the value was updated (or false if the key was not found)
  39081. */
  39082. set(key: string, value: T): boolean;
  39083. /**
  39084. * Get the element of the given key and remove it from the dictionary
  39085. * @param key defines the key to search
  39086. * @returns the value associated with the key or null if not found
  39087. */
  39088. getAndRemove(key: string): Nullable<T>;
  39089. /**
  39090. * Remove a key/value from the dictionary.
  39091. * @param key the key to remove
  39092. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39093. */
  39094. remove(key: string): boolean;
  39095. /**
  39096. * Clear the whole content of the dictionary
  39097. */
  39098. clear(): void;
  39099. /**
  39100. * Gets the current count
  39101. */
  39102. get count(): number;
  39103. /**
  39104. * Execute a callback on each key/val of the dictionary.
  39105. * Note that you can remove any element in this dictionary in the callback implementation
  39106. * @param callback the callback to execute on a given key/value pair
  39107. */
  39108. forEach(callback: (key: string, val: T) => void): void;
  39109. /**
  39110. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39111. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39112. * Note that you can remove any element in this dictionary in the callback implementation
  39113. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39114. * @returns the first item
  39115. */
  39116. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39117. private _count;
  39118. private _data;
  39119. }
  39120. }
  39121. declare module BABYLON {
  39122. /** @hidden */
  39123. export interface ICollisionCoordinator {
  39124. createCollider(): Collider;
  39125. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39126. init(scene: Scene): void;
  39127. }
  39128. /** @hidden */
  39129. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39130. private _scene;
  39131. private _scaledPosition;
  39132. private _scaledVelocity;
  39133. private _finalPosition;
  39134. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39135. createCollider(): Collider;
  39136. init(scene: Scene): void;
  39137. private _collideWithWorld;
  39138. }
  39139. }
  39140. declare module BABYLON {
  39141. /**
  39142. * Class used to manage all inputs for the scene.
  39143. */
  39144. export class InputManager {
  39145. /** The distance in pixel that you have to move to prevent some events */
  39146. static DragMovementThreshold: number;
  39147. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39148. static LongPressDelay: number;
  39149. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39150. static DoubleClickDelay: number;
  39151. /** If you need to check double click without raising a single click at first click, enable this flag */
  39152. static ExclusiveDoubleClickMode: boolean;
  39153. /** 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. */
  39154. private _alreadyAttached;
  39155. private _wheelEventName;
  39156. private _onPointerMove;
  39157. private _onPointerDown;
  39158. private _onPointerUp;
  39159. private _initClickEvent;
  39160. private _initActionManager;
  39161. private _delayedSimpleClick;
  39162. private _delayedSimpleClickTimeout;
  39163. private _previousDelayedSimpleClickTimeout;
  39164. private _meshPickProceed;
  39165. private _previousButtonPressed;
  39166. private _currentPickResult;
  39167. private _previousPickResult;
  39168. private _totalPointersPressed;
  39169. private _doubleClickOccured;
  39170. private _pointerOverMesh;
  39171. private _pickedDownMesh;
  39172. private _pickedUpMesh;
  39173. private _pointerX;
  39174. private _pointerY;
  39175. private _unTranslatedPointerX;
  39176. private _unTranslatedPointerY;
  39177. private _startingPointerPosition;
  39178. private _previousStartingPointerPosition;
  39179. private _startingPointerTime;
  39180. private _previousStartingPointerTime;
  39181. private _pointerCaptures;
  39182. private _meshUnderPointerId;
  39183. private _onKeyDown;
  39184. private _onKeyUp;
  39185. private _onCanvasFocusObserver;
  39186. private _onCanvasBlurObserver;
  39187. private _scene;
  39188. /**
  39189. * Creates a new InputManager
  39190. * @param scene defines the hosting scene
  39191. */
  39192. constructor(scene: Scene);
  39193. /**
  39194. * Gets the mesh that is currently under the pointer
  39195. */
  39196. get meshUnderPointer(): Nullable<AbstractMesh>;
  39197. /**
  39198. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39199. * @param pointerId the pointer id to use
  39200. * @returns The mesh under this pointer id or null if not found
  39201. */
  39202. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39203. /**
  39204. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39205. */
  39206. get unTranslatedPointer(): Vector2;
  39207. /**
  39208. * Gets or sets the current on-screen X position of the pointer
  39209. */
  39210. get pointerX(): number;
  39211. set pointerX(value: number);
  39212. /**
  39213. * Gets or sets the current on-screen Y position of the pointer
  39214. */
  39215. get pointerY(): number;
  39216. set pointerY(value: number);
  39217. private _updatePointerPosition;
  39218. private _processPointerMove;
  39219. private _setRayOnPointerInfo;
  39220. private _checkPrePointerObservable;
  39221. /**
  39222. * Use this method to simulate a pointer move on a mesh
  39223. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39224. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39225. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39226. */
  39227. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39228. /**
  39229. * Use this method to simulate a pointer down on a mesh
  39230. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39231. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39232. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39233. */
  39234. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39235. private _processPointerDown;
  39236. /** @hidden */
  39237. _isPointerSwiping(): boolean;
  39238. /**
  39239. * Use this method to simulate a pointer up on a mesh
  39240. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39241. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39242. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39243. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39244. */
  39245. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39246. private _processPointerUp;
  39247. /**
  39248. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39249. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39250. * @returns true if the pointer was captured
  39251. */
  39252. isPointerCaptured(pointerId?: number): boolean;
  39253. /**
  39254. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39255. * @param attachUp defines if you want to attach events to pointerup
  39256. * @param attachDown defines if you want to attach events to pointerdown
  39257. * @param attachMove defines if you want to attach events to pointermove
  39258. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39259. */
  39260. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39261. /**
  39262. * Detaches all event handlers
  39263. */
  39264. detachControl(): void;
  39265. /**
  39266. * Force the value of meshUnderPointer
  39267. * @param mesh defines the mesh to use
  39268. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39269. */
  39270. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39271. /**
  39272. * Gets the mesh under the pointer
  39273. * @returns a Mesh or null if no mesh is under the pointer
  39274. */
  39275. getPointerOverMesh(): Nullable<AbstractMesh>;
  39276. }
  39277. }
  39278. declare module BABYLON {
  39279. /**
  39280. * This class defines the direct association between an animation and a target
  39281. */
  39282. export class TargetedAnimation {
  39283. /**
  39284. * Animation to perform
  39285. */
  39286. animation: Animation;
  39287. /**
  39288. * Target to animate
  39289. */
  39290. target: any;
  39291. /**
  39292. * Returns the string "TargetedAnimation"
  39293. * @returns "TargetedAnimation"
  39294. */
  39295. getClassName(): string;
  39296. /**
  39297. * Serialize the object
  39298. * @returns the JSON object representing the current entity
  39299. */
  39300. serialize(): any;
  39301. }
  39302. /**
  39303. * Use this class to create coordinated animations on multiple targets
  39304. */
  39305. export class AnimationGroup implements IDisposable {
  39306. /** The name of the animation group */
  39307. name: string;
  39308. private _scene;
  39309. private _targetedAnimations;
  39310. private _animatables;
  39311. private _from;
  39312. private _to;
  39313. private _isStarted;
  39314. private _isPaused;
  39315. private _speedRatio;
  39316. private _loopAnimation;
  39317. private _isAdditive;
  39318. /**
  39319. * Gets or sets the unique id of the node
  39320. */
  39321. uniqueId: number;
  39322. /**
  39323. * This observable will notify when one animation have ended
  39324. */
  39325. onAnimationEndObservable: Observable<TargetedAnimation>;
  39326. /**
  39327. * Observer raised when one animation loops
  39328. */
  39329. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39330. /**
  39331. * Observer raised when all animations have looped
  39332. */
  39333. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39334. /**
  39335. * This observable will notify when all animations have ended.
  39336. */
  39337. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39338. /**
  39339. * This observable will notify when all animations have paused.
  39340. */
  39341. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39342. /**
  39343. * This observable will notify when all animations are playing.
  39344. */
  39345. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39346. /**
  39347. * Gets the first frame
  39348. */
  39349. get from(): number;
  39350. /**
  39351. * Gets the last frame
  39352. */
  39353. get to(): number;
  39354. /**
  39355. * Define if the animations are started
  39356. */
  39357. get isStarted(): boolean;
  39358. /**
  39359. * Gets a value indicating that the current group is playing
  39360. */
  39361. get isPlaying(): boolean;
  39362. /**
  39363. * Gets or sets the speed ratio to use for all animations
  39364. */
  39365. get speedRatio(): number;
  39366. /**
  39367. * Gets or sets the speed ratio to use for all animations
  39368. */
  39369. set speedRatio(value: number);
  39370. /**
  39371. * Gets or sets if all animations should loop or not
  39372. */
  39373. get loopAnimation(): boolean;
  39374. set loopAnimation(value: boolean);
  39375. /**
  39376. * Gets or sets if all animations should be evaluated additively
  39377. */
  39378. get isAdditive(): boolean;
  39379. set isAdditive(value: boolean);
  39380. /**
  39381. * Gets the targeted animations for this animation group
  39382. */
  39383. get targetedAnimations(): Array<TargetedAnimation>;
  39384. /**
  39385. * returning the list of animatables controlled by this animation group.
  39386. */
  39387. get animatables(): Array<Animatable>;
  39388. /**
  39389. * Gets the list of target animations
  39390. */
  39391. get children(): TargetedAnimation[];
  39392. /**
  39393. * Instantiates a new Animation Group.
  39394. * This helps managing several animations at once.
  39395. * @see https://doc.babylonjs.com/how_to/group
  39396. * @param name Defines the name of the group
  39397. * @param scene Defines the scene the group belongs to
  39398. */
  39399. constructor(
  39400. /** The name of the animation group */
  39401. name: string, scene?: Nullable<Scene>);
  39402. /**
  39403. * Add an animation (with its target) in the group
  39404. * @param animation defines the animation we want to add
  39405. * @param target defines the target of the animation
  39406. * @returns the TargetedAnimation object
  39407. */
  39408. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39409. /**
  39410. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39411. * It can add constant keys at begin or end
  39412. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39413. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39414. * @returns the animation group
  39415. */
  39416. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39417. private _animationLoopCount;
  39418. private _animationLoopFlags;
  39419. private _processLoop;
  39420. /**
  39421. * Start all animations on given targets
  39422. * @param loop defines if animations must loop
  39423. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39424. * @param from defines the from key (optional)
  39425. * @param to defines the to key (optional)
  39426. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39427. * @returns the current animation group
  39428. */
  39429. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39430. /**
  39431. * Pause all animations
  39432. * @returns the animation group
  39433. */
  39434. pause(): AnimationGroup;
  39435. /**
  39436. * Play all animations to initial state
  39437. * This function will start() the animations if they were not started or will restart() them if they were paused
  39438. * @param loop defines if animations must loop
  39439. * @returns the animation group
  39440. */
  39441. play(loop?: boolean): AnimationGroup;
  39442. /**
  39443. * Reset all animations to initial state
  39444. * @returns the animation group
  39445. */
  39446. reset(): AnimationGroup;
  39447. /**
  39448. * Restart animations from key 0
  39449. * @returns the animation group
  39450. */
  39451. restart(): AnimationGroup;
  39452. /**
  39453. * Stop all animations
  39454. * @returns the animation group
  39455. */
  39456. stop(): AnimationGroup;
  39457. /**
  39458. * Set animation weight for all animatables
  39459. * @param weight defines the weight to use
  39460. * @return the animationGroup
  39461. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39462. */
  39463. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39464. /**
  39465. * Synchronize and normalize all animatables with a source animatable
  39466. * @param root defines the root animatable to synchronize with
  39467. * @return the animationGroup
  39468. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39469. */
  39470. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39471. /**
  39472. * Goes to a specific frame in this animation group
  39473. * @param frame the frame number to go to
  39474. * @return the animationGroup
  39475. */
  39476. goToFrame(frame: number): AnimationGroup;
  39477. /**
  39478. * Dispose all associated resources
  39479. */
  39480. dispose(): void;
  39481. private _checkAnimationGroupEnded;
  39482. /**
  39483. * Clone the current animation group and returns a copy
  39484. * @param newName defines the name of the new group
  39485. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39486. * @returns the new aniamtion group
  39487. */
  39488. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39489. /**
  39490. * Serializes the animationGroup to an object
  39491. * @returns Serialized object
  39492. */
  39493. serialize(): any;
  39494. /**
  39495. * Returns a new AnimationGroup object parsed from the source provided.
  39496. * @param parsedAnimationGroup defines the source
  39497. * @param scene defines the scene that will receive the animationGroup
  39498. * @returns a new AnimationGroup
  39499. */
  39500. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39501. /**
  39502. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39503. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39504. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39505. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39506. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39507. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39508. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39509. */
  39510. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39511. /**
  39512. * Returns the string "AnimationGroup"
  39513. * @returns "AnimationGroup"
  39514. */
  39515. getClassName(): string;
  39516. /**
  39517. * Creates a detailled string about the object
  39518. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39519. * @returns a string representing the object
  39520. */
  39521. toString(fullDetails?: boolean): string;
  39522. }
  39523. }
  39524. declare module BABYLON {
  39525. /**
  39526. * Define an interface for all classes that will hold resources
  39527. */
  39528. export interface IDisposable {
  39529. /**
  39530. * Releases all held resources
  39531. */
  39532. dispose(): void;
  39533. }
  39534. /** Interface defining initialization parameters for Scene class */
  39535. export interface SceneOptions {
  39536. /**
  39537. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39538. * It will improve performance when the number of geometries becomes important.
  39539. */
  39540. useGeometryUniqueIdsMap?: boolean;
  39541. /**
  39542. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39543. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39544. */
  39545. useMaterialMeshMap?: boolean;
  39546. /**
  39547. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39548. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39549. */
  39550. useClonedMeshMap?: boolean;
  39551. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39552. virtual?: boolean;
  39553. }
  39554. /**
  39555. * Represents a scene to be rendered by the engine.
  39556. * @see https://doc.babylonjs.com/features/scene
  39557. */
  39558. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39559. /** The fog is deactivated */
  39560. static readonly FOGMODE_NONE: number;
  39561. /** The fog density is following an exponential function */
  39562. static readonly FOGMODE_EXP: number;
  39563. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39564. static readonly FOGMODE_EXP2: number;
  39565. /** The fog density is following a linear function. */
  39566. static readonly FOGMODE_LINEAR: number;
  39567. /**
  39568. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39569. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39570. */
  39571. static MinDeltaTime: number;
  39572. /**
  39573. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39574. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39575. */
  39576. static MaxDeltaTime: number;
  39577. /**
  39578. * Factory used to create the default material.
  39579. * @param name The name of the material to create
  39580. * @param scene The scene to create the material for
  39581. * @returns The default material
  39582. */
  39583. static DefaultMaterialFactory(scene: Scene): Material;
  39584. /**
  39585. * Factory used to create the a collision coordinator.
  39586. * @returns The collision coordinator
  39587. */
  39588. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39589. /** @hidden */
  39590. _inputManager: InputManager;
  39591. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39592. cameraToUseForPointers: Nullable<Camera>;
  39593. /** @hidden */
  39594. readonly _isScene: boolean;
  39595. /** @hidden */
  39596. _blockEntityCollection: boolean;
  39597. /**
  39598. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39599. */
  39600. autoClear: boolean;
  39601. /**
  39602. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39603. */
  39604. autoClearDepthAndStencil: boolean;
  39605. /**
  39606. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39607. */
  39608. clearColor: Color4;
  39609. /**
  39610. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39611. */
  39612. ambientColor: Color3;
  39613. /**
  39614. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39615. * It should only be one of the following (if not the default embedded one):
  39616. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39617. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39618. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39619. * The material properties need to be setup according to the type of texture in use.
  39620. */
  39621. environmentBRDFTexture: BaseTexture;
  39622. /**
  39623. * Texture used in all pbr material as the reflection texture.
  39624. * As in the majority of the scene they are the same (exception for multi room and so on),
  39625. * this is easier to reference from here than from all the materials.
  39626. */
  39627. get environmentTexture(): Nullable<BaseTexture>;
  39628. /**
  39629. * Texture used in all pbr material as the reflection texture.
  39630. * As in the majority of the scene they are the same (exception for multi room and so on),
  39631. * this is easier to set here than in all the materials.
  39632. */
  39633. set environmentTexture(value: Nullable<BaseTexture>);
  39634. /** @hidden */
  39635. protected _environmentIntensity: number;
  39636. /**
  39637. * Intensity of the environment in all pbr material.
  39638. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39639. * As in the majority of the scene they are the same (exception for multi room and so on),
  39640. * this is easier to reference from here than from all the materials.
  39641. */
  39642. get environmentIntensity(): number;
  39643. /**
  39644. * Intensity of the environment in all pbr material.
  39645. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39646. * As in the majority of the scene they are the same (exception for multi room and so on),
  39647. * this is easier to set here than in all the materials.
  39648. */
  39649. set environmentIntensity(value: number);
  39650. /** @hidden */
  39651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39652. /**
  39653. * Default image processing configuration used either in the rendering
  39654. * Forward main pass or through the imageProcessingPostProcess if present.
  39655. * As in the majority of the scene they are the same (exception for multi camera),
  39656. * this is easier to reference from here than from all the materials and post process.
  39657. *
  39658. * No setter as we it is a shared configuration, you can set the values instead.
  39659. */
  39660. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39661. private _forceWireframe;
  39662. /**
  39663. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39664. */
  39665. set forceWireframe(value: boolean);
  39666. get forceWireframe(): boolean;
  39667. private _skipFrustumClipping;
  39668. /**
  39669. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39670. */
  39671. set skipFrustumClipping(value: boolean);
  39672. get skipFrustumClipping(): boolean;
  39673. private _forcePointsCloud;
  39674. /**
  39675. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39676. */
  39677. set forcePointsCloud(value: boolean);
  39678. get forcePointsCloud(): boolean;
  39679. /**
  39680. * Gets or sets the active clipplane 1
  39681. */
  39682. clipPlane: Nullable<Plane>;
  39683. /**
  39684. * Gets or sets the active clipplane 2
  39685. */
  39686. clipPlane2: Nullable<Plane>;
  39687. /**
  39688. * Gets or sets the active clipplane 3
  39689. */
  39690. clipPlane3: Nullable<Plane>;
  39691. /**
  39692. * Gets or sets the active clipplane 4
  39693. */
  39694. clipPlane4: Nullable<Plane>;
  39695. /**
  39696. * Gets or sets the active clipplane 5
  39697. */
  39698. clipPlane5: Nullable<Plane>;
  39699. /**
  39700. * Gets or sets the active clipplane 6
  39701. */
  39702. clipPlane6: Nullable<Plane>;
  39703. /**
  39704. * Gets or sets a boolean indicating if animations are enabled
  39705. */
  39706. animationsEnabled: boolean;
  39707. private _animationPropertiesOverride;
  39708. /**
  39709. * Gets or sets the animation properties override
  39710. */
  39711. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39712. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39713. /**
  39714. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39715. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39716. */
  39717. useConstantAnimationDeltaTime: boolean;
  39718. /**
  39719. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39720. * Please note that it requires to run a ray cast through the scene on every frame
  39721. */
  39722. constantlyUpdateMeshUnderPointer: boolean;
  39723. /**
  39724. * Defines the HTML cursor to use when hovering over interactive elements
  39725. */
  39726. hoverCursor: string;
  39727. /**
  39728. * Defines the HTML default cursor to use (empty by default)
  39729. */
  39730. defaultCursor: string;
  39731. /**
  39732. * Defines whether cursors are handled by the scene.
  39733. */
  39734. doNotHandleCursors: boolean;
  39735. /**
  39736. * This is used to call preventDefault() on pointer down
  39737. * in order to block unwanted artifacts like system double clicks
  39738. */
  39739. preventDefaultOnPointerDown: boolean;
  39740. /**
  39741. * This is used to call preventDefault() on pointer up
  39742. * in order to block unwanted artifacts like system double clicks
  39743. */
  39744. preventDefaultOnPointerUp: boolean;
  39745. /**
  39746. * Gets or sets user defined metadata
  39747. */
  39748. metadata: any;
  39749. /**
  39750. * For internal use only. Please do not use.
  39751. */
  39752. reservedDataStore: any;
  39753. /**
  39754. * Gets the name of the plugin used to load this scene (null by default)
  39755. */
  39756. loadingPluginName: string;
  39757. /**
  39758. * Use this array to add regular expressions used to disable offline support for specific urls
  39759. */
  39760. disableOfflineSupportExceptionRules: RegExp[];
  39761. /**
  39762. * An event triggered when the scene is disposed.
  39763. */
  39764. onDisposeObservable: Observable<Scene>;
  39765. private _onDisposeObserver;
  39766. /** Sets a function to be executed when this scene is disposed. */
  39767. set onDispose(callback: () => void);
  39768. /**
  39769. * An event triggered before rendering the scene (right after animations and physics)
  39770. */
  39771. onBeforeRenderObservable: Observable<Scene>;
  39772. private _onBeforeRenderObserver;
  39773. /** Sets a function to be executed before rendering this scene */
  39774. set beforeRender(callback: Nullable<() => void>);
  39775. /**
  39776. * An event triggered after rendering the scene
  39777. */
  39778. onAfterRenderObservable: Observable<Scene>;
  39779. /**
  39780. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39781. */
  39782. onAfterRenderCameraObservable: Observable<Camera>;
  39783. private _onAfterRenderObserver;
  39784. /** Sets a function to be executed after rendering this scene */
  39785. set afterRender(callback: Nullable<() => void>);
  39786. /**
  39787. * An event triggered before animating the scene
  39788. */
  39789. onBeforeAnimationsObservable: Observable<Scene>;
  39790. /**
  39791. * An event triggered after animations processing
  39792. */
  39793. onAfterAnimationsObservable: Observable<Scene>;
  39794. /**
  39795. * An event triggered before draw calls are ready to be sent
  39796. */
  39797. onBeforeDrawPhaseObservable: Observable<Scene>;
  39798. /**
  39799. * An event triggered after draw calls have been sent
  39800. */
  39801. onAfterDrawPhaseObservable: Observable<Scene>;
  39802. /**
  39803. * An event triggered when the scene is ready
  39804. */
  39805. onReadyObservable: Observable<Scene>;
  39806. /**
  39807. * An event triggered before rendering a camera
  39808. */
  39809. onBeforeCameraRenderObservable: Observable<Camera>;
  39810. private _onBeforeCameraRenderObserver;
  39811. /** Sets a function to be executed before rendering a camera*/
  39812. set beforeCameraRender(callback: () => void);
  39813. /**
  39814. * An event triggered after rendering a camera
  39815. */
  39816. onAfterCameraRenderObservable: Observable<Camera>;
  39817. private _onAfterCameraRenderObserver;
  39818. /** Sets a function to be executed after rendering a camera*/
  39819. set afterCameraRender(callback: () => void);
  39820. /**
  39821. * An event triggered when active meshes evaluation is about to start
  39822. */
  39823. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39824. /**
  39825. * An event triggered when active meshes evaluation is done
  39826. */
  39827. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39828. /**
  39829. * An event triggered when particles rendering is about to start
  39830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39831. */
  39832. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39833. /**
  39834. * An event triggered when particles rendering is done
  39835. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39836. */
  39837. onAfterParticlesRenderingObservable: Observable<Scene>;
  39838. /**
  39839. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39840. */
  39841. onDataLoadedObservable: Observable<Scene>;
  39842. /**
  39843. * An event triggered when a camera is created
  39844. */
  39845. onNewCameraAddedObservable: Observable<Camera>;
  39846. /**
  39847. * An event triggered when a camera is removed
  39848. */
  39849. onCameraRemovedObservable: Observable<Camera>;
  39850. /**
  39851. * An event triggered when a light is created
  39852. */
  39853. onNewLightAddedObservable: Observable<Light>;
  39854. /**
  39855. * An event triggered when a light is removed
  39856. */
  39857. onLightRemovedObservable: Observable<Light>;
  39858. /**
  39859. * An event triggered when a geometry is created
  39860. */
  39861. onNewGeometryAddedObservable: Observable<Geometry>;
  39862. /**
  39863. * An event triggered when a geometry is removed
  39864. */
  39865. onGeometryRemovedObservable: Observable<Geometry>;
  39866. /**
  39867. * An event triggered when a transform node is created
  39868. */
  39869. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39870. /**
  39871. * An event triggered when a transform node is removed
  39872. */
  39873. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39874. /**
  39875. * An event triggered when a mesh is created
  39876. */
  39877. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39878. /**
  39879. * An event triggered when a mesh is removed
  39880. */
  39881. onMeshRemovedObservable: Observable<AbstractMesh>;
  39882. /**
  39883. * An event triggered when a skeleton is created
  39884. */
  39885. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39886. /**
  39887. * An event triggered when a skeleton is removed
  39888. */
  39889. onSkeletonRemovedObservable: Observable<Skeleton>;
  39890. /**
  39891. * An event triggered when a material is created
  39892. */
  39893. onNewMaterialAddedObservable: Observable<Material>;
  39894. /**
  39895. * An event triggered when a material is removed
  39896. */
  39897. onMaterialRemovedObservable: Observable<Material>;
  39898. /**
  39899. * An event triggered when a texture is created
  39900. */
  39901. onNewTextureAddedObservable: Observable<BaseTexture>;
  39902. /**
  39903. * An event triggered when a texture is removed
  39904. */
  39905. onTextureRemovedObservable: Observable<BaseTexture>;
  39906. /**
  39907. * An event triggered when render targets are about to be rendered
  39908. * Can happen multiple times per frame.
  39909. */
  39910. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39911. /**
  39912. * An event triggered when render targets were rendered.
  39913. * Can happen multiple times per frame.
  39914. */
  39915. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39916. /**
  39917. * An event triggered before calculating deterministic simulation step
  39918. */
  39919. onBeforeStepObservable: Observable<Scene>;
  39920. /**
  39921. * An event triggered after calculating deterministic simulation step
  39922. */
  39923. onAfterStepObservable: Observable<Scene>;
  39924. /**
  39925. * An event triggered when the activeCamera property is updated
  39926. */
  39927. onActiveCameraChanged: Observable<Scene>;
  39928. /**
  39929. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39930. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39931. * 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)
  39932. */
  39933. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39934. /**
  39935. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39937. * 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)
  39938. */
  39939. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39940. /**
  39941. * This Observable will when a mesh has been imported into the scene.
  39942. */
  39943. onMeshImportedObservable: Observable<AbstractMesh>;
  39944. /**
  39945. * This Observable will when an animation file has been imported into the scene.
  39946. */
  39947. onAnimationFileImportedObservable: Observable<Scene>;
  39948. /**
  39949. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39950. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39951. */
  39952. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39953. /** @hidden */
  39954. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39955. /**
  39956. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39957. */
  39958. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39959. /**
  39960. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39961. */
  39962. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39963. /**
  39964. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39965. */
  39966. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39967. /** Callback called when a pointer move is detected */
  39968. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39969. /** Callback called when a pointer down is detected */
  39970. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39971. /** Callback called when a pointer up is detected */
  39972. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39973. /** Callback called when a pointer pick is detected */
  39974. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39975. /**
  39976. * 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).
  39977. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39978. */
  39979. onPrePointerObservable: Observable<PointerInfoPre>;
  39980. /**
  39981. * Observable event triggered each time an input event is received from the rendering canvas
  39982. */
  39983. onPointerObservable: Observable<PointerInfo>;
  39984. /**
  39985. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39986. */
  39987. get unTranslatedPointer(): Vector2;
  39988. /**
  39989. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39990. */
  39991. static get DragMovementThreshold(): number;
  39992. static set DragMovementThreshold(value: number);
  39993. /**
  39994. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39995. */
  39996. static get LongPressDelay(): number;
  39997. static set LongPressDelay(value: number);
  39998. /**
  39999. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40000. */
  40001. static get DoubleClickDelay(): number;
  40002. static set DoubleClickDelay(value: number);
  40003. /** If you need to check double click without raising a single click at first click, enable this flag */
  40004. static get ExclusiveDoubleClickMode(): boolean;
  40005. static set ExclusiveDoubleClickMode(value: boolean);
  40006. /** @hidden */
  40007. _mirroredCameraPosition: Nullable<Vector3>;
  40008. /**
  40009. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40010. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40011. */
  40012. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40013. /**
  40014. * Observable event triggered each time an keyboard event is received from the hosting window
  40015. */
  40016. onKeyboardObservable: Observable<KeyboardInfo>;
  40017. private _useRightHandedSystem;
  40018. /**
  40019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40020. */
  40021. set useRightHandedSystem(value: boolean);
  40022. get useRightHandedSystem(): boolean;
  40023. private _timeAccumulator;
  40024. private _currentStepId;
  40025. private _currentInternalStep;
  40026. /**
  40027. * Sets the step Id used by deterministic lock step
  40028. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40029. * @param newStepId defines the step Id
  40030. */
  40031. setStepId(newStepId: number): void;
  40032. /**
  40033. * Gets the step Id used by deterministic lock step
  40034. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40035. * @returns the step Id
  40036. */
  40037. getStepId(): number;
  40038. /**
  40039. * Gets the internal step used by deterministic lock step
  40040. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40041. * @returns the internal step
  40042. */
  40043. getInternalStep(): number;
  40044. private _fogEnabled;
  40045. /**
  40046. * Gets or sets a boolean indicating if fog is enabled on this scene
  40047. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40048. * (Default is true)
  40049. */
  40050. set fogEnabled(value: boolean);
  40051. get fogEnabled(): boolean;
  40052. private _fogMode;
  40053. /**
  40054. * Gets or sets the fog mode to use
  40055. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40056. * | mode | value |
  40057. * | --- | --- |
  40058. * | FOGMODE_NONE | 0 |
  40059. * | FOGMODE_EXP | 1 |
  40060. * | FOGMODE_EXP2 | 2 |
  40061. * | FOGMODE_LINEAR | 3 |
  40062. */
  40063. set fogMode(value: number);
  40064. get fogMode(): number;
  40065. /**
  40066. * Gets or sets the fog color to use
  40067. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40068. * (Default is Color3(0.2, 0.2, 0.3))
  40069. */
  40070. fogColor: Color3;
  40071. /**
  40072. * Gets or sets the fog density to use
  40073. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40074. * (Default is 0.1)
  40075. */
  40076. fogDensity: number;
  40077. /**
  40078. * Gets or sets the fog start distance to use
  40079. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40080. * (Default is 0)
  40081. */
  40082. fogStart: number;
  40083. /**
  40084. * Gets or sets the fog end distance to use
  40085. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40086. * (Default is 1000)
  40087. */
  40088. fogEnd: number;
  40089. /**
  40090. * Flag indicating that the frame buffer binding is handled by another component
  40091. */
  40092. prePass: boolean;
  40093. private _shadowsEnabled;
  40094. /**
  40095. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40096. */
  40097. set shadowsEnabled(value: boolean);
  40098. get shadowsEnabled(): boolean;
  40099. private _lightsEnabled;
  40100. /**
  40101. * Gets or sets a boolean indicating if lights are enabled on this scene
  40102. */
  40103. set lightsEnabled(value: boolean);
  40104. get lightsEnabled(): boolean;
  40105. /** All of the active cameras added to this scene. */
  40106. activeCameras: Camera[];
  40107. /** @hidden */
  40108. _activeCamera: Nullable<Camera>;
  40109. /** Gets or sets the current active camera */
  40110. get activeCamera(): Nullable<Camera>;
  40111. set activeCamera(value: Nullable<Camera>);
  40112. private _defaultMaterial;
  40113. /** The default material used on meshes when no material is affected */
  40114. get defaultMaterial(): Material;
  40115. /** The default material used on meshes when no material is affected */
  40116. set defaultMaterial(value: Material);
  40117. private _texturesEnabled;
  40118. /**
  40119. * Gets or sets a boolean indicating if textures are enabled on this scene
  40120. */
  40121. set texturesEnabled(value: boolean);
  40122. get texturesEnabled(): boolean;
  40123. /**
  40124. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40125. */
  40126. physicsEnabled: boolean;
  40127. /**
  40128. * Gets or sets a boolean indicating if particles are enabled on this scene
  40129. */
  40130. particlesEnabled: boolean;
  40131. /**
  40132. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40133. */
  40134. spritesEnabled: boolean;
  40135. private _skeletonsEnabled;
  40136. /**
  40137. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40138. */
  40139. set skeletonsEnabled(value: boolean);
  40140. get skeletonsEnabled(): boolean;
  40141. /**
  40142. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40143. */
  40144. lensFlaresEnabled: boolean;
  40145. /**
  40146. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40147. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40148. */
  40149. collisionsEnabled: boolean;
  40150. private _collisionCoordinator;
  40151. /** @hidden */
  40152. get collisionCoordinator(): ICollisionCoordinator;
  40153. /**
  40154. * Defines the gravity applied to this scene (used only for collisions)
  40155. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40156. */
  40157. gravity: Vector3;
  40158. /**
  40159. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40160. */
  40161. postProcessesEnabled: boolean;
  40162. /**
  40163. * Gets the current postprocess manager
  40164. */
  40165. postProcessManager: PostProcessManager;
  40166. /**
  40167. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40168. */
  40169. renderTargetsEnabled: boolean;
  40170. /**
  40171. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40172. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40173. */
  40174. dumpNextRenderTargets: boolean;
  40175. /**
  40176. * The list of user defined render targets added to the scene
  40177. */
  40178. customRenderTargets: RenderTargetTexture[];
  40179. /**
  40180. * Defines if texture loading must be delayed
  40181. * If true, textures will only be loaded when they need to be rendered
  40182. */
  40183. useDelayedTextureLoading: boolean;
  40184. /**
  40185. * Gets the list of meshes imported to the scene through SceneLoader
  40186. */
  40187. importedMeshesFiles: String[];
  40188. /**
  40189. * Gets or sets a boolean indicating if probes are enabled on this scene
  40190. */
  40191. probesEnabled: boolean;
  40192. /**
  40193. * Gets or sets the current offline provider to use to store scene data
  40194. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40195. */
  40196. offlineProvider: IOfflineProvider;
  40197. /**
  40198. * Gets or sets the action manager associated with the scene
  40199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40200. */
  40201. actionManager: AbstractActionManager;
  40202. private _meshesForIntersections;
  40203. /**
  40204. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40205. */
  40206. proceduralTexturesEnabled: boolean;
  40207. private _engine;
  40208. private _totalVertices;
  40209. /** @hidden */
  40210. _activeIndices: PerfCounter;
  40211. /** @hidden */
  40212. _activeParticles: PerfCounter;
  40213. /** @hidden */
  40214. _activeBones: PerfCounter;
  40215. private _animationRatio;
  40216. /** @hidden */
  40217. _animationTimeLast: number;
  40218. /** @hidden */
  40219. _animationTime: number;
  40220. /**
  40221. * Gets or sets a general scale for animation speed
  40222. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40223. */
  40224. animationTimeScale: number;
  40225. /** @hidden */
  40226. _cachedMaterial: Nullable<Material>;
  40227. /** @hidden */
  40228. _cachedEffect: Nullable<Effect>;
  40229. /** @hidden */
  40230. _cachedVisibility: Nullable<number>;
  40231. private _renderId;
  40232. private _frameId;
  40233. private _executeWhenReadyTimeoutId;
  40234. private _intermediateRendering;
  40235. private _viewUpdateFlag;
  40236. private _projectionUpdateFlag;
  40237. /** @hidden */
  40238. _toBeDisposed: Nullable<IDisposable>[];
  40239. private _activeRequests;
  40240. /** @hidden */
  40241. _pendingData: any[];
  40242. private _isDisposed;
  40243. /**
  40244. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40245. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40246. */
  40247. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40248. private _activeMeshes;
  40249. private _processedMaterials;
  40250. private _renderTargets;
  40251. /** @hidden */
  40252. _activeParticleSystems: SmartArray<IParticleSystem>;
  40253. private _activeSkeletons;
  40254. private _softwareSkinnedMeshes;
  40255. private _renderingManager;
  40256. /** @hidden */
  40257. _activeAnimatables: Animatable[];
  40258. private _transformMatrix;
  40259. private _sceneUbo;
  40260. /** @hidden */
  40261. _viewMatrix: Matrix;
  40262. private _projectionMatrix;
  40263. /** @hidden */
  40264. _forcedViewPosition: Nullable<Vector3>;
  40265. /** @hidden */
  40266. _frustumPlanes: Plane[];
  40267. /**
  40268. * Gets the list of frustum planes (built from the active camera)
  40269. */
  40270. get frustumPlanes(): Plane[];
  40271. /**
  40272. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40273. * This is useful if there are more lights that the maximum simulteanous authorized
  40274. */
  40275. requireLightSorting: boolean;
  40276. /** @hidden */
  40277. readonly useMaterialMeshMap: boolean;
  40278. /** @hidden */
  40279. readonly useClonedMeshMap: boolean;
  40280. private _externalData;
  40281. private _uid;
  40282. /**
  40283. * @hidden
  40284. * Backing store of defined scene components.
  40285. */
  40286. _components: ISceneComponent[];
  40287. /**
  40288. * @hidden
  40289. * Backing store of defined scene components.
  40290. */
  40291. _serializableComponents: ISceneSerializableComponent[];
  40292. /**
  40293. * List of components to register on the next registration step.
  40294. */
  40295. private _transientComponents;
  40296. /**
  40297. * Registers the transient components if needed.
  40298. */
  40299. private _registerTransientComponents;
  40300. /**
  40301. * @hidden
  40302. * Add a component to the scene.
  40303. * Note that the ccomponent could be registered on th next frame if this is called after
  40304. * the register component stage.
  40305. * @param component Defines the component to add to the scene
  40306. */
  40307. _addComponent(component: ISceneComponent): void;
  40308. /**
  40309. * @hidden
  40310. * Gets a component from the scene.
  40311. * @param name defines the name of the component to retrieve
  40312. * @returns the component or null if not present
  40313. */
  40314. _getComponent(name: string): Nullable<ISceneComponent>;
  40315. /**
  40316. * @hidden
  40317. * Defines the actions happening before camera updates.
  40318. */
  40319. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40320. /**
  40321. * @hidden
  40322. * Defines the actions happening before clear the canvas.
  40323. */
  40324. _beforeClearStage: Stage<SimpleStageAction>;
  40325. /**
  40326. * @hidden
  40327. * Defines the actions when collecting render targets for the frame.
  40328. */
  40329. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40330. /**
  40331. * @hidden
  40332. * Defines the actions happening for one camera in the frame.
  40333. */
  40334. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40335. /**
  40336. * @hidden
  40337. * Defines the actions happening during the per mesh ready checks.
  40338. */
  40339. _isReadyForMeshStage: Stage<MeshStageAction>;
  40340. /**
  40341. * @hidden
  40342. * Defines the actions happening before evaluate active mesh checks.
  40343. */
  40344. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40345. /**
  40346. * @hidden
  40347. * Defines the actions happening during the evaluate sub mesh checks.
  40348. */
  40349. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40350. /**
  40351. * @hidden
  40352. * Defines the actions happening during the active mesh stage.
  40353. */
  40354. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40355. /**
  40356. * @hidden
  40357. * Defines the actions happening during the per camera render target step.
  40358. */
  40359. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40360. /**
  40361. * @hidden
  40362. * Defines the actions happening just before the active camera is drawing.
  40363. */
  40364. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40365. /**
  40366. * @hidden
  40367. * Defines the actions happening just before a render target is drawing.
  40368. */
  40369. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40370. /**
  40371. * @hidden
  40372. * Defines the actions happening just before a rendering group is drawing.
  40373. */
  40374. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40375. /**
  40376. * @hidden
  40377. * Defines the actions happening just before a mesh is drawing.
  40378. */
  40379. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40380. /**
  40381. * @hidden
  40382. * Defines the actions happening just after a mesh has been drawn.
  40383. */
  40384. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40385. /**
  40386. * @hidden
  40387. * Defines the actions happening just after a rendering group has been drawn.
  40388. */
  40389. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40390. /**
  40391. * @hidden
  40392. * Defines the actions happening just after the active camera has been drawn.
  40393. */
  40394. _afterCameraDrawStage: Stage<CameraStageAction>;
  40395. /**
  40396. * @hidden
  40397. * Defines the actions happening just after a render target has been drawn.
  40398. */
  40399. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40400. /**
  40401. * @hidden
  40402. * Defines the actions happening just after rendering all cameras and computing intersections.
  40403. */
  40404. _afterRenderStage: Stage<SimpleStageAction>;
  40405. /**
  40406. * @hidden
  40407. * Defines the actions happening when a pointer move event happens.
  40408. */
  40409. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40410. /**
  40411. * @hidden
  40412. * Defines the actions happening when a pointer down event happens.
  40413. */
  40414. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40415. /**
  40416. * @hidden
  40417. * Defines the actions happening when a pointer up event happens.
  40418. */
  40419. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40420. /**
  40421. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40422. */
  40423. private geometriesByUniqueId;
  40424. /**
  40425. * Creates a new Scene
  40426. * @param engine defines the engine to use to render this scene
  40427. * @param options defines the scene options
  40428. */
  40429. constructor(engine: Engine, options?: SceneOptions);
  40430. /**
  40431. * Gets a string identifying the name of the class
  40432. * @returns "Scene" string
  40433. */
  40434. getClassName(): string;
  40435. private _defaultMeshCandidates;
  40436. /**
  40437. * @hidden
  40438. */
  40439. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40440. private _defaultSubMeshCandidates;
  40441. /**
  40442. * @hidden
  40443. */
  40444. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40445. /**
  40446. * Sets the default candidate providers for the scene.
  40447. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40448. * and getCollidingSubMeshCandidates to their default function
  40449. */
  40450. setDefaultCandidateProviders(): void;
  40451. /**
  40452. * Gets the mesh that is currently under the pointer
  40453. */
  40454. get meshUnderPointer(): Nullable<AbstractMesh>;
  40455. /**
  40456. * Gets or sets the current on-screen X position of the pointer
  40457. */
  40458. get pointerX(): number;
  40459. set pointerX(value: number);
  40460. /**
  40461. * Gets or sets the current on-screen Y position of the pointer
  40462. */
  40463. get pointerY(): number;
  40464. set pointerY(value: number);
  40465. /**
  40466. * Gets the cached material (ie. the latest rendered one)
  40467. * @returns the cached material
  40468. */
  40469. getCachedMaterial(): Nullable<Material>;
  40470. /**
  40471. * Gets the cached effect (ie. the latest rendered one)
  40472. * @returns the cached effect
  40473. */
  40474. getCachedEffect(): Nullable<Effect>;
  40475. /**
  40476. * Gets the cached visibility state (ie. the latest rendered one)
  40477. * @returns the cached visibility state
  40478. */
  40479. getCachedVisibility(): Nullable<number>;
  40480. /**
  40481. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40482. * @param material defines the current material
  40483. * @param effect defines the current effect
  40484. * @param visibility defines the current visibility state
  40485. * @returns true if one parameter is not cached
  40486. */
  40487. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40488. /**
  40489. * Gets the engine associated with the scene
  40490. * @returns an Engine
  40491. */
  40492. getEngine(): Engine;
  40493. /**
  40494. * Gets the total number of vertices rendered per frame
  40495. * @returns the total number of vertices rendered per frame
  40496. */
  40497. getTotalVertices(): number;
  40498. /**
  40499. * Gets the performance counter for total vertices
  40500. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40501. */
  40502. get totalVerticesPerfCounter(): PerfCounter;
  40503. /**
  40504. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40505. * @returns the total number of active indices rendered per frame
  40506. */
  40507. getActiveIndices(): number;
  40508. /**
  40509. * Gets the performance counter for active indices
  40510. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40511. */
  40512. get totalActiveIndicesPerfCounter(): PerfCounter;
  40513. /**
  40514. * Gets the total number of active particles rendered per frame
  40515. * @returns the total number of active particles rendered per frame
  40516. */
  40517. getActiveParticles(): number;
  40518. /**
  40519. * Gets the performance counter for active particles
  40520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40521. */
  40522. get activeParticlesPerfCounter(): PerfCounter;
  40523. /**
  40524. * Gets the total number of active bones rendered per frame
  40525. * @returns the total number of active bones rendered per frame
  40526. */
  40527. getActiveBones(): number;
  40528. /**
  40529. * Gets the performance counter for active bones
  40530. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40531. */
  40532. get activeBonesPerfCounter(): PerfCounter;
  40533. /**
  40534. * Gets the array of active meshes
  40535. * @returns an array of AbstractMesh
  40536. */
  40537. getActiveMeshes(): SmartArray<AbstractMesh>;
  40538. /**
  40539. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40540. * @returns a number
  40541. */
  40542. getAnimationRatio(): number;
  40543. /**
  40544. * Gets an unique Id for the current render phase
  40545. * @returns a number
  40546. */
  40547. getRenderId(): number;
  40548. /**
  40549. * Gets an unique Id for the current frame
  40550. * @returns a number
  40551. */
  40552. getFrameId(): number;
  40553. /** Call this function if you want to manually increment the render Id*/
  40554. incrementRenderId(): void;
  40555. private _createUbo;
  40556. /**
  40557. * Use this method to simulate a pointer move on a mesh
  40558. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40559. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40560. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40561. * @returns the current scene
  40562. */
  40563. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40564. /**
  40565. * Use this method to simulate a pointer down on a mesh
  40566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40569. * @returns the current scene
  40570. */
  40571. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40572. /**
  40573. * Use this method to simulate a pointer up on a mesh
  40574. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40575. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40576. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40577. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40578. * @returns the current scene
  40579. */
  40580. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40581. /**
  40582. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40583. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40584. * @returns true if the pointer was captured
  40585. */
  40586. isPointerCaptured(pointerId?: number): boolean;
  40587. /**
  40588. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40589. * @param attachUp defines if you want to attach events to pointerup
  40590. * @param attachDown defines if you want to attach events to pointerdown
  40591. * @param attachMove defines if you want to attach events to pointermove
  40592. */
  40593. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40594. /** Detaches all event handlers*/
  40595. detachControl(): void;
  40596. /**
  40597. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40598. * Delay loaded resources are not taking in account
  40599. * @return true if all required resources are ready
  40600. */
  40601. isReady(): boolean;
  40602. /** Resets all cached information relative to material (including effect and visibility) */
  40603. resetCachedMaterial(): void;
  40604. /**
  40605. * Registers a function to be called before every frame render
  40606. * @param func defines the function to register
  40607. */
  40608. registerBeforeRender(func: () => void): void;
  40609. /**
  40610. * Unregisters a function called before every frame render
  40611. * @param func defines the function to unregister
  40612. */
  40613. unregisterBeforeRender(func: () => void): void;
  40614. /**
  40615. * Registers a function to be called after every frame render
  40616. * @param func defines the function to register
  40617. */
  40618. registerAfterRender(func: () => void): void;
  40619. /**
  40620. * Unregisters a function called after every frame render
  40621. * @param func defines the function to unregister
  40622. */
  40623. unregisterAfterRender(func: () => void): void;
  40624. private _executeOnceBeforeRender;
  40625. /**
  40626. * The provided function will run before render once and will be disposed afterwards.
  40627. * A timeout delay can be provided so that the function will be executed in N ms.
  40628. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40629. * @param func The function to be executed.
  40630. * @param timeout optional delay in ms
  40631. */
  40632. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40633. /** @hidden */
  40634. _addPendingData(data: any): void;
  40635. /** @hidden */
  40636. _removePendingData(data: any): void;
  40637. /**
  40638. * Returns the number of items waiting to be loaded
  40639. * @returns the number of items waiting to be loaded
  40640. */
  40641. getWaitingItemsCount(): number;
  40642. /**
  40643. * Returns a boolean indicating if the scene is still loading data
  40644. */
  40645. get isLoading(): boolean;
  40646. /**
  40647. * Registers a function to be executed when the scene is ready
  40648. * @param {Function} func - the function to be executed
  40649. */
  40650. executeWhenReady(func: () => void): void;
  40651. /**
  40652. * Returns a promise that resolves when the scene is ready
  40653. * @returns A promise that resolves when the scene is ready
  40654. */
  40655. whenReadyAsync(): Promise<void>;
  40656. /** @hidden */
  40657. _checkIsReady(): void;
  40658. /**
  40659. * Gets all animatable attached to the scene
  40660. */
  40661. get animatables(): Animatable[];
  40662. /**
  40663. * Resets the last animation time frame.
  40664. * Useful to override when animations start running when loading a scene for the first time.
  40665. */
  40666. resetLastAnimationTimeFrame(): void;
  40667. /**
  40668. * Gets the current view matrix
  40669. * @returns a Matrix
  40670. */
  40671. getViewMatrix(): Matrix;
  40672. /**
  40673. * Gets the current projection matrix
  40674. * @returns a Matrix
  40675. */
  40676. getProjectionMatrix(): Matrix;
  40677. /**
  40678. * Gets the current transform matrix
  40679. * @returns a Matrix made of View * Projection
  40680. */
  40681. getTransformMatrix(): Matrix;
  40682. /**
  40683. * Sets the current transform matrix
  40684. * @param viewL defines the View matrix to use
  40685. * @param projectionL defines the Projection matrix to use
  40686. * @param viewR defines the right View matrix to use (if provided)
  40687. * @param projectionR defines the right Projection matrix to use (if provided)
  40688. */
  40689. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40690. /**
  40691. * Gets the uniform buffer used to store scene data
  40692. * @returns a UniformBuffer
  40693. */
  40694. getSceneUniformBuffer(): UniformBuffer;
  40695. /**
  40696. * Gets an unique (relatively to the current scene) Id
  40697. * @returns an unique number for the scene
  40698. */
  40699. getUniqueId(): number;
  40700. /**
  40701. * Add a mesh to the list of scene's meshes
  40702. * @param newMesh defines the mesh to add
  40703. * @param recursive if all child meshes should also be added to the scene
  40704. */
  40705. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40706. /**
  40707. * Remove a mesh for the list of scene's meshes
  40708. * @param toRemove defines the mesh to remove
  40709. * @param recursive if all child meshes should also be removed from the scene
  40710. * @returns the index where the mesh was in the mesh list
  40711. */
  40712. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40713. /**
  40714. * Add a transform node to the list of scene's transform nodes
  40715. * @param newTransformNode defines the transform node to add
  40716. */
  40717. addTransformNode(newTransformNode: TransformNode): void;
  40718. /**
  40719. * Remove a transform node for the list of scene's transform nodes
  40720. * @param toRemove defines the transform node to remove
  40721. * @returns the index where the transform node was in the transform node list
  40722. */
  40723. removeTransformNode(toRemove: TransformNode): number;
  40724. /**
  40725. * Remove a skeleton for the list of scene's skeletons
  40726. * @param toRemove defines the skeleton to remove
  40727. * @returns the index where the skeleton was in the skeleton list
  40728. */
  40729. removeSkeleton(toRemove: Skeleton): number;
  40730. /**
  40731. * Remove a morph target for the list of scene's morph targets
  40732. * @param toRemove defines the morph target to remove
  40733. * @returns the index where the morph target was in the morph target list
  40734. */
  40735. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40736. /**
  40737. * Remove a light for the list of scene's lights
  40738. * @param toRemove defines the light to remove
  40739. * @returns the index where the light was in the light list
  40740. */
  40741. removeLight(toRemove: Light): number;
  40742. /**
  40743. * Remove a camera for the list of scene's cameras
  40744. * @param toRemove defines the camera to remove
  40745. * @returns the index where the camera was in the camera list
  40746. */
  40747. removeCamera(toRemove: Camera): number;
  40748. /**
  40749. * Remove a particle system for the list of scene's particle systems
  40750. * @param toRemove defines the particle system to remove
  40751. * @returns the index where the particle system was in the particle system list
  40752. */
  40753. removeParticleSystem(toRemove: IParticleSystem): number;
  40754. /**
  40755. * Remove a animation for the list of scene's animations
  40756. * @param toRemove defines the animation to remove
  40757. * @returns the index where the animation was in the animation list
  40758. */
  40759. removeAnimation(toRemove: Animation): number;
  40760. /**
  40761. * Will stop the animation of the given target
  40762. * @param target - the target
  40763. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40764. * @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)
  40765. */
  40766. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40767. /**
  40768. * Removes the given animation group from this scene.
  40769. * @param toRemove The animation group to remove
  40770. * @returns The index of the removed animation group
  40771. */
  40772. removeAnimationGroup(toRemove: AnimationGroup): number;
  40773. /**
  40774. * Removes the given multi-material from this scene.
  40775. * @param toRemove The multi-material to remove
  40776. * @returns The index of the removed multi-material
  40777. */
  40778. removeMultiMaterial(toRemove: MultiMaterial): number;
  40779. /**
  40780. * Removes the given material from this scene.
  40781. * @param toRemove The material to remove
  40782. * @returns The index of the removed material
  40783. */
  40784. removeMaterial(toRemove: Material): number;
  40785. /**
  40786. * Removes the given action manager from this scene.
  40787. * @param toRemove The action manager to remove
  40788. * @returns The index of the removed action manager
  40789. */
  40790. removeActionManager(toRemove: AbstractActionManager): number;
  40791. /**
  40792. * Removes the given texture from this scene.
  40793. * @param toRemove The texture to remove
  40794. * @returns The index of the removed texture
  40795. */
  40796. removeTexture(toRemove: BaseTexture): number;
  40797. /**
  40798. * Adds the given light to this scene
  40799. * @param newLight The light to add
  40800. */
  40801. addLight(newLight: Light): void;
  40802. /**
  40803. * Sorts the list list based on light priorities
  40804. */
  40805. sortLightsByPriority(): void;
  40806. /**
  40807. * Adds the given camera to this scene
  40808. * @param newCamera The camera to add
  40809. */
  40810. addCamera(newCamera: Camera): void;
  40811. /**
  40812. * Adds the given skeleton to this scene
  40813. * @param newSkeleton The skeleton to add
  40814. */
  40815. addSkeleton(newSkeleton: Skeleton): void;
  40816. /**
  40817. * Adds the given particle system to this scene
  40818. * @param newParticleSystem The particle system to add
  40819. */
  40820. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40821. /**
  40822. * Adds the given animation to this scene
  40823. * @param newAnimation The animation to add
  40824. */
  40825. addAnimation(newAnimation: Animation): void;
  40826. /**
  40827. * Adds the given animation group to this scene.
  40828. * @param newAnimationGroup The animation group to add
  40829. */
  40830. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40831. /**
  40832. * Adds the given multi-material to this scene
  40833. * @param newMultiMaterial The multi-material to add
  40834. */
  40835. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40836. /**
  40837. * Adds the given material to this scene
  40838. * @param newMaterial The material to add
  40839. */
  40840. addMaterial(newMaterial: Material): void;
  40841. /**
  40842. * Adds the given morph target to this scene
  40843. * @param newMorphTargetManager The morph target to add
  40844. */
  40845. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40846. /**
  40847. * Adds the given geometry to this scene
  40848. * @param newGeometry The geometry to add
  40849. */
  40850. addGeometry(newGeometry: Geometry): void;
  40851. /**
  40852. * Adds the given action manager to this scene
  40853. * @param newActionManager The action manager to add
  40854. */
  40855. addActionManager(newActionManager: AbstractActionManager): void;
  40856. /**
  40857. * Adds the given texture to this scene.
  40858. * @param newTexture The texture to add
  40859. */
  40860. addTexture(newTexture: BaseTexture): void;
  40861. /**
  40862. * Switch active camera
  40863. * @param newCamera defines the new active camera
  40864. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40865. */
  40866. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40867. /**
  40868. * sets the active camera of the scene using its ID
  40869. * @param id defines the camera's ID
  40870. * @return the new active camera or null if none found.
  40871. */
  40872. setActiveCameraByID(id: string): Nullable<Camera>;
  40873. /**
  40874. * sets the active camera of the scene using its name
  40875. * @param name defines the camera's name
  40876. * @returns the new active camera or null if none found.
  40877. */
  40878. setActiveCameraByName(name: string): Nullable<Camera>;
  40879. /**
  40880. * get an animation group using its name
  40881. * @param name defines the material's name
  40882. * @return the animation group or null if none found.
  40883. */
  40884. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40885. /**
  40886. * Get a material using its unique id
  40887. * @param uniqueId defines the material's unique id
  40888. * @return the material or null if none found.
  40889. */
  40890. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40891. /**
  40892. * get a material using its id
  40893. * @param id defines the material's ID
  40894. * @return the material or null if none found.
  40895. */
  40896. getMaterialByID(id: string): Nullable<Material>;
  40897. /**
  40898. * Gets a the last added material using a given id
  40899. * @param id defines the material's ID
  40900. * @return the last material with the given id or null if none found.
  40901. */
  40902. getLastMaterialByID(id: string): Nullable<Material>;
  40903. /**
  40904. * Gets a material using its name
  40905. * @param name defines the material's name
  40906. * @return the material or null if none found.
  40907. */
  40908. getMaterialByName(name: string): Nullable<Material>;
  40909. /**
  40910. * Get a texture using its unique id
  40911. * @param uniqueId defines the texture's unique id
  40912. * @return the texture or null if none found.
  40913. */
  40914. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40915. /**
  40916. * Gets a camera using its id
  40917. * @param id defines the id to look for
  40918. * @returns the camera or null if not found
  40919. */
  40920. getCameraByID(id: string): Nullable<Camera>;
  40921. /**
  40922. * Gets a camera using its unique id
  40923. * @param uniqueId defines the unique id to look for
  40924. * @returns the camera or null if not found
  40925. */
  40926. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40927. /**
  40928. * Gets a camera using its name
  40929. * @param name defines the camera's name
  40930. * @return the camera or null if none found.
  40931. */
  40932. getCameraByName(name: string): Nullable<Camera>;
  40933. /**
  40934. * Gets a bone using its id
  40935. * @param id defines the bone's id
  40936. * @return the bone or null if not found
  40937. */
  40938. getBoneByID(id: string): Nullable<Bone>;
  40939. /**
  40940. * Gets a bone using its id
  40941. * @param name defines the bone's name
  40942. * @return the bone or null if not found
  40943. */
  40944. getBoneByName(name: string): Nullable<Bone>;
  40945. /**
  40946. * Gets a light node using its name
  40947. * @param name defines the the light's name
  40948. * @return the light or null if none found.
  40949. */
  40950. getLightByName(name: string): Nullable<Light>;
  40951. /**
  40952. * Gets a light node using its id
  40953. * @param id defines the light's id
  40954. * @return the light or null if none found.
  40955. */
  40956. getLightByID(id: string): Nullable<Light>;
  40957. /**
  40958. * Gets a light node using its scene-generated unique ID
  40959. * @param uniqueId defines the light's unique id
  40960. * @return the light or null if none found.
  40961. */
  40962. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40963. /**
  40964. * Gets a particle system by id
  40965. * @param id defines the particle system id
  40966. * @return the corresponding system or null if none found
  40967. */
  40968. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40969. /**
  40970. * Gets a geometry using its ID
  40971. * @param id defines the geometry's id
  40972. * @return the geometry or null if none found.
  40973. */
  40974. getGeometryByID(id: string): Nullable<Geometry>;
  40975. private _getGeometryByUniqueID;
  40976. /**
  40977. * Add a new geometry to this scene
  40978. * @param geometry defines the geometry to be added to the scene.
  40979. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40980. * @return a boolean defining if the geometry was added or not
  40981. */
  40982. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40983. /**
  40984. * Removes an existing geometry
  40985. * @param geometry defines the geometry to be removed from the scene
  40986. * @return a boolean defining if the geometry was removed or not
  40987. */
  40988. removeGeometry(geometry: Geometry): boolean;
  40989. /**
  40990. * Gets the list of geometries attached to the scene
  40991. * @returns an array of Geometry
  40992. */
  40993. getGeometries(): Geometry[];
  40994. /**
  40995. * Gets the first added mesh found of a given ID
  40996. * @param id defines the id to search for
  40997. * @return the mesh found or null if not found at all
  40998. */
  40999. getMeshByID(id: string): Nullable<AbstractMesh>;
  41000. /**
  41001. * Gets a list of meshes using their id
  41002. * @param id defines the id to search for
  41003. * @returns a list of meshes
  41004. */
  41005. getMeshesByID(id: string): Array<AbstractMesh>;
  41006. /**
  41007. * Gets the first added transform node found of a given ID
  41008. * @param id defines the id to search for
  41009. * @return the found transform node or null if not found at all.
  41010. */
  41011. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41012. /**
  41013. * Gets a transform node with its auto-generated unique id
  41014. * @param uniqueId efines the unique id to search for
  41015. * @return the found transform node or null if not found at all.
  41016. */
  41017. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41018. /**
  41019. * Gets a list of transform nodes using their id
  41020. * @param id defines the id to search for
  41021. * @returns a list of transform nodes
  41022. */
  41023. getTransformNodesByID(id: string): Array<TransformNode>;
  41024. /**
  41025. * Gets a mesh with its auto-generated unique id
  41026. * @param uniqueId defines the unique id to search for
  41027. * @return the found mesh or null if not found at all.
  41028. */
  41029. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41030. /**
  41031. * Gets a the last added mesh using a given id
  41032. * @param id defines the id to search for
  41033. * @return the found mesh or null if not found at all.
  41034. */
  41035. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41036. /**
  41037. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41038. * @param id defines the id to search for
  41039. * @return the found node or null if not found at all
  41040. */
  41041. getLastEntryByID(id: string): Nullable<Node>;
  41042. /**
  41043. * Gets a node (Mesh, Camera, Light) using a given id
  41044. * @param id defines the id to search for
  41045. * @return the found node or null if not found at all
  41046. */
  41047. getNodeByID(id: string): Nullable<Node>;
  41048. /**
  41049. * Gets a node (Mesh, Camera, Light) using a given name
  41050. * @param name defines the name to search for
  41051. * @return the found node or null if not found at all.
  41052. */
  41053. getNodeByName(name: string): Nullable<Node>;
  41054. /**
  41055. * Gets a mesh using a given name
  41056. * @param name defines the name to search for
  41057. * @return the found mesh or null if not found at all.
  41058. */
  41059. getMeshByName(name: string): Nullable<AbstractMesh>;
  41060. /**
  41061. * Gets a transform node using a given name
  41062. * @param name defines the name to search for
  41063. * @return the found transform node or null if not found at all.
  41064. */
  41065. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41066. /**
  41067. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41068. * @param id defines the id to search for
  41069. * @return the found skeleton or null if not found at all.
  41070. */
  41071. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41072. /**
  41073. * Gets a skeleton using a given auto generated unique id
  41074. * @param uniqueId defines the unique id to search for
  41075. * @return the found skeleton or null if not found at all.
  41076. */
  41077. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41078. /**
  41079. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41080. * @param id defines the id to search for
  41081. * @return the found skeleton or null if not found at all.
  41082. */
  41083. getSkeletonById(id: string): Nullable<Skeleton>;
  41084. /**
  41085. * Gets a skeleton using a given name
  41086. * @param name defines the name to search for
  41087. * @return the found skeleton or null if not found at all.
  41088. */
  41089. getSkeletonByName(name: string): Nullable<Skeleton>;
  41090. /**
  41091. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41092. * @param id defines the id to search for
  41093. * @return the found morph target manager or null if not found at all.
  41094. */
  41095. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41096. /**
  41097. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41098. * @param id defines the id to search for
  41099. * @return the found morph target or null if not found at all.
  41100. */
  41101. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41102. /**
  41103. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41104. * @param name defines the name to search for
  41105. * @return the found morph target or null if not found at all.
  41106. */
  41107. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41108. /**
  41109. * Gets a post process using a given name (if many are found, this function will pick the first one)
  41110. * @param name defines the name to search for
  41111. * @return the found post process or null if not found at all.
  41112. */
  41113. getPostProcessByName(name: string): Nullable<PostProcess>;
  41114. /**
  41115. * Gets a boolean indicating if the given mesh is active
  41116. * @param mesh defines the mesh to look for
  41117. * @returns true if the mesh is in the active list
  41118. */
  41119. isActiveMesh(mesh: AbstractMesh): boolean;
  41120. /**
  41121. * Return a unique id as a string which can serve as an identifier for the scene
  41122. */
  41123. get uid(): string;
  41124. /**
  41125. * Add an externaly attached data from its key.
  41126. * This method call will fail and return false, if such key already exists.
  41127. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41128. * @param key the unique key that identifies the data
  41129. * @param data the data object to associate to the key for this Engine instance
  41130. * @return true if no such key were already present and the data was added successfully, false otherwise
  41131. */
  41132. addExternalData<T>(key: string, data: T): boolean;
  41133. /**
  41134. * Get an externaly attached data from its key
  41135. * @param key the unique key that identifies the data
  41136. * @return the associated data, if present (can be null), or undefined if not present
  41137. */
  41138. getExternalData<T>(key: string): Nullable<T>;
  41139. /**
  41140. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41141. * @param key the unique key that identifies the data
  41142. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41143. * @return the associated data, can be null if the factory returned null.
  41144. */
  41145. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41146. /**
  41147. * Remove an externaly attached data from the Engine instance
  41148. * @param key the unique key that identifies the data
  41149. * @return true if the data was successfully removed, false if it doesn't exist
  41150. */
  41151. removeExternalData(key: string): boolean;
  41152. private _evaluateSubMesh;
  41153. /**
  41154. * Clear the processed materials smart array preventing retention point in material dispose.
  41155. */
  41156. freeProcessedMaterials(): void;
  41157. private _preventFreeActiveMeshesAndRenderingGroups;
  41158. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41159. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41160. * when disposing several meshes in a row or a hierarchy of meshes.
  41161. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41162. */
  41163. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41164. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41165. /**
  41166. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41167. */
  41168. freeActiveMeshes(): void;
  41169. /**
  41170. * Clear the info related to rendering groups preventing retention points during dispose.
  41171. */
  41172. freeRenderingGroups(): void;
  41173. /** @hidden */
  41174. _isInIntermediateRendering(): boolean;
  41175. /**
  41176. * Lambda returning the list of potentially active meshes.
  41177. */
  41178. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41179. /**
  41180. * Lambda returning the list of potentially active sub meshes.
  41181. */
  41182. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41183. /**
  41184. * Lambda returning the list of potentially intersecting sub meshes.
  41185. */
  41186. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41187. /**
  41188. * Lambda returning the list of potentially colliding sub meshes.
  41189. */
  41190. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41191. private _activeMeshesFrozen;
  41192. private _skipEvaluateActiveMeshesCompletely;
  41193. /**
  41194. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41195. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41196. * @param onSuccess optional success callback
  41197. * @param onError optional error callback
  41198. * @returns the current scene
  41199. */
  41200. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  41201. /**
  41202. * Use this function to restart evaluating active meshes on every frame
  41203. * @returns the current scene
  41204. */
  41205. unfreezeActiveMeshes(): Scene;
  41206. private _evaluateActiveMeshes;
  41207. private _activeMesh;
  41208. /**
  41209. * Update the transform matrix to update from the current active camera
  41210. * @param force defines a boolean used to force the update even if cache is up to date
  41211. */
  41212. updateTransformMatrix(force?: boolean): void;
  41213. private _bindFrameBuffer;
  41214. /** @hidden */
  41215. _allowPostProcessClearColor: boolean;
  41216. /** @hidden */
  41217. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41218. private _processSubCameras;
  41219. private _checkIntersections;
  41220. /** @hidden */
  41221. _advancePhysicsEngineStep(step: number): void;
  41222. /**
  41223. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41224. */
  41225. getDeterministicFrameTime: () => number;
  41226. /** @hidden */
  41227. _animate(): void;
  41228. /** Execute all animations (for a frame) */
  41229. animate(): void;
  41230. /**
  41231. * Render the scene
  41232. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41233. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41234. */
  41235. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41236. /**
  41237. * Freeze all materials
  41238. * A frozen material will not be updatable but should be faster to render
  41239. */
  41240. freezeMaterials(): void;
  41241. /**
  41242. * Unfreeze all materials
  41243. * A frozen material will not be updatable but should be faster to render
  41244. */
  41245. unfreezeMaterials(): void;
  41246. /**
  41247. * Releases all held ressources
  41248. */
  41249. dispose(): void;
  41250. /**
  41251. * Gets if the scene is already disposed
  41252. */
  41253. get isDisposed(): boolean;
  41254. /**
  41255. * Call this function to reduce memory footprint of the scene.
  41256. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41257. */
  41258. clearCachedVertexData(): void;
  41259. /**
  41260. * This function will remove the local cached buffer data from texture.
  41261. * It will save memory but will prevent the texture from being rebuilt
  41262. */
  41263. cleanCachedTextureBuffer(): void;
  41264. /**
  41265. * Get the world extend vectors with an optional filter
  41266. *
  41267. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41268. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41269. */
  41270. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41271. min: Vector3;
  41272. max: Vector3;
  41273. };
  41274. /**
  41275. * Creates a ray that can be used to pick in the scene
  41276. * @param x defines the x coordinate of the origin (on-screen)
  41277. * @param y defines the y coordinate of the origin (on-screen)
  41278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41279. * @param camera defines the camera to use for the picking
  41280. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41281. * @returns a Ray
  41282. */
  41283. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41284. /**
  41285. * Creates a ray that can be used to pick in the scene
  41286. * @param x defines the x coordinate of the origin (on-screen)
  41287. * @param y defines the y coordinate of the origin (on-screen)
  41288. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41289. * @param result defines the ray where to store the picking ray
  41290. * @param camera defines the camera to use for the picking
  41291. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41292. * @returns the current scene
  41293. */
  41294. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41295. /**
  41296. * Creates a ray that can be used to pick in the scene
  41297. * @param x defines the x coordinate of the origin (on-screen)
  41298. * @param y defines the y coordinate of the origin (on-screen)
  41299. * @param camera defines the camera to use for the picking
  41300. * @returns a Ray
  41301. */
  41302. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41303. /**
  41304. * Creates a ray that can be used to pick in the scene
  41305. * @param x defines the x coordinate of the origin (on-screen)
  41306. * @param y defines the y coordinate of the origin (on-screen)
  41307. * @param result defines the ray where to store the picking ray
  41308. * @param camera defines the camera to use for the picking
  41309. * @returns the current scene
  41310. */
  41311. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41312. /** Launch a ray to try to pick a mesh in the scene
  41313. * @param x position on screen
  41314. * @param y position on screen
  41315. * @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
  41316. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41317. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41319. * @returns a PickingInfo
  41320. */
  41321. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41322. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41323. * @param x position on screen
  41324. * @param y position on screen
  41325. * @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
  41326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41327. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41328. * @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)
  41329. */
  41330. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41331. /** Use the given ray to pick a mesh in the scene
  41332. * @param ray The ray to use to pick meshes
  41333. * @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
  41334. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41336. * @returns a PickingInfo
  41337. */
  41338. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41339. /**
  41340. * Launch a ray to try to pick a mesh in the scene
  41341. * @param x X position on screen
  41342. * @param y Y position on screen
  41343. * @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
  41344. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41345. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41346. * @returns an array of PickingInfo
  41347. */
  41348. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41349. /**
  41350. * Launch a ray to try to pick a mesh in the scene
  41351. * @param ray Ray to use
  41352. * @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
  41353. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41354. * @returns an array of PickingInfo
  41355. */
  41356. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41357. /**
  41358. * Force the value of meshUnderPointer
  41359. * @param mesh defines the mesh to use
  41360. * @param pointerId optional pointer id when using more than one pointer
  41361. */
  41362. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41363. /**
  41364. * Gets the mesh under the pointer
  41365. * @returns a Mesh or null if no mesh is under the pointer
  41366. */
  41367. getPointerOverMesh(): Nullable<AbstractMesh>;
  41368. /** @hidden */
  41369. _rebuildGeometries(): void;
  41370. /** @hidden */
  41371. _rebuildTextures(): void;
  41372. private _getByTags;
  41373. /**
  41374. * Get a list of meshes by tags
  41375. * @param tagsQuery defines the tags query to use
  41376. * @param forEach defines a predicate used to filter results
  41377. * @returns an array of Mesh
  41378. */
  41379. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41380. /**
  41381. * Get a list of cameras by tags
  41382. * @param tagsQuery defines the tags query to use
  41383. * @param forEach defines a predicate used to filter results
  41384. * @returns an array of Camera
  41385. */
  41386. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41387. /**
  41388. * Get a list of lights by tags
  41389. * @param tagsQuery defines the tags query to use
  41390. * @param forEach defines a predicate used to filter results
  41391. * @returns an array of Light
  41392. */
  41393. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41394. /**
  41395. * Get a list of materials by tags
  41396. * @param tagsQuery defines the tags query to use
  41397. * @param forEach defines a predicate used to filter results
  41398. * @returns an array of Material
  41399. */
  41400. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41401. /**
  41402. * Get a list of transform nodes by tags
  41403. * @param tagsQuery defines the tags query to use
  41404. * @param forEach defines a predicate used to filter results
  41405. * @returns an array of TransformNode
  41406. */
  41407. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41408. /**
  41409. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41410. * This allowed control for front to back rendering or reversly depending of the special needs.
  41411. *
  41412. * @param renderingGroupId The rendering group id corresponding to its index
  41413. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41414. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41415. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41416. */
  41417. 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;
  41418. /**
  41419. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41420. *
  41421. * @param renderingGroupId The rendering group id corresponding to its index
  41422. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41423. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41424. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41425. */
  41426. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41427. /**
  41428. * Gets the current auto clear configuration for one rendering group of the rendering
  41429. * manager.
  41430. * @param index the rendering group index to get the information for
  41431. * @returns The auto clear setup for the requested rendering group
  41432. */
  41433. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41434. private _blockMaterialDirtyMechanism;
  41435. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41436. get blockMaterialDirtyMechanism(): boolean;
  41437. set blockMaterialDirtyMechanism(value: boolean);
  41438. /**
  41439. * Will flag all materials as dirty to trigger new shader compilation
  41440. * @param flag defines the flag used to specify which material part must be marked as dirty
  41441. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41442. */
  41443. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41444. /** @hidden */
  41445. _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;
  41446. /** @hidden */
  41447. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41448. /** @hidden */
  41449. _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;
  41450. /** @hidden */
  41451. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41452. /** @hidden */
  41453. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41454. /** @hidden */
  41455. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41456. }
  41457. }
  41458. declare module BABYLON {
  41459. /**
  41460. * Set of assets to keep when moving a scene into an asset container.
  41461. */
  41462. export class KeepAssets extends AbstractScene {
  41463. }
  41464. /**
  41465. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41466. */
  41467. export class InstantiatedEntries {
  41468. /**
  41469. * List of new root nodes (eg. nodes with no parent)
  41470. */
  41471. rootNodes: TransformNode[];
  41472. /**
  41473. * List of new skeletons
  41474. */
  41475. skeletons: Skeleton[];
  41476. /**
  41477. * List of new animation groups
  41478. */
  41479. animationGroups: AnimationGroup[];
  41480. }
  41481. /**
  41482. * Container with a set of assets that can be added or removed from a scene.
  41483. */
  41484. export class AssetContainer extends AbstractScene {
  41485. private _wasAddedToScene;
  41486. /**
  41487. * The scene the AssetContainer belongs to.
  41488. */
  41489. scene: Scene;
  41490. /**
  41491. * Instantiates an AssetContainer.
  41492. * @param scene The scene the AssetContainer belongs to.
  41493. */
  41494. constructor(scene: Scene);
  41495. /**
  41496. * Instantiate or clone all meshes and add the new ones to the scene.
  41497. * Skeletons and animation groups will all be cloned
  41498. * @param nameFunction defines an optional function used to get new names for clones
  41499. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41500. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41501. */
  41502. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41503. /**
  41504. * Adds all the assets from the container to the scene.
  41505. */
  41506. addAllToScene(): void;
  41507. /**
  41508. * Removes all the assets in the container from the scene
  41509. */
  41510. removeAllFromScene(): void;
  41511. /**
  41512. * Disposes all the assets in the container
  41513. */
  41514. dispose(): void;
  41515. private _moveAssets;
  41516. /**
  41517. * Removes all the assets contained in the scene and adds them to the container.
  41518. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41519. */
  41520. moveAllFromScene(keepAssets?: KeepAssets): void;
  41521. /**
  41522. * 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.
  41523. * @returns the root mesh
  41524. */
  41525. createRootMesh(): Mesh;
  41526. /**
  41527. * Merge animations (direct and animation groups) from this asset container into a scene
  41528. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41529. * @param animatables set of animatables to retarget to a node from the scene
  41530. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41531. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41532. */
  41533. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41534. }
  41535. }
  41536. declare module BABYLON {
  41537. /**
  41538. * Defines how the parser contract is defined.
  41539. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41540. */
  41541. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41542. /**
  41543. * Defines how the individual parser contract is defined.
  41544. * These parser can parse an individual asset
  41545. */
  41546. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41547. /**
  41548. * Base class of the scene acting as a container for the different elements composing a scene.
  41549. * This class is dynamically extended by the different components of the scene increasing
  41550. * flexibility and reducing coupling
  41551. */
  41552. export abstract class AbstractScene {
  41553. /**
  41554. * Stores the list of available parsers in the application.
  41555. */
  41556. private static _BabylonFileParsers;
  41557. /**
  41558. * Stores the list of available individual parsers in the application.
  41559. */
  41560. private static _IndividualBabylonFileParsers;
  41561. /**
  41562. * Adds a parser in the list of available ones
  41563. * @param name Defines the name of the parser
  41564. * @param parser Defines the parser to add
  41565. */
  41566. static AddParser(name: string, parser: BabylonFileParser): void;
  41567. /**
  41568. * Gets a general parser from the list of avaialble ones
  41569. * @param name Defines the name of the parser
  41570. * @returns the requested parser or null
  41571. */
  41572. static GetParser(name: string): Nullable<BabylonFileParser>;
  41573. /**
  41574. * Adds n individual parser in the list of available ones
  41575. * @param name Defines the name of the parser
  41576. * @param parser Defines the parser to add
  41577. */
  41578. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41579. /**
  41580. * Gets an individual parser from the list of avaialble ones
  41581. * @param name Defines the name of the parser
  41582. * @returns the requested parser or null
  41583. */
  41584. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41585. /**
  41586. * Parser json data and populate both a scene and its associated container object
  41587. * @param jsonData Defines the data to parse
  41588. * @param scene Defines the scene to parse the data for
  41589. * @param container Defines the container attached to the parsing sequence
  41590. * @param rootUrl Defines the root url of the data
  41591. */
  41592. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41593. /**
  41594. * Gets the list of root nodes (ie. nodes with no parent)
  41595. */
  41596. rootNodes: Node[];
  41597. /** All of the cameras added to this scene
  41598. * @see https://doc.babylonjs.com/babylon101/cameras
  41599. */
  41600. cameras: Camera[];
  41601. /**
  41602. * All of the lights added to this scene
  41603. * @see https://doc.babylonjs.com/babylon101/lights
  41604. */
  41605. lights: Light[];
  41606. /**
  41607. * All of the (abstract) meshes added to this scene
  41608. */
  41609. meshes: AbstractMesh[];
  41610. /**
  41611. * The list of skeletons added to the scene
  41612. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41613. */
  41614. skeletons: Skeleton[];
  41615. /**
  41616. * All of the particle systems added to this scene
  41617. * @see https://doc.babylonjs.com/babylon101/particles
  41618. */
  41619. particleSystems: IParticleSystem[];
  41620. /**
  41621. * Gets a list of Animations associated with the scene
  41622. */
  41623. animations: Animation[];
  41624. /**
  41625. * All of the animation groups added to this scene
  41626. * @see https://doc.babylonjs.com/how_to/group
  41627. */
  41628. animationGroups: AnimationGroup[];
  41629. /**
  41630. * All of the multi-materials added to this scene
  41631. * @see https://doc.babylonjs.com/how_to/multi_materials
  41632. */
  41633. multiMaterials: MultiMaterial[];
  41634. /**
  41635. * All of the materials added to this scene
  41636. * In the context of a Scene, it is not supposed to be modified manually.
  41637. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41638. * Note also that the order of the Material within the array is not significant and might change.
  41639. * @see https://doc.babylonjs.com/babylon101/materials
  41640. */
  41641. materials: Material[];
  41642. /**
  41643. * The list of morph target managers added to the scene
  41644. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41645. */
  41646. morphTargetManagers: MorphTargetManager[];
  41647. /**
  41648. * The list of geometries used in the scene.
  41649. */
  41650. geometries: Geometry[];
  41651. /**
  41652. * All of the tranform nodes added to this scene
  41653. * In the context of a Scene, it is not supposed to be modified manually.
  41654. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41655. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41656. * @see https://doc.babylonjs.com/how_to/transformnode
  41657. */
  41658. transformNodes: TransformNode[];
  41659. /**
  41660. * ActionManagers available on the scene.
  41661. */
  41662. actionManagers: AbstractActionManager[];
  41663. /**
  41664. * Textures to keep.
  41665. */
  41666. textures: BaseTexture[];
  41667. /** @hidden */
  41668. protected _environmentTexture: Nullable<BaseTexture>;
  41669. /**
  41670. * Texture used in all pbr material as the reflection texture.
  41671. * As in the majority of the scene they are the same (exception for multi room and so on),
  41672. * this is easier to reference from here than from all the materials.
  41673. */
  41674. get environmentTexture(): Nullable<BaseTexture>;
  41675. set environmentTexture(value: Nullable<BaseTexture>);
  41676. /**
  41677. * The list of postprocesses added to the scene
  41678. */
  41679. postProcesses: PostProcess[];
  41680. /**
  41681. * @returns all meshes, lights, cameras, transformNodes and bones
  41682. */
  41683. getNodes(): Array<Node>;
  41684. }
  41685. }
  41686. declare module BABYLON {
  41687. /**
  41688. * Interface used to define options for Sound class
  41689. */
  41690. export interface ISoundOptions {
  41691. /**
  41692. * Does the sound autoplay once loaded.
  41693. */
  41694. autoplay?: boolean;
  41695. /**
  41696. * Does the sound loop after it finishes playing once.
  41697. */
  41698. loop?: boolean;
  41699. /**
  41700. * Sound's volume
  41701. */
  41702. volume?: number;
  41703. /**
  41704. * Is it a spatial sound?
  41705. */
  41706. spatialSound?: boolean;
  41707. /**
  41708. * Maximum distance to hear that sound
  41709. */
  41710. maxDistance?: number;
  41711. /**
  41712. * Uses user defined attenuation function
  41713. */
  41714. useCustomAttenuation?: boolean;
  41715. /**
  41716. * Define the roll off factor of spatial sounds.
  41717. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41718. */
  41719. rolloffFactor?: number;
  41720. /**
  41721. * Define the reference distance the sound should be heard perfectly.
  41722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41723. */
  41724. refDistance?: number;
  41725. /**
  41726. * Define the distance attenuation model the sound will follow.
  41727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41728. */
  41729. distanceModel?: string;
  41730. /**
  41731. * Defines the playback speed (1 by default)
  41732. */
  41733. playbackRate?: number;
  41734. /**
  41735. * Defines if the sound is from a streaming source
  41736. */
  41737. streaming?: boolean;
  41738. /**
  41739. * Defines an optional length (in seconds) inside the sound file
  41740. */
  41741. length?: number;
  41742. /**
  41743. * Defines an optional offset (in seconds) inside the sound file
  41744. */
  41745. offset?: number;
  41746. /**
  41747. * If true, URLs will not be required to state the audio file codec to use.
  41748. */
  41749. skipCodecCheck?: boolean;
  41750. }
  41751. /**
  41752. * Defines a sound that can be played in the application.
  41753. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41755. */
  41756. export class Sound {
  41757. /**
  41758. * The name of the sound in the scene.
  41759. */
  41760. name: string;
  41761. /**
  41762. * Does the sound autoplay once loaded.
  41763. */
  41764. autoplay: boolean;
  41765. /**
  41766. * Does the sound loop after it finishes playing once.
  41767. */
  41768. loop: boolean;
  41769. /**
  41770. * Does the sound use a custom attenuation curve to simulate the falloff
  41771. * happening when the source gets further away from the camera.
  41772. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41773. */
  41774. useCustomAttenuation: boolean;
  41775. /**
  41776. * The sound track id this sound belongs to.
  41777. */
  41778. soundTrackId: number;
  41779. /**
  41780. * Is this sound currently played.
  41781. */
  41782. isPlaying: boolean;
  41783. /**
  41784. * Is this sound currently paused.
  41785. */
  41786. isPaused: boolean;
  41787. /**
  41788. * Does this sound enables spatial sound.
  41789. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41790. */
  41791. spatialSound: boolean;
  41792. /**
  41793. * Define the reference distance the sound should be heard perfectly.
  41794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41795. */
  41796. refDistance: number;
  41797. /**
  41798. * Define the roll off factor of spatial sounds.
  41799. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41800. */
  41801. rolloffFactor: number;
  41802. /**
  41803. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41804. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41805. */
  41806. maxDistance: number;
  41807. /**
  41808. * Define the distance attenuation model the sound will follow.
  41809. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41810. */
  41811. distanceModel: string;
  41812. /**
  41813. * @hidden
  41814. * Back Compat
  41815. **/
  41816. onended: () => any;
  41817. /**
  41818. * Gets or sets an object used to store user defined information for the sound.
  41819. */
  41820. metadata: any;
  41821. /**
  41822. * Observable event when the current playing sound finishes.
  41823. */
  41824. onEndedObservable: Observable<Sound>;
  41825. private _panningModel;
  41826. private _playbackRate;
  41827. private _streaming;
  41828. private _startTime;
  41829. private _startOffset;
  41830. private _position;
  41831. /** @hidden */
  41832. _positionInEmitterSpace: boolean;
  41833. private _localDirection;
  41834. private _volume;
  41835. private _isReadyToPlay;
  41836. private _isDirectional;
  41837. private _readyToPlayCallback;
  41838. private _audioBuffer;
  41839. private _soundSource;
  41840. private _streamingSource;
  41841. private _soundPanner;
  41842. private _soundGain;
  41843. private _inputAudioNode;
  41844. private _outputAudioNode;
  41845. private _coneInnerAngle;
  41846. private _coneOuterAngle;
  41847. private _coneOuterGain;
  41848. private _scene;
  41849. private _connectedTransformNode;
  41850. private _customAttenuationFunction;
  41851. private _registerFunc;
  41852. private _isOutputConnected;
  41853. private _htmlAudioElement;
  41854. private _urlType;
  41855. private _length?;
  41856. private _offset?;
  41857. /** @hidden */
  41858. static _SceneComponentInitialization: (scene: Scene) => void;
  41859. /**
  41860. * Create a sound and attach it to a scene
  41861. * @param name Name of your sound
  41862. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41863. * @param scene defines the scene the sound belongs to
  41864. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41865. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41866. */
  41867. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41868. /**
  41869. * Release the sound and its associated resources
  41870. */
  41871. dispose(): void;
  41872. /**
  41873. * Gets if the sounds is ready to be played or not.
  41874. * @returns true if ready, otherwise false
  41875. */
  41876. isReady(): boolean;
  41877. private _soundLoaded;
  41878. /**
  41879. * Sets the data of the sound from an audiobuffer
  41880. * @param audioBuffer The audioBuffer containing the data
  41881. */
  41882. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41883. /**
  41884. * Updates the current sounds options such as maxdistance, loop...
  41885. * @param options A JSON object containing values named as the object properties
  41886. */
  41887. updateOptions(options: ISoundOptions): void;
  41888. private _createSpatialParameters;
  41889. private _updateSpatialParameters;
  41890. /**
  41891. * Switch the panning model to HRTF:
  41892. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41894. */
  41895. switchPanningModelToHRTF(): void;
  41896. /**
  41897. * Switch the panning model to Equal Power:
  41898. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41900. */
  41901. switchPanningModelToEqualPower(): void;
  41902. private _switchPanningModel;
  41903. /**
  41904. * Connect this sound to a sound track audio node like gain...
  41905. * @param soundTrackAudioNode the sound track audio node to connect to
  41906. */
  41907. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41908. /**
  41909. * Transform this sound into a directional source
  41910. * @param coneInnerAngle Size of the inner cone in degree
  41911. * @param coneOuterAngle Size of the outer cone in degree
  41912. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41913. */
  41914. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41915. /**
  41916. * Gets or sets the inner angle for the directional cone.
  41917. */
  41918. get directionalConeInnerAngle(): number;
  41919. /**
  41920. * Gets or sets the inner angle for the directional cone.
  41921. */
  41922. set directionalConeInnerAngle(value: number);
  41923. /**
  41924. * Gets or sets the outer angle for the directional cone.
  41925. */
  41926. get directionalConeOuterAngle(): number;
  41927. /**
  41928. * Gets or sets the outer angle for the directional cone.
  41929. */
  41930. set directionalConeOuterAngle(value: number);
  41931. /**
  41932. * Sets the position of the emitter if spatial sound is enabled
  41933. * @param newPosition Defines the new posisiton
  41934. */
  41935. setPosition(newPosition: Vector3): void;
  41936. /**
  41937. * Sets the local direction of the emitter if spatial sound is enabled
  41938. * @param newLocalDirection Defines the new local direction
  41939. */
  41940. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41941. private _updateDirection;
  41942. /** @hidden */
  41943. updateDistanceFromListener(): void;
  41944. /**
  41945. * Sets a new custom attenuation function for the sound.
  41946. * @param callback Defines the function used for the attenuation
  41947. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41948. */
  41949. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41950. /**
  41951. * Play the sound
  41952. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41953. * @param offset (optional) Start the sound at a specific time in seconds
  41954. * @param length (optional) Sound duration (in seconds)
  41955. */
  41956. play(time?: number, offset?: number, length?: number): void;
  41957. private _onended;
  41958. /**
  41959. * Stop the sound
  41960. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41961. */
  41962. stop(time?: number): void;
  41963. /**
  41964. * Put the sound in pause
  41965. */
  41966. pause(): void;
  41967. /**
  41968. * Sets a dedicated volume for this sounds
  41969. * @param newVolume Define the new volume of the sound
  41970. * @param time Define time for gradual change to new volume
  41971. */
  41972. setVolume(newVolume: number, time?: number): void;
  41973. /**
  41974. * Set the sound play back rate
  41975. * @param newPlaybackRate Define the playback rate the sound should be played at
  41976. */
  41977. setPlaybackRate(newPlaybackRate: number): void;
  41978. /**
  41979. * Gets the volume of the sound.
  41980. * @returns the volume of the sound
  41981. */
  41982. getVolume(): number;
  41983. /**
  41984. * Attach the sound to a dedicated mesh
  41985. * @param transformNode The transform node to connect the sound with
  41986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41987. */
  41988. attachToMesh(transformNode: TransformNode): void;
  41989. /**
  41990. * Detach the sound from the previously attached mesh
  41991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41992. */
  41993. detachFromMesh(): void;
  41994. private _onRegisterAfterWorldMatrixUpdate;
  41995. /**
  41996. * Clone the current sound in the scene.
  41997. * @returns the new sound clone
  41998. */
  41999. clone(): Nullable<Sound>;
  42000. /**
  42001. * Gets the current underlying audio buffer containing the data
  42002. * @returns the audio buffer
  42003. */
  42004. getAudioBuffer(): Nullable<AudioBuffer>;
  42005. /**
  42006. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42007. * @returns the source node
  42008. */
  42009. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42010. /**
  42011. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42012. * @returns the gain node
  42013. */
  42014. getSoundGain(): Nullable<GainNode>;
  42015. /**
  42016. * Serializes the Sound in a JSON representation
  42017. * @returns the JSON representation of the sound
  42018. */
  42019. serialize(): any;
  42020. /**
  42021. * Parse a JSON representation of a sound to innstantiate in a given scene
  42022. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42023. * @param scene Define the scene the new parsed sound should be created in
  42024. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42025. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42026. * @returns the newly parsed sound
  42027. */
  42028. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42029. }
  42030. }
  42031. declare module BABYLON {
  42032. /**
  42033. * This defines an action helpful to play a defined sound on a triggered action.
  42034. */
  42035. export class PlaySoundAction extends Action {
  42036. private _sound;
  42037. /**
  42038. * Instantiate the action
  42039. * @param triggerOptions defines the trigger options
  42040. * @param sound defines the sound to play
  42041. * @param condition defines the trigger related conditions
  42042. */
  42043. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42044. /** @hidden */
  42045. _prepare(): void;
  42046. /**
  42047. * Execute the action and play the sound.
  42048. */
  42049. execute(): void;
  42050. /**
  42051. * Serializes the actions and its related information.
  42052. * @param parent defines the object to serialize in
  42053. * @returns the serialized object
  42054. */
  42055. serialize(parent: any): any;
  42056. }
  42057. /**
  42058. * This defines an action helpful to stop a defined sound on a triggered action.
  42059. */
  42060. export class StopSoundAction extends Action {
  42061. private _sound;
  42062. /**
  42063. * Instantiate the action
  42064. * @param triggerOptions defines the trigger options
  42065. * @param sound defines the sound to stop
  42066. * @param condition defines the trigger related conditions
  42067. */
  42068. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42069. /** @hidden */
  42070. _prepare(): void;
  42071. /**
  42072. * Execute the action and stop the sound.
  42073. */
  42074. execute(): void;
  42075. /**
  42076. * Serializes the actions and its related information.
  42077. * @param parent defines the object to serialize in
  42078. * @returns the serialized object
  42079. */
  42080. serialize(parent: any): any;
  42081. }
  42082. }
  42083. declare module BABYLON {
  42084. /**
  42085. * This defines an action responsible to change the value of a property
  42086. * by interpolating between its current value and the newly set one once triggered.
  42087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42088. */
  42089. export class InterpolateValueAction extends Action {
  42090. /**
  42091. * Defines the path of the property where the value should be interpolated
  42092. */
  42093. propertyPath: string;
  42094. /**
  42095. * Defines the target value at the end of the interpolation.
  42096. */
  42097. value: any;
  42098. /**
  42099. * Defines the time it will take for the property to interpolate to the value.
  42100. */
  42101. duration: number;
  42102. /**
  42103. * Defines if the other scene animations should be stopped when the action has been triggered
  42104. */
  42105. stopOtherAnimations?: boolean;
  42106. /**
  42107. * Defines a callback raised once the interpolation animation has been done.
  42108. */
  42109. onInterpolationDone?: () => void;
  42110. /**
  42111. * Observable triggered once the interpolation animation has been done.
  42112. */
  42113. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42114. private _target;
  42115. private _effectiveTarget;
  42116. private _property;
  42117. /**
  42118. * Instantiate the action
  42119. * @param triggerOptions defines the trigger options
  42120. * @param target defines the object containing the value to interpolate
  42121. * @param propertyPath defines the path to the property in the target object
  42122. * @param value defines the target value at the end of the interpolation
  42123. * @param duration deines the time it will take for the property to interpolate to the value.
  42124. * @param condition defines the trigger related conditions
  42125. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42126. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42127. */
  42128. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42129. /** @hidden */
  42130. _prepare(): void;
  42131. /**
  42132. * Execute the action starts the value interpolation.
  42133. */
  42134. execute(): void;
  42135. /**
  42136. * Serializes the actions and its related information.
  42137. * @param parent defines the object to serialize in
  42138. * @returns the serialized object
  42139. */
  42140. serialize(parent: any): any;
  42141. }
  42142. }
  42143. declare module BABYLON {
  42144. /**
  42145. * Options allowed during the creation of a sound track.
  42146. */
  42147. export interface ISoundTrackOptions {
  42148. /**
  42149. * The volume the sound track should take during creation
  42150. */
  42151. volume?: number;
  42152. /**
  42153. * Define if the sound track is the main sound track of the scene
  42154. */
  42155. mainTrack?: boolean;
  42156. }
  42157. /**
  42158. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42159. * It will be also used in a future release to apply effects on a specific track.
  42160. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42161. */
  42162. export class SoundTrack {
  42163. /**
  42164. * The unique identifier of the sound track in the scene.
  42165. */
  42166. id: number;
  42167. /**
  42168. * The list of sounds included in the sound track.
  42169. */
  42170. soundCollection: Array<Sound>;
  42171. private _outputAudioNode;
  42172. private _scene;
  42173. private _connectedAnalyser;
  42174. private _options;
  42175. private _isInitialized;
  42176. /**
  42177. * Creates a new sound track.
  42178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42179. * @param scene Define the scene the sound track belongs to
  42180. * @param options
  42181. */
  42182. constructor(scene: Scene, options?: ISoundTrackOptions);
  42183. private _initializeSoundTrackAudioGraph;
  42184. /**
  42185. * Release the sound track and its associated resources
  42186. */
  42187. dispose(): void;
  42188. /**
  42189. * Adds a sound to this sound track
  42190. * @param sound define the cound to add
  42191. * @ignoreNaming
  42192. */
  42193. AddSound(sound: Sound): void;
  42194. /**
  42195. * Removes a sound to this sound track
  42196. * @param sound define the cound to remove
  42197. * @ignoreNaming
  42198. */
  42199. RemoveSound(sound: Sound): void;
  42200. /**
  42201. * Set a global volume for the full sound track.
  42202. * @param newVolume Define the new volume of the sound track
  42203. */
  42204. setVolume(newVolume: number): void;
  42205. /**
  42206. * Switch the panning model to HRTF:
  42207. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42209. */
  42210. switchPanningModelToHRTF(): void;
  42211. /**
  42212. * Switch the panning model to Equal Power:
  42213. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42215. */
  42216. switchPanningModelToEqualPower(): void;
  42217. /**
  42218. * Connect the sound track to an audio analyser allowing some amazing
  42219. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42221. * @param analyser The analyser to connect to the engine
  42222. */
  42223. connectToAnalyser(analyser: Analyser): void;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. interface AbstractScene {
  42228. /**
  42229. * The list of sounds used in the scene.
  42230. */
  42231. sounds: Nullable<Array<Sound>>;
  42232. }
  42233. interface Scene {
  42234. /**
  42235. * @hidden
  42236. * Backing field
  42237. */
  42238. _mainSoundTrack: SoundTrack;
  42239. /**
  42240. * The main sound track played by the scene.
  42241. * It cotains your primary collection of sounds.
  42242. */
  42243. mainSoundTrack: SoundTrack;
  42244. /**
  42245. * The list of sound tracks added to the scene
  42246. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42247. */
  42248. soundTracks: Nullable<Array<SoundTrack>>;
  42249. /**
  42250. * Gets a sound using a given name
  42251. * @param name defines the name to search for
  42252. * @return the found sound or null if not found at all.
  42253. */
  42254. getSoundByName(name: string): Nullable<Sound>;
  42255. /**
  42256. * Gets or sets if audio support is enabled
  42257. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42258. */
  42259. audioEnabled: boolean;
  42260. /**
  42261. * Gets or sets if audio will be output to headphones
  42262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42263. */
  42264. headphone: boolean;
  42265. /**
  42266. * Gets or sets custom audio listener position provider
  42267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42268. */
  42269. audioListenerPositionProvider: Nullable<() => Vector3>;
  42270. /**
  42271. * Gets or sets a refresh rate when using 3D audio positioning
  42272. */
  42273. audioPositioningRefreshRate: number;
  42274. }
  42275. /**
  42276. * Defines the sound scene component responsible to manage any sounds
  42277. * in a given scene.
  42278. */
  42279. export class AudioSceneComponent implements ISceneSerializableComponent {
  42280. private static _CameraDirectionLH;
  42281. private static _CameraDirectionRH;
  42282. /**
  42283. * The component name helpfull to identify the component in the list of scene components.
  42284. */
  42285. readonly name: string;
  42286. /**
  42287. * The scene the component belongs to.
  42288. */
  42289. scene: Scene;
  42290. private _audioEnabled;
  42291. /**
  42292. * Gets whether audio is enabled or not.
  42293. * Please use related enable/disable method to switch state.
  42294. */
  42295. get audioEnabled(): boolean;
  42296. private _headphone;
  42297. /**
  42298. * Gets whether audio is outputing to headphone or not.
  42299. * Please use the according Switch methods to change output.
  42300. */
  42301. get headphone(): boolean;
  42302. /**
  42303. * Gets or sets a refresh rate when using 3D audio positioning
  42304. */
  42305. audioPositioningRefreshRate: number;
  42306. private _audioListenerPositionProvider;
  42307. /**
  42308. * Gets the current audio listener position provider
  42309. */
  42310. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42311. /**
  42312. * Sets a custom listener position for all sounds in the scene
  42313. * By default, this is the position of the first active camera
  42314. */
  42315. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42316. /**
  42317. * Creates a new instance of the component for the given scene
  42318. * @param scene Defines the scene to register the component in
  42319. */
  42320. constructor(scene: Scene);
  42321. /**
  42322. * Registers the component in a given scene
  42323. */
  42324. register(): void;
  42325. /**
  42326. * Rebuilds the elements related to this component in case of
  42327. * context lost for instance.
  42328. */
  42329. rebuild(): void;
  42330. /**
  42331. * Serializes the component data to the specified json object
  42332. * @param serializationObject The object to serialize to
  42333. */
  42334. serialize(serializationObject: any): void;
  42335. /**
  42336. * Adds all the elements from the container to the scene
  42337. * @param container the container holding the elements
  42338. */
  42339. addFromContainer(container: AbstractScene): void;
  42340. /**
  42341. * Removes all the elements in the container from the scene
  42342. * @param container contains the elements to remove
  42343. * @param dispose if the removed element should be disposed (default: false)
  42344. */
  42345. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42346. /**
  42347. * Disposes the component and the associated ressources.
  42348. */
  42349. dispose(): void;
  42350. /**
  42351. * Disables audio in the associated scene.
  42352. */
  42353. disableAudio(): void;
  42354. /**
  42355. * Enables audio in the associated scene.
  42356. */
  42357. enableAudio(): void;
  42358. /**
  42359. * Switch audio to headphone output.
  42360. */
  42361. switchAudioModeForHeadphones(): void;
  42362. /**
  42363. * Switch audio to normal speakers.
  42364. */
  42365. switchAudioModeForNormalSpeakers(): void;
  42366. private _cachedCameraDirection;
  42367. private _cachedCameraPosition;
  42368. private _lastCheck;
  42369. private _afterRender;
  42370. }
  42371. }
  42372. declare module BABYLON {
  42373. /**
  42374. * Wraps one or more Sound objects and selects one with random weight for playback.
  42375. */
  42376. export class WeightedSound {
  42377. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42378. loop: boolean;
  42379. private _coneInnerAngle;
  42380. private _coneOuterAngle;
  42381. private _volume;
  42382. /** A Sound is currently playing. */
  42383. isPlaying: boolean;
  42384. /** A Sound is currently paused. */
  42385. isPaused: boolean;
  42386. private _sounds;
  42387. private _weights;
  42388. private _currentIndex?;
  42389. /**
  42390. * Creates a new WeightedSound from the list of sounds given.
  42391. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42392. * @param sounds Array of Sounds that will be selected from.
  42393. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42394. */
  42395. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42396. /**
  42397. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42398. */
  42399. get directionalConeInnerAngle(): number;
  42400. /**
  42401. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42402. */
  42403. set directionalConeInnerAngle(value: number);
  42404. /**
  42405. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42406. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42407. */
  42408. get directionalConeOuterAngle(): number;
  42409. /**
  42410. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42411. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42412. */
  42413. set directionalConeOuterAngle(value: number);
  42414. /**
  42415. * Playback volume.
  42416. */
  42417. get volume(): number;
  42418. /**
  42419. * Playback volume.
  42420. */
  42421. set volume(value: number);
  42422. private _onended;
  42423. /**
  42424. * Suspend playback
  42425. */
  42426. pause(): void;
  42427. /**
  42428. * Stop playback
  42429. */
  42430. stop(): void;
  42431. /**
  42432. * Start playback.
  42433. * @param startOffset Position the clip head at a specific time in seconds.
  42434. */
  42435. play(startOffset?: number): void;
  42436. }
  42437. }
  42438. declare module BABYLON {
  42439. /**
  42440. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42441. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42442. */
  42443. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42444. /**
  42445. * Gets the name of the behavior.
  42446. */
  42447. get name(): string;
  42448. /**
  42449. * The easing function used by animations
  42450. */
  42451. static EasingFunction: BackEase;
  42452. /**
  42453. * The easing mode used by animations
  42454. */
  42455. static EasingMode: number;
  42456. /**
  42457. * The duration of the animation, in milliseconds
  42458. */
  42459. transitionDuration: number;
  42460. /**
  42461. * Length of the distance animated by the transition when lower radius is reached
  42462. */
  42463. lowerRadiusTransitionRange: number;
  42464. /**
  42465. * Length of the distance animated by the transition when upper radius is reached
  42466. */
  42467. upperRadiusTransitionRange: number;
  42468. private _autoTransitionRange;
  42469. /**
  42470. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42471. */
  42472. get autoTransitionRange(): boolean;
  42473. /**
  42474. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42475. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42476. */
  42477. set autoTransitionRange(value: boolean);
  42478. private _attachedCamera;
  42479. private _onAfterCheckInputsObserver;
  42480. private _onMeshTargetChangedObserver;
  42481. /**
  42482. * Initializes the behavior.
  42483. */
  42484. init(): void;
  42485. /**
  42486. * Attaches the behavior to its arc rotate camera.
  42487. * @param camera Defines the camera to attach the behavior to
  42488. */
  42489. attach(camera: ArcRotateCamera): void;
  42490. /**
  42491. * Detaches the behavior from its current arc rotate camera.
  42492. */
  42493. detach(): void;
  42494. private _radiusIsAnimating;
  42495. private _radiusBounceTransition;
  42496. private _animatables;
  42497. private _cachedWheelPrecision;
  42498. /**
  42499. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42500. * @param radiusLimit The limit to check against.
  42501. * @return Bool to indicate if at limit.
  42502. */
  42503. private _isRadiusAtLimit;
  42504. /**
  42505. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42506. * @param radiusDelta The delta by which to animate to. Can be negative.
  42507. */
  42508. private _applyBoundRadiusAnimation;
  42509. /**
  42510. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42511. */
  42512. protected _clearAnimationLocks(): void;
  42513. /**
  42514. * Stops and removes all animations that have been applied to the camera
  42515. */
  42516. stopAllAnimations(): void;
  42517. }
  42518. }
  42519. declare module BABYLON {
  42520. /**
  42521. * 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.
  42522. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42523. */
  42524. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42525. /**
  42526. * Gets the name of the behavior.
  42527. */
  42528. get name(): string;
  42529. private _mode;
  42530. private _radiusScale;
  42531. private _positionScale;
  42532. private _defaultElevation;
  42533. private _elevationReturnTime;
  42534. private _elevationReturnWaitTime;
  42535. private _zoomStopsAnimation;
  42536. private _framingTime;
  42537. /**
  42538. * The easing function used by animations
  42539. */
  42540. static EasingFunction: ExponentialEase;
  42541. /**
  42542. * The easing mode used by animations
  42543. */
  42544. static EasingMode: number;
  42545. /**
  42546. * Sets the current mode used by the behavior
  42547. */
  42548. set mode(mode: number);
  42549. /**
  42550. * Gets current mode used by the behavior.
  42551. */
  42552. get mode(): number;
  42553. /**
  42554. * Sets the scale applied to the radius (1 by default)
  42555. */
  42556. set radiusScale(radius: number);
  42557. /**
  42558. * Gets the scale applied to the radius
  42559. */
  42560. get radiusScale(): number;
  42561. /**
  42562. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42563. */
  42564. set positionScale(scale: number);
  42565. /**
  42566. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42567. */
  42568. get positionScale(): number;
  42569. /**
  42570. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42571. * behaviour is triggered, in radians.
  42572. */
  42573. set defaultElevation(elevation: number);
  42574. /**
  42575. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42576. * behaviour is triggered, in radians.
  42577. */
  42578. get defaultElevation(): number;
  42579. /**
  42580. * Sets the time (in milliseconds) taken to return to the default beta position.
  42581. * Negative value indicates camera should not return to default.
  42582. */
  42583. set elevationReturnTime(speed: number);
  42584. /**
  42585. * Gets the time (in milliseconds) taken to return to the default beta position.
  42586. * Negative value indicates camera should not return to default.
  42587. */
  42588. get elevationReturnTime(): number;
  42589. /**
  42590. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42591. */
  42592. set elevationReturnWaitTime(time: number);
  42593. /**
  42594. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42595. */
  42596. get elevationReturnWaitTime(): number;
  42597. /**
  42598. * Sets the flag that indicates if user zooming should stop animation.
  42599. */
  42600. set zoomStopsAnimation(flag: boolean);
  42601. /**
  42602. * Gets the flag that indicates if user zooming should stop animation.
  42603. */
  42604. get zoomStopsAnimation(): boolean;
  42605. /**
  42606. * Sets the transition time when framing the mesh, in milliseconds
  42607. */
  42608. set framingTime(time: number);
  42609. /**
  42610. * Gets the transition time when framing the mesh, in milliseconds
  42611. */
  42612. get framingTime(): number;
  42613. /**
  42614. * Define if the behavior should automatically change the configured
  42615. * camera limits and sensibilities.
  42616. */
  42617. autoCorrectCameraLimitsAndSensibility: boolean;
  42618. private _onPrePointerObservableObserver;
  42619. private _onAfterCheckInputsObserver;
  42620. private _onMeshTargetChangedObserver;
  42621. private _attachedCamera;
  42622. private _isPointerDown;
  42623. private _lastInteractionTime;
  42624. /**
  42625. * Initializes the behavior.
  42626. */
  42627. init(): void;
  42628. /**
  42629. * Attaches the behavior to its arc rotate camera.
  42630. * @param camera Defines the camera to attach the behavior to
  42631. */
  42632. attach(camera: ArcRotateCamera): void;
  42633. /**
  42634. * Detaches the behavior from its current arc rotate camera.
  42635. */
  42636. detach(): void;
  42637. private _animatables;
  42638. private _betaIsAnimating;
  42639. private _betaTransition;
  42640. private _radiusTransition;
  42641. private _vectorTransition;
  42642. /**
  42643. * Targets the given mesh and updates zoom level accordingly.
  42644. * @param mesh The mesh to target.
  42645. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42646. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42647. */
  42648. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42649. /**
  42650. * Targets the given mesh with its children and updates zoom level accordingly.
  42651. * @param mesh The mesh to target.
  42652. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42653. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42654. */
  42655. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42656. /**
  42657. * Targets the given meshes with their children and updates zoom level accordingly.
  42658. * @param meshes The mesh to target.
  42659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42661. */
  42662. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42663. /**
  42664. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42665. * @param minimumWorld Determines the smaller position of the bounding box extend
  42666. * @param maximumWorld Determines the bigger position of the bounding box extend
  42667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42669. */
  42670. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42671. /**
  42672. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42673. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42674. * frustum width.
  42675. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42676. * to fully enclose the mesh in the viewing frustum.
  42677. */
  42678. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42679. /**
  42680. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42681. * is automatically returned to its default position (expected to be above ground plane).
  42682. */
  42683. private _maintainCameraAboveGround;
  42684. /**
  42685. * Returns the frustum slope based on the canvas ratio and camera FOV
  42686. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42687. */
  42688. private _getFrustumSlope;
  42689. /**
  42690. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42691. */
  42692. private _clearAnimationLocks;
  42693. /**
  42694. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42695. */
  42696. private _applyUserInteraction;
  42697. /**
  42698. * Stops and removes all animations that have been applied to the camera
  42699. */
  42700. stopAllAnimations(): void;
  42701. /**
  42702. * Gets a value indicating if the user is moving the camera
  42703. */
  42704. get isUserIsMoving(): boolean;
  42705. /**
  42706. * The camera can move all the way towards the mesh.
  42707. */
  42708. static IgnoreBoundsSizeMode: number;
  42709. /**
  42710. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42711. */
  42712. static FitFrustumSidesMode: number;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * Base class for Camera Pointer Inputs.
  42718. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42719. * for example usage.
  42720. */
  42721. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42722. /**
  42723. * Defines the camera the input is attached to.
  42724. */
  42725. abstract camera: Camera;
  42726. /**
  42727. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42728. */
  42729. protected _altKey: boolean;
  42730. protected _ctrlKey: boolean;
  42731. protected _metaKey: boolean;
  42732. protected _shiftKey: boolean;
  42733. /**
  42734. * Which mouse buttons were pressed at time of last mouse event.
  42735. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42736. */
  42737. protected _buttonsPressed: number;
  42738. /**
  42739. * Defines the buttons associated with the input to handle camera move.
  42740. */
  42741. buttons: number[];
  42742. /**
  42743. * Attach the input controls to a specific dom element to get the input from.
  42744. * @param element Defines the element the controls should be listened from
  42745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42746. */
  42747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42748. /**
  42749. * Detach the current controls from the specified dom element.
  42750. * @param element Defines the element to stop listening the inputs from
  42751. */
  42752. detachControl(element: Nullable<HTMLElement>): void;
  42753. /**
  42754. * Gets the class name of the current input.
  42755. * @returns the class name
  42756. */
  42757. getClassName(): string;
  42758. /**
  42759. * Get the friendly name associated with the input class.
  42760. * @returns the input friendly name
  42761. */
  42762. getSimpleName(): string;
  42763. /**
  42764. * Called on pointer POINTERDOUBLETAP event.
  42765. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42766. */
  42767. protected onDoubleTap(type: string): void;
  42768. /**
  42769. * Called on pointer POINTERMOVE event if only a single touch is active.
  42770. * Override this method to provide functionality.
  42771. */
  42772. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42773. /**
  42774. * Called on pointer POINTERMOVE event if multiple touches are active.
  42775. * Override this method to provide functionality.
  42776. */
  42777. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42778. /**
  42779. * Called on JS contextmenu event.
  42780. * Override this method to provide functionality.
  42781. */
  42782. protected onContextMenu(evt: PointerEvent): void;
  42783. /**
  42784. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42785. * press.
  42786. * Override this method to provide functionality.
  42787. */
  42788. protected onButtonDown(evt: PointerEvent): void;
  42789. /**
  42790. * Called each time a new POINTERUP event occurs. Ie, for each button
  42791. * release.
  42792. * Override this method to provide functionality.
  42793. */
  42794. protected onButtonUp(evt: PointerEvent): void;
  42795. /**
  42796. * Called when window becomes inactive.
  42797. * Override this method to provide functionality.
  42798. */
  42799. protected onLostFocus(): void;
  42800. private _pointerInput;
  42801. private _observer;
  42802. private _onLostFocus;
  42803. private pointA;
  42804. private pointB;
  42805. }
  42806. }
  42807. declare module BABYLON {
  42808. /**
  42809. * Manage the pointers inputs to control an arc rotate camera.
  42810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42811. */
  42812. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42813. /**
  42814. * Defines the camera the input is attached to.
  42815. */
  42816. camera: ArcRotateCamera;
  42817. /**
  42818. * Gets the class name of the current input.
  42819. * @returns the class name
  42820. */
  42821. getClassName(): string;
  42822. /**
  42823. * Defines the buttons associated with the input to handle camera move.
  42824. */
  42825. buttons: number[];
  42826. /**
  42827. * Defines the pointer angular sensibility along the X axis or how fast is
  42828. * the camera rotating.
  42829. */
  42830. angularSensibilityX: number;
  42831. /**
  42832. * Defines the pointer angular sensibility along the Y axis or how fast is
  42833. * the camera rotating.
  42834. */
  42835. angularSensibilityY: number;
  42836. /**
  42837. * Defines the pointer pinch precision or how fast is the camera zooming.
  42838. */
  42839. pinchPrecision: number;
  42840. /**
  42841. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42842. * from 0.
  42843. * It defines the percentage of current camera.radius to use as delta when
  42844. * pinch zoom is used.
  42845. */
  42846. pinchDeltaPercentage: number;
  42847. /**
  42848. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42849. * that any object in the plane at the camera's target point will scale
  42850. * perfectly with finger motion.
  42851. * Overrides pinchDeltaPercentage and pinchPrecision.
  42852. */
  42853. useNaturalPinchZoom: boolean;
  42854. /**
  42855. * Defines the pointer panning sensibility or how fast is the camera moving.
  42856. */
  42857. panningSensibility: number;
  42858. /**
  42859. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42860. */
  42861. multiTouchPanning: boolean;
  42862. /**
  42863. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42864. * zoom (pinch) through multitouch.
  42865. */
  42866. multiTouchPanAndZoom: boolean;
  42867. /**
  42868. * Revers pinch action direction.
  42869. */
  42870. pinchInwards: boolean;
  42871. private _isPanClick;
  42872. private _twoFingerActivityCount;
  42873. private _isPinching;
  42874. /**
  42875. * Called on pointer POINTERMOVE event if only a single touch is active.
  42876. */
  42877. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42878. /**
  42879. * Called on pointer POINTERDOUBLETAP event.
  42880. */
  42881. protected onDoubleTap(type: string): void;
  42882. /**
  42883. * Called on pointer POINTERMOVE event if multiple touches are active.
  42884. */
  42885. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42886. /**
  42887. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42888. * press.
  42889. */
  42890. protected onButtonDown(evt: PointerEvent): void;
  42891. /**
  42892. * Called each time a new POINTERUP event occurs. Ie, for each button
  42893. * release.
  42894. */
  42895. protected onButtonUp(evt: PointerEvent): void;
  42896. /**
  42897. * Called when window becomes inactive.
  42898. */
  42899. protected onLostFocus(): void;
  42900. }
  42901. }
  42902. declare module BABYLON {
  42903. /**
  42904. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42906. */
  42907. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42908. /**
  42909. * Defines the camera the input is attached to.
  42910. */
  42911. camera: ArcRotateCamera;
  42912. /**
  42913. * Defines the list of key codes associated with the up action (increase alpha)
  42914. */
  42915. keysUp: number[];
  42916. /**
  42917. * Defines the list of key codes associated with the down action (decrease alpha)
  42918. */
  42919. keysDown: number[];
  42920. /**
  42921. * Defines the list of key codes associated with the left action (increase beta)
  42922. */
  42923. keysLeft: number[];
  42924. /**
  42925. * Defines the list of key codes associated with the right action (decrease beta)
  42926. */
  42927. keysRight: number[];
  42928. /**
  42929. * Defines the list of key codes associated with the reset action.
  42930. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42931. */
  42932. keysReset: number[];
  42933. /**
  42934. * Defines the panning sensibility of the inputs.
  42935. * (How fast is the camera panning)
  42936. */
  42937. panningSensibility: number;
  42938. /**
  42939. * Defines the zooming sensibility of the inputs.
  42940. * (How fast is the camera zooming)
  42941. */
  42942. zoomingSensibility: number;
  42943. /**
  42944. * Defines whether maintaining the alt key down switch the movement mode from
  42945. * orientation to zoom.
  42946. */
  42947. useAltToZoom: boolean;
  42948. /**
  42949. * Rotation speed of the camera
  42950. */
  42951. angularSpeed: number;
  42952. private _keys;
  42953. private _ctrlPressed;
  42954. private _altPressed;
  42955. private _onCanvasBlurObserver;
  42956. private _onKeyboardObserver;
  42957. private _engine;
  42958. private _scene;
  42959. /**
  42960. * Attach the input controls to a specific dom element to get the input from.
  42961. * @param element Defines the element the controls should be listened from
  42962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42963. */
  42964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42965. /**
  42966. * Detach the current controls from the specified dom element.
  42967. * @param element Defines the element to stop listening the inputs from
  42968. */
  42969. detachControl(element: Nullable<HTMLElement>): void;
  42970. /**
  42971. * Update the current camera state depending on the inputs that have been used this frame.
  42972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42973. */
  42974. checkInputs(): void;
  42975. /**
  42976. * Gets the class name of the current intput.
  42977. * @returns the class name
  42978. */
  42979. getClassName(): string;
  42980. /**
  42981. * Get the friendly name associated with the input class.
  42982. * @returns the input friendly name
  42983. */
  42984. getSimpleName(): string;
  42985. }
  42986. }
  42987. declare module BABYLON {
  42988. /**
  42989. * Manage the mouse wheel inputs to control an arc rotate camera.
  42990. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42991. */
  42992. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42993. /**
  42994. * Defines the camera the input is attached to.
  42995. */
  42996. camera: ArcRotateCamera;
  42997. /**
  42998. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42999. */
  43000. wheelPrecision: number;
  43001. /**
  43002. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43003. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43004. */
  43005. wheelDeltaPercentage: number;
  43006. private _wheel;
  43007. private _observer;
  43008. private computeDeltaFromMouseWheelLegacyEvent;
  43009. /**
  43010. * Attach the input controls to a specific dom element to get the input from.
  43011. * @param element Defines the element the controls should be listened from
  43012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43013. */
  43014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43015. /**
  43016. * Detach the current controls from the specified dom element.
  43017. * @param element Defines the element to stop listening the inputs from
  43018. */
  43019. detachControl(element: Nullable<HTMLElement>): void;
  43020. /**
  43021. * Gets the class name of the current intput.
  43022. * @returns the class name
  43023. */
  43024. getClassName(): string;
  43025. /**
  43026. * Get the friendly name associated with the input class.
  43027. * @returns the input friendly name
  43028. */
  43029. getSimpleName(): string;
  43030. }
  43031. }
  43032. declare module BABYLON {
  43033. /**
  43034. * Default Inputs manager for the ArcRotateCamera.
  43035. * It groups all the default supported inputs for ease of use.
  43036. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43037. */
  43038. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43039. /**
  43040. * Instantiates a new ArcRotateCameraInputsManager.
  43041. * @param camera Defines the camera the inputs belong to
  43042. */
  43043. constructor(camera: ArcRotateCamera);
  43044. /**
  43045. * Add mouse wheel input support to the input manager.
  43046. * @returns the current input manager
  43047. */
  43048. addMouseWheel(): ArcRotateCameraInputsManager;
  43049. /**
  43050. * Add pointers input support to the input manager.
  43051. * @returns the current input manager
  43052. */
  43053. addPointers(): ArcRotateCameraInputsManager;
  43054. /**
  43055. * Add keyboard input support to the input manager.
  43056. * @returns the current input manager
  43057. */
  43058. addKeyboard(): ArcRotateCameraInputsManager;
  43059. }
  43060. }
  43061. declare module BABYLON {
  43062. /**
  43063. * This represents an orbital type of camera.
  43064. *
  43065. * 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.
  43066. * 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.
  43067. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43068. */
  43069. export class ArcRotateCamera extends TargetCamera {
  43070. /**
  43071. * Defines the rotation angle of the camera along the longitudinal axis.
  43072. */
  43073. alpha: number;
  43074. /**
  43075. * Defines the rotation angle of the camera along the latitudinal axis.
  43076. */
  43077. beta: number;
  43078. /**
  43079. * Defines the radius of the camera from it s target point.
  43080. */
  43081. radius: number;
  43082. protected _target: Vector3;
  43083. protected _targetHost: Nullable<AbstractMesh>;
  43084. /**
  43085. * Defines the target point of the camera.
  43086. * The camera looks towards it form the radius distance.
  43087. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  43088. */
  43089. get target(): Vector3;
  43090. set target(value: Vector3);
  43091. /**
  43092. * Define the current local position of the camera in the scene
  43093. */
  43094. get position(): Vector3;
  43095. set position(newPosition: Vector3);
  43096. protected _upToYMatrix: Matrix;
  43097. protected _YToUpMatrix: Matrix;
  43098. /**
  43099. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43100. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43101. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43102. */
  43103. set upVector(vec: Vector3);
  43104. get upVector(): Vector3;
  43105. /**
  43106. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43107. */
  43108. setMatUp(): void;
  43109. /**
  43110. * Current inertia value on the longitudinal axis.
  43111. * The bigger this number the longer it will take for the camera to stop.
  43112. */
  43113. inertialAlphaOffset: number;
  43114. /**
  43115. * Current inertia value on the latitudinal axis.
  43116. * The bigger this number the longer it will take for the camera to stop.
  43117. */
  43118. inertialBetaOffset: number;
  43119. /**
  43120. * Current inertia value on the radius axis.
  43121. * The bigger this number the longer it will take for the camera to stop.
  43122. */
  43123. inertialRadiusOffset: number;
  43124. /**
  43125. * Minimum allowed angle on the longitudinal axis.
  43126. * This can help limiting how the Camera is able to move in the scene.
  43127. */
  43128. lowerAlphaLimit: Nullable<number>;
  43129. /**
  43130. * Maximum allowed angle on the longitudinal axis.
  43131. * This can help limiting how the Camera is able to move in the scene.
  43132. */
  43133. upperAlphaLimit: Nullable<number>;
  43134. /**
  43135. * Minimum allowed angle on the latitudinal axis.
  43136. * This can help limiting how the Camera is able to move in the scene.
  43137. */
  43138. lowerBetaLimit: number;
  43139. /**
  43140. * Maximum allowed angle on the latitudinal axis.
  43141. * This can help limiting how the Camera is able to move in the scene.
  43142. */
  43143. upperBetaLimit: number;
  43144. /**
  43145. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43146. * This can help limiting how the Camera is able to move in the scene.
  43147. */
  43148. lowerRadiusLimit: Nullable<number>;
  43149. /**
  43150. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43151. * This can help limiting how the Camera is able to move in the scene.
  43152. */
  43153. upperRadiusLimit: Nullable<number>;
  43154. /**
  43155. * Defines the current inertia value used during panning of the camera along the X axis.
  43156. */
  43157. inertialPanningX: number;
  43158. /**
  43159. * Defines the current inertia value used during panning of the camera along the Y axis.
  43160. */
  43161. inertialPanningY: number;
  43162. /**
  43163. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43164. * Basically if your fingers moves away from more than this distance you will be considered
  43165. * in pinch mode.
  43166. */
  43167. pinchToPanMaxDistance: number;
  43168. /**
  43169. * Defines the maximum distance the camera can pan.
  43170. * This could help keeping the cammera always in your scene.
  43171. */
  43172. panningDistanceLimit: Nullable<number>;
  43173. /**
  43174. * Defines the target of the camera before paning.
  43175. */
  43176. panningOriginTarget: Vector3;
  43177. /**
  43178. * Defines the value of the inertia used during panning.
  43179. * 0 would mean stop inertia and one would mean no decelleration at all.
  43180. */
  43181. panningInertia: number;
  43182. /**
  43183. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43184. */
  43185. get angularSensibilityX(): number;
  43186. set angularSensibilityX(value: number);
  43187. /**
  43188. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43189. */
  43190. get angularSensibilityY(): number;
  43191. set angularSensibilityY(value: number);
  43192. /**
  43193. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43194. */
  43195. get pinchPrecision(): number;
  43196. set pinchPrecision(value: number);
  43197. /**
  43198. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43199. * It will be used instead of pinchDeltaPrecision if different from 0.
  43200. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43201. */
  43202. get pinchDeltaPercentage(): number;
  43203. set pinchDeltaPercentage(value: number);
  43204. /**
  43205. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43206. * and pinch delta percentage.
  43207. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43208. * that any object in the plane at the camera's target point will scale
  43209. * perfectly with finger motion.
  43210. */
  43211. get useNaturalPinchZoom(): boolean;
  43212. set useNaturalPinchZoom(value: boolean);
  43213. /**
  43214. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43215. */
  43216. get panningSensibility(): number;
  43217. set panningSensibility(value: number);
  43218. /**
  43219. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43220. */
  43221. get keysUp(): number[];
  43222. set keysUp(value: number[]);
  43223. /**
  43224. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43225. */
  43226. get keysDown(): number[];
  43227. set keysDown(value: number[]);
  43228. /**
  43229. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43230. */
  43231. get keysLeft(): number[];
  43232. set keysLeft(value: number[]);
  43233. /**
  43234. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43235. */
  43236. get keysRight(): number[];
  43237. set keysRight(value: number[]);
  43238. /**
  43239. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43240. */
  43241. get wheelPrecision(): number;
  43242. set wheelPrecision(value: number);
  43243. /**
  43244. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43245. * It will be used instead of pinchDeltaPrecision if different from 0.
  43246. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43247. */
  43248. get wheelDeltaPercentage(): number;
  43249. set wheelDeltaPercentage(value: number);
  43250. /**
  43251. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43252. */
  43253. zoomOnFactor: number;
  43254. /**
  43255. * Defines a screen offset for the camera position.
  43256. */
  43257. targetScreenOffset: Vector2;
  43258. /**
  43259. * Allows the camera to be completely reversed.
  43260. * If false the camera can not arrive upside down.
  43261. */
  43262. allowUpsideDown: boolean;
  43263. /**
  43264. * Define if double tap/click is used to restore the previously saved state of the camera.
  43265. */
  43266. useInputToRestoreState: boolean;
  43267. /** @hidden */
  43268. _viewMatrix: Matrix;
  43269. /** @hidden */
  43270. _useCtrlForPanning: boolean;
  43271. /** @hidden */
  43272. _panningMouseButton: number;
  43273. /**
  43274. * Defines the input associated to the camera.
  43275. */
  43276. inputs: ArcRotateCameraInputsManager;
  43277. /** @hidden */
  43278. _reset: () => void;
  43279. /**
  43280. * Defines the allowed panning axis.
  43281. */
  43282. panningAxis: Vector3;
  43283. protected _localDirection: Vector3;
  43284. protected _transformedDirection: Vector3;
  43285. private _bouncingBehavior;
  43286. /**
  43287. * Gets the bouncing behavior of the camera if it has been enabled.
  43288. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43289. */
  43290. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43291. /**
  43292. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43293. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43294. */
  43295. get useBouncingBehavior(): boolean;
  43296. set useBouncingBehavior(value: boolean);
  43297. private _framingBehavior;
  43298. /**
  43299. * Gets the framing behavior of the camera if it has been enabled.
  43300. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43301. */
  43302. get framingBehavior(): Nullable<FramingBehavior>;
  43303. /**
  43304. * Defines if the framing behavior of the camera is enabled on the camera.
  43305. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43306. */
  43307. get useFramingBehavior(): boolean;
  43308. set useFramingBehavior(value: boolean);
  43309. private _autoRotationBehavior;
  43310. /**
  43311. * Gets the auto rotation behavior of the camera if it has been enabled.
  43312. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43313. */
  43314. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43315. /**
  43316. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43317. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43318. */
  43319. get useAutoRotationBehavior(): boolean;
  43320. set useAutoRotationBehavior(value: boolean);
  43321. /**
  43322. * Observable triggered when the mesh target has been changed on the camera.
  43323. */
  43324. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43325. /**
  43326. * Event raised when the camera is colliding with a mesh.
  43327. */
  43328. onCollide: (collidedMesh: AbstractMesh) => void;
  43329. /**
  43330. * Defines whether the camera should check collision with the objects oh the scene.
  43331. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43332. */
  43333. checkCollisions: boolean;
  43334. /**
  43335. * Defines the collision radius of the camera.
  43336. * This simulates a sphere around the camera.
  43337. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43338. */
  43339. collisionRadius: Vector3;
  43340. protected _collider: Collider;
  43341. protected _previousPosition: Vector3;
  43342. protected _collisionVelocity: Vector3;
  43343. protected _newPosition: Vector3;
  43344. protected _previousAlpha: number;
  43345. protected _previousBeta: number;
  43346. protected _previousRadius: number;
  43347. protected _collisionTriggered: boolean;
  43348. protected _targetBoundingCenter: Nullable<Vector3>;
  43349. private _computationVector;
  43350. /**
  43351. * Instantiates a new ArcRotateCamera in a given scene
  43352. * @param name Defines the name of the camera
  43353. * @param alpha Defines the camera rotation along the logitudinal axis
  43354. * @param beta Defines the camera rotation along the latitudinal axis
  43355. * @param radius Defines the camera distance from its target
  43356. * @param target Defines the camera target
  43357. * @param scene Defines the scene the camera belongs to
  43358. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43359. */
  43360. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43361. /** @hidden */
  43362. _initCache(): void;
  43363. /** @hidden */
  43364. _updateCache(ignoreParentClass?: boolean): void;
  43365. protected _getTargetPosition(): Vector3;
  43366. private _storedAlpha;
  43367. private _storedBeta;
  43368. private _storedRadius;
  43369. private _storedTarget;
  43370. private _storedTargetScreenOffset;
  43371. /**
  43372. * Stores the current state of the camera (alpha, beta, radius and target)
  43373. * @returns the camera itself
  43374. */
  43375. storeState(): Camera;
  43376. /**
  43377. * @hidden
  43378. * Restored camera state. You must call storeState() first
  43379. */
  43380. _restoreStateValues(): boolean;
  43381. /** @hidden */
  43382. _isSynchronizedViewMatrix(): boolean;
  43383. /**
  43384. * Attached controls to the current camera.
  43385. * @param element Defines the element the controls should be listened from
  43386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43387. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43388. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43389. */
  43390. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43391. /**
  43392. * Detach the current controls from the camera.
  43393. * The camera will stop reacting to inputs.
  43394. * @param element Defines the element to stop listening the inputs from
  43395. */
  43396. detachControl(element: HTMLElement): void;
  43397. /** @hidden */
  43398. _checkInputs(): void;
  43399. protected _checkLimits(): void;
  43400. /**
  43401. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43402. */
  43403. rebuildAnglesAndRadius(): void;
  43404. /**
  43405. * Use a position to define the current camera related information like alpha, beta and radius
  43406. * @param position Defines the position to set the camera at
  43407. */
  43408. setPosition(position: Vector3): void;
  43409. /**
  43410. * Defines the target the camera should look at.
  43411. * This will automatically adapt alpha beta and radius to fit within the new target.
  43412. * @param target Defines the new target as a Vector or a mesh
  43413. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43414. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43415. */
  43416. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43417. /** @hidden */
  43418. _getViewMatrix(): Matrix;
  43419. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43420. /**
  43421. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43422. * @param meshes Defines the mesh to zoom on
  43423. * @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)
  43424. */
  43425. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43426. /**
  43427. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43428. * The target will be changed but the radius
  43429. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43430. * @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)
  43431. */
  43432. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43433. min: Vector3;
  43434. max: Vector3;
  43435. distance: number;
  43436. }, doNotUpdateMaxZ?: boolean): void;
  43437. /**
  43438. * @override
  43439. * Override Camera.createRigCamera
  43440. */
  43441. createRigCamera(name: string, cameraIndex: number): Camera;
  43442. /**
  43443. * @hidden
  43444. * @override
  43445. * Override Camera._updateRigCameras
  43446. */
  43447. _updateRigCameras(): void;
  43448. /**
  43449. * Destroy the camera and release the current resources hold by it.
  43450. */
  43451. dispose(): void;
  43452. /**
  43453. * Gets the current object class name.
  43454. * @return the class name
  43455. */
  43456. getClassName(): string;
  43457. }
  43458. }
  43459. declare module BABYLON {
  43460. /**
  43461. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43462. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43463. */
  43464. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43465. /**
  43466. * Gets the name of the behavior.
  43467. */
  43468. get name(): string;
  43469. private _zoomStopsAnimation;
  43470. private _idleRotationSpeed;
  43471. private _idleRotationWaitTime;
  43472. private _idleRotationSpinupTime;
  43473. /**
  43474. * Sets the flag that indicates if user zooming should stop animation.
  43475. */
  43476. set zoomStopsAnimation(flag: boolean);
  43477. /**
  43478. * Gets the flag that indicates if user zooming should stop animation.
  43479. */
  43480. get zoomStopsAnimation(): boolean;
  43481. /**
  43482. * Sets the default speed at which the camera rotates around the model.
  43483. */
  43484. set idleRotationSpeed(speed: number);
  43485. /**
  43486. * Gets the default speed at which the camera rotates around the model.
  43487. */
  43488. get idleRotationSpeed(): number;
  43489. /**
  43490. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43491. */
  43492. set idleRotationWaitTime(time: number);
  43493. /**
  43494. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43495. */
  43496. get idleRotationWaitTime(): number;
  43497. /**
  43498. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43499. */
  43500. set idleRotationSpinupTime(time: number);
  43501. /**
  43502. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43503. */
  43504. get idleRotationSpinupTime(): number;
  43505. /**
  43506. * Gets a value indicating if the camera is currently rotating because of this behavior
  43507. */
  43508. get rotationInProgress(): boolean;
  43509. private _onPrePointerObservableObserver;
  43510. private _onAfterCheckInputsObserver;
  43511. private _attachedCamera;
  43512. private _isPointerDown;
  43513. private _lastFrameTime;
  43514. private _lastInteractionTime;
  43515. private _cameraRotationSpeed;
  43516. /**
  43517. * Initializes the behavior.
  43518. */
  43519. init(): void;
  43520. /**
  43521. * Attaches the behavior to its arc rotate camera.
  43522. * @param camera Defines the camera to attach the behavior to
  43523. */
  43524. attach(camera: ArcRotateCamera): void;
  43525. /**
  43526. * Detaches the behavior from its current arc rotate camera.
  43527. */
  43528. detach(): void;
  43529. /**
  43530. * Returns true if user is scrolling.
  43531. * @return true if user is scrolling.
  43532. */
  43533. private _userIsZooming;
  43534. private _lastFrameRadius;
  43535. private _shouldAnimationStopForInteraction;
  43536. /**
  43537. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43538. */
  43539. private _applyUserInteraction;
  43540. private _userIsMoving;
  43541. }
  43542. }
  43543. declare module BABYLON {
  43544. /**
  43545. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43546. */
  43547. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43548. private ui;
  43549. /**
  43550. * The name of the behavior
  43551. */
  43552. name: string;
  43553. /**
  43554. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43555. */
  43556. distanceAwayFromFace: number;
  43557. /**
  43558. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43559. */
  43560. distanceAwayFromBottomOfFace: number;
  43561. private _faceVectors;
  43562. private _target;
  43563. private _scene;
  43564. private _onRenderObserver;
  43565. private _tmpMatrix;
  43566. private _tmpVector;
  43567. /**
  43568. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43569. * @param ui The transform node that should be attched to the mesh
  43570. */
  43571. constructor(ui: TransformNode);
  43572. /**
  43573. * Initializes the behavior
  43574. */
  43575. init(): void;
  43576. private _closestFace;
  43577. private _zeroVector;
  43578. private _lookAtTmpMatrix;
  43579. private _lookAtToRef;
  43580. /**
  43581. * Attaches the AttachToBoxBehavior to the passed in mesh
  43582. * @param target The mesh that the specified node will be attached to
  43583. */
  43584. attach(target: Mesh): void;
  43585. /**
  43586. * Detaches the behavior from the mesh
  43587. */
  43588. detach(): void;
  43589. }
  43590. }
  43591. declare module BABYLON {
  43592. /**
  43593. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43594. */
  43595. export class FadeInOutBehavior implements Behavior<Mesh> {
  43596. /**
  43597. * Time in milliseconds to delay before fading in (Default: 0)
  43598. */
  43599. delay: number;
  43600. /**
  43601. * Time in milliseconds for the mesh to fade in (Default: 300)
  43602. */
  43603. fadeInTime: number;
  43604. private _millisecondsPerFrame;
  43605. private _hovered;
  43606. private _hoverValue;
  43607. private _ownerNode;
  43608. /**
  43609. * Instatiates the FadeInOutBehavior
  43610. */
  43611. constructor();
  43612. /**
  43613. * The name of the behavior
  43614. */
  43615. get name(): string;
  43616. /**
  43617. * Initializes the behavior
  43618. */
  43619. init(): void;
  43620. /**
  43621. * Attaches the fade behavior on the passed in mesh
  43622. * @param ownerNode The mesh that will be faded in/out once attached
  43623. */
  43624. attach(ownerNode: Mesh): void;
  43625. /**
  43626. * Detaches the behavior from the mesh
  43627. */
  43628. detach(): void;
  43629. /**
  43630. * Triggers the mesh to begin fading in or out
  43631. * @param value if the object should fade in or out (true to fade in)
  43632. */
  43633. fadeIn(value: boolean): void;
  43634. private _update;
  43635. private _setAllVisibility;
  43636. }
  43637. }
  43638. declare module BABYLON {
  43639. /**
  43640. * Class containing a set of static utilities functions for managing Pivots
  43641. * @hidden
  43642. */
  43643. export class PivotTools {
  43644. private static _PivotCached;
  43645. private static _OldPivotPoint;
  43646. private static _PivotTranslation;
  43647. private static _PivotTmpVector;
  43648. private static _PivotPostMultiplyPivotMatrix;
  43649. /** @hidden */
  43650. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43651. /** @hidden */
  43652. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43653. }
  43654. }
  43655. declare module BABYLON {
  43656. /**
  43657. * Class containing static functions to help procedurally build meshes
  43658. */
  43659. export class PlaneBuilder {
  43660. /**
  43661. * Creates a plane mesh
  43662. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43663. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43664. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43666. * * 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
  43667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43668. * @param name defines the name of the mesh
  43669. * @param options defines the options used to create the mesh
  43670. * @param scene defines the hosting scene
  43671. * @returns the plane mesh
  43672. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43673. */
  43674. static CreatePlane(name: string, options: {
  43675. size?: number;
  43676. width?: number;
  43677. height?: number;
  43678. sideOrientation?: number;
  43679. frontUVs?: Vector4;
  43680. backUVs?: Vector4;
  43681. updatable?: boolean;
  43682. sourcePlane?: Plane;
  43683. }, scene?: Nullable<Scene>): Mesh;
  43684. }
  43685. }
  43686. declare module BABYLON {
  43687. /**
  43688. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43689. */
  43690. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43691. private static _AnyMouseID;
  43692. /**
  43693. * Abstract mesh the behavior is set on
  43694. */
  43695. attachedNode: AbstractMesh;
  43696. private _dragPlane;
  43697. private _scene;
  43698. private _pointerObserver;
  43699. private _beforeRenderObserver;
  43700. private static _planeScene;
  43701. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43702. /**
  43703. * 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)
  43704. */
  43705. maxDragAngle: number;
  43706. /**
  43707. * @hidden
  43708. */
  43709. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43710. /**
  43711. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43712. */
  43713. currentDraggingPointerID: number;
  43714. /**
  43715. * The last position where the pointer hit the drag plane in world space
  43716. */
  43717. lastDragPosition: Vector3;
  43718. /**
  43719. * If the behavior is currently in a dragging state
  43720. */
  43721. dragging: boolean;
  43722. /**
  43723. * 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)
  43724. */
  43725. dragDeltaRatio: number;
  43726. /**
  43727. * If the drag plane orientation should be updated during the dragging (Default: true)
  43728. */
  43729. updateDragPlane: boolean;
  43730. private _debugMode;
  43731. private _moving;
  43732. /**
  43733. * Fires each time the attached mesh is dragged with the pointer
  43734. * * delta between last drag position and current drag position in world space
  43735. * * dragDistance along the drag axis
  43736. * * dragPlaneNormal normal of the current drag plane used during the drag
  43737. * * dragPlanePoint in world space where the drag intersects the drag plane
  43738. */
  43739. onDragObservable: Observable<{
  43740. delta: Vector3;
  43741. dragPlanePoint: Vector3;
  43742. dragPlaneNormal: Vector3;
  43743. dragDistance: number;
  43744. pointerId: number;
  43745. }>;
  43746. /**
  43747. * Fires each time a drag begins (eg. mouse down on mesh)
  43748. */
  43749. onDragStartObservable: Observable<{
  43750. dragPlanePoint: Vector3;
  43751. pointerId: number;
  43752. }>;
  43753. /**
  43754. * Fires each time a drag ends (eg. mouse release after drag)
  43755. */
  43756. onDragEndObservable: Observable<{
  43757. dragPlanePoint: Vector3;
  43758. pointerId: number;
  43759. }>;
  43760. /**
  43761. * If the attached mesh should be moved when dragged
  43762. */
  43763. moveAttached: boolean;
  43764. /**
  43765. * If the drag behavior will react to drag events (Default: true)
  43766. */
  43767. enabled: boolean;
  43768. /**
  43769. * If pointer events should start and release the drag (Default: true)
  43770. */
  43771. startAndReleaseDragOnPointerEvents: boolean;
  43772. /**
  43773. * If camera controls should be detached during the drag
  43774. */
  43775. detachCameraControls: boolean;
  43776. /**
  43777. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43778. */
  43779. useObjectOrientationForDragging: boolean;
  43780. private _options;
  43781. /**
  43782. * Gets the options used by the behavior
  43783. */
  43784. get options(): {
  43785. dragAxis?: Vector3;
  43786. dragPlaneNormal?: Vector3;
  43787. };
  43788. /**
  43789. * Sets the options used by the behavior
  43790. */
  43791. set options(options: {
  43792. dragAxis?: Vector3;
  43793. dragPlaneNormal?: Vector3;
  43794. });
  43795. /**
  43796. * Creates a pointer drag behavior that can be attached to a mesh
  43797. * @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)
  43798. */
  43799. constructor(options?: {
  43800. dragAxis?: Vector3;
  43801. dragPlaneNormal?: Vector3;
  43802. });
  43803. /**
  43804. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43805. */
  43806. validateDrag: (targetPosition: Vector3) => boolean;
  43807. /**
  43808. * The name of the behavior
  43809. */
  43810. get name(): string;
  43811. /**
  43812. * Initializes the behavior
  43813. */
  43814. init(): void;
  43815. private _tmpVector;
  43816. private _alternatePickedPoint;
  43817. private _worldDragAxis;
  43818. private _targetPosition;
  43819. private _attachedElement;
  43820. /**
  43821. * Attaches the drag behavior the passed in mesh
  43822. * @param ownerNode The mesh that will be dragged around once attached
  43823. * @param predicate Predicate to use for pick filtering
  43824. */
  43825. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43826. /**
  43827. * Force relase the drag action by code.
  43828. */
  43829. releaseDrag(): void;
  43830. private _startDragRay;
  43831. private _lastPointerRay;
  43832. /**
  43833. * Simulates the start of a pointer drag event on the behavior
  43834. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43835. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43836. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43837. */
  43838. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43839. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43840. private _dragDelta;
  43841. protected _moveDrag(ray: Ray): void;
  43842. private _pickWithRayOnDragPlane;
  43843. private _pointA;
  43844. private _pointC;
  43845. private _localAxis;
  43846. private _lookAt;
  43847. private _updateDragPlanePosition;
  43848. /**
  43849. * Detaches the behavior from the mesh
  43850. */
  43851. detach(): void;
  43852. }
  43853. }
  43854. declare module BABYLON {
  43855. /**
  43856. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43857. */
  43858. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43859. private _dragBehaviorA;
  43860. private _dragBehaviorB;
  43861. private _startDistance;
  43862. private _initialScale;
  43863. private _targetScale;
  43864. private _ownerNode;
  43865. private _sceneRenderObserver;
  43866. /**
  43867. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43868. */
  43869. constructor();
  43870. /**
  43871. * The name of the behavior
  43872. */
  43873. get name(): string;
  43874. /**
  43875. * Initializes the behavior
  43876. */
  43877. init(): void;
  43878. private _getCurrentDistance;
  43879. /**
  43880. * Attaches the scale behavior the passed in mesh
  43881. * @param ownerNode The mesh that will be scaled around once attached
  43882. */
  43883. attach(ownerNode: Mesh): void;
  43884. /**
  43885. * Detaches the behavior from the mesh
  43886. */
  43887. detach(): void;
  43888. }
  43889. }
  43890. declare module BABYLON {
  43891. /**
  43892. * 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
  43893. */
  43894. export class SixDofDragBehavior implements Behavior<Mesh> {
  43895. private static _virtualScene;
  43896. private _ownerNode;
  43897. private _sceneRenderObserver;
  43898. private _scene;
  43899. private _targetPosition;
  43900. private _virtualOriginMesh;
  43901. private _virtualDragMesh;
  43902. private _pointerObserver;
  43903. private _moving;
  43904. private _startingOrientation;
  43905. private _attachedElement;
  43906. /**
  43907. * 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)
  43908. */
  43909. private zDragFactor;
  43910. /**
  43911. * If the object should rotate to face the drag origin
  43912. */
  43913. rotateDraggedObject: boolean;
  43914. /**
  43915. * If the behavior is currently in a dragging state
  43916. */
  43917. dragging: boolean;
  43918. /**
  43919. * 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)
  43920. */
  43921. dragDeltaRatio: number;
  43922. /**
  43923. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43924. */
  43925. currentDraggingPointerID: number;
  43926. /**
  43927. * If camera controls should be detached during the drag
  43928. */
  43929. detachCameraControls: boolean;
  43930. /**
  43931. * Fires each time a drag starts
  43932. */
  43933. onDragStartObservable: Observable<{}>;
  43934. /**
  43935. * Fires each time a drag ends (eg. mouse release after drag)
  43936. */
  43937. onDragEndObservable: Observable<{}>;
  43938. /**
  43939. * 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
  43940. */
  43941. constructor();
  43942. /**
  43943. * The name of the behavior
  43944. */
  43945. get name(): string;
  43946. /**
  43947. * Initializes the behavior
  43948. */
  43949. init(): void;
  43950. /**
  43951. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43952. */
  43953. private get _pointerCamera();
  43954. /**
  43955. * Attaches the scale behavior the passed in mesh
  43956. * @param ownerNode The mesh that will be scaled around once attached
  43957. */
  43958. attach(ownerNode: Mesh): void;
  43959. /**
  43960. * Detaches the behavior from the mesh
  43961. */
  43962. detach(): void;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. /**
  43967. * Class used to apply inverse kinematics to bones
  43968. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43969. */
  43970. export class BoneIKController {
  43971. private static _tmpVecs;
  43972. private static _tmpQuat;
  43973. private static _tmpMats;
  43974. /**
  43975. * Gets or sets the target mesh
  43976. */
  43977. targetMesh: AbstractMesh;
  43978. /** Gets or sets the mesh used as pole */
  43979. poleTargetMesh: AbstractMesh;
  43980. /**
  43981. * Gets or sets the bone used as pole
  43982. */
  43983. poleTargetBone: Nullable<Bone>;
  43984. /**
  43985. * Gets or sets the target position
  43986. */
  43987. targetPosition: Vector3;
  43988. /**
  43989. * Gets or sets the pole target position
  43990. */
  43991. poleTargetPosition: Vector3;
  43992. /**
  43993. * Gets or sets the pole target local offset
  43994. */
  43995. poleTargetLocalOffset: Vector3;
  43996. /**
  43997. * Gets or sets the pole angle
  43998. */
  43999. poleAngle: number;
  44000. /**
  44001. * Gets or sets the mesh associated with the controller
  44002. */
  44003. mesh: AbstractMesh;
  44004. /**
  44005. * 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)
  44006. */
  44007. slerpAmount: number;
  44008. private _bone1Quat;
  44009. private _bone1Mat;
  44010. private _bone2Ang;
  44011. private _bone1;
  44012. private _bone2;
  44013. private _bone1Length;
  44014. private _bone2Length;
  44015. private _maxAngle;
  44016. private _maxReach;
  44017. private _rightHandedSystem;
  44018. private _bendAxis;
  44019. private _slerping;
  44020. private _adjustRoll;
  44021. /**
  44022. * Gets or sets maximum allowed angle
  44023. */
  44024. get maxAngle(): number;
  44025. set maxAngle(value: number);
  44026. /**
  44027. * Creates a new BoneIKController
  44028. * @param mesh defines the mesh to control
  44029. * @param bone defines the bone to control
  44030. * @param options defines options to set up the controller
  44031. */
  44032. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44033. targetMesh?: AbstractMesh;
  44034. poleTargetMesh?: AbstractMesh;
  44035. poleTargetBone?: Bone;
  44036. poleTargetLocalOffset?: Vector3;
  44037. poleAngle?: number;
  44038. bendAxis?: Vector3;
  44039. maxAngle?: number;
  44040. slerpAmount?: number;
  44041. });
  44042. private _setMaxAngle;
  44043. /**
  44044. * Force the controller to update the bones
  44045. */
  44046. update(): void;
  44047. }
  44048. }
  44049. declare module BABYLON {
  44050. /**
  44051. * Class used to make a bone look toward a point in space
  44052. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44053. */
  44054. export class BoneLookController {
  44055. private static _tmpVecs;
  44056. private static _tmpQuat;
  44057. private static _tmpMats;
  44058. /**
  44059. * The target Vector3 that the bone will look at
  44060. */
  44061. target: Vector3;
  44062. /**
  44063. * The mesh that the bone is attached to
  44064. */
  44065. mesh: AbstractMesh;
  44066. /**
  44067. * The bone that will be looking to the target
  44068. */
  44069. bone: Bone;
  44070. /**
  44071. * The up axis of the coordinate system that is used when the bone is rotated
  44072. */
  44073. upAxis: Vector3;
  44074. /**
  44075. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44076. */
  44077. upAxisSpace: Space;
  44078. /**
  44079. * Used to make an adjustment to the yaw of the bone
  44080. */
  44081. adjustYaw: number;
  44082. /**
  44083. * Used to make an adjustment to the pitch of the bone
  44084. */
  44085. adjustPitch: number;
  44086. /**
  44087. * Used to make an adjustment to the roll of the bone
  44088. */
  44089. adjustRoll: number;
  44090. /**
  44091. * 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)
  44092. */
  44093. slerpAmount: number;
  44094. private _minYaw;
  44095. private _maxYaw;
  44096. private _minPitch;
  44097. private _maxPitch;
  44098. private _minYawSin;
  44099. private _minYawCos;
  44100. private _maxYawSin;
  44101. private _maxYawCos;
  44102. private _midYawConstraint;
  44103. private _minPitchTan;
  44104. private _maxPitchTan;
  44105. private _boneQuat;
  44106. private _slerping;
  44107. private _transformYawPitch;
  44108. private _transformYawPitchInv;
  44109. private _firstFrameSkipped;
  44110. private _yawRange;
  44111. private _fowardAxis;
  44112. /**
  44113. * Gets or sets the minimum yaw angle that the bone can look to
  44114. */
  44115. get minYaw(): number;
  44116. set minYaw(value: number);
  44117. /**
  44118. * Gets or sets the maximum yaw angle that the bone can look to
  44119. */
  44120. get maxYaw(): number;
  44121. set maxYaw(value: number);
  44122. /**
  44123. * Gets or sets the minimum pitch angle that the bone can look to
  44124. */
  44125. get minPitch(): number;
  44126. set minPitch(value: number);
  44127. /**
  44128. * Gets or sets the maximum pitch angle that the bone can look to
  44129. */
  44130. get maxPitch(): number;
  44131. set maxPitch(value: number);
  44132. /**
  44133. * Create a BoneLookController
  44134. * @param mesh the mesh that the bone belongs to
  44135. * @param bone the bone that will be looking to the target
  44136. * @param target the target Vector3 to look at
  44137. * @param options optional settings:
  44138. * * maxYaw: the maximum angle the bone will yaw to
  44139. * * minYaw: the minimum angle the bone will yaw to
  44140. * * maxPitch: the maximum angle the bone will pitch to
  44141. * * minPitch: the minimum angle the bone will yaw to
  44142. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44143. * * upAxis: the up axis of the coordinate system
  44144. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44145. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44146. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44147. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44148. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44149. * * adjustRoll: used to make an adjustment to the roll of the bone
  44150. **/
  44151. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44152. maxYaw?: number;
  44153. minYaw?: number;
  44154. maxPitch?: number;
  44155. minPitch?: number;
  44156. slerpAmount?: number;
  44157. upAxis?: Vector3;
  44158. upAxisSpace?: Space;
  44159. yawAxis?: Vector3;
  44160. pitchAxis?: Vector3;
  44161. adjustYaw?: number;
  44162. adjustPitch?: number;
  44163. adjustRoll?: number;
  44164. });
  44165. /**
  44166. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44167. */
  44168. update(): void;
  44169. private _getAngleDiff;
  44170. private _getAngleBetween;
  44171. private _isAngleBetween;
  44172. }
  44173. }
  44174. declare module BABYLON {
  44175. /**
  44176. * Manage the gamepad inputs to control an arc rotate camera.
  44177. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44178. */
  44179. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44180. /**
  44181. * Defines the camera the input is attached to.
  44182. */
  44183. camera: ArcRotateCamera;
  44184. /**
  44185. * Defines the gamepad the input is gathering event from.
  44186. */
  44187. gamepad: Nullable<Gamepad>;
  44188. /**
  44189. * Defines the gamepad rotation sensiblity.
  44190. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44191. */
  44192. gamepadRotationSensibility: number;
  44193. /**
  44194. * Defines the gamepad move sensiblity.
  44195. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44196. */
  44197. gamepadMoveSensibility: number;
  44198. private _yAxisScale;
  44199. /**
  44200. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44201. */
  44202. get invertYAxis(): boolean;
  44203. set invertYAxis(value: boolean);
  44204. private _onGamepadConnectedObserver;
  44205. private _onGamepadDisconnectedObserver;
  44206. /**
  44207. * Attach the input controls to a specific dom element to get the input from.
  44208. * @param element Defines the element the controls should be listened from
  44209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44210. */
  44211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44212. /**
  44213. * Detach the current controls from the specified dom element.
  44214. * @param element Defines the element to stop listening the inputs from
  44215. */
  44216. detachControl(element: Nullable<HTMLElement>): void;
  44217. /**
  44218. * Update the current camera state depending on the inputs that have been used this frame.
  44219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44220. */
  44221. checkInputs(): void;
  44222. /**
  44223. * Gets the class name of the current intput.
  44224. * @returns the class name
  44225. */
  44226. getClassName(): string;
  44227. /**
  44228. * Get the friendly name associated with the input class.
  44229. * @returns the input friendly name
  44230. */
  44231. getSimpleName(): string;
  44232. }
  44233. }
  44234. declare module BABYLON {
  44235. interface ArcRotateCameraInputsManager {
  44236. /**
  44237. * Add orientation input support to the input manager.
  44238. * @returns the current input manager
  44239. */
  44240. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44241. }
  44242. /**
  44243. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44245. */
  44246. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44247. /**
  44248. * Defines the camera the input is attached to.
  44249. */
  44250. camera: ArcRotateCamera;
  44251. /**
  44252. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44253. */
  44254. alphaCorrection: number;
  44255. /**
  44256. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44257. */
  44258. gammaCorrection: number;
  44259. private _alpha;
  44260. private _gamma;
  44261. private _dirty;
  44262. private _deviceOrientationHandler;
  44263. /**
  44264. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44265. */
  44266. constructor();
  44267. /**
  44268. * Attach the input controls to a specific dom element to get the input from.
  44269. * @param element Defines the element the controls should be listened from
  44270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44271. */
  44272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44273. /** @hidden */
  44274. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44275. /**
  44276. * Update the current camera state depending on the inputs that have been used this frame.
  44277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44278. */
  44279. checkInputs(): void;
  44280. /**
  44281. * Detach the current controls from the specified dom element.
  44282. * @param element Defines the element to stop listening the inputs from
  44283. */
  44284. detachControl(element: Nullable<HTMLElement>): void;
  44285. /**
  44286. * Gets the class name of the current intput.
  44287. * @returns the class name
  44288. */
  44289. getClassName(): string;
  44290. /**
  44291. * Get the friendly name associated with the input class.
  44292. * @returns the input friendly name
  44293. */
  44294. getSimpleName(): string;
  44295. }
  44296. }
  44297. declare module BABYLON {
  44298. /**
  44299. * Listen to mouse events to control the camera.
  44300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44301. */
  44302. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44303. /**
  44304. * Defines the camera the input is attached to.
  44305. */
  44306. camera: FlyCamera;
  44307. /**
  44308. * Defines if touch is enabled. (Default is true.)
  44309. */
  44310. touchEnabled: boolean;
  44311. /**
  44312. * Defines the buttons associated with the input to handle camera rotation.
  44313. */
  44314. buttons: number[];
  44315. /**
  44316. * Assign buttons for Yaw control.
  44317. */
  44318. buttonsYaw: number[];
  44319. /**
  44320. * Assign buttons for Pitch control.
  44321. */
  44322. buttonsPitch: number[];
  44323. /**
  44324. * Assign buttons for Roll control.
  44325. */
  44326. buttonsRoll: number[];
  44327. /**
  44328. * Detect if any button is being pressed while mouse is moved.
  44329. * -1 = Mouse locked.
  44330. * 0 = Left button.
  44331. * 1 = Middle Button.
  44332. * 2 = Right Button.
  44333. */
  44334. activeButton: number;
  44335. /**
  44336. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44337. * Higher values reduce its sensitivity.
  44338. */
  44339. angularSensibility: number;
  44340. private _observer;
  44341. private _rollObserver;
  44342. private previousPosition;
  44343. private noPreventDefault;
  44344. private element;
  44345. /**
  44346. * Listen to mouse events to control the camera.
  44347. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44349. */
  44350. constructor(touchEnabled?: boolean);
  44351. /**
  44352. * Attach the mouse control to the HTML DOM element.
  44353. * @param element Defines the element that listens to the input events.
  44354. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44355. */
  44356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44357. /**
  44358. * Detach the current controls from the specified dom element.
  44359. * @param element Defines the element to stop listening the inputs from
  44360. */
  44361. detachControl(element: Nullable<HTMLElement>): void;
  44362. /**
  44363. * Gets the class name of the current input.
  44364. * @returns the class name.
  44365. */
  44366. getClassName(): string;
  44367. /**
  44368. * Get the friendly name associated with the input class.
  44369. * @returns the input's friendly name.
  44370. */
  44371. getSimpleName(): string;
  44372. private _pointerInput;
  44373. private _onMouseMove;
  44374. /**
  44375. * Rotate camera by mouse offset.
  44376. */
  44377. private rotateCamera;
  44378. }
  44379. }
  44380. declare module BABYLON {
  44381. /**
  44382. * Default Inputs manager for the FlyCamera.
  44383. * It groups all the default supported inputs for ease of use.
  44384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44385. */
  44386. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44387. /**
  44388. * Instantiates a new FlyCameraInputsManager.
  44389. * @param camera Defines the camera the inputs belong to.
  44390. */
  44391. constructor(camera: FlyCamera);
  44392. /**
  44393. * Add keyboard input support to the input manager.
  44394. * @returns the new FlyCameraKeyboardMoveInput().
  44395. */
  44396. addKeyboard(): FlyCameraInputsManager;
  44397. /**
  44398. * Add mouse input support to the input manager.
  44399. * @param touchEnabled Enable touch screen support.
  44400. * @returns the new FlyCameraMouseInput().
  44401. */
  44402. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44403. }
  44404. }
  44405. declare module BABYLON {
  44406. /**
  44407. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44408. * such as in a 3D Space Shooter or a Flight Simulator.
  44409. */
  44410. export class FlyCamera extends TargetCamera {
  44411. /**
  44412. * Define the collision ellipsoid of the camera.
  44413. * This is helpful for simulating a camera body, like a player's body.
  44414. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44415. */
  44416. ellipsoid: Vector3;
  44417. /**
  44418. * Define an offset for the position of the ellipsoid around the camera.
  44419. * This can be helpful if the camera is attached away from the player's body center,
  44420. * such as at its head.
  44421. */
  44422. ellipsoidOffset: Vector3;
  44423. /**
  44424. * Enable or disable collisions of the camera with the rest of the scene objects.
  44425. */
  44426. checkCollisions: boolean;
  44427. /**
  44428. * Enable or disable gravity on the camera.
  44429. */
  44430. applyGravity: boolean;
  44431. /**
  44432. * Define the current direction the camera is moving to.
  44433. */
  44434. cameraDirection: Vector3;
  44435. /**
  44436. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44437. * This overrides and empties cameraRotation.
  44438. */
  44439. rotationQuaternion: Quaternion;
  44440. /**
  44441. * Track Roll to maintain the wanted Rolling when looking around.
  44442. */
  44443. _trackRoll: number;
  44444. /**
  44445. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44446. */
  44447. rollCorrect: number;
  44448. /**
  44449. * Mimic a banked turn, Rolling the camera when Yawing.
  44450. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44451. */
  44452. bankedTurn: boolean;
  44453. /**
  44454. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44455. */
  44456. bankedTurnLimit: number;
  44457. /**
  44458. * Value of 0 disables the banked Roll.
  44459. * Value of 1 is equal to the Yaw angle in radians.
  44460. */
  44461. bankedTurnMultiplier: number;
  44462. /**
  44463. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44464. */
  44465. inputs: FlyCameraInputsManager;
  44466. /**
  44467. * Gets the input sensibility for mouse input.
  44468. * Higher values reduce sensitivity.
  44469. */
  44470. get angularSensibility(): number;
  44471. /**
  44472. * Sets the input sensibility for a mouse input.
  44473. * Higher values reduce sensitivity.
  44474. */
  44475. set angularSensibility(value: number);
  44476. /**
  44477. * Get the keys for camera movement forward.
  44478. */
  44479. get keysForward(): number[];
  44480. /**
  44481. * Set the keys for camera movement forward.
  44482. */
  44483. set keysForward(value: number[]);
  44484. /**
  44485. * Get the keys for camera movement backward.
  44486. */
  44487. get keysBackward(): number[];
  44488. set keysBackward(value: number[]);
  44489. /**
  44490. * Get the keys for camera movement up.
  44491. */
  44492. get keysUp(): number[];
  44493. /**
  44494. * Set the keys for camera movement up.
  44495. */
  44496. set keysUp(value: number[]);
  44497. /**
  44498. * Get the keys for camera movement down.
  44499. */
  44500. get keysDown(): number[];
  44501. /**
  44502. * Set the keys for camera movement down.
  44503. */
  44504. set keysDown(value: number[]);
  44505. /**
  44506. * Get the keys for camera movement left.
  44507. */
  44508. get keysLeft(): number[];
  44509. /**
  44510. * Set the keys for camera movement left.
  44511. */
  44512. set keysLeft(value: number[]);
  44513. /**
  44514. * Set the keys for camera movement right.
  44515. */
  44516. get keysRight(): number[];
  44517. /**
  44518. * Set the keys for camera movement right.
  44519. */
  44520. set keysRight(value: number[]);
  44521. /**
  44522. * Event raised when the camera collides with a mesh in the scene.
  44523. */
  44524. onCollide: (collidedMesh: AbstractMesh) => void;
  44525. private _collider;
  44526. private _needMoveForGravity;
  44527. private _oldPosition;
  44528. private _diffPosition;
  44529. private _newPosition;
  44530. /** @hidden */
  44531. _localDirection: Vector3;
  44532. /** @hidden */
  44533. _transformedDirection: Vector3;
  44534. /**
  44535. * Instantiates a FlyCamera.
  44536. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44537. * such as in a 3D Space Shooter or a Flight Simulator.
  44538. * @param name Define the name of the camera in the scene.
  44539. * @param position Define the starting position of the camera in the scene.
  44540. * @param scene Define the scene the camera belongs to.
  44541. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44542. */
  44543. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44544. /**
  44545. * Attach a control to the HTML DOM element.
  44546. * @param element Defines the element that listens to the input events.
  44547. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44548. */
  44549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44550. /**
  44551. * Detach a control from the HTML DOM element.
  44552. * The camera will stop reacting to that input.
  44553. * @param element Defines the element that listens to the input events.
  44554. */
  44555. detachControl(element: HTMLElement): void;
  44556. private _collisionMask;
  44557. /**
  44558. * Get the mask that the camera ignores in collision events.
  44559. */
  44560. get collisionMask(): number;
  44561. /**
  44562. * Set the mask that the camera ignores in collision events.
  44563. */
  44564. set collisionMask(mask: number);
  44565. /** @hidden */
  44566. _collideWithWorld(displacement: Vector3): void;
  44567. /** @hidden */
  44568. private _onCollisionPositionChange;
  44569. /** @hidden */
  44570. _checkInputs(): void;
  44571. /** @hidden */
  44572. _decideIfNeedsToMove(): boolean;
  44573. /** @hidden */
  44574. _updatePosition(): void;
  44575. /**
  44576. * Restore the Roll to its target value at the rate specified.
  44577. * @param rate - Higher means slower restoring.
  44578. * @hidden
  44579. */
  44580. restoreRoll(rate: number): void;
  44581. /**
  44582. * Destroy the camera and release the current resources held by it.
  44583. */
  44584. dispose(): void;
  44585. /**
  44586. * Get the current object class name.
  44587. * @returns the class name.
  44588. */
  44589. getClassName(): string;
  44590. }
  44591. }
  44592. declare module BABYLON {
  44593. /**
  44594. * Listen to keyboard events to control the camera.
  44595. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44596. */
  44597. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44598. /**
  44599. * Defines the camera the input is attached to.
  44600. */
  44601. camera: FlyCamera;
  44602. /**
  44603. * The list of keyboard keys used to control the forward move of the camera.
  44604. */
  44605. keysForward: number[];
  44606. /**
  44607. * The list of keyboard keys used to control the backward move of the camera.
  44608. */
  44609. keysBackward: number[];
  44610. /**
  44611. * The list of keyboard keys used to control the forward move of the camera.
  44612. */
  44613. keysUp: number[];
  44614. /**
  44615. * The list of keyboard keys used to control the backward move of the camera.
  44616. */
  44617. keysDown: number[];
  44618. /**
  44619. * The list of keyboard keys used to control the right strafe move of the camera.
  44620. */
  44621. keysRight: number[];
  44622. /**
  44623. * The list of keyboard keys used to control the left strafe move of the camera.
  44624. */
  44625. keysLeft: number[];
  44626. private _keys;
  44627. private _onCanvasBlurObserver;
  44628. private _onKeyboardObserver;
  44629. private _engine;
  44630. private _scene;
  44631. /**
  44632. * Attach the input controls to a specific dom element to get the input from.
  44633. * @param element Defines the element the controls should be listened from
  44634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44635. */
  44636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44637. /**
  44638. * Detach the current controls from the specified dom element.
  44639. * @param element Defines the element to stop listening the inputs from
  44640. */
  44641. detachControl(element: Nullable<HTMLElement>): void;
  44642. /**
  44643. * Gets the class name of the current intput.
  44644. * @returns the class name
  44645. */
  44646. getClassName(): string;
  44647. /** @hidden */
  44648. _onLostFocus(e: FocusEvent): void;
  44649. /**
  44650. * Get the friendly name associated with the input class.
  44651. * @returns the input friendly name
  44652. */
  44653. getSimpleName(): string;
  44654. /**
  44655. * Update the current camera state depending on the inputs that have been used this frame.
  44656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44657. */
  44658. checkInputs(): void;
  44659. }
  44660. }
  44661. declare module BABYLON {
  44662. /**
  44663. * Manage the mouse wheel inputs to control a follow camera.
  44664. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44665. */
  44666. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44667. /**
  44668. * Defines the camera the input is attached to.
  44669. */
  44670. camera: FollowCamera;
  44671. /**
  44672. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44673. */
  44674. axisControlRadius: boolean;
  44675. /**
  44676. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44677. */
  44678. axisControlHeight: boolean;
  44679. /**
  44680. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44681. */
  44682. axisControlRotation: boolean;
  44683. /**
  44684. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44685. * relation to mouseWheel events.
  44686. */
  44687. wheelPrecision: number;
  44688. /**
  44689. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44690. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44691. */
  44692. wheelDeltaPercentage: number;
  44693. private _wheel;
  44694. private _observer;
  44695. /**
  44696. * Attach the input controls to a specific dom element to get the input from.
  44697. * @param element Defines the element the controls should be listened from
  44698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44699. */
  44700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44701. /**
  44702. * Detach the current controls from the specified dom element.
  44703. * @param element Defines the element to stop listening the inputs from
  44704. */
  44705. detachControl(element: Nullable<HTMLElement>): void;
  44706. /**
  44707. * Gets the class name of the current intput.
  44708. * @returns the class name
  44709. */
  44710. getClassName(): string;
  44711. /**
  44712. * Get the friendly name associated with the input class.
  44713. * @returns the input friendly name
  44714. */
  44715. getSimpleName(): string;
  44716. }
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * Manage the pointers inputs to control an follow camera.
  44721. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44722. */
  44723. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44724. /**
  44725. * Defines the camera the input is attached to.
  44726. */
  44727. camera: FollowCamera;
  44728. /**
  44729. * Gets the class name of the current input.
  44730. * @returns the class name
  44731. */
  44732. getClassName(): string;
  44733. /**
  44734. * Defines the pointer angular sensibility along the X axis or how fast is
  44735. * the camera rotating.
  44736. * A negative number will reverse the axis direction.
  44737. */
  44738. angularSensibilityX: number;
  44739. /**
  44740. * Defines the pointer angular sensibility along the Y axis or how fast is
  44741. * the camera rotating.
  44742. * A negative number will reverse the axis direction.
  44743. */
  44744. angularSensibilityY: number;
  44745. /**
  44746. * Defines the pointer pinch precision or how fast is the camera zooming.
  44747. * A negative number will reverse the axis direction.
  44748. */
  44749. pinchPrecision: number;
  44750. /**
  44751. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44752. * from 0.
  44753. * It defines the percentage of current camera.radius to use as delta when
  44754. * pinch zoom is used.
  44755. */
  44756. pinchDeltaPercentage: number;
  44757. /**
  44758. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44759. */
  44760. axisXControlRadius: boolean;
  44761. /**
  44762. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44763. */
  44764. axisXControlHeight: boolean;
  44765. /**
  44766. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44767. */
  44768. axisXControlRotation: boolean;
  44769. /**
  44770. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44771. */
  44772. axisYControlRadius: boolean;
  44773. /**
  44774. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44775. */
  44776. axisYControlHeight: boolean;
  44777. /**
  44778. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44779. */
  44780. axisYControlRotation: boolean;
  44781. /**
  44782. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44783. */
  44784. axisPinchControlRadius: boolean;
  44785. /**
  44786. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44787. */
  44788. axisPinchControlHeight: boolean;
  44789. /**
  44790. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44791. */
  44792. axisPinchControlRotation: boolean;
  44793. /**
  44794. * Log error messages if basic misconfiguration has occurred.
  44795. */
  44796. warningEnable: boolean;
  44797. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44798. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44799. private _warningCounter;
  44800. private _warning;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /**
  44805. * Default Inputs manager for the FollowCamera.
  44806. * It groups all the default supported inputs for ease of use.
  44807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44808. */
  44809. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44810. /**
  44811. * Instantiates a new FollowCameraInputsManager.
  44812. * @param camera Defines the camera the inputs belong to
  44813. */
  44814. constructor(camera: FollowCamera);
  44815. /**
  44816. * Add keyboard input support to the input manager.
  44817. * @returns the current input manager
  44818. */
  44819. addKeyboard(): FollowCameraInputsManager;
  44820. /**
  44821. * Add mouse wheel input support to the input manager.
  44822. * @returns the current input manager
  44823. */
  44824. addMouseWheel(): FollowCameraInputsManager;
  44825. /**
  44826. * Add pointers input support to the input manager.
  44827. * @returns the current input manager
  44828. */
  44829. addPointers(): FollowCameraInputsManager;
  44830. /**
  44831. * Add orientation input support to the input manager.
  44832. * @returns the current input manager
  44833. */
  44834. addVRDeviceOrientation(): FollowCameraInputsManager;
  44835. }
  44836. }
  44837. declare module BABYLON {
  44838. /**
  44839. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44840. * an arc rotate version arcFollowCamera are available.
  44841. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44842. */
  44843. export class FollowCamera extends TargetCamera {
  44844. /**
  44845. * Distance the follow camera should follow an object at
  44846. */
  44847. radius: number;
  44848. /**
  44849. * Minimum allowed distance of the camera to the axis of rotation
  44850. * (The camera can not get closer).
  44851. * This can help limiting how the Camera is able to move in the scene.
  44852. */
  44853. lowerRadiusLimit: Nullable<number>;
  44854. /**
  44855. * Maximum allowed distance of the camera to the axis of rotation
  44856. * (The camera can not get further).
  44857. * This can help limiting how the Camera is able to move in the scene.
  44858. */
  44859. upperRadiusLimit: Nullable<number>;
  44860. /**
  44861. * Define a rotation offset between the camera and the object it follows
  44862. */
  44863. rotationOffset: number;
  44864. /**
  44865. * Minimum allowed angle to camera position relative to target object.
  44866. * This can help limiting how the Camera is able to move in the scene.
  44867. */
  44868. lowerRotationOffsetLimit: Nullable<number>;
  44869. /**
  44870. * Maximum allowed angle to camera position relative to target object.
  44871. * This can help limiting how the Camera is able to move in the scene.
  44872. */
  44873. upperRotationOffsetLimit: Nullable<number>;
  44874. /**
  44875. * Define a height offset between the camera and the object it follows.
  44876. * It can help following an object from the top (like a car chaing a plane)
  44877. */
  44878. heightOffset: number;
  44879. /**
  44880. * Minimum allowed height of camera position relative to target object.
  44881. * This can help limiting how the Camera is able to move in the scene.
  44882. */
  44883. lowerHeightOffsetLimit: Nullable<number>;
  44884. /**
  44885. * Maximum allowed height of camera position relative to target object.
  44886. * This can help limiting how the Camera is able to move in the scene.
  44887. */
  44888. upperHeightOffsetLimit: Nullable<number>;
  44889. /**
  44890. * Define how fast the camera can accelerate to follow it s target.
  44891. */
  44892. cameraAcceleration: number;
  44893. /**
  44894. * Define the speed limit of the camera following an object.
  44895. */
  44896. maxCameraSpeed: number;
  44897. /**
  44898. * Define the target of the camera.
  44899. */
  44900. lockedTarget: Nullable<AbstractMesh>;
  44901. /**
  44902. * Defines the input associated with the camera.
  44903. */
  44904. inputs: FollowCameraInputsManager;
  44905. /**
  44906. * Instantiates the follow camera.
  44907. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44908. * @param name Define the name of the camera in the scene
  44909. * @param position Define the position of the camera
  44910. * @param scene Define the scene the camera belong to
  44911. * @param lockedTarget Define the target of the camera
  44912. */
  44913. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44914. private _follow;
  44915. /**
  44916. * Attached controls to the current camera.
  44917. * @param element Defines the element the controls should be listened from
  44918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44919. */
  44920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44921. /**
  44922. * Detach the current controls from the camera.
  44923. * The camera will stop reacting to inputs.
  44924. * @param element Defines the element to stop listening the inputs from
  44925. */
  44926. detachControl(element: HTMLElement): void;
  44927. /** @hidden */
  44928. _checkInputs(): void;
  44929. private _checkLimits;
  44930. /**
  44931. * Gets the camera class name.
  44932. * @returns the class name
  44933. */
  44934. getClassName(): string;
  44935. }
  44936. /**
  44937. * Arc Rotate version of the follow camera.
  44938. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44939. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44940. */
  44941. export class ArcFollowCamera extends TargetCamera {
  44942. /** The longitudinal angle of the camera */
  44943. alpha: number;
  44944. /** The latitudinal angle of the camera */
  44945. beta: number;
  44946. /** The radius of the camera from its target */
  44947. radius: number;
  44948. private _cartesianCoordinates;
  44949. /** Define the camera target (the mesh it should follow) */
  44950. private _meshTarget;
  44951. /**
  44952. * Instantiates a new ArcFollowCamera
  44953. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44954. * @param name Define the name of the camera
  44955. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44956. * @param beta Define the rotation angle of the camera around the elevation axis
  44957. * @param radius Define the radius of the camera from its target point
  44958. * @param target Define the target of the camera
  44959. * @param scene Define the scene the camera belongs to
  44960. */
  44961. constructor(name: string,
  44962. /** The longitudinal angle of the camera */
  44963. alpha: number,
  44964. /** The latitudinal angle of the camera */
  44965. beta: number,
  44966. /** The radius of the camera from its target */
  44967. radius: number,
  44968. /** Define the camera target (the mesh it should follow) */
  44969. target: Nullable<AbstractMesh>, scene: Scene);
  44970. private _follow;
  44971. /** @hidden */
  44972. _checkInputs(): void;
  44973. /**
  44974. * Returns the class name of the object.
  44975. * It is mostly used internally for serialization purposes.
  44976. */
  44977. getClassName(): string;
  44978. }
  44979. }
  44980. declare module BABYLON {
  44981. /**
  44982. * Manage the keyboard inputs to control the movement of a follow camera.
  44983. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44984. */
  44985. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44986. /**
  44987. * Defines the camera the input is attached to.
  44988. */
  44989. camera: FollowCamera;
  44990. /**
  44991. * Defines the list of key codes associated with the up action (increase heightOffset)
  44992. */
  44993. keysHeightOffsetIncr: number[];
  44994. /**
  44995. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44996. */
  44997. keysHeightOffsetDecr: number[];
  44998. /**
  44999. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45000. */
  45001. keysHeightOffsetModifierAlt: boolean;
  45002. /**
  45003. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45004. */
  45005. keysHeightOffsetModifierCtrl: boolean;
  45006. /**
  45007. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45008. */
  45009. keysHeightOffsetModifierShift: boolean;
  45010. /**
  45011. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45012. */
  45013. keysRotationOffsetIncr: number[];
  45014. /**
  45015. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45016. */
  45017. keysRotationOffsetDecr: number[];
  45018. /**
  45019. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45020. */
  45021. keysRotationOffsetModifierAlt: boolean;
  45022. /**
  45023. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45024. */
  45025. keysRotationOffsetModifierCtrl: boolean;
  45026. /**
  45027. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45028. */
  45029. keysRotationOffsetModifierShift: boolean;
  45030. /**
  45031. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45032. */
  45033. keysRadiusIncr: number[];
  45034. /**
  45035. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45036. */
  45037. keysRadiusDecr: number[];
  45038. /**
  45039. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45040. */
  45041. keysRadiusModifierAlt: boolean;
  45042. /**
  45043. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45044. */
  45045. keysRadiusModifierCtrl: boolean;
  45046. /**
  45047. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45048. */
  45049. keysRadiusModifierShift: boolean;
  45050. /**
  45051. * Defines the rate of change of heightOffset.
  45052. */
  45053. heightSensibility: number;
  45054. /**
  45055. * Defines the rate of change of rotationOffset.
  45056. */
  45057. rotationSensibility: number;
  45058. /**
  45059. * Defines the rate of change of radius.
  45060. */
  45061. radiusSensibility: number;
  45062. private _keys;
  45063. private _ctrlPressed;
  45064. private _altPressed;
  45065. private _shiftPressed;
  45066. private _onCanvasBlurObserver;
  45067. private _onKeyboardObserver;
  45068. private _engine;
  45069. private _scene;
  45070. /**
  45071. * Attach the input controls to a specific dom element to get the input from.
  45072. * @param element Defines the element the controls should be listened from
  45073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45074. */
  45075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45076. /**
  45077. * Detach the current controls from the specified dom element.
  45078. * @param element Defines the element to stop listening the inputs from
  45079. */
  45080. detachControl(element: Nullable<HTMLElement>): void;
  45081. /**
  45082. * Update the current camera state depending on the inputs that have been used this frame.
  45083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45084. */
  45085. checkInputs(): void;
  45086. /**
  45087. * Gets the class name of the current input.
  45088. * @returns the class name
  45089. */
  45090. getClassName(): string;
  45091. /**
  45092. * Get the friendly name associated with the input class.
  45093. * @returns the input friendly name
  45094. */
  45095. getSimpleName(): string;
  45096. /**
  45097. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45098. * allow modification of the heightOffset value.
  45099. */
  45100. private _modifierHeightOffset;
  45101. /**
  45102. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45103. * allow modification of the rotationOffset value.
  45104. */
  45105. private _modifierRotationOffset;
  45106. /**
  45107. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45108. * allow modification of the radius value.
  45109. */
  45110. private _modifierRadius;
  45111. }
  45112. }
  45113. declare module BABYLON {
  45114. interface FreeCameraInputsManager {
  45115. /**
  45116. * @hidden
  45117. */
  45118. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45119. /**
  45120. * Add orientation input support to the input manager.
  45121. * @returns the current input manager
  45122. */
  45123. addDeviceOrientation(): FreeCameraInputsManager;
  45124. }
  45125. /**
  45126. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45127. * Screen rotation is taken into account.
  45128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45129. */
  45130. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45131. private _camera;
  45132. private _screenOrientationAngle;
  45133. private _constantTranform;
  45134. private _screenQuaternion;
  45135. private _alpha;
  45136. private _beta;
  45137. private _gamma;
  45138. /**
  45139. * Can be used to detect if a device orientation sensor is available on a device
  45140. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45141. * @returns a promise that will resolve on orientation change
  45142. */
  45143. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45144. /**
  45145. * @hidden
  45146. */
  45147. _onDeviceOrientationChangedObservable: Observable<void>;
  45148. /**
  45149. * Instantiates a new input
  45150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45151. */
  45152. constructor();
  45153. /**
  45154. * Define the camera controlled by the input.
  45155. */
  45156. get camera(): FreeCamera;
  45157. set camera(camera: FreeCamera);
  45158. /**
  45159. * Attach the input controls to a specific dom element to get the input from.
  45160. * @param element Defines the element the controls should be listened from
  45161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45162. */
  45163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45164. private _orientationChanged;
  45165. private _deviceOrientation;
  45166. /**
  45167. * Detach the current controls from the specified dom element.
  45168. * @param element Defines the element to stop listening the inputs from
  45169. */
  45170. detachControl(element: Nullable<HTMLElement>): void;
  45171. /**
  45172. * Update the current camera state depending on the inputs that have been used this frame.
  45173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45174. */
  45175. checkInputs(): void;
  45176. /**
  45177. * Gets the class name of the current intput.
  45178. * @returns the class name
  45179. */
  45180. getClassName(): string;
  45181. /**
  45182. * Get the friendly name associated with the input class.
  45183. * @returns the input friendly name
  45184. */
  45185. getSimpleName(): string;
  45186. }
  45187. }
  45188. declare module BABYLON {
  45189. /**
  45190. * Manage the gamepad inputs to control a free camera.
  45191. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45192. */
  45193. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45194. /**
  45195. * Define the camera the input is attached to.
  45196. */
  45197. camera: FreeCamera;
  45198. /**
  45199. * Define the Gamepad controlling the input
  45200. */
  45201. gamepad: Nullable<Gamepad>;
  45202. /**
  45203. * Defines the gamepad rotation sensiblity.
  45204. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45205. */
  45206. gamepadAngularSensibility: number;
  45207. /**
  45208. * Defines the gamepad move sensiblity.
  45209. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45210. */
  45211. gamepadMoveSensibility: number;
  45212. private _yAxisScale;
  45213. /**
  45214. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45215. */
  45216. get invertYAxis(): boolean;
  45217. set invertYAxis(value: boolean);
  45218. private _onGamepadConnectedObserver;
  45219. private _onGamepadDisconnectedObserver;
  45220. private _cameraTransform;
  45221. private _deltaTransform;
  45222. private _vector3;
  45223. private _vector2;
  45224. /**
  45225. * Attach the input controls to a specific dom element to get the input from.
  45226. * @param element Defines the element the controls should be listened from
  45227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45228. */
  45229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45230. /**
  45231. * Detach the current controls from the specified dom element.
  45232. * @param element Defines the element to stop listening the inputs from
  45233. */
  45234. detachControl(element: Nullable<HTMLElement>): void;
  45235. /**
  45236. * Update the current camera state depending on the inputs that have been used this frame.
  45237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45238. */
  45239. checkInputs(): void;
  45240. /**
  45241. * Gets the class name of the current intput.
  45242. * @returns the class name
  45243. */
  45244. getClassName(): string;
  45245. /**
  45246. * Get the friendly name associated with the input class.
  45247. * @returns the input friendly name
  45248. */
  45249. getSimpleName(): string;
  45250. }
  45251. }
  45252. declare module BABYLON {
  45253. /**
  45254. * Defines the potential axis of a Joystick
  45255. */
  45256. export enum JoystickAxis {
  45257. /** X axis */
  45258. X = 0,
  45259. /** Y axis */
  45260. Y = 1,
  45261. /** Z axis */
  45262. Z = 2
  45263. }
  45264. /**
  45265. * Represents the different customization options available
  45266. * for VirtualJoystick
  45267. */
  45268. interface VirtualJoystickCustomizations {
  45269. /**
  45270. * Size of the joystick's puck
  45271. */
  45272. puckSize: number;
  45273. /**
  45274. * Size of the joystick's container
  45275. */
  45276. containerSize: number;
  45277. /**
  45278. * Color of the joystick && puck
  45279. */
  45280. color: string;
  45281. /**
  45282. * Image URL for the joystick's puck
  45283. */
  45284. puckImage?: string;
  45285. /**
  45286. * Image URL for the joystick's container
  45287. */
  45288. containerImage?: string;
  45289. /**
  45290. * Defines the unmoving position of the joystick container
  45291. */
  45292. position?: {
  45293. x: number;
  45294. y: number;
  45295. };
  45296. /**
  45297. * Defines whether or not the joystick container is always visible
  45298. */
  45299. alwaysVisible: boolean;
  45300. /**
  45301. * Defines whether or not to limit the movement of the puck to the joystick's container
  45302. */
  45303. limitToContainer: boolean;
  45304. }
  45305. /**
  45306. * Class used to define virtual joystick (used in touch mode)
  45307. */
  45308. export class VirtualJoystick {
  45309. /**
  45310. * Gets or sets a boolean indicating that left and right values must be inverted
  45311. */
  45312. reverseLeftRight: boolean;
  45313. /**
  45314. * Gets or sets a boolean indicating that up and down values must be inverted
  45315. */
  45316. reverseUpDown: boolean;
  45317. /**
  45318. * Gets the offset value for the position (ie. the change of the position value)
  45319. */
  45320. deltaPosition: Vector3;
  45321. /**
  45322. * Gets a boolean indicating if the virtual joystick was pressed
  45323. */
  45324. pressed: boolean;
  45325. /**
  45326. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45327. */
  45328. static Canvas: Nullable<HTMLCanvasElement>;
  45329. /**
  45330. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45331. */
  45332. limitToContainer: boolean;
  45333. private static _globalJoystickIndex;
  45334. private static _alwaysVisibleSticks;
  45335. private static vjCanvasContext;
  45336. private static vjCanvasWidth;
  45337. private static vjCanvasHeight;
  45338. private static halfWidth;
  45339. private static _GetDefaultOptions;
  45340. private _action;
  45341. private _axisTargetedByLeftAndRight;
  45342. private _axisTargetedByUpAndDown;
  45343. private _joystickSensibility;
  45344. private _inversedSensibility;
  45345. private _joystickPointerID;
  45346. private _joystickColor;
  45347. private _joystickPointerPos;
  45348. private _joystickPreviousPointerPos;
  45349. private _joystickPointerStartPos;
  45350. private _deltaJoystickVector;
  45351. private _leftJoystick;
  45352. private _touches;
  45353. private _joystickPosition;
  45354. private _alwaysVisible;
  45355. private _puckImage;
  45356. private _containerImage;
  45357. private _joystickPuckSize;
  45358. private _joystickContainerSize;
  45359. private _clearPuckSize;
  45360. private _clearContainerSize;
  45361. private _clearPuckSizeOffset;
  45362. private _clearContainerSizeOffset;
  45363. private _onPointerDownHandlerRef;
  45364. private _onPointerMoveHandlerRef;
  45365. private _onPointerUpHandlerRef;
  45366. private _onResize;
  45367. /**
  45368. * Creates a new virtual joystick
  45369. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45370. * @param customizations Defines the options we want to customize the VirtualJoystick
  45371. */
  45372. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45373. /**
  45374. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45375. * @param newJoystickSensibility defines the new sensibility
  45376. */
  45377. setJoystickSensibility(newJoystickSensibility: number): void;
  45378. private _onPointerDown;
  45379. private _onPointerMove;
  45380. private _onPointerUp;
  45381. /**
  45382. * Change the color of the virtual joystick
  45383. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45384. */
  45385. setJoystickColor(newColor: string): void;
  45386. /**
  45387. * Size of the joystick's container
  45388. */
  45389. set containerSize(newSize: number);
  45390. get containerSize(): number;
  45391. /**
  45392. * Size of the joystick's puck
  45393. */
  45394. set puckSize(newSize: number);
  45395. get puckSize(): number;
  45396. /**
  45397. * Clears the set position of the joystick
  45398. */
  45399. clearPosition(): void;
  45400. /**
  45401. * Defines whether or not the joystick container is always visible
  45402. */
  45403. set alwaysVisible(value: boolean);
  45404. get alwaysVisible(): boolean;
  45405. /**
  45406. * Sets the constant position of the Joystick container
  45407. * @param x X axis coordinate
  45408. * @param y Y axis coordinate
  45409. */
  45410. setPosition(x: number, y: number): void;
  45411. /**
  45412. * Defines a callback to call when the joystick is touched
  45413. * @param action defines the callback
  45414. */
  45415. setActionOnTouch(action: () => any): void;
  45416. /**
  45417. * Defines which axis you'd like to control for left & right
  45418. * @param axis defines the axis to use
  45419. */
  45420. setAxisForLeftRight(axis: JoystickAxis): void;
  45421. /**
  45422. * Defines which axis you'd like to control for up & down
  45423. * @param axis defines the axis to use
  45424. */
  45425. setAxisForUpDown(axis: JoystickAxis): void;
  45426. /**
  45427. * Clears the canvas from the previous puck / container draw
  45428. */
  45429. private _clearPreviousDraw;
  45430. /**
  45431. * Loads `urlPath` to be used for the container's image
  45432. * @param urlPath defines the urlPath of an image to use
  45433. */
  45434. setContainerImage(urlPath: string): void;
  45435. /**
  45436. * Loads `urlPath` to be used for the puck's image
  45437. * @param urlPath defines the urlPath of an image to use
  45438. */
  45439. setPuckImage(urlPath: string): void;
  45440. /**
  45441. * Draws the Virtual Joystick's container
  45442. */
  45443. private _drawContainer;
  45444. /**
  45445. * Draws the Virtual Joystick's puck
  45446. */
  45447. private _drawPuck;
  45448. private _drawVirtualJoystick;
  45449. /**
  45450. * Release internal HTML canvas
  45451. */
  45452. releaseCanvas(): void;
  45453. }
  45454. }
  45455. declare module BABYLON {
  45456. interface FreeCameraInputsManager {
  45457. /**
  45458. * Add virtual joystick input support to the input manager.
  45459. * @returns the current input manager
  45460. */
  45461. addVirtualJoystick(): FreeCameraInputsManager;
  45462. }
  45463. /**
  45464. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45466. */
  45467. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45468. /**
  45469. * Defines the camera the input is attached to.
  45470. */
  45471. camera: FreeCamera;
  45472. private _leftjoystick;
  45473. private _rightjoystick;
  45474. /**
  45475. * Gets the left stick of the virtual joystick.
  45476. * @returns The virtual Joystick
  45477. */
  45478. getLeftJoystick(): VirtualJoystick;
  45479. /**
  45480. * Gets the right stick of the virtual joystick.
  45481. * @returns The virtual Joystick
  45482. */
  45483. getRightJoystick(): VirtualJoystick;
  45484. /**
  45485. * Update the current camera state depending on the inputs that have been used this frame.
  45486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45487. */
  45488. checkInputs(): void;
  45489. /**
  45490. * Attach the input controls to a specific dom element to get the input from.
  45491. * @param element Defines the element the controls should be listened from
  45492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45493. */
  45494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45495. /**
  45496. * Detach the current controls from the specified dom element.
  45497. * @param element Defines the element to stop listening the inputs from
  45498. */
  45499. detachControl(element: Nullable<HTMLElement>): void;
  45500. /**
  45501. * Gets the class name of the current intput.
  45502. * @returns the class name
  45503. */
  45504. getClassName(): string;
  45505. /**
  45506. * Get the friendly name associated with the input class.
  45507. * @returns the input friendly name
  45508. */
  45509. getSimpleName(): string;
  45510. }
  45511. }
  45512. declare module BABYLON {
  45513. /**
  45514. * This represents a FPS type of camera controlled by touch.
  45515. * This is like a universal camera minus the Gamepad controls.
  45516. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45517. */
  45518. export class TouchCamera extends FreeCamera {
  45519. /**
  45520. * Defines the touch sensibility for rotation.
  45521. * The higher the faster.
  45522. */
  45523. get touchAngularSensibility(): number;
  45524. set touchAngularSensibility(value: number);
  45525. /**
  45526. * Defines the touch sensibility for move.
  45527. * The higher the faster.
  45528. */
  45529. get touchMoveSensibility(): number;
  45530. set touchMoveSensibility(value: number);
  45531. /**
  45532. * Instantiates a new touch camera.
  45533. * This represents a FPS type of camera controlled by touch.
  45534. * This is like a universal camera minus the Gamepad controls.
  45535. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45536. * @param name Define the name of the camera in the scene
  45537. * @param position Define the start position of the camera in the scene
  45538. * @param scene Define the scene the camera belongs to
  45539. */
  45540. constructor(name: string, position: Vector3, scene: Scene);
  45541. /**
  45542. * Gets the current object class name.
  45543. * @return the class name
  45544. */
  45545. getClassName(): string;
  45546. /** @hidden */
  45547. _setupInputs(): void;
  45548. }
  45549. }
  45550. declare module BABYLON {
  45551. /**
  45552. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45553. * being tilted forward or back and left or right.
  45554. */
  45555. export class DeviceOrientationCamera extends FreeCamera {
  45556. private _initialQuaternion;
  45557. private _quaternionCache;
  45558. private _tmpDragQuaternion;
  45559. private _disablePointerInputWhenUsingDeviceOrientation;
  45560. /**
  45561. * Creates a new device orientation camera
  45562. * @param name The name of the camera
  45563. * @param position The start position camera
  45564. * @param scene The scene the camera belongs to
  45565. */
  45566. constructor(name: string, position: Vector3, scene: Scene);
  45567. /**
  45568. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45569. */
  45570. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45571. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45572. private _dragFactor;
  45573. /**
  45574. * Enabled turning on the y axis when the orientation sensor is active
  45575. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45576. */
  45577. enableHorizontalDragging(dragFactor?: number): void;
  45578. /**
  45579. * Gets the current instance class name ("DeviceOrientationCamera").
  45580. * This helps avoiding instanceof at run time.
  45581. * @returns the class name
  45582. */
  45583. getClassName(): string;
  45584. /**
  45585. * @hidden
  45586. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45587. */
  45588. _checkInputs(): void;
  45589. /**
  45590. * Reset the camera to its default orientation on the specified axis only.
  45591. * @param axis The axis to reset
  45592. */
  45593. resetToCurrentRotation(axis?: Axis): void;
  45594. }
  45595. }
  45596. declare module BABYLON {
  45597. /**
  45598. * Defines supported buttons for XBox360 compatible gamepads
  45599. */
  45600. export enum Xbox360Button {
  45601. /** A */
  45602. A = 0,
  45603. /** B */
  45604. B = 1,
  45605. /** X */
  45606. X = 2,
  45607. /** Y */
  45608. Y = 3,
  45609. /** Left button */
  45610. LB = 4,
  45611. /** Right button */
  45612. RB = 5,
  45613. /** Back */
  45614. Back = 8,
  45615. /** Start */
  45616. Start = 9,
  45617. /** Left stick */
  45618. LeftStick = 10,
  45619. /** Right stick */
  45620. RightStick = 11
  45621. }
  45622. /** Defines values for XBox360 DPad */
  45623. export enum Xbox360Dpad {
  45624. /** Up */
  45625. Up = 12,
  45626. /** Down */
  45627. Down = 13,
  45628. /** Left */
  45629. Left = 14,
  45630. /** Right */
  45631. Right = 15
  45632. }
  45633. /**
  45634. * Defines a XBox360 gamepad
  45635. */
  45636. export class Xbox360Pad extends Gamepad {
  45637. private _leftTrigger;
  45638. private _rightTrigger;
  45639. private _onlefttriggerchanged;
  45640. private _onrighttriggerchanged;
  45641. private _onbuttondown;
  45642. private _onbuttonup;
  45643. private _ondpaddown;
  45644. private _ondpadup;
  45645. /** Observable raised when a button is pressed */
  45646. onButtonDownObservable: Observable<Xbox360Button>;
  45647. /** Observable raised when a button is released */
  45648. onButtonUpObservable: Observable<Xbox360Button>;
  45649. /** Observable raised when a pad is pressed */
  45650. onPadDownObservable: Observable<Xbox360Dpad>;
  45651. /** Observable raised when a pad is released */
  45652. onPadUpObservable: Observable<Xbox360Dpad>;
  45653. private _buttonA;
  45654. private _buttonB;
  45655. private _buttonX;
  45656. private _buttonY;
  45657. private _buttonBack;
  45658. private _buttonStart;
  45659. private _buttonLB;
  45660. private _buttonRB;
  45661. private _buttonLeftStick;
  45662. private _buttonRightStick;
  45663. private _dPadUp;
  45664. private _dPadDown;
  45665. private _dPadLeft;
  45666. private _dPadRight;
  45667. private _isXboxOnePad;
  45668. /**
  45669. * Creates a new XBox360 gamepad object
  45670. * @param id defines the id of this gamepad
  45671. * @param index defines its index
  45672. * @param gamepad defines the internal HTML gamepad object
  45673. * @param xboxOne defines if it is a XBox One gamepad
  45674. */
  45675. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45676. /**
  45677. * Defines the callback to call when left trigger is pressed
  45678. * @param callback defines the callback to use
  45679. */
  45680. onlefttriggerchanged(callback: (value: number) => void): void;
  45681. /**
  45682. * Defines the callback to call when right trigger is pressed
  45683. * @param callback defines the callback to use
  45684. */
  45685. onrighttriggerchanged(callback: (value: number) => void): void;
  45686. /**
  45687. * Gets the left trigger value
  45688. */
  45689. get leftTrigger(): number;
  45690. /**
  45691. * Sets the left trigger value
  45692. */
  45693. set leftTrigger(newValue: number);
  45694. /**
  45695. * Gets the right trigger value
  45696. */
  45697. get rightTrigger(): number;
  45698. /**
  45699. * Sets the right trigger value
  45700. */
  45701. set rightTrigger(newValue: number);
  45702. /**
  45703. * Defines the callback to call when a button is pressed
  45704. * @param callback defines the callback to use
  45705. */
  45706. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45707. /**
  45708. * Defines the callback to call when a button is released
  45709. * @param callback defines the callback to use
  45710. */
  45711. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45712. /**
  45713. * Defines the callback to call when a pad is pressed
  45714. * @param callback defines the callback to use
  45715. */
  45716. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45717. /**
  45718. * Defines the callback to call when a pad is released
  45719. * @param callback defines the callback to use
  45720. */
  45721. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45722. private _setButtonValue;
  45723. private _setDPadValue;
  45724. /**
  45725. * Gets the value of the `A` button
  45726. */
  45727. get buttonA(): number;
  45728. /**
  45729. * Sets the value of the `A` button
  45730. */
  45731. set buttonA(value: number);
  45732. /**
  45733. * Gets the value of the `B` button
  45734. */
  45735. get buttonB(): number;
  45736. /**
  45737. * Sets the value of the `B` button
  45738. */
  45739. set buttonB(value: number);
  45740. /**
  45741. * Gets the value of the `X` button
  45742. */
  45743. get buttonX(): number;
  45744. /**
  45745. * Sets the value of the `X` button
  45746. */
  45747. set buttonX(value: number);
  45748. /**
  45749. * Gets the value of the `Y` button
  45750. */
  45751. get buttonY(): number;
  45752. /**
  45753. * Sets the value of the `Y` button
  45754. */
  45755. set buttonY(value: number);
  45756. /**
  45757. * Gets the value of the `Start` button
  45758. */
  45759. get buttonStart(): number;
  45760. /**
  45761. * Sets the value of the `Start` button
  45762. */
  45763. set buttonStart(value: number);
  45764. /**
  45765. * Gets the value of the `Back` button
  45766. */
  45767. get buttonBack(): number;
  45768. /**
  45769. * Sets the value of the `Back` button
  45770. */
  45771. set buttonBack(value: number);
  45772. /**
  45773. * Gets the value of the `Left` button
  45774. */
  45775. get buttonLB(): number;
  45776. /**
  45777. * Sets the value of the `Left` button
  45778. */
  45779. set buttonLB(value: number);
  45780. /**
  45781. * Gets the value of the `Right` button
  45782. */
  45783. get buttonRB(): number;
  45784. /**
  45785. * Sets the value of the `Right` button
  45786. */
  45787. set buttonRB(value: number);
  45788. /**
  45789. * Gets the value of the Left joystick
  45790. */
  45791. get buttonLeftStick(): number;
  45792. /**
  45793. * Sets the value of the Left joystick
  45794. */
  45795. set buttonLeftStick(value: number);
  45796. /**
  45797. * Gets the value of the Right joystick
  45798. */
  45799. get buttonRightStick(): number;
  45800. /**
  45801. * Sets the value of the Right joystick
  45802. */
  45803. set buttonRightStick(value: number);
  45804. /**
  45805. * Gets the value of D-pad up
  45806. */
  45807. get dPadUp(): number;
  45808. /**
  45809. * Sets the value of D-pad up
  45810. */
  45811. set dPadUp(value: number);
  45812. /**
  45813. * Gets the value of D-pad down
  45814. */
  45815. get dPadDown(): number;
  45816. /**
  45817. * Sets the value of D-pad down
  45818. */
  45819. set dPadDown(value: number);
  45820. /**
  45821. * Gets the value of D-pad left
  45822. */
  45823. get dPadLeft(): number;
  45824. /**
  45825. * Sets the value of D-pad left
  45826. */
  45827. set dPadLeft(value: number);
  45828. /**
  45829. * Gets the value of D-pad right
  45830. */
  45831. get dPadRight(): number;
  45832. /**
  45833. * Sets the value of D-pad right
  45834. */
  45835. set dPadRight(value: number);
  45836. /**
  45837. * Force the gamepad to synchronize with device values
  45838. */
  45839. update(): void;
  45840. /**
  45841. * Disposes the gamepad
  45842. */
  45843. dispose(): void;
  45844. }
  45845. }
  45846. declare module BABYLON {
  45847. /**
  45848. * Defines supported buttons for DualShock compatible gamepads
  45849. */
  45850. export enum DualShockButton {
  45851. /** Cross */
  45852. Cross = 0,
  45853. /** Circle */
  45854. Circle = 1,
  45855. /** Square */
  45856. Square = 2,
  45857. /** Triangle */
  45858. Triangle = 3,
  45859. /** L1 */
  45860. L1 = 4,
  45861. /** R1 */
  45862. R1 = 5,
  45863. /** Share */
  45864. Share = 8,
  45865. /** Options */
  45866. Options = 9,
  45867. /** Left stick */
  45868. LeftStick = 10,
  45869. /** Right stick */
  45870. RightStick = 11
  45871. }
  45872. /** Defines values for DualShock DPad */
  45873. export enum DualShockDpad {
  45874. /** Up */
  45875. Up = 12,
  45876. /** Down */
  45877. Down = 13,
  45878. /** Left */
  45879. Left = 14,
  45880. /** Right */
  45881. Right = 15
  45882. }
  45883. /**
  45884. * Defines a DualShock gamepad
  45885. */
  45886. export class DualShockPad extends Gamepad {
  45887. private _leftTrigger;
  45888. private _rightTrigger;
  45889. private _onlefttriggerchanged;
  45890. private _onrighttriggerchanged;
  45891. private _onbuttondown;
  45892. private _onbuttonup;
  45893. private _ondpaddown;
  45894. private _ondpadup;
  45895. /** Observable raised when a button is pressed */
  45896. onButtonDownObservable: Observable<DualShockButton>;
  45897. /** Observable raised when a button is released */
  45898. onButtonUpObservable: Observable<DualShockButton>;
  45899. /** Observable raised when a pad is pressed */
  45900. onPadDownObservable: Observable<DualShockDpad>;
  45901. /** Observable raised when a pad is released */
  45902. onPadUpObservable: Observable<DualShockDpad>;
  45903. private _buttonCross;
  45904. private _buttonCircle;
  45905. private _buttonSquare;
  45906. private _buttonTriangle;
  45907. private _buttonShare;
  45908. private _buttonOptions;
  45909. private _buttonL1;
  45910. private _buttonR1;
  45911. private _buttonLeftStick;
  45912. private _buttonRightStick;
  45913. private _dPadUp;
  45914. private _dPadDown;
  45915. private _dPadLeft;
  45916. private _dPadRight;
  45917. /**
  45918. * Creates a new DualShock gamepad object
  45919. * @param id defines the id of this gamepad
  45920. * @param index defines its index
  45921. * @param gamepad defines the internal HTML gamepad object
  45922. */
  45923. constructor(id: string, index: number, gamepad: any);
  45924. /**
  45925. * Defines the callback to call when left trigger is pressed
  45926. * @param callback defines the callback to use
  45927. */
  45928. onlefttriggerchanged(callback: (value: number) => void): void;
  45929. /**
  45930. * Defines the callback to call when right trigger is pressed
  45931. * @param callback defines the callback to use
  45932. */
  45933. onrighttriggerchanged(callback: (value: number) => void): void;
  45934. /**
  45935. * Gets the left trigger value
  45936. */
  45937. get leftTrigger(): number;
  45938. /**
  45939. * Sets the left trigger value
  45940. */
  45941. set leftTrigger(newValue: number);
  45942. /**
  45943. * Gets the right trigger value
  45944. */
  45945. get rightTrigger(): number;
  45946. /**
  45947. * Sets the right trigger value
  45948. */
  45949. set rightTrigger(newValue: number);
  45950. /**
  45951. * Defines the callback to call when a button is pressed
  45952. * @param callback defines the callback to use
  45953. */
  45954. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45955. /**
  45956. * Defines the callback to call when a button is released
  45957. * @param callback defines the callback to use
  45958. */
  45959. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45960. /**
  45961. * Defines the callback to call when a pad is pressed
  45962. * @param callback defines the callback to use
  45963. */
  45964. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45965. /**
  45966. * Defines the callback to call when a pad is released
  45967. * @param callback defines the callback to use
  45968. */
  45969. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45970. private _setButtonValue;
  45971. private _setDPadValue;
  45972. /**
  45973. * Gets the value of the `Cross` button
  45974. */
  45975. get buttonCross(): number;
  45976. /**
  45977. * Sets the value of the `Cross` button
  45978. */
  45979. set buttonCross(value: number);
  45980. /**
  45981. * Gets the value of the `Circle` button
  45982. */
  45983. get buttonCircle(): number;
  45984. /**
  45985. * Sets the value of the `Circle` button
  45986. */
  45987. set buttonCircle(value: number);
  45988. /**
  45989. * Gets the value of the `Square` button
  45990. */
  45991. get buttonSquare(): number;
  45992. /**
  45993. * Sets the value of the `Square` button
  45994. */
  45995. set buttonSquare(value: number);
  45996. /**
  45997. * Gets the value of the `Triangle` button
  45998. */
  45999. get buttonTriangle(): number;
  46000. /**
  46001. * Sets the value of the `Triangle` button
  46002. */
  46003. set buttonTriangle(value: number);
  46004. /**
  46005. * Gets the value of the `Options` button
  46006. */
  46007. get buttonOptions(): number;
  46008. /**
  46009. * Sets the value of the `Options` button
  46010. */
  46011. set buttonOptions(value: number);
  46012. /**
  46013. * Gets the value of the `Share` button
  46014. */
  46015. get buttonShare(): number;
  46016. /**
  46017. * Sets the value of the `Share` button
  46018. */
  46019. set buttonShare(value: number);
  46020. /**
  46021. * Gets the value of the `L1` button
  46022. */
  46023. get buttonL1(): number;
  46024. /**
  46025. * Sets the value of the `L1` button
  46026. */
  46027. set buttonL1(value: number);
  46028. /**
  46029. * Gets the value of the `R1` button
  46030. */
  46031. get buttonR1(): number;
  46032. /**
  46033. * Sets the value of the `R1` button
  46034. */
  46035. set buttonR1(value: number);
  46036. /**
  46037. * Gets the value of the Left joystick
  46038. */
  46039. get buttonLeftStick(): number;
  46040. /**
  46041. * Sets the value of the Left joystick
  46042. */
  46043. set buttonLeftStick(value: number);
  46044. /**
  46045. * Gets the value of the Right joystick
  46046. */
  46047. get buttonRightStick(): number;
  46048. /**
  46049. * Sets the value of the Right joystick
  46050. */
  46051. set buttonRightStick(value: number);
  46052. /**
  46053. * Gets the value of D-pad up
  46054. */
  46055. get dPadUp(): number;
  46056. /**
  46057. * Sets the value of D-pad up
  46058. */
  46059. set dPadUp(value: number);
  46060. /**
  46061. * Gets the value of D-pad down
  46062. */
  46063. get dPadDown(): number;
  46064. /**
  46065. * Sets the value of D-pad down
  46066. */
  46067. set dPadDown(value: number);
  46068. /**
  46069. * Gets the value of D-pad left
  46070. */
  46071. get dPadLeft(): number;
  46072. /**
  46073. * Sets the value of D-pad left
  46074. */
  46075. set dPadLeft(value: number);
  46076. /**
  46077. * Gets the value of D-pad right
  46078. */
  46079. get dPadRight(): number;
  46080. /**
  46081. * Sets the value of D-pad right
  46082. */
  46083. set dPadRight(value: number);
  46084. /**
  46085. * Force the gamepad to synchronize with device values
  46086. */
  46087. update(): void;
  46088. /**
  46089. * Disposes the gamepad
  46090. */
  46091. dispose(): void;
  46092. }
  46093. }
  46094. declare module BABYLON {
  46095. /**
  46096. * Manager for handling gamepads
  46097. */
  46098. export class GamepadManager {
  46099. private _scene?;
  46100. private _babylonGamepads;
  46101. private _oneGamepadConnected;
  46102. /** @hidden */
  46103. _isMonitoring: boolean;
  46104. private _gamepadEventSupported;
  46105. private _gamepadSupport?;
  46106. /**
  46107. * observable to be triggered when the gamepad controller has been connected
  46108. */
  46109. onGamepadConnectedObservable: Observable<Gamepad>;
  46110. /**
  46111. * observable to be triggered when the gamepad controller has been disconnected
  46112. */
  46113. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46114. private _onGamepadConnectedEvent;
  46115. private _onGamepadDisconnectedEvent;
  46116. /**
  46117. * Initializes the gamepad manager
  46118. * @param _scene BabylonJS scene
  46119. */
  46120. constructor(_scene?: Scene | undefined);
  46121. /**
  46122. * The gamepads in the game pad manager
  46123. */
  46124. get gamepads(): Gamepad[];
  46125. /**
  46126. * Get the gamepad controllers based on type
  46127. * @param type The type of gamepad controller
  46128. * @returns Nullable gamepad
  46129. */
  46130. getGamepadByType(type?: number): Nullable<Gamepad>;
  46131. /**
  46132. * Disposes the gamepad manager
  46133. */
  46134. dispose(): void;
  46135. private _addNewGamepad;
  46136. private _startMonitoringGamepads;
  46137. private _stopMonitoringGamepads;
  46138. /** @hidden */
  46139. _checkGamepadsStatus(): void;
  46140. private _updateGamepadObjects;
  46141. }
  46142. }
  46143. declare module BABYLON {
  46144. interface Scene {
  46145. /** @hidden */
  46146. _gamepadManager: Nullable<GamepadManager>;
  46147. /**
  46148. * Gets the gamepad manager associated with the scene
  46149. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46150. */
  46151. gamepadManager: GamepadManager;
  46152. }
  46153. /**
  46154. * Interface representing a free camera inputs manager
  46155. */
  46156. interface FreeCameraInputsManager {
  46157. /**
  46158. * Adds gamepad input support to the FreeCameraInputsManager.
  46159. * @returns the FreeCameraInputsManager
  46160. */
  46161. addGamepad(): FreeCameraInputsManager;
  46162. }
  46163. /**
  46164. * Interface representing an arc rotate camera inputs manager
  46165. */
  46166. interface ArcRotateCameraInputsManager {
  46167. /**
  46168. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46169. * @returns the camera inputs manager
  46170. */
  46171. addGamepad(): ArcRotateCameraInputsManager;
  46172. }
  46173. /**
  46174. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46175. */
  46176. export class GamepadSystemSceneComponent implements ISceneComponent {
  46177. /**
  46178. * The component name helpfull to identify the component in the list of scene components.
  46179. */
  46180. readonly name: string;
  46181. /**
  46182. * The scene the component belongs to.
  46183. */
  46184. scene: Scene;
  46185. /**
  46186. * Creates a new instance of the component for the given scene
  46187. * @param scene Defines the scene to register the component in
  46188. */
  46189. constructor(scene: Scene);
  46190. /**
  46191. * Registers the component in a given scene
  46192. */
  46193. register(): void;
  46194. /**
  46195. * Rebuilds the elements related to this component in case of
  46196. * context lost for instance.
  46197. */
  46198. rebuild(): void;
  46199. /**
  46200. * Disposes the component and the associated ressources
  46201. */
  46202. dispose(): void;
  46203. private _beforeCameraUpdate;
  46204. }
  46205. }
  46206. declare module BABYLON {
  46207. /**
  46208. * 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,
  46209. * which still works and will still be found in many Playgrounds.
  46210. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46211. */
  46212. export class UniversalCamera extends TouchCamera {
  46213. /**
  46214. * Defines the gamepad rotation sensiblity.
  46215. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46216. */
  46217. get gamepadAngularSensibility(): number;
  46218. set gamepadAngularSensibility(value: number);
  46219. /**
  46220. * Defines the gamepad move sensiblity.
  46221. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46222. */
  46223. get gamepadMoveSensibility(): number;
  46224. set gamepadMoveSensibility(value: number);
  46225. /**
  46226. * 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,
  46227. * which still works and will still be found in many Playgrounds.
  46228. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46229. * @param name Define the name of the camera in the scene
  46230. * @param position Define the start position of the camera in the scene
  46231. * @param scene Define the scene the camera belongs to
  46232. */
  46233. constructor(name: string, position: Vector3, scene: Scene);
  46234. /**
  46235. * Gets the current object class name.
  46236. * @return the class name
  46237. */
  46238. getClassName(): string;
  46239. }
  46240. }
  46241. declare module BABYLON {
  46242. /**
  46243. * This represents a FPS type of camera. This is only here for back compat purpose.
  46244. * Please use the UniversalCamera instead as both are identical.
  46245. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46246. */
  46247. export class GamepadCamera extends UniversalCamera {
  46248. /**
  46249. * Instantiates a new Gamepad Camera
  46250. * This represents a FPS type of camera. This is only here for back compat purpose.
  46251. * Please use the UniversalCamera instead as both are identical.
  46252. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46253. * @param name Define the name of the camera in the scene
  46254. * @param position Define the start position of the camera in the scene
  46255. * @param scene Define the scene the camera belongs to
  46256. */
  46257. constructor(name: string, position: Vector3, scene: Scene);
  46258. /**
  46259. * Gets the current object class name.
  46260. * @return the class name
  46261. */
  46262. getClassName(): string;
  46263. }
  46264. }
  46265. declare module BABYLON {
  46266. /** @hidden */
  46267. export var passPixelShader: {
  46268. name: string;
  46269. shader: string;
  46270. };
  46271. }
  46272. declare module BABYLON {
  46273. /** @hidden */
  46274. export var passCubePixelShader: {
  46275. name: string;
  46276. shader: string;
  46277. };
  46278. }
  46279. declare module BABYLON {
  46280. /**
  46281. * PassPostProcess which produces an output the same as it's input
  46282. */
  46283. export class PassPostProcess extends PostProcess {
  46284. /**
  46285. * Gets a string identifying the name of the class
  46286. * @returns "PassPostProcess" string
  46287. */
  46288. getClassName(): string;
  46289. /**
  46290. * Creates the PassPostProcess
  46291. * @param name The name of the effect.
  46292. * @param options The required width/height ratio to downsize to before computing the render pass.
  46293. * @param camera The camera to apply the render pass to.
  46294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46295. * @param engine The engine which the post process will be applied. (default: current engine)
  46296. * @param reusable If the post process can be reused on the same frame. (default: false)
  46297. * @param textureType The type of texture to be used when performing the post processing.
  46298. * @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)
  46299. */
  46300. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46301. /** @hidden */
  46302. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46303. }
  46304. /**
  46305. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46306. */
  46307. export class PassCubePostProcess extends PostProcess {
  46308. private _face;
  46309. /**
  46310. * Gets or sets the cube face to display.
  46311. * * 0 is +X
  46312. * * 1 is -X
  46313. * * 2 is +Y
  46314. * * 3 is -Y
  46315. * * 4 is +Z
  46316. * * 5 is -Z
  46317. */
  46318. get face(): number;
  46319. set face(value: number);
  46320. /**
  46321. * Gets a string identifying the name of the class
  46322. * @returns "PassCubePostProcess" string
  46323. */
  46324. getClassName(): string;
  46325. /**
  46326. * Creates the PassCubePostProcess
  46327. * @param name The name of the effect.
  46328. * @param options The required width/height ratio to downsize to before computing the render pass.
  46329. * @param camera The camera to apply the render pass to.
  46330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46331. * @param engine The engine which the post process will be applied. (default: current engine)
  46332. * @param reusable If the post process can be reused on the same frame. (default: false)
  46333. * @param textureType The type of texture to be used when performing the post processing.
  46334. * @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)
  46335. */
  46336. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46337. /** @hidden */
  46338. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46339. }
  46340. }
  46341. declare module BABYLON {
  46342. /** @hidden */
  46343. export var anaglyphPixelShader: {
  46344. name: string;
  46345. shader: string;
  46346. };
  46347. }
  46348. declare module BABYLON {
  46349. /**
  46350. * Postprocess used to generate anaglyphic rendering
  46351. */
  46352. export class AnaglyphPostProcess extends PostProcess {
  46353. private _passedProcess;
  46354. /**
  46355. * Gets a string identifying the name of the class
  46356. * @returns "AnaglyphPostProcess" string
  46357. */
  46358. getClassName(): string;
  46359. /**
  46360. * Creates a new AnaglyphPostProcess
  46361. * @param name defines postprocess name
  46362. * @param options defines creation options or target ratio scale
  46363. * @param rigCameras defines cameras using this postprocess
  46364. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46365. * @param engine defines hosting engine
  46366. * @param reusable defines if the postprocess will be reused multiple times per frame
  46367. */
  46368. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46369. }
  46370. }
  46371. declare module BABYLON {
  46372. /**
  46373. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46374. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46375. */
  46376. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46377. /**
  46378. * Creates a new AnaglyphArcRotateCamera
  46379. * @param name defines camera name
  46380. * @param alpha defines alpha angle (in radians)
  46381. * @param beta defines beta angle (in radians)
  46382. * @param radius defines radius
  46383. * @param target defines camera target
  46384. * @param interaxialDistance defines distance between each color axis
  46385. * @param scene defines the hosting scene
  46386. */
  46387. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46388. /**
  46389. * Gets camera class name
  46390. * @returns AnaglyphArcRotateCamera
  46391. */
  46392. getClassName(): string;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /**
  46397. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46398. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46399. */
  46400. export class AnaglyphFreeCamera extends FreeCamera {
  46401. /**
  46402. * Creates a new AnaglyphFreeCamera
  46403. * @param name defines camera name
  46404. * @param position defines initial position
  46405. * @param interaxialDistance defines distance between each color axis
  46406. * @param scene defines the hosting scene
  46407. */
  46408. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46409. /**
  46410. * Gets camera class name
  46411. * @returns AnaglyphFreeCamera
  46412. */
  46413. getClassName(): string;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46419. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46420. */
  46421. export class AnaglyphGamepadCamera extends GamepadCamera {
  46422. /**
  46423. * Creates a new AnaglyphGamepadCamera
  46424. * @param name defines camera name
  46425. * @param position defines initial position
  46426. * @param interaxialDistance defines distance between each color axis
  46427. * @param scene defines the hosting scene
  46428. */
  46429. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46430. /**
  46431. * Gets camera class name
  46432. * @returns AnaglyphGamepadCamera
  46433. */
  46434. getClassName(): string;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46440. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46441. */
  46442. export class AnaglyphUniversalCamera extends UniversalCamera {
  46443. /**
  46444. * Creates a new AnaglyphUniversalCamera
  46445. * @param name defines camera name
  46446. * @param position defines initial position
  46447. * @param interaxialDistance defines distance between each color axis
  46448. * @param scene defines the hosting scene
  46449. */
  46450. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46451. /**
  46452. * Gets camera class name
  46453. * @returns AnaglyphUniversalCamera
  46454. */
  46455. getClassName(): string;
  46456. }
  46457. }
  46458. declare module BABYLON {
  46459. /**
  46460. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46461. * @see https://doc.babylonjs.com/features/cameras
  46462. */
  46463. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46464. /**
  46465. * Creates a new StereoscopicArcRotateCamera
  46466. * @param name defines camera name
  46467. * @param alpha defines alpha angle (in radians)
  46468. * @param beta defines beta angle (in radians)
  46469. * @param radius defines radius
  46470. * @param target defines camera target
  46471. * @param interaxialDistance defines distance between each color axis
  46472. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46473. * @param scene defines the hosting scene
  46474. */
  46475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46476. /**
  46477. * Gets camera class name
  46478. * @returns StereoscopicArcRotateCamera
  46479. */
  46480. getClassName(): string;
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46486. * @see https://doc.babylonjs.com/features/cameras
  46487. */
  46488. export class StereoscopicFreeCamera extends FreeCamera {
  46489. /**
  46490. * Creates a new StereoscopicFreeCamera
  46491. * @param name defines camera name
  46492. * @param position defines initial position
  46493. * @param interaxialDistance defines distance between each color axis
  46494. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46495. * @param scene defines the hosting scene
  46496. */
  46497. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46498. /**
  46499. * Gets camera class name
  46500. * @returns StereoscopicFreeCamera
  46501. */
  46502. getClassName(): string;
  46503. }
  46504. }
  46505. declare module BABYLON {
  46506. /**
  46507. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46508. * @see https://doc.babylonjs.com/features/cameras
  46509. */
  46510. export class StereoscopicGamepadCamera extends GamepadCamera {
  46511. /**
  46512. * Creates a new StereoscopicGamepadCamera
  46513. * @param name defines camera name
  46514. * @param position defines initial position
  46515. * @param interaxialDistance defines distance between each color axis
  46516. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46517. * @param scene defines the hosting scene
  46518. */
  46519. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46520. /**
  46521. * Gets camera class name
  46522. * @returns StereoscopicGamepadCamera
  46523. */
  46524. getClassName(): string;
  46525. }
  46526. }
  46527. declare module BABYLON {
  46528. /**
  46529. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46530. * @see https://doc.babylonjs.com/features/cameras
  46531. */
  46532. export class StereoscopicUniversalCamera extends UniversalCamera {
  46533. /**
  46534. * Creates a new StereoscopicUniversalCamera
  46535. * @param name defines camera name
  46536. * @param position defines initial position
  46537. * @param interaxialDistance defines distance between each color axis
  46538. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46539. * @param scene defines the hosting scene
  46540. */
  46541. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46542. /**
  46543. * Gets camera class name
  46544. * @returns StereoscopicUniversalCamera
  46545. */
  46546. getClassName(): string;
  46547. }
  46548. }
  46549. declare module BABYLON {
  46550. /**
  46551. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46552. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46553. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46554. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46555. */
  46556. export class VirtualJoysticksCamera extends FreeCamera {
  46557. /**
  46558. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46559. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46560. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46561. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46562. * @param name Define the name of the camera in the scene
  46563. * @param position Define the start position of the camera in the scene
  46564. * @param scene Define the scene the camera belongs to
  46565. */
  46566. constructor(name: string, position: Vector3, scene: Scene);
  46567. /**
  46568. * Gets the current object class name.
  46569. * @return the class name
  46570. */
  46571. getClassName(): string;
  46572. }
  46573. }
  46574. declare module BABYLON {
  46575. /**
  46576. * This represents all the required metrics to create a VR camera.
  46577. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46578. */
  46579. export class VRCameraMetrics {
  46580. /**
  46581. * Define the horizontal resolution off the screen.
  46582. */
  46583. hResolution: number;
  46584. /**
  46585. * Define the vertical resolution off the screen.
  46586. */
  46587. vResolution: number;
  46588. /**
  46589. * Define the horizontal screen size.
  46590. */
  46591. hScreenSize: number;
  46592. /**
  46593. * Define the vertical screen size.
  46594. */
  46595. vScreenSize: number;
  46596. /**
  46597. * Define the vertical screen center position.
  46598. */
  46599. vScreenCenter: number;
  46600. /**
  46601. * Define the distance of the eyes to the screen.
  46602. */
  46603. eyeToScreenDistance: number;
  46604. /**
  46605. * Define the distance between both lenses
  46606. */
  46607. lensSeparationDistance: number;
  46608. /**
  46609. * Define the distance between both viewer's eyes.
  46610. */
  46611. interpupillaryDistance: number;
  46612. /**
  46613. * Define the distortion factor of the VR postprocess.
  46614. * Please, touch with care.
  46615. */
  46616. distortionK: number[];
  46617. /**
  46618. * Define the chromatic aberration correction factors for the VR post process.
  46619. */
  46620. chromaAbCorrection: number[];
  46621. /**
  46622. * Define the scale factor of the post process.
  46623. * The smaller the better but the slower.
  46624. */
  46625. postProcessScaleFactor: number;
  46626. /**
  46627. * Define an offset for the lens center.
  46628. */
  46629. lensCenterOffset: number;
  46630. /**
  46631. * Define if the current vr camera should compensate the distortion of the lense or not.
  46632. */
  46633. compensateDistortion: boolean;
  46634. /**
  46635. * Defines if multiview should be enabled when rendering (Default: false)
  46636. */
  46637. multiviewEnabled: boolean;
  46638. /**
  46639. * Gets the rendering aspect ratio based on the provided resolutions.
  46640. */
  46641. get aspectRatio(): number;
  46642. /**
  46643. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46644. */
  46645. get aspectRatioFov(): number;
  46646. /**
  46647. * @hidden
  46648. */
  46649. get leftHMatrix(): Matrix;
  46650. /**
  46651. * @hidden
  46652. */
  46653. get rightHMatrix(): Matrix;
  46654. /**
  46655. * @hidden
  46656. */
  46657. get leftPreViewMatrix(): Matrix;
  46658. /**
  46659. * @hidden
  46660. */
  46661. get rightPreViewMatrix(): Matrix;
  46662. /**
  46663. * Get the default VRMetrics based on the most generic setup.
  46664. * @returns the default vr metrics
  46665. */
  46666. static GetDefault(): VRCameraMetrics;
  46667. }
  46668. }
  46669. declare module BABYLON {
  46670. /** @hidden */
  46671. export var vrDistortionCorrectionPixelShader: {
  46672. name: string;
  46673. shader: string;
  46674. };
  46675. }
  46676. declare module BABYLON {
  46677. /**
  46678. * VRDistortionCorrectionPostProcess used for mobile VR
  46679. */
  46680. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46681. private _isRightEye;
  46682. private _distortionFactors;
  46683. private _postProcessScaleFactor;
  46684. private _lensCenterOffset;
  46685. private _scaleIn;
  46686. private _scaleFactor;
  46687. private _lensCenter;
  46688. /**
  46689. * Gets a string identifying the name of the class
  46690. * @returns "VRDistortionCorrectionPostProcess" string
  46691. */
  46692. getClassName(): string;
  46693. /**
  46694. * Initializes the VRDistortionCorrectionPostProcess
  46695. * @param name The name of the effect.
  46696. * @param camera The camera to apply the render pass to.
  46697. * @param isRightEye If this is for the right eye distortion
  46698. * @param vrMetrics All the required metrics for the VR camera
  46699. */
  46700. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46701. }
  46702. }
  46703. declare module BABYLON {
  46704. /**
  46705. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46706. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46707. */
  46708. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46709. /**
  46710. * Creates a new VRDeviceOrientationArcRotateCamera
  46711. * @param name defines camera name
  46712. * @param alpha defines the camera rotation along the logitudinal axis
  46713. * @param beta defines the camera rotation along the latitudinal axis
  46714. * @param radius defines the camera distance from its target
  46715. * @param target defines the camera target
  46716. * @param scene defines the scene the camera belongs to
  46717. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46718. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46719. */
  46720. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46721. /**
  46722. * Gets camera class name
  46723. * @returns VRDeviceOrientationArcRotateCamera
  46724. */
  46725. getClassName(): string;
  46726. }
  46727. }
  46728. declare module BABYLON {
  46729. /**
  46730. * Camera used to simulate VR rendering (based on FreeCamera)
  46731. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46732. */
  46733. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46734. /**
  46735. * Creates a new VRDeviceOrientationFreeCamera
  46736. * @param name defines camera name
  46737. * @param position defines the start position of the camera
  46738. * @param scene defines the scene the camera belongs to
  46739. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46740. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46741. */
  46742. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46743. /**
  46744. * Gets camera class name
  46745. * @returns VRDeviceOrientationFreeCamera
  46746. */
  46747. getClassName(): string;
  46748. }
  46749. }
  46750. declare module BABYLON {
  46751. /**
  46752. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46753. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46754. */
  46755. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46756. /**
  46757. * Creates a new VRDeviceOrientationGamepadCamera
  46758. * @param name defines camera name
  46759. * @param position defines the start position of the camera
  46760. * @param scene defines the scene the camera belongs to
  46761. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46762. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46763. */
  46764. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46765. /**
  46766. * Gets camera class name
  46767. * @returns VRDeviceOrientationGamepadCamera
  46768. */
  46769. getClassName(): string;
  46770. }
  46771. }
  46772. declare module BABYLON {
  46773. /**
  46774. * A class extending Texture allowing drawing on a texture
  46775. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46776. */
  46777. export class DynamicTexture extends Texture {
  46778. private _generateMipMaps;
  46779. private _canvas;
  46780. private _context;
  46781. /**
  46782. * Creates a DynamicTexture
  46783. * @param name defines the name of the texture
  46784. * @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
  46785. * @param scene defines the scene where you want the texture
  46786. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46787. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46788. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46789. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  46790. */
  46791. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  46792. /**
  46793. * Get the current class name of the texture useful for serialization or dynamic coding.
  46794. * @returns "DynamicTexture"
  46795. */
  46796. getClassName(): string;
  46797. /**
  46798. * Gets the current state of canRescale
  46799. */
  46800. get canRescale(): boolean;
  46801. private _recreate;
  46802. /**
  46803. * Scales the texture
  46804. * @param ratio the scale factor to apply to both width and height
  46805. */
  46806. scale(ratio: number): void;
  46807. /**
  46808. * Resizes the texture
  46809. * @param width the new width
  46810. * @param height the new height
  46811. */
  46812. scaleTo(width: number, height: number): void;
  46813. /**
  46814. * Gets the context of the canvas used by the texture
  46815. * @returns the canvas context of the dynamic texture
  46816. */
  46817. getContext(): CanvasRenderingContext2D;
  46818. /**
  46819. * Clears the texture
  46820. */
  46821. clear(): void;
  46822. /**
  46823. * Updates the texture
  46824. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46825. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46826. */
  46827. update(invertY?: boolean, premulAlpha?: boolean): void;
  46828. /**
  46829. * Draws text onto the texture
  46830. * @param text defines the text to be drawn
  46831. * @param x defines the placement of the text from the left
  46832. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46833. * @param font defines the font to be used with font-style, font-size, font-name
  46834. * @param color defines the color used for the text
  46835. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46836. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46837. * @param update defines whether texture is immediately update (default is true)
  46838. */
  46839. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46840. /**
  46841. * Clones the texture
  46842. * @returns the clone of the texture.
  46843. */
  46844. clone(): DynamicTexture;
  46845. /**
  46846. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46847. * @returns a serialized dynamic texture object
  46848. */
  46849. serialize(): any;
  46850. private _IsCanvasElement;
  46851. /** @hidden */
  46852. _rebuild(): void;
  46853. }
  46854. }
  46855. declare module BABYLON {
  46856. /**
  46857. * Class containing static functions to help procedurally build meshes
  46858. */
  46859. export class GroundBuilder {
  46860. /**
  46861. * Creates a ground mesh
  46862. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46863. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46865. * @param name defines the name of the mesh
  46866. * @param options defines the options used to create the mesh
  46867. * @param scene defines the hosting scene
  46868. * @returns the ground mesh
  46869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46870. */
  46871. static CreateGround(name: string, options: {
  46872. width?: number;
  46873. height?: number;
  46874. subdivisions?: number;
  46875. subdivisionsX?: number;
  46876. subdivisionsY?: number;
  46877. updatable?: boolean;
  46878. }, scene: any): Mesh;
  46879. /**
  46880. * Creates a tiled ground mesh
  46881. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46882. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46883. * * 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
  46884. * * 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
  46885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46886. * @param name defines the name of the mesh
  46887. * @param options defines the options used to create the mesh
  46888. * @param scene defines the hosting scene
  46889. * @returns the tiled ground mesh
  46890. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46891. */
  46892. static CreateTiledGround(name: string, options: {
  46893. xmin: number;
  46894. zmin: number;
  46895. xmax: number;
  46896. zmax: number;
  46897. subdivisions?: {
  46898. w: number;
  46899. h: number;
  46900. };
  46901. precision?: {
  46902. w: number;
  46903. h: number;
  46904. };
  46905. updatable?: boolean;
  46906. }, scene?: Nullable<Scene>): Mesh;
  46907. /**
  46908. * Creates a ground mesh from a height map
  46909. * * The parameter `url` sets the URL of the height map image resource.
  46910. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46911. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46912. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46913. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46914. * * 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.
  46915. * * 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).
  46916. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46918. * @param name defines the name of the mesh
  46919. * @param url defines the url to the height map
  46920. * @param options defines the options used to create the mesh
  46921. * @param scene defines the hosting scene
  46922. * @returns the ground mesh
  46923. * @see https://doc.babylonjs.com/babylon101/height_map
  46924. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46925. */
  46926. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46927. width?: number;
  46928. height?: number;
  46929. subdivisions?: number;
  46930. minHeight?: number;
  46931. maxHeight?: number;
  46932. colorFilter?: Color3;
  46933. alphaFilter?: number;
  46934. updatable?: boolean;
  46935. onReady?: (mesh: GroundMesh) => void;
  46936. }, scene?: Nullable<Scene>): GroundMesh;
  46937. }
  46938. }
  46939. declare module BABYLON {
  46940. /**
  46941. * Class containing static functions to help procedurally build meshes
  46942. */
  46943. export class TorusBuilder {
  46944. /**
  46945. * Creates a torus mesh
  46946. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46947. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46948. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46950. * * 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
  46951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46952. * @param name defines the name of the mesh
  46953. * @param options defines the options used to create the mesh
  46954. * @param scene defines the hosting scene
  46955. * @returns the torus mesh
  46956. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46957. */
  46958. static CreateTorus(name: string, options: {
  46959. diameter?: number;
  46960. thickness?: number;
  46961. tessellation?: number;
  46962. updatable?: boolean;
  46963. sideOrientation?: number;
  46964. frontUVs?: Vector4;
  46965. backUVs?: Vector4;
  46966. }, scene: any): Mesh;
  46967. }
  46968. }
  46969. declare module BABYLON {
  46970. /**
  46971. * Class containing static functions to help procedurally build meshes
  46972. */
  46973. export class CylinderBuilder {
  46974. /**
  46975. * Creates a cylinder or a cone mesh
  46976. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46977. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46978. * * 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.
  46979. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46980. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46981. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46982. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46983. * * 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).
  46984. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46985. * * 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).
  46986. * * 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
  46987. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46988. * * 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
  46989. * * 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.
  46990. * * If `enclose` is false, a ring surface is one element.
  46991. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46992. * * 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
  46993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46994. * * 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
  46995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46996. * @param name defines the name of the mesh
  46997. * @param options defines the options used to create the mesh
  46998. * @param scene defines the hosting scene
  46999. * @returns the cylinder mesh
  47000. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47001. */
  47002. static CreateCylinder(name: string, options: {
  47003. height?: number;
  47004. diameterTop?: number;
  47005. diameterBottom?: number;
  47006. diameter?: number;
  47007. tessellation?: number;
  47008. subdivisions?: number;
  47009. arc?: number;
  47010. faceColors?: Color4[];
  47011. faceUV?: Vector4[];
  47012. updatable?: boolean;
  47013. hasRings?: boolean;
  47014. enclose?: boolean;
  47015. cap?: number;
  47016. sideOrientation?: number;
  47017. frontUVs?: Vector4;
  47018. backUVs?: Vector4;
  47019. }, scene: any): Mesh;
  47020. }
  47021. }
  47022. declare module BABYLON {
  47023. /**
  47024. * States of the webXR experience
  47025. */
  47026. export enum WebXRState {
  47027. /**
  47028. * Transitioning to being in XR mode
  47029. */
  47030. ENTERING_XR = 0,
  47031. /**
  47032. * Transitioning to non XR mode
  47033. */
  47034. EXITING_XR = 1,
  47035. /**
  47036. * In XR mode and presenting
  47037. */
  47038. IN_XR = 2,
  47039. /**
  47040. * Not entered XR mode
  47041. */
  47042. NOT_IN_XR = 3
  47043. }
  47044. /**
  47045. * Abstraction of the XR render target
  47046. */
  47047. export interface WebXRRenderTarget extends IDisposable {
  47048. /**
  47049. * xrpresent context of the canvas which can be used to display/mirror xr content
  47050. */
  47051. canvasContext: WebGLRenderingContext;
  47052. /**
  47053. * xr layer for the canvas
  47054. */
  47055. xrLayer: Nullable<XRWebGLLayer>;
  47056. /**
  47057. * Initializes the xr layer for the session
  47058. * @param xrSession xr session
  47059. * @returns a promise that will resolve once the XR Layer has been created
  47060. */
  47061. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47062. }
  47063. }
  47064. declare module BABYLON {
  47065. /**
  47066. * COnfiguration object for WebXR output canvas
  47067. */
  47068. export class WebXRManagedOutputCanvasOptions {
  47069. /**
  47070. * An optional canvas in case you wish to create it yourself and provide it here.
  47071. * If not provided, a new canvas will be created
  47072. */
  47073. canvasElement?: HTMLCanvasElement;
  47074. /**
  47075. * Options for this XR Layer output
  47076. */
  47077. canvasOptions?: XRWebGLLayerOptions;
  47078. /**
  47079. * CSS styling for a newly created canvas (if not provided)
  47080. */
  47081. newCanvasCssStyle?: string;
  47082. /**
  47083. * Get the default values of the configuration object
  47084. * @param engine defines the engine to use (can be null)
  47085. * @returns default values of this configuration object
  47086. */
  47087. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  47088. }
  47089. /**
  47090. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47091. */
  47092. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47093. private _options;
  47094. private _canvas;
  47095. private _engine;
  47096. private _originalCanvasSize;
  47097. /**
  47098. * Rendering context of the canvas which can be used to display/mirror xr content
  47099. */
  47100. canvasContext: WebGLRenderingContext;
  47101. /**
  47102. * xr layer for the canvas
  47103. */
  47104. xrLayer: Nullable<XRWebGLLayer>;
  47105. /**
  47106. * Obseervers registered here will be triggered when the xr layer was initialized
  47107. */
  47108. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47109. /**
  47110. * Initializes the canvas to be added/removed upon entering/exiting xr
  47111. * @param _xrSessionManager The XR Session manager
  47112. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47113. */
  47114. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47115. /**
  47116. * Disposes of the object
  47117. */
  47118. dispose(): void;
  47119. /**
  47120. * Initializes the xr layer for the session
  47121. * @param xrSession xr session
  47122. * @returns a promise that will resolve once the XR Layer has been created
  47123. */
  47124. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47125. private _addCanvas;
  47126. private _removeCanvas;
  47127. private _setCanvasSize;
  47128. private _setManagedOutputCanvas;
  47129. }
  47130. }
  47131. declare module BABYLON {
  47132. /**
  47133. * Manages an XRSession to work with Babylon's engine
  47134. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47135. */
  47136. export class WebXRSessionManager implements IDisposable {
  47137. /** The scene which the session should be created for */
  47138. scene: Scene;
  47139. private _referenceSpace;
  47140. private _rttProvider;
  47141. private _sessionEnded;
  47142. private _xrNavigator;
  47143. private baseLayer;
  47144. /**
  47145. * The base reference space from which the session started. good if you want to reset your
  47146. * reference space
  47147. */
  47148. baseReferenceSpace: XRReferenceSpace;
  47149. /**
  47150. * Current XR frame
  47151. */
  47152. currentFrame: Nullable<XRFrame>;
  47153. /** WebXR timestamp updated every frame */
  47154. currentTimestamp: number;
  47155. /**
  47156. * Used just in case of a failure to initialize an immersive session.
  47157. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47158. */
  47159. defaultHeightCompensation: number;
  47160. /**
  47161. * Fires every time a new xrFrame arrives which can be used to update the camera
  47162. */
  47163. onXRFrameObservable: Observable<XRFrame>;
  47164. /**
  47165. * Fires when the reference space changed
  47166. */
  47167. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47168. /**
  47169. * Fires when the xr session is ended either by the device or manually done
  47170. */
  47171. onXRSessionEnded: Observable<any>;
  47172. /**
  47173. * Fires when the xr session is ended either by the device or manually done
  47174. */
  47175. onXRSessionInit: Observable<XRSession>;
  47176. /**
  47177. * Underlying xr session
  47178. */
  47179. session: XRSession;
  47180. /**
  47181. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47182. * or get the offset the player is currently at.
  47183. */
  47184. viewerReferenceSpace: XRReferenceSpace;
  47185. /**
  47186. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47187. * @param scene The scene which the session should be created for
  47188. */
  47189. constructor(
  47190. /** The scene which the session should be created for */
  47191. scene: Scene);
  47192. /**
  47193. * The current reference space used in this session. This reference space can constantly change!
  47194. * It is mainly used to offset the camera's position.
  47195. */
  47196. get referenceSpace(): XRReferenceSpace;
  47197. /**
  47198. * Set a new reference space and triggers the observable
  47199. */
  47200. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47201. /**
  47202. * Disposes of the session manager
  47203. */
  47204. dispose(): void;
  47205. /**
  47206. * Stops the xrSession and restores the render loop
  47207. * @returns Promise which resolves after it exits XR
  47208. */
  47209. exitXRAsync(): Promise<void>;
  47210. /**
  47211. * Gets the correct render target texture to be rendered this frame for this eye
  47212. * @param eye the eye for which to get the render target
  47213. * @returns the render target for the specified eye
  47214. */
  47215. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47216. /**
  47217. * Creates a WebXRRenderTarget object for the XR session
  47218. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47219. * @param options optional options to provide when creating a new render target
  47220. * @returns a WebXR render target to which the session can render
  47221. */
  47222. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47223. /**
  47224. * Initializes the manager
  47225. * After initialization enterXR can be called to start an XR session
  47226. * @returns Promise which resolves after it is initialized
  47227. */
  47228. initializeAsync(): Promise<void>;
  47229. /**
  47230. * Initializes an xr session
  47231. * @param xrSessionMode mode to initialize
  47232. * @param xrSessionInit defines optional and required values to pass to the session builder
  47233. * @returns a promise which will resolve once the session has been initialized
  47234. */
  47235. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47236. /**
  47237. * Checks if a session would be supported for the creation options specified
  47238. * @param sessionMode session mode to check if supported eg. immersive-vr
  47239. * @returns A Promise that resolves to true if supported and false if not
  47240. */
  47241. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47242. /**
  47243. * Resets the reference space to the one started the session
  47244. */
  47245. resetReferenceSpace(): void;
  47246. /**
  47247. * Starts rendering to the xr layer
  47248. */
  47249. runXRRenderLoop(): void;
  47250. /**
  47251. * Sets the reference space on the xr session
  47252. * @param referenceSpaceType space to set
  47253. * @returns a promise that will resolve once the reference space has been set
  47254. */
  47255. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47256. /**
  47257. * Updates the render state of the session
  47258. * @param state state to set
  47259. * @returns a promise that resolves once the render state has been updated
  47260. */
  47261. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47262. /**
  47263. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47264. * @param sessionMode defines the session to test
  47265. * @returns a promise with boolean as final value
  47266. */
  47267. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47268. private _createRenderTargetTexture;
  47269. }
  47270. }
  47271. declare module BABYLON {
  47272. /**
  47273. * WebXR Camera which holds the views for the xrSession
  47274. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47275. */
  47276. export class WebXRCamera extends FreeCamera {
  47277. private _xrSessionManager;
  47278. private _firstFrame;
  47279. private _referenceQuaternion;
  47280. private _referencedPosition;
  47281. private _xrInvPositionCache;
  47282. private _xrInvQuaternionCache;
  47283. /**
  47284. * Observable raised before camera teleportation
  47285. */
  47286. onBeforeCameraTeleport: Observable<Vector3>;
  47287. /**
  47288. * Observable raised after camera teleportation
  47289. */
  47290. onAfterCameraTeleport: Observable<Vector3>;
  47291. /**
  47292. * Should position compensation execute on first frame.
  47293. * This is used when copying the position from a native (non XR) camera
  47294. */
  47295. compensateOnFirstFrame: boolean;
  47296. /**
  47297. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47298. * @param name the name of the camera
  47299. * @param scene the scene to add the camera to
  47300. * @param _xrSessionManager a constructed xr session manager
  47301. */
  47302. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47303. /**
  47304. * Return the user's height, unrelated to the current ground.
  47305. * This will be the y position of this camera, when ground level is 0.
  47306. */
  47307. get realWorldHeight(): number;
  47308. /** @hidden */
  47309. _updateForDualEyeDebugging(): void;
  47310. /**
  47311. * Sets this camera's transformation based on a non-vr camera
  47312. * @param otherCamera the non-vr camera to copy the transformation from
  47313. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47314. */
  47315. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47316. /**
  47317. * Gets the current instance class name ("WebXRCamera").
  47318. * @returns the class name
  47319. */
  47320. getClassName(): string;
  47321. private _rotate180;
  47322. private _updateFromXRSession;
  47323. private _updateNumberOfRigCameras;
  47324. private _updateReferenceSpace;
  47325. private _updateReferenceSpaceOffset;
  47326. }
  47327. }
  47328. declare module BABYLON {
  47329. /**
  47330. * Defining the interface required for a (webxr) feature
  47331. */
  47332. export interface IWebXRFeature extends IDisposable {
  47333. /**
  47334. * Is this feature attached
  47335. */
  47336. attached: boolean;
  47337. /**
  47338. * Should auto-attach be disabled?
  47339. */
  47340. disableAutoAttach: boolean;
  47341. /**
  47342. * Attach the feature to the session
  47343. * Will usually be called by the features manager
  47344. *
  47345. * @param force should attachment be forced (even when already attached)
  47346. * @returns true if successful.
  47347. */
  47348. attach(force?: boolean): boolean;
  47349. /**
  47350. * Detach the feature from the session
  47351. * Will usually be called by the features manager
  47352. *
  47353. * @returns true if successful.
  47354. */
  47355. detach(): boolean;
  47356. /**
  47357. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47358. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47359. *
  47360. * @returns whether or not the feature is compatible in this environment
  47361. */
  47362. isCompatible(): boolean;
  47363. /**
  47364. * Was this feature disposed;
  47365. */
  47366. isDisposed: boolean;
  47367. /**
  47368. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47369. */
  47370. xrNativeFeatureName?: string;
  47371. /**
  47372. * A list of (Babylon WebXR) features this feature depends on
  47373. */
  47374. dependsOn?: string[];
  47375. }
  47376. /**
  47377. * A list of the currently available features without referencing them
  47378. */
  47379. export class WebXRFeatureName {
  47380. /**
  47381. * The name of the anchor system feature
  47382. */
  47383. static readonly ANCHOR_SYSTEM: string;
  47384. /**
  47385. * The name of the background remover feature
  47386. */
  47387. static readonly BACKGROUND_REMOVER: string;
  47388. /**
  47389. * The name of the hit test feature
  47390. */
  47391. static readonly HIT_TEST: string;
  47392. /**
  47393. * physics impostors for xr controllers feature
  47394. */
  47395. static readonly PHYSICS_CONTROLLERS: string;
  47396. /**
  47397. * The name of the plane detection feature
  47398. */
  47399. static readonly PLANE_DETECTION: string;
  47400. /**
  47401. * The name of the pointer selection feature
  47402. */
  47403. static readonly POINTER_SELECTION: string;
  47404. /**
  47405. * The name of the teleportation feature
  47406. */
  47407. static readonly TELEPORTATION: string;
  47408. /**
  47409. * The name of the feature points feature.
  47410. */
  47411. static readonly FEATURE_POINTS: string;
  47412. /**
  47413. * The name of the hand tracking feature.
  47414. */
  47415. static readonly HAND_TRACKING: string;
  47416. }
  47417. /**
  47418. * Defining the constructor of a feature. Used to register the modules.
  47419. */
  47420. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47421. /**
  47422. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47423. * It is mainly used in AR sessions.
  47424. *
  47425. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47426. */
  47427. export class WebXRFeaturesManager implements IDisposable {
  47428. private _xrSessionManager;
  47429. private static readonly _AvailableFeatures;
  47430. private _features;
  47431. /**
  47432. * constructs a new features manages.
  47433. *
  47434. * @param _xrSessionManager an instance of WebXRSessionManager
  47435. */
  47436. constructor(_xrSessionManager: WebXRSessionManager);
  47437. /**
  47438. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47439. * Mainly used internally.
  47440. *
  47441. * @param featureName the name of the feature to register
  47442. * @param constructorFunction the function used to construct the module
  47443. * @param version the (babylon) version of the module
  47444. * @param stable is that a stable version of this module
  47445. */
  47446. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47447. /**
  47448. * Returns a constructor of a specific feature.
  47449. *
  47450. * @param featureName the name of the feature to construct
  47451. * @param version the version of the feature to load
  47452. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47453. * @param options optional options provided to the module.
  47454. * @returns a function that, when called, will return a new instance of this feature
  47455. */
  47456. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47457. /**
  47458. * Can be used to return the list of features currently registered
  47459. *
  47460. * @returns an Array of available features
  47461. */
  47462. static GetAvailableFeatures(): string[];
  47463. /**
  47464. * Gets the versions available for a specific feature
  47465. * @param featureName the name of the feature
  47466. * @returns an array with the available versions
  47467. */
  47468. static GetAvailableVersions(featureName: string): string[];
  47469. /**
  47470. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  47475. /**
  47476. * Return the latest stable version of this feature
  47477. * @param featureName the name of the feature to search
  47478. * @returns the version number. if not found will return -1
  47479. */
  47480. static GetStableVersionOfFeature(featureName: string): number;
  47481. /**
  47482. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47483. * Can be used during a session to start a feature
  47484. * @param featureName the name of feature to attach
  47485. */
  47486. attachFeature(featureName: string): void;
  47487. /**
  47488. * Can be used inside a session or when the session ends to detach a specific feature
  47489. * @param featureName the name of the feature to detach
  47490. */
  47491. detachFeature(featureName: string): void;
  47492. /**
  47493. * Used to disable an already-enabled feature
  47494. * The feature will be disposed and will be recreated once enabled.
  47495. * @param featureName the feature to disable
  47496. * @returns true if disable was successful
  47497. */
  47498. disableFeature(featureName: string | {
  47499. Name: string;
  47500. }): boolean;
  47501. /**
  47502. * dispose this features manager
  47503. */
  47504. dispose(): void;
  47505. /**
  47506. * 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.
  47507. * 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.
  47508. *
  47509. * @param featureName the name of the feature to load or the class of the feature
  47510. * @param version optional version to load. if not provided the latest version will be enabled
  47511. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47512. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47513. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47514. * @returns a new constructed feature or throws an error if feature not found.
  47515. */
  47516. enableFeature(featureName: string | {
  47517. Name: string;
  47518. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47519. /**
  47520. * get the implementation of an enabled feature.
  47521. * @param featureName the name of the feature to load
  47522. * @returns the feature class, if found
  47523. */
  47524. getEnabledFeature(featureName: string): IWebXRFeature;
  47525. /**
  47526. * Get the list of enabled features
  47527. * @returns an array of enabled features
  47528. */
  47529. getEnabledFeatures(): string[];
  47530. /**
  47531. * This function will exten the session creation configuration object with enabled features.
  47532. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47533. * according to the defined "required" variable, provided during enableFeature call
  47534. * @param xrSessionInit the xr Session init object to extend
  47535. *
  47536. * @returns an extended XRSessionInit object
  47537. */
  47538. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47539. }
  47540. }
  47541. declare module BABYLON {
  47542. /**
  47543. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47544. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47545. */
  47546. export class WebXRExperienceHelper implements IDisposable {
  47547. private scene;
  47548. private _nonVRCamera;
  47549. private _originalSceneAutoClear;
  47550. private _supported;
  47551. /**
  47552. * Camera used to render xr content
  47553. */
  47554. camera: WebXRCamera;
  47555. /** A features manager for this xr session */
  47556. featuresManager: WebXRFeaturesManager;
  47557. /**
  47558. * Observers registered here will be triggered after the camera's initial transformation is set
  47559. * This can be used to set a different ground level or an extra rotation.
  47560. *
  47561. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47562. * to the position set after this observable is done executing.
  47563. */
  47564. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47565. /**
  47566. * Fires when the state of the experience helper has changed
  47567. */
  47568. onStateChangedObservable: Observable<WebXRState>;
  47569. /** Session manager used to keep track of xr session */
  47570. sessionManager: WebXRSessionManager;
  47571. /**
  47572. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47573. */
  47574. state: WebXRState;
  47575. /**
  47576. * Creates a WebXRExperienceHelper
  47577. * @param scene The scene the helper should be created in
  47578. */
  47579. private constructor();
  47580. /**
  47581. * Creates the experience helper
  47582. * @param scene the scene to attach the experience helper to
  47583. * @returns a promise for the experience helper
  47584. */
  47585. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47586. /**
  47587. * Disposes of the experience helper
  47588. */
  47589. dispose(): void;
  47590. /**
  47591. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47592. * @param sessionMode options for the XR session
  47593. * @param referenceSpaceType frame of reference of the XR session
  47594. * @param renderTarget the output canvas that will be used to enter XR mode
  47595. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47596. * @returns promise that resolves after xr mode has entered
  47597. */
  47598. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47599. /**
  47600. * Exits XR mode and returns the scene to its original state
  47601. * @returns promise that resolves after xr mode has exited
  47602. */
  47603. exitXRAsync(): Promise<void>;
  47604. private _nonXRToXRCamera;
  47605. private _setState;
  47606. }
  47607. }
  47608. declare module BABYLON {
  47609. /**
  47610. * X-Y values for axes in WebXR
  47611. */
  47612. export interface IWebXRMotionControllerAxesValue {
  47613. /**
  47614. * The value of the x axis
  47615. */
  47616. x: number;
  47617. /**
  47618. * The value of the y-axis
  47619. */
  47620. y: number;
  47621. }
  47622. /**
  47623. * changed / previous values for the values of this component
  47624. */
  47625. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47626. /**
  47627. * current (this frame) value
  47628. */
  47629. current: T;
  47630. /**
  47631. * previous (last change) value
  47632. */
  47633. previous: T;
  47634. }
  47635. /**
  47636. * Represents changes in the component between current frame and last values recorded
  47637. */
  47638. export interface IWebXRMotionControllerComponentChanges {
  47639. /**
  47640. * will be populated with previous and current values if axes changed
  47641. */
  47642. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47643. /**
  47644. * will be populated with previous and current values if pressed changed
  47645. */
  47646. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47647. /**
  47648. * will be populated with previous and current values if touched changed
  47649. */
  47650. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47651. /**
  47652. * will be populated with previous and current values if value changed
  47653. */
  47654. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47655. }
  47656. /**
  47657. * This class represents a single component (for example button or thumbstick) of a motion controller
  47658. */
  47659. export class WebXRControllerComponent implements IDisposable {
  47660. /**
  47661. * the id of this component
  47662. */
  47663. id: string;
  47664. /**
  47665. * the type of the component
  47666. */
  47667. type: MotionControllerComponentType;
  47668. private _buttonIndex;
  47669. private _axesIndices;
  47670. private _axes;
  47671. private _changes;
  47672. private _currentValue;
  47673. private _hasChanges;
  47674. private _pressed;
  47675. private _touched;
  47676. /**
  47677. * button component type
  47678. */
  47679. static BUTTON_TYPE: MotionControllerComponentType;
  47680. /**
  47681. * squeeze component type
  47682. */
  47683. static SQUEEZE_TYPE: MotionControllerComponentType;
  47684. /**
  47685. * Thumbstick component type
  47686. */
  47687. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47688. /**
  47689. * Touchpad component type
  47690. */
  47691. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47692. /**
  47693. * trigger component type
  47694. */
  47695. static TRIGGER_TYPE: MotionControllerComponentType;
  47696. /**
  47697. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47698. * the axes data changes
  47699. */
  47700. onAxisValueChangedObservable: Observable<{
  47701. x: number;
  47702. y: number;
  47703. }>;
  47704. /**
  47705. * Observers registered here will be triggered when the state of a button changes
  47706. * State change is either pressed / touched / value
  47707. */
  47708. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47709. /**
  47710. * Creates a new component for a motion controller.
  47711. * It is created by the motion controller itself
  47712. *
  47713. * @param id the id of this component
  47714. * @param type the type of the component
  47715. * @param _buttonIndex index in the buttons array of the gamepad
  47716. * @param _axesIndices indices of the values in the axes array of the gamepad
  47717. */
  47718. constructor(
  47719. /**
  47720. * the id of this component
  47721. */
  47722. id: string,
  47723. /**
  47724. * the type of the component
  47725. */
  47726. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47727. /**
  47728. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47729. */
  47730. get axes(): IWebXRMotionControllerAxesValue;
  47731. /**
  47732. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47733. */
  47734. get changes(): IWebXRMotionControllerComponentChanges;
  47735. /**
  47736. * Return whether or not the component changed the last frame
  47737. */
  47738. get hasChanges(): boolean;
  47739. /**
  47740. * is the button currently pressed
  47741. */
  47742. get pressed(): boolean;
  47743. /**
  47744. * is the button currently touched
  47745. */
  47746. get touched(): boolean;
  47747. /**
  47748. * Get the current value of this component
  47749. */
  47750. get value(): number;
  47751. /**
  47752. * Dispose this component
  47753. */
  47754. dispose(): void;
  47755. /**
  47756. * Are there axes correlating to this component
  47757. * @return true is axes data is available
  47758. */
  47759. isAxes(): boolean;
  47760. /**
  47761. * Is this component a button (hence - pressable)
  47762. * @returns true if can be pressed
  47763. */
  47764. isButton(): boolean;
  47765. /**
  47766. * update this component using the gamepad object it is in. Called on every frame
  47767. * @param nativeController the native gamepad controller object
  47768. */
  47769. update(nativeController: IMinimalMotionControllerObject): void;
  47770. }
  47771. }
  47772. declare module BABYLON {
  47773. /**
  47774. * Interface used to represent data loading progression
  47775. */
  47776. export interface ISceneLoaderProgressEvent {
  47777. /**
  47778. * Defines if data length to load can be evaluated
  47779. */
  47780. readonly lengthComputable: boolean;
  47781. /**
  47782. * Defines the loaded data length
  47783. */
  47784. readonly loaded: number;
  47785. /**
  47786. * Defines the data length to load
  47787. */
  47788. readonly total: number;
  47789. }
  47790. /**
  47791. * Interface used by SceneLoader plugins to define supported file extensions
  47792. */
  47793. export interface ISceneLoaderPluginExtensions {
  47794. /**
  47795. * Defines the list of supported extensions
  47796. */
  47797. [extension: string]: {
  47798. isBinary: boolean;
  47799. };
  47800. }
  47801. /**
  47802. * Interface used by SceneLoader plugin factory
  47803. */
  47804. export interface ISceneLoaderPluginFactory {
  47805. /**
  47806. * Defines the name of the factory
  47807. */
  47808. name: string;
  47809. /**
  47810. * Function called to create a new plugin
  47811. * @return the new plugin
  47812. */
  47813. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47814. /**
  47815. * The callback that returns true if the data can be directly loaded.
  47816. * @param data string containing the file data
  47817. * @returns if the data can be loaded directly
  47818. */
  47819. canDirectLoad?(data: string): boolean;
  47820. }
  47821. /**
  47822. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47823. */
  47824. export interface ISceneLoaderPluginBase {
  47825. /**
  47826. * The friendly name of this plugin.
  47827. */
  47828. name: string;
  47829. /**
  47830. * The file extensions supported by this plugin.
  47831. */
  47832. extensions: string | ISceneLoaderPluginExtensions;
  47833. /**
  47834. * The callback called when loading from a url.
  47835. * @param scene scene loading this url
  47836. * @param url url to load
  47837. * @param onSuccess callback called when the file successfully loads
  47838. * @param onProgress callback called while file is loading (if the server supports this mode)
  47839. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47840. * @param onError callback called when the file fails to load
  47841. * @returns a file request object
  47842. */
  47843. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47844. /**
  47845. * The callback called when loading from a file object.
  47846. * @param scene scene loading this file
  47847. * @param file defines the file to load
  47848. * @param onSuccess defines the callback to call when data is loaded
  47849. * @param onProgress defines the callback to call during loading process
  47850. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47851. * @param onError defines the callback to call when an error occurs
  47852. * @returns a file request object
  47853. */
  47854. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47855. /**
  47856. * The callback that returns true if the data can be directly loaded.
  47857. * @param data string containing the file data
  47858. * @returns if the data can be loaded directly
  47859. */
  47860. canDirectLoad?(data: string): boolean;
  47861. /**
  47862. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47863. * @param scene scene loading this data
  47864. * @param data string containing the data
  47865. * @returns data to pass to the plugin
  47866. */
  47867. directLoad?(scene: Scene, data: string): any;
  47868. /**
  47869. * The callback that allows custom handling of the root url based on the response url.
  47870. * @param rootUrl the original root url
  47871. * @param responseURL the response url if available
  47872. * @returns the new root url
  47873. */
  47874. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47875. }
  47876. /**
  47877. * Interface used to define a SceneLoader plugin
  47878. */
  47879. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47880. /**
  47881. * Import meshes into a scene.
  47882. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47883. * @param scene The scene to import into
  47884. * @param data The data to import
  47885. * @param rootUrl The root url for scene and resources
  47886. * @param meshes The meshes array to import into
  47887. * @param particleSystems The particle systems array to import into
  47888. * @param skeletons The skeletons array to import into
  47889. * @param onError The callback when import fails
  47890. * @returns True if successful or false otherwise
  47891. */
  47892. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47893. /**
  47894. * Load into a scene.
  47895. * @param scene The scene to load into
  47896. * @param data The data to import
  47897. * @param rootUrl The root url for scene and resources
  47898. * @param onError The callback when import fails
  47899. * @returns True if successful or false otherwise
  47900. */
  47901. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47902. /**
  47903. * Load into an asset container.
  47904. * @param scene The scene to load into
  47905. * @param data The data to import
  47906. * @param rootUrl The root url for scene and resources
  47907. * @param onError The callback when import fails
  47908. * @returns The loaded asset container
  47909. */
  47910. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47911. }
  47912. /**
  47913. * Interface used to define an async SceneLoader plugin
  47914. */
  47915. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47916. /**
  47917. * Import meshes into a scene.
  47918. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47919. * @param scene The scene to import into
  47920. * @param data The data to import
  47921. * @param rootUrl The root url for scene and resources
  47922. * @param onProgress The callback when the load progresses
  47923. * @param fileName Defines the name of the file to load
  47924. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47925. */
  47926. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47927. meshes: AbstractMesh[];
  47928. particleSystems: IParticleSystem[];
  47929. skeletons: Skeleton[];
  47930. animationGroups: AnimationGroup[];
  47931. }>;
  47932. /**
  47933. * Load into a scene.
  47934. * @param scene The scene to load into
  47935. * @param data The data to import
  47936. * @param rootUrl The root url for scene and resources
  47937. * @param onProgress The callback when the load progresses
  47938. * @param fileName Defines the name of the file to load
  47939. * @returns Nothing
  47940. */
  47941. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47942. /**
  47943. * Load into an asset container.
  47944. * @param scene The scene to load into
  47945. * @param data The data to import
  47946. * @param rootUrl The root url for scene and resources
  47947. * @param onProgress The callback when the load progresses
  47948. * @param fileName Defines the name of the file to load
  47949. * @returns The loaded asset container
  47950. */
  47951. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47952. }
  47953. /**
  47954. * Mode that determines how to handle old animation groups before loading new ones.
  47955. */
  47956. export enum SceneLoaderAnimationGroupLoadingMode {
  47957. /**
  47958. * Reset all old animations to initial state then dispose them.
  47959. */
  47960. Clean = 0,
  47961. /**
  47962. * Stop all old animations.
  47963. */
  47964. Stop = 1,
  47965. /**
  47966. * Restart old animations from first frame.
  47967. */
  47968. Sync = 2,
  47969. /**
  47970. * Old animations remains untouched.
  47971. */
  47972. NoSync = 3
  47973. }
  47974. /**
  47975. * Defines a plugin registered by the SceneLoader
  47976. */
  47977. interface IRegisteredPlugin {
  47978. /**
  47979. * Defines the plugin to use
  47980. */
  47981. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47982. /**
  47983. * Defines if the plugin supports binary data
  47984. */
  47985. isBinary: boolean;
  47986. }
  47987. /**
  47988. * Class used to load scene from various file formats using registered plugins
  47989. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47990. */
  47991. export class SceneLoader {
  47992. /**
  47993. * No logging while loading
  47994. */
  47995. static readonly NO_LOGGING: number;
  47996. /**
  47997. * Minimal logging while loading
  47998. */
  47999. static readonly MINIMAL_LOGGING: number;
  48000. /**
  48001. * Summary logging while loading
  48002. */
  48003. static readonly SUMMARY_LOGGING: number;
  48004. /**
  48005. * Detailled logging while loading
  48006. */
  48007. static readonly DETAILED_LOGGING: number;
  48008. /**
  48009. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48010. */
  48011. static get ForceFullSceneLoadingForIncremental(): boolean;
  48012. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48013. /**
  48014. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48015. */
  48016. static get ShowLoadingScreen(): boolean;
  48017. static set ShowLoadingScreen(value: boolean);
  48018. /**
  48019. * Defines the current logging level (while loading the scene)
  48020. * @ignorenaming
  48021. */
  48022. static get loggingLevel(): number;
  48023. static set loggingLevel(value: number);
  48024. /**
  48025. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48026. */
  48027. static get CleanBoneMatrixWeights(): boolean;
  48028. static set CleanBoneMatrixWeights(value: boolean);
  48029. /**
  48030. * Event raised when a plugin is used to load a scene
  48031. */
  48032. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48033. private static _registeredPlugins;
  48034. private static _showingLoadingScreen;
  48035. /**
  48036. * Gets the default plugin (used to load Babylon files)
  48037. * @returns the .babylon plugin
  48038. */
  48039. static GetDefaultPlugin(): IRegisteredPlugin;
  48040. private static _GetPluginForExtension;
  48041. private static _GetPluginForDirectLoad;
  48042. private static _GetPluginForFilename;
  48043. private static _GetDirectLoad;
  48044. private static _LoadData;
  48045. private static _GetFileInfo;
  48046. /**
  48047. * Gets a plugin that can load the given extension
  48048. * @param extension defines the extension to load
  48049. * @returns a plugin or null if none works
  48050. */
  48051. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48052. /**
  48053. * Gets a boolean indicating that the given extension can be loaded
  48054. * @param extension defines the extension to load
  48055. * @returns true if the extension is supported
  48056. */
  48057. static IsPluginForExtensionAvailable(extension: string): boolean;
  48058. /**
  48059. * Adds a new plugin to the list of registered plugins
  48060. * @param plugin defines the plugin to add
  48061. */
  48062. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48063. /**
  48064. * Import meshes into a scene
  48065. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48066. * @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)
  48067. * @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)
  48068. * @param scene the instance of BABYLON.Scene to append to
  48069. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  48070. * @param onProgress a callback with a progress event for each file being loaded
  48071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48072. * @param pluginExtension the extension used to determine the plugin
  48073. * @returns The loaded plugin
  48074. */
  48075. 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>;
  48076. /**
  48077. * Import meshes into a scene
  48078. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48079. * @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)
  48080. * @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)
  48081. * @param scene the instance of BABYLON.Scene to append to
  48082. * @param onProgress a callback with a progress event for each file being loaded
  48083. * @param pluginExtension the extension used to determine the plugin
  48084. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48085. */
  48086. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48087. meshes: AbstractMesh[];
  48088. particleSystems: IParticleSystem[];
  48089. skeletons: Skeleton[];
  48090. animationGroups: AnimationGroup[];
  48091. }>;
  48092. /**
  48093. * Load a scene
  48094. * @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)
  48095. * @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)
  48096. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48097. * @param onSuccess a callback with the scene when import succeeds
  48098. * @param onProgress a callback with a progress event for each file being loaded
  48099. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48100. * @param pluginExtension the extension used to determine the plugin
  48101. * @returns The loaded plugin
  48102. */
  48103. 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>;
  48104. /**
  48105. * Load a scene
  48106. * @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)
  48107. * @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)
  48108. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48109. * @param onProgress a callback with a progress event for each file being loaded
  48110. * @param pluginExtension the extension used to determine the plugin
  48111. * @returns The loaded scene
  48112. */
  48113. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48114. /**
  48115. * Append a scene
  48116. * @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)
  48117. * @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)
  48118. * @param scene is the instance of BABYLON.Scene to append to
  48119. * @param onSuccess a callback with the scene when import succeeds
  48120. * @param onProgress a callback with a progress event for each file being loaded
  48121. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48122. * @param pluginExtension the extension used to determine the plugin
  48123. * @returns The loaded plugin
  48124. */
  48125. 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>;
  48126. /**
  48127. * Append a scene
  48128. * @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)
  48129. * @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)
  48130. * @param scene is the instance of BABYLON.Scene to append to
  48131. * @param onProgress a callback with a progress event for each file being loaded
  48132. * @param pluginExtension the extension used to determine the plugin
  48133. * @returns The given scene
  48134. */
  48135. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48136. /**
  48137. * Load a scene into an asset container
  48138. * @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)
  48139. * @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)
  48140. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48141. * @param onSuccess a callback with the scene when import succeeds
  48142. * @param onProgress a callback with a progress event for each file being loaded
  48143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48144. * @param pluginExtension the extension used to determine the plugin
  48145. * @returns The loaded plugin
  48146. */
  48147. 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>;
  48148. /**
  48149. * Load a scene into an asset container
  48150. * @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)
  48151. * @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)
  48152. * @param scene is the instance of Scene to append to
  48153. * @param onProgress a callback with a progress event for each file being loaded
  48154. * @param pluginExtension the extension used to determine the plugin
  48155. * @returns The loaded asset container
  48156. */
  48157. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48158. /**
  48159. * Import animations from a file into a scene
  48160. * @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)
  48161. * @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)
  48162. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48163. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48164. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48165. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48166. * @param onSuccess a callback with the scene when import succeeds
  48167. * @param onProgress a callback with a progress event for each file being loaded
  48168. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48169. * @param pluginExtension the extension used to determine the plugin
  48170. */
  48171. 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;
  48172. /**
  48173. * Import animations from a file into a scene
  48174. * @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)
  48175. * @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)
  48176. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48177. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48178. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48179. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48180. * @param onSuccess a callback with the scene when import succeeds
  48181. * @param onProgress a callback with a progress event for each file being loaded
  48182. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48183. * @param pluginExtension the extension used to determine the plugin
  48184. * @returns the updated scene with imported animations
  48185. */
  48186. 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>;
  48187. }
  48188. }
  48189. declare module BABYLON {
  48190. /**
  48191. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48192. */
  48193. export type MotionControllerHandedness = "none" | "left" | "right";
  48194. /**
  48195. * The type of components available in motion controllers.
  48196. * This is not the name of the component.
  48197. */
  48198. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48199. /**
  48200. * The state of a controller component
  48201. */
  48202. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48203. /**
  48204. * The schema of motion controller layout.
  48205. * No object will be initialized using this interface
  48206. * This is used just to define the profile.
  48207. */
  48208. export interface IMotionControllerLayout {
  48209. /**
  48210. * Path to load the assets. Usually relative to the base path
  48211. */
  48212. assetPath: string;
  48213. /**
  48214. * Available components (unsorted)
  48215. */
  48216. components: {
  48217. /**
  48218. * A map of component Ids
  48219. */
  48220. [componentId: string]: {
  48221. /**
  48222. * The type of input the component outputs
  48223. */
  48224. type: MotionControllerComponentType;
  48225. /**
  48226. * The indices of this component in the gamepad object
  48227. */
  48228. gamepadIndices: {
  48229. /**
  48230. * Index of button
  48231. */
  48232. button?: number;
  48233. /**
  48234. * If available, index of x-axis
  48235. */
  48236. xAxis?: number;
  48237. /**
  48238. * If available, index of y-axis
  48239. */
  48240. yAxis?: number;
  48241. };
  48242. /**
  48243. * The mesh's root node name
  48244. */
  48245. rootNodeName: string;
  48246. /**
  48247. * Animation definitions for this model
  48248. */
  48249. visualResponses: {
  48250. [stateKey: string]: {
  48251. /**
  48252. * What property will be animated
  48253. */
  48254. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48255. /**
  48256. * What states influence this visual response
  48257. */
  48258. states: MotionControllerComponentStateType[];
  48259. /**
  48260. * Type of animation - movement or visibility
  48261. */
  48262. valueNodeProperty: "transform" | "visibility";
  48263. /**
  48264. * Base node name to move. Its position will be calculated according to the min and max nodes
  48265. */
  48266. valueNodeName?: string;
  48267. /**
  48268. * Minimum movement node
  48269. */
  48270. minNodeName?: string;
  48271. /**
  48272. * Max movement node
  48273. */
  48274. maxNodeName?: string;
  48275. };
  48276. };
  48277. /**
  48278. * If touch enabled, what is the name of node to display user feedback
  48279. */
  48280. touchPointNodeName?: string;
  48281. };
  48282. };
  48283. /**
  48284. * Is it xr standard mapping or not
  48285. */
  48286. gamepadMapping: "" | "xr-standard";
  48287. /**
  48288. * Base root node of this entire model
  48289. */
  48290. rootNodeName: string;
  48291. /**
  48292. * Defines the main button component id
  48293. */
  48294. selectComponentId: string;
  48295. }
  48296. /**
  48297. * A definition for the layout map in the input profile
  48298. */
  48299. export interface IMotionControllerLayoutMap {
  48300. /**
  48301. * Layouts with handedness type as a key
  48302. */
  48303. [handedness: string]: IMotionControllerLayout;
  48304. }
  48305. /**
  48306. * The XR Input profile schema
  48307. * Profiles can be found here:
  48308. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48309. */
  48310. export interface IMotionControllerProfile {
  48311. /**
  48312. * fallback profiles for this profileId
  48313. */
  48314. fallbackProfileIds: string[];
  48315. /**
  48316. * The layout map, with handedness as key
  48317. */
  48318. layouts: IMotionControllerLayoutMap;
  48319. /**
  48320. * The id of this profile
  48321. * correlates to the profile(s) in the xrInput.profiles array
  48322. */
  48323. profileId: string;
  48324. }
  48325. /**
  48326. * A helper-interface for the 3 meshes needed for controller button animation
  48327. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48328. */
  48329. export interface IMotionControllerButtonMeshMap {
  48330. /**
  48331. * the mesh that defines the pressed value mesh position.
  48332. * This is used to find the max-position of this button
  48333. */
  48334. pressedMesh: AbstractMesh;
  48335. /**
  48336. * the mesh that defines the unpressed value mesh position.
  48337. * This is used to find the min (or initial) position of this button
  48338. */
  48339. unpressedMesh: AbstractMesh;
  48340. /**
  48341. * The mesh that will be changed when value changes
  48342. */
  48343. valueMesh: AbstractMesh;
  48344. }
  48345. /**
  48346. * A helper-interface for the 3 meshes needed for controller axis animation.
  48347. * This will be expanded when touchpad animations are fully supported
  48348. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48349. */
  48350. export interface IMotionControllerMeshMap {
  48351. /**
  48352. * the mesh that defines the maximum value mesh position.
  48353. */
  48354. maxMesh?: AbstractMesh;
  48355. /**
  48356. * the mesh that defines the minimum value mesh position.
  48357. */
  48358. minMesh?: AbstractMesh;
  48359. /**
  48360. * The mesh that will be changed when axis value changes
  48361. */
  48362. valueMesh?: AbstractMesh;
  48363. }
  48364. /**
  48365. * The elements needed for change-detection of the gamepad objects in motion controllers
  48366. */
  48367. export interface IMinimalMotionControllerObject {
  48368. /**
  48369. * Available axes of this controller
  48370. */
  48371. axes: number[];
  48372. /**
  48373. * An array of available buttons
  48374. */
  48375. buttons: Array<{
  48376. /**
  48377. * Value of the button/trigger
  48378. */
  48379. value: number;
  48380. /**
  48381. * If the button/trigger is currently touched
  48382. */
  48383. touched: boolean;
  48384. /**
  48385. * If the button/trigger is currently pressed
  48386. */
  48387. pressed: boolean;
  48388. }>;
  48389. /**
  48390. * EXPERIMENTAL haptic support.
  48391. */
  48392. hapticActuators?: Array<{
  48393. pulse: (value: number, duration: number) => Promise<boolean>;
  48394. }>;
  48395. }
  48396. /**
  48397. * An Abstract Motion controller
  48398. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48399. * Each component has an observable to check for changes in value and state
  48400. */
  48401. export abstract class WebXRAbstractMotionController implements IDisposable {
  48402. protected scene: Scene;
  48403. protected layout: IMotionControllerLayout;
  48404. /**
  48405. * The gamepad object correlating to this controller
  48406. */
  48407. gamepadObject: IMinimalMotionControllerObject;
  48408. /**
  48409. * handedness (left/right/none) of this controller
  48410. */
  48411. handedness: MotionControllerHandedness;
  48412. private _initComponent;
  48413. private _modelReady;
  48414. /**
  48415. * A map of components (WebXRControllerComponent) in this motion controller
  48416. * Components have a ComponentType and can also have both button and axis definitions
  48417. */
  48418. readonly components: {
  48419. [id: string]: WebXRControllerComponent;
  48420. };
  48421. /**
  48422. * Disable the model's animation. Can be set at any time.
  48423. */
  48424. disableAnimation: boolean;
  48425. /**
  48426. * Observers registered here will be triggered when the model of this controller is done loading
  48427. */
  48428. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48429. /**
  48430. * The profile id of this motion controller
  48431. */
  48432. abstract profileId: string;
  48433. /**
  48434. * The root mesh of the model. It is null if the model was not yet initialized
  48435. */
  48436. rootMesh: Nullable<AbstractMesh>;
  48437. /**
  48438. * constructs a new abstract motion controller
  48439. * @param scene the scene to which the model of the controller will be added
  48440. * @param layout The profile layout to load
  48441. * @param gamepadObject The gamepad object correlating to this controller
  48442. * @param handedness handedness (left/right/none) of this controller
  48443. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48444. */
  48445. constructor(scene: Scene, layout: IMotionControllerLayout,
  48446. /**
  48447. * The gamepad object correlating to this controller
  48448. */
  48449. gamepadObject: IMinimalMotionControllerObject,
  48450. /**
  48451. * handedness (left/right/none) of this controller
  48452. */
  48453. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48454. /**
  48455. * Dispose this controller, the model mesh and all its components
  48456. */
  48457. dispose(): void;
  48458. /**
  48459. * Returns all components of specific type
  48460. * @param type the type to search for
  48461. * @return an array of components with this type
  48462. */
  48463. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48464. /**
  48465. * get a component based an its component id as defined in layout.components
  48466. * @param id the id of the component
  48467. * @returns the component correlates to the id or undefined if not found
  48468. */
  48469. getComponent(id: string): WebXRControllerComponent;
  48470. /**
  48471. * Get the list of components available in this motion controller
  48472. * @returns an array of strings correlating to available components
  48473. */
  48474. getComponentIds(): string[];
  48475. /**
  48476. * Get the first component of specific type
  48477. * @param type type of component to find
  48478. * @return a controller component or null if not found
  48479. */
  48480. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48481. /**
  48482. * Get the main (Select) component of this controller as defined in the layout
  48483. * @returns the main component of this controller
  48484. */
  48485. getMainComponent(): WebXRControllerComponent;
  48486. /**
  48487. * Loads the model correlating to this controller
  48488. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48489. * @returns A promise fulfilled with the result of the model loading
  48490. */
  48491. loadModel(): Promise<boolean>;
  48492. /**
  48493. * Update this model using the current XRFrame
  48494. * @param xrFrame the current xr frame to use and update the model
  48495. */
  48496. updateFromXRFrame(xrFrame: XRFrame): void;
  48497. /**
  48498. * Backwards compatibility due to a deeply-integrated typo
  48499. */
  48500. get handness(): XREye;
  48501. /**
  48502. * Pulse (vibrate) this controller
  48503. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48504. * Consecutive calls to this function will cancel the last pulse call
  48505. *
  48506. * @param value the strength of the pulse in 0.0...1.0 range
  48507. * @param duration Duration of the pulse in milliseconds
  48508. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48509. * @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
  48510. */
  48511. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48512. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48513. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48514. /**
  48515. * Moves the axis on the controller mesh based on its current state
  48516. * @param axis the index of the axis
  48517. * @param axisValue the value of the axis which determines the meshes new position
  48518. * @hidden
  48519. */
  48520. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48521. /**
  48522. * Update the model itself with the current frame data
  48523. * @param xrFrame the frame to use for updating the model mesh
  48524. */
  48525. protected updateModel(xrFrame: XRFrame): void;
  48526. /**
  48527. * Get the filename and path for this controller's model
  48528. * @returns a map of filename and path
  48529. */
  48530. protected abstract _getFilenameAndPath(): {
  48531. filename: string;
  48532. path: string;
  48533. };
  48534. /**
  48535. * This function is called before the mesh is loaded. It checks for loading constraints.
  48536. * For example, this function can check if the GLB loader is available
  48537. * If this function returns false, the generic controller will be loaded instead
  48538. * @returns Is the client ready to load the mesh
  48539. */
  48540. protected abstract _getModelLoadingConstraints(): boolean;
  48541. /**
  48542. * This function will be called after the model was successfully loaded and can be used
  48543. * for mesh transformations before it is available for the user
  48544. * @param meshes the loaded meshes
  48545. */
  48546. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48547. /**
  48548. * Set the root mesh for this controller. Important for the WebXR controller class
  48549. * @param meshes the loaded meshes
  48550. */
  48551. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48552. /**
  48553. * A function executed each frame that updates the mesh (if needed)
  48554. * @param xrFrame the current xrFrame
  48555. */
  48556. protected abstract _updateModel(xrFrame: XRFrame): void;
  48557. private _getGenericFilenameAndPath;
  48558. private _getGenericParentMesh;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. /**
  48563. * A generic trigger-only motion controller for WebXR
  48564. */
  48565. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48566. /**
  48567. * Static version of the profile id of this controller
  48568. */
  48569. static ProfileId: string;
  48570. profileId: string;
  48571. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48572. protected _getFilenameAndPath(): {
  48573. filename: string;
  48574. path: string;
  48575. };
  48576. protected _getModelLoadingConstraints(): boolean;
  48577. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48578. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48579. protected _updateModel(): void;
  48580. }
  48581. }
  48582. declare module BABYLON {
  48583. /**
  48584. * Class containing static functions to help procedurally build meshes
  48585. */
  48586. export class SphereBuilder {
  48587. /**
  48588. * Creates a sphere mesh
  48589. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48590. * * 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`)
  48591. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48592. * * 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
  48593. * * 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)
  48594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48595. * * 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
  48596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48597. * @param name defines the name of the mesh
  48598. * @param options defines the options used to create the mesh
  48599. * @param scene defines the hosting scene
  48600. * @returns the sphere mesh
  48601. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48602. */
  48603. static CreateSphere(name: string, options: {
  48604. segments?: number;
  48605. diameter?: number;
  48606. diameterX?: number;
  48607. diameterY?: number;
  48608. diameterZ?: number;
  48609. arc?: number;
  48610. slice?: number;
  48611. sideOrientation?: number;
  48612. frontUVs?: Vector4;
  48613. backUVs?: Vector4;
  48614. updatable?: boolean;
  48615. }, scene?: Nullable<Scene>): Mesh;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. /**
  48620. * A profiled motion controller has its profile loaded from an online repository.
  48621. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48622. */
  48623. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48624. private _repositoryUrl;
  48625. private _buttonMeshMapping;
  48626. private _touchDots;
  48627. /**
  48628. * The profile ID of this controller. Will be populated when the controller initializes.
  48629. */
  48630. profileId: string;
  48631. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48632. dispose(): void;
  48633. protected _getFilenameAndPath(): {
  48634. filename: string;
  48635. path: string;
  48636. };
  48637. protected _getModelLoadingConstraints(): boolean;
  48638. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48639. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48640. protected _updateModel(_xrFrame: XRFrame): void;
  48641. }
  48642. }
  48643. declare module BABYLON {
  48644. /**
  48645. * A construction function type to create a new controller based on an xrInput object
  48646. */
  48647. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48648. /**
  48649. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48650. *
  48651. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48652. * it should be replaced with auto-loaded controllers.
  48653. *
  48654. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48655. */
  48656. export class WebXRMotionControllerManager {
  48657. private static _AvailableControllers;
  48658. private static _Fallbacks;
  48659. private static _ProfileLoadingPromises;
  48660. private static _ProfilesList;
  48661. /**
  48662. * The base URL of the online controller repository. Can be changed at any time.
  48663. */
  48664. static BaseRepositoryUrl: string;
  48665. /**
  48666. * Which repository gets priority - local or online
  48667. */
  48668. static PrioritizeOnlineRepository: boolean;
  48669. /**
  48670. * Use the online repository, or use only locally-defined controllers
  48671. */
  48672. static UseOnlineRepository: boolean;
  48673. /**
  48674. * Clear the cache used for profile loading and reload when requested again
  48675. */
  48676. static ClearProfilesCache(): void;
  48677. /**
  48678. * Register the default fallbacks.
  48679. * This function is called automatically when this file is imported.
  48680. */
  48681. static DefaultFallbacks(): void;
  48682. /**
  48683. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48684. * @param profileId the profile to which a fallback needs to be found
  48685. * @return an array with corresponding fallback profiles
  48686. */
  48687. static FindFallbackWithProfileId(profileId: string): string[];
  48688. /**
  48689. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48690. * The order of search:
  48691. *
  48692. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48693. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48694. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48695. * 4) return the generic trigger controller if none were found
  48696. *
  48697. * @param xrInput the xrInput to which a new controller is initialized
  48698. * @param scene the scene to which the model will be added
  48699. * @param forceProfile force a certain profile for this controller
  48700. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48701. */
  48702. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48703. /**
  48704. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48705. *
  48706. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48707. *
  48708. * @param type the profile type to register
  48709. * @param constructFunction the function to be called when loading this profile
  48710. */
  48711. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48712. /**
  48713. * Register a fallback to a specific profile.
  48714. * @param profileId the profileId that will receive the fallbacks
  48715. * @param fallbacks A list of fallback profiles
  48716. */
  48717. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48718. /**
  48719. * Will update the list of profiles available in the repository
  48720. * @return a promise that resolves to a map of profiles available online
  48721. */
  48722. static UpdateProfilesList(): Promise<{
  48723. [profile: string]: string;
  48724. }>;
  48725. private static _LoadProfileFromRepository;
  48726. private static _LoadProfilesFromAvailableControllers;
  48727. }
  48728. }
  48729. declare module BABYLON {
  48730. /**
  48731. * Configuration options for the WebXR controller creation
  48732. */
  48733. export interface IWebXRControllerOptions {
  48734. /**
  48735. * Should the controller mesh be animated when a user interacts with it
  48736. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48737. */
  48738. disableMotionControllerAnimation?: boolean;
  48739. /**
  48740. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48741. */
  48742. doNotLoadControllerMesh?: boolean;
  48743. /**
  48744. * Force a specific controller type for this controller.
  48745. * This can be used when creating your own profile or when testing different controllers
  48746. */
  48747. forceControllerProfile?: string;
  48748. /**
  48749. * Defines a rendering group ID for meshes that will be loaded.
  48750. * This is for the default controllers only.
  48751. */
  48752. renderingGroupId?: number;
  48753. }
  48754. /**
  48755. * Represents an XR controller
  48756. */
  48757. export class WebXRInputSource {
  48758. private _scene;
  48759. /** The underlying input source for the controller */
  48760. inputSource: XRInputSource;
  48761. private _options;
  48762. private _tmpVector;
  48763. private _uniqueId;
  48764. private _disposed;
  48765. /**
  48766. * 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
  48767. */
  48768. grip?: AbstractMesh;
  48769. /**
  48770. * If available, this is the gamepad object related to this controller.
  48771. * Using this object it is possible to get click events and trackpad changes of the
  48772. * webxr controller that is currently being used.
  48773. */
  48774. motionController?: WebXRAbstractMotionController;
  48775. /**
  48776. * Event that fires when the controller is removed/disposed.
  48777. * The object provided as event data is this controller, after associated assets were disposed.
  48778. * uniqueId is still available.
  48779. */
  48780. onDisposeObservable: Observable<WebXRInputSource>;
  48781. /**
  48782. * Will be triggered when the mesh associated with the motion controller is done loading.
  48783. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48784. * A shortened version of controller -> motion controller -> on mesh loaded.
  48785. */
  48786. onMeshLoadedObservable: Observable<AbstractMesh>;
  48787. /**
  48788. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48789. */
  48790. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48791. /**
  48792. * Pointer which can be used to select objects or attach a visible laser to
  48793. */
  48794. pointer: AbstractMesh;
  48795. /**
  48796. * Creates the input source object
  48797. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48798. * @param _scene the scene which the controller should be associated to
  48799. * @param inputSource the underlying input source for the controller
  48800. * @param _options options for this controller creation
  48801. */
  48802. constructor(_scene: Scene,
  48803. /** The underlying input source for the controller */
  48804. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48805. /**
  48806. * Get this controllers unique id
  48807. */
  48808. get uniqueId(): string;
  48809. /**
  48810. * Disposes of the object
  48811. */
  48812. dispose(): void;
  48813. /**
  48814. * Gets a world space ray coming from the pointer or grip
  48815. * @param result the resulting ray
  48816. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48817. */
  48818. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48819. /**
  48820. * Updates the controller pose based on the given XRFrame
  48821. * @param xrFrame xr frame to update the pose with
  48822. * @param referenceSpace reference space to use
  48823. */
  48824. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48825. }
  48826. }
  48827. declare module BABYLON {
  48828. /**
  48829. * The schema for initialization options of the XR Input class
  48830. */
  48831. export interface IWebXRInputOptions {
  48832. /**
  48833. * If set to true no model will be automatically loaded
  48834. */
  48835. doNotLoadControllerMeshes?: boolean;
  48836. /**
  48837. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48838. * If not found, the xr input profile data will be used.
  48839. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48840. */
  48841. forceInputProfile?: string;
  48842. /**
  48843. * Do not send a request to the controller repository to load the profile.
  48844. *
  48845. * Instead, use the controllers available in babylon itself.
  48846. */
  48847. disableOnlineControllerRepository?: boolean;
  48848. /**
  48849. * A custom URL for the controllers repository
  48850. */
  48851. customControllersRepositoryURL?: string;
  48852. /**
  48853. * Should the controller model's components not move according to the user input
  48854. */
  48855. disableControllerAnimation?: boolean;
  48856. /**
  48857. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48858. */
  48859. controllerOptions?: IWebXRControllerOptions;
  48860. }
  48861. /**
  48862. * XR input used to track XR inputs such as controllers/rays
  48863. */
  48864. export class WebXRInput implements IDisposable {
  48865. /**
  48866. * the xr session manager for this session
  48867. */
  48868. xrSessionManager: WebXRSessionManager;
  48869. /**
  48870. * the WebXR camera for this session. Mainly used for teleportation
  48871. */
  48872. xrCamera: WebXRCamera;
  48873. private readonly options;
  48874. /**
  48875. * XR controllers being tracked
  48876. */
  48877. controllers: Array<WebXRInputSource>;
  48878. private _frameObserver;
  48879. private _sessionEndedObserver;
  48880. private _sessionInitObserver;
  48881. /**
  48882. * Event when a controller has been connected/added
  48883. */
  48884. onControllerAddedObservable: Observable<WebXRInputSource>;
  48885. /**
  48886. * Event when a controller has been removed/disconnected
  48887. */
  48888. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48889. /**
  48890. * Initializes the WebXRInput
  48891. * @param xrSessionManager the xr session manager for this session
  48892. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48893. * @param options = initialization options for this xr input
  48894. */
  48895. constructor(
  48896. /**
  48897. * the xr session manager for this session
  48898. */
  48899. xrSessionManager: WebXRSessionManager,
  48900. /**
  48901. * the WebXR camera for this session. Mainly used for teleportation
  48902. */
  48903. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48904. private _onInputSourcesChange;
  48905. private _addAndRemoveControllers;
  48906. /**
  48907. * Disposes of the object
  48908. */
  48909. dispose(): void;
  48910. }
  48911. }
  48912. declare module BABYLON {
  48913. /**
  48914. * This is the base class for all WebXR features.
  48915. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48916. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48917. */
  48918. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48919. protected _xrSessionManager: WebXRSessionManager;
  48920. private _attached;
  48921. private _removeOnDetach;
  48922. /**
  48923. * Is this feature disposed?
  48924. */
  48925. isDisposed: boolean;
  48926. /**
  48927. * Should auto-attach be disabled?
  48928. */
  48929. disableAutoAttach: boolean;
  48930. /**
  48931. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48932. */
  48933. xrNativeFeatureName: string;
  48934. /**
  48935. * Construct a new (abstract) WebXR feature
  48936. * @param _xrSessionManager the xr session manager for this feature
  48937. */
  48938. constructor(_xrSessionManager: WebXRSessionManager);
  48939. /**
  48940. * Is this feature attached
  48941. */
  48942. get attached(): boolean;
  48943. /**
  48944. * attach this feature
  48945. *
  48946. * @param force should attachment be forced (even when already attached)
  48947. * @returns true if successful, false is failed or already attached
  48948. */
  48949. attach(force?: boolean): boolean;
  48950. /**
  48951. * detach this feature.
  48952. *
  48953. * @returns true if successful, false if failed or already detached
  48954. */
  48955. detach(): boolean;
  48956. /**
  48957. * Dispose this feature and all of the resources attached
  48958. */
  48959. dispose(): void;
  48960. /**
  48961. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48962. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48963. *
  48964. * @returns whether or not the feature is compatible in this environment
  48965. */
  48966. isCompatible(): boolean;
  48967. /**
  48968. * This is used to register callbacks that will automatically be removed when detach is called.
  48969. * @param observable the observable to which the observer will be attached
  48970. * @param callback the callback to register
  48971. */
  48972. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48973. /**
  48974. * Code in this function will be executed on each xrFrame received from the browser.
  48975. * This function will not execute after the feature is detached.
  48976. * @param _xrFrame the current frame
  48977. */
  48978. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48979. }
  48980. }
  48981. declare module BABYLON {
  48982. /**
  48983. * Renders a layer on top of an existing scene
  48984. */
  48985. export class UtilityLayerRenderer implements IDisposable {
  48986. /** the original scene that will be rendered on top of */
  48987. originalScene: Scene;
  48988. private _pointerCaptures;
  48989. private _lastPointerEvents;
  48990. private static _DefaultUtilityLayer;
  48991. private static _DefaultKeepDepthUtilityLayer;
  48992. private _sharedGizmoLight;
  48993. private _renderCamera;
  48994. /**
  48995. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48996. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48997. * @returns the camera that is used when rendering the utility layer
  48998. */
  48999. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49000. /**
  49001. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49002. * @param cam the camera that should be used when rendering the utility layer
  49003. */
  49004. setRenderCamera(cam: Nullable<Camera>): void;
  49005. /**
  49006. * @hidden
  49007. * Light which used by gizmos to get light shading
  49008. */
  49009. _getSharedGizmoLight(): HemisphericLight;
  49010. /**
  49011. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49012. */
  49013. pickUtilitySceneFirst: boolean;
  49014. /**
  49015. * 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)
  49016. */
  49017. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49018. /**
  49019. * 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)
  49020. */
  49021. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49022. /**
  49023. * The scene that is rendered on top of the original scene
  49024. */
  49025. utilityLayerScene: Scene;
  49026. /**
  49027. * If the utility layer should automatically be rendered on top of existing scene
  49028. */
  49029. shouldRender: boolean;
  49030. /**
  49031. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49032. */
  49033. onlyCheckPointerDownEvents: boolean;
  49034. /**
  49035. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49036. */
  49037. processAllEvents: boolean;
  49038. /**
  49039. * Observable raised when the pointer move from the utility layer scene to the main scene
  49040. */
  49041. onPointerOutObservable: Observable<number>;
  49042. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49043. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49044. private _afterRenderObserver;
  49045. private _sceneDisposeObserver;
  49046. private _originalPointerObserver;
  49047. /**
  49048. * Instantiates a UtilityLayerRenderer
  49049. * @param originalScene the original scene that will be rendered on top of
  49050. * @param handleEvents boolean indicating if the utility layer should handle events
  49051. */
  49052. constructor(
  49053. /** the original scene that will be rendered on top of */
  49054. originalScene: Scene, handleEvents?: boolean);
  49055. private _notifyObservers;
  49056. /**
  49057. * Renders the utility layers scene on top of the original scene
  49058. */
  49059. render(): void;
  49060. /**
  49061. * Disposes of the renderer
  49062. */
  49063. dispose(): void;
  49064. private _updateCamera;
  49065. }
  49066. }
  49067. declare module BABYLON {
  49068. /**
  49069. * Options interface for the pointer selection module
  49070. */
  49071. export interface IWebXRControllerPointerSelectionOptions {
  49072. /**
  49073. * if provided, this scene will be used to render meshes.
  49074. */
  49075. customUtilityLayerScene?: Scene;
  49076. /**
  49077. * 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)
  49078. * If not disabled, the last picked point will be used to execute a pointer up event
  49079. * If disabled, pointer up event will be triggered right after the pointer down event.
  49080. * Used in screen and gaze target ray mode only
  49081. */
  49082. disablePointerUpOnTouchOut: boolean;
  49083. /**
  49084. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  49085. */
  49086. forceGazeMode: boolean;
  49087. /**
  49088. * 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
  49089. * to start a new countdown to the pointer down event.
  49090. * Defaults to 1.
  49091. */
  49092. gazeModePointerMovedFactor?: number;
  49093. /**
  49094. * Different button type to use instead of the main component
  49095. */
  49096. overrideButtonId?: string;
  49097. /**
  49098. * use this rendering group id for the meshes (optional)
  49099. */
  49100. renderingGroupId?: number;
  49101. /**
  49102. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49103. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49104. * 3000 means 3 seconds between pointing at something and selecting it
  49105. */
  49106. timeToSelect?: number;
  49107. /**
  49108. * Should meshes created here be added to a utility layer or the main scene
  49109. */
  49110. useUtilityLayer?: boolean;
  49111. /**
  49112. * Optional WebXR camera to be used for gaze selection
  49113. */
  49114. gazeCamera?: WebXRCamera;
  49115. /**
  49116. * the xr input to use with this pointer selection
  49117. */
  49118. xrInput: WebXRInput;
  49119. }
  49120. /**
  49121. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49122. */
  49123. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49124. private readonly _options;
  49125. private static _idCounter;
  49126. private _attachController;
  49127. private _controllers;
  49128. private _scene;
  49129. private _tmpVectorForPickCompare;
  49130. /**
  49131. * The module's name
  49132. */
  49133. static readonly Name: string;
  49134. /**
  49135. * The (Babylon) version of this module.
  49136. * This is an integer representing the implementation version.
  49137. * This number does not correspond to the WebXR specs version
  49138. */
  49139. static readonly Version: number;
  49140. /**
  49141. * Disable lighting on the laser pointer (so it will always be visible)
  49142. */
  49143. disablePointerLighting: boolean;
  49144. /**
  49145. * Disable lighting on the selection mesh (so it will always be visible)
  49146. */
  49147. disableSelectionMeshLighting: boolean;
  49148. /**
  49149. * Should the laser pointer be displayed
  49150. */
  49151. displayLaserPointer: boolean;
  49152. /**
  49153. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49154. */
  49155. displaySelectionMesh: boolean;
  49156. /**
  49157. * This color will be set to the laser pointer when selection is triggered
  49158. */
  49159. laserPointerPickedColor: Color3;
  49160. /**
  49161. * Default color of the laser pointer
  49162. */
  49163. laserPointerDefaultColor: Color3;
  49164. /**
  49165. * default color of the selection ring
  49166. */
  49167. selectionMeshDefaultColor: Color3;
  49168. /**
  49169. * This color will be applied to the selection ring when selection is triggered
  49170. */
  49171. selectionMeshPickedColor: Color3;
  49172. /**
  49173. * Optional filter to be used for ray selection. This predicate shares behavior with
  49174. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49175. */
  49176. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49177. /**
  49178. * constructs a new background remover module
  49179. * @param _xrSessionManager the session manager for this module
  49180. * @param _options read-only options to be used in this module
  49181. */
  49182. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49183. /**
  49184. * attach this feature
  49185. * Will usually be called by the features manager
  49186. *
  49187. * @returns true if successful.
  49188. */
  49189. attach(): boolean;
  49190. /**
  49191. * detach this feature.
  49192. * Will usually be called by the features manager
  49193. *
  49194. * @returns true if successful.
  49195. */
  49196. detach(): boolean;
  49197. /**
  49198. * Will get the mesh under a specific pointer.
  49199. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49200. * @param controllerId the controllerId to check
  49201. * @returns The mesh under pointer or null if no mesh is under the pointer
  49202. */
  49203. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49204. /**
  49205. * Get the xr controller that correlates to the pointer id in the pointer event
  49206. *
  49207. * @param id the pointer id to search for
  49208. * @returns the controller that correlates to this id or null if not found
  49209. */
  49210. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49211. protected _onXRFrame(_xrFrame: XRFrame): void;
  49212. private _attachGazeMode;
  49213. private _attachScreenRayMode;
  49214. private _attachTrackedPointerRayMode;
  49215. private _convertNormalToDirectionOfRay;
  49216. private _detachController;
  49217. private _generateNewMeshPair;
  49218. private _pickingMoved;
  49219. private _updatePointerDistance;
  49220. /** @hidden */
  49221. get lasterPointerDefaultColor(): Color3;
  49222. }
  49223. }
  49224. declare module BABYLON {
  49225. /**
  49226. * Button which can be used to enter a different mode of XR
  49227. */
  49228. export class WebXREnterExitUIButton {
  49229. /** button element */
  49230. element: HTMLElement;
  49231. /** XR initialization options for the button */
  49232. sessionMode: XRSessionMode;
  49233. /** Reference space type */
  49234. referenceSpaceType: XRReferenceSpaceType;
  49235. /**
  49236. * Creates a WebXREnterExitUIButton
  49237. * @param element button element
  49238. * @param sessionMode XR initialization session mode
  49239. * @param referenceSpaceType the type of reference space to be used
  49240. */
  49241. constructor(
  49242. /** button element */
  49243. element: HTMLElement,
  49244. /** XR initialization options for the button */
  49245. sessionMode: XRSessionMode,
  49246. /** Reference space type */
  49247. referenceSpaceType: XRReferenceSpaceType);
  49248. /**
  49249. * Extendable function which can be used to update the button's visuals when the state changes
  49250. * @param activeButton the current active button in the UI
  49251. */
  49252. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49253. }
  49254. /**
  49255. * Options to create the webXR UI
  49256. */
  49257. export class WebXREnterExitUIOptions {
  49258. /**
  49259. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49260. */
  49261. customButtons?: Array<WebXREnterExitUIButton>;
  49262. /**
  49263. * A reference space type to use when creating the default button.
  49264. * Default is local-floor
  49265. */
  49266. referenceSpaceType?: XRReferenceSpaceType;
  49267. /**
  49268. * Context to enter xr with
  49269. */
  49270. renderTarget?: Nullable<WebXRRenderTarget>;
  49271. /**
  49272. * A session mode to use when creating the default button.
  49273. * Default is immersive-vr
  49274. */
  49275. sessionMode?: XRSessionMode;
  49276. /**
  49277. * A list of optional features to init the session with
  49278. */
  49279. optionalFeatures?: string[];
  49280. /**
  49281. * A list of optional features to init the session with
  49282. */
  49283. requiredFeatures?: string[];
  49284. }
  49285. /**
  49286. * UI to allow the user to enter/exit XR mode
  49287. */
  49288. export class WebXREnterExitUI implements IDisposable {
  49289. private scene;
  49290. /** version of the options passed to this UI */
  49291. options: WebXREnterExitUIOptions;
  49292. private _activeButton;
  49293. private _buttons;
  49294. /**
  49295. * The HTML Div Element to which buttons are added.
  49296. */
  49297. readonly overlay: HTMLDivElement;
  49298. /**
  49299. * Fired every time the active button is changed.
  49300. *
  49301. * When xr is entered via a button that launches xr that button will be the callback parameter
  49302. *
  49303. * When exiting xr the callback parameter will be null)
  49304. */
  49305. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49306. /**
  49307. *
  49308. * @param scene babylon scene object to use
  49309. * @param options (read-only) version of the options passed to this UI
  49310. */
  49311. private constructor();
  49312. /**
  49313. * Creates UI to allow the user to enter/exit XR mode
  49314. * @param scene the scene to add the ui to
  49315. * @param helper the xr experience helper to enter/exit xr with
  49316. * @param options options to configure the UI
  49317. * @returns the created ui
  49318. */
  49319. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49320. /**
  49321. * Disposes of the XR UI component
  49322. */
  49323. dispose(): void;
  49324. private _updateButtons;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /**
  49329. * Class containing static functions to help procedurally build meshes
  49330. */
  49331. export class LinesBuilder {
  49332. /**
  49333. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49334. * * 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
  49335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49336. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49337. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49338. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49339. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49340. * * 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
  49341. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49344. * @param name defines the name of the new line system
  49345. * @param options defines the options used to create the line system
  49346. * @param scene defines the hosting scene
  49347. * @returns a new line system mesh
  49348. */
  49349. static CreateLineSystem(name: string, options: {
  49350. lines: Vector3[][];
  49351. updatable?: boolean;
  49352. instance?: Nullable<LinesMesh>;
  49353. colors?: Nullable<Color4[][]>;
  49354. useVertexAlpha?: boolean;
  49355. }, scene: Nullable<Scene>): LinesMesh;
  49356. /**
  49357. * Creates a line mesh
  49358. * 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
  49359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49360. * * The parameter `points` is an array successive Vector3
  49361. * * 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
  49362. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49364. * * When updating an instance, remember that only point positions can change, not the number of points
  49365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49367. * @param name defines the name of the new line system
  49368. * @param options defines the options used to create the line system
  49369. * @param scene defines the hosting scene
  49370. * @returns a new line mesh
  49371. */
  49372. static CreateLines(name: string, options: {
  49373. points: Vector3[];
  49374. updatable?: boolean;
  49375. instance?: Nullable<LinesMesh>;
  49376. colors?: Color4[];
  49377. useVertexAlpha?: boolean;
  49378. }, scene?: Nullable<Scene>): LinesMesh;
  49379. /**
  49380. * Creates a dashed line mesh
  49381. * * 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
  49382. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49383. * * The parameter `points` is an array successive Vector3
  49384. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49385. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49386. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49387. * * 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
  49388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49389. * * When updating an instance, remember that only point positions can change, not the number of points
  49390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49391. * @param name defines the name of the mesh
  49392. * @param options defines the options used to create the mesh
  49393. * @param scene defines the hosting scene
  49394. * @returns the dashed line mesh
  49395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49396. */
  49397. static CreateDashedLines(name: string, options: {
  49398. points: Vector3[];
  49399. dashSize?: number;
  49400. gapSize?: number;
  49401. dashNb?: number;
  49402. updatable?: boolean;
  49403. instance?: LinesMesh;
  49404. useVertexAlpha?: boolean;
  49405. }, scene?: Nullable<Scene>): LinesMesh;
  49406. }
  49407. }
  49408. declare module BABYLON {
  49409. /**
  49410. * Construction options for a timer
  49411. */
  49412. export interface ITimerOptions<T> {
  49413. /**
  49414. * Time-to-end
  49415. */
  49416. timeout: number;
  49417. /**
  49418. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49419. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49420. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49421. */
  49422. contextObservable: Observable<T>;
  49423. /**
  49424. * Optional parameters when adding an observer to the observable
  49425. */
  49426. observableParameters?: {
  49427. mask?: number;
  49428. insertFirst?: boolean;
  49429. scope?: any;
  49430. };
  49431. /**
  49432. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49433. */
  49434. breakCondition?: (data?: ITimerData<T>) => boolean;
  49435. /**
  49436. * Will be triggered when the time condition has met
  49437. */
  49438. onEnded?: (data: ITimerData<any>) => void;
  49439. /**
  49440. * Will be triggered when the break condition has met (prematurely ended)
  49441. */
  49442. onAborted?: (data: ITimerData<any>) => void;
  49443. /**
  49444. * Optional function to execute on each tick (or count)
  49445. */
  49446. onTick?: (data: ITimerData<any>) => void;
  49447. }
  49448. /**
  49449. * An interface defining the data sent by the timer
  49450. */
  49451. export interface ITimerData<T> {
  49452. /**
  49453. * When did it start
  49454. */
  49455. startTime: number;
  49456. /**
  49457. * Time now
  49458. */
  49459. currentTime: number;
  49460. /**
  49461. * Time passed since started
  49462. */
  49463. deltaTime: number;
  49464. /**
  49465. * How much is completed, in [0.0...1.0].
  49466. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49467. */
  49468. completeRate: number;
  49469. /**
  49470. * What the registered observable sent in the last count
  49471. */
  49472. payload: T;
  49473. }
  49474. /**
  49475. * The current state of the timer
  49476. */
  49477. export enum TimerState {
  49478. /**
  49479. * Timer initialized, not yet started
  49480. */
  49481. INIT = 0,
  49482. /**
  49483. * Timer started and counting
  49484. */
  49485. STARTED = 1,
  49486. /**
  49487. * Timer ended (whether aborted or time reached)
  49488. */
  49489. ENDED = 2
  49490. }
  49491. /**
  49492. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49493. *
  49494. * @param options options with which to initialize this timer
  49495. */
  49496. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49497. /**
  49498. * An advanced implementation of a timer class
  49499. */
  49500. export class AdvancedTimer<T = any> implements IDisposable {
  49501. /**
  49502. * Will notify each time the timer calculates the remaining time
  49503. */
  49504. onEachCountObservable: Observable<ITimerData<T>>;
  49505. /**
  49506. * Will trigger when the timer was aborted due to the break condition
  49507. */
  49508. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49509. /**
  49510. * Will trigger when the timer ended successfully
  49511. */
  49512. onTimerEndedObservable: Observable<ITimerData<T>>;
  49513. /**
  49514. * Will trigger when the timer state has changed
  49515. */
  49516. onStateChangedObservable: Observable<TimerState>;
  49517. private _observer;
  49518. private _contextObservable;
  49519. private _observableParameters;
  49520. private _startTime;
  49521. private _timer;
  49522. private _state;
  49523. private _breakCondition;
  49524. private _timeToEnd;
  49525. private _breakOnNextTick;
  49526. /**
  49527. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49528. * @param options construction options for this advanced timer
  49529. */
  49530. constructor(options: ITimerOptions<T>);
  49531. /**
  49532. * set a breaking condition for this timer. Default is to never break during count
  49533. * @param predicate the new break condition. Returns true to break, false otherwise
  49534. */
  49535. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49536. /**
  49537. * Reset ALL associated observables in this advanced timer
  49538. */
  49539. clearObservables(): void;
  49540. /**
  49541. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49542. *
  49543. * @param timeToEnd how much time to measure until timer ended
  49544. */
  49545. start(timeToEnd?: number): void;
  49546. /**
  49547. * Will force a stop on the next tick.
  49548. */
  49549. stop(): void;
  49550. /**
  49551. * Dispose this timer, clearing all resources
  49552. */
  49553. dispose(): void;
  49554. private _setState;
  49555. private _tick;
  49556. private _stop;
  49557. }
  49558. }
  49559. declare module BABYLON {
  49560. /**
  49561. * The options container for the teleportation module
  49562. */
  49563. export interface IWebXRTeleportationOptions {
  49564. /**
  49565. * if provided, this scene will be used to render meshes.
  49566. */
  49567. customUtilityLayerScene?: Scene;
  49568. /**
  49569. * Values to configure the default target mesh
  49570. */
  49571. defaultTargetMeshOptions?: {
  49572. /**
  49573. * Fill color of the teleportation area
  49574. */
  49575. teleportationFillColor?: string;
  49576. /**
  49577. * Border color for the teleportation area
  49578. */
  49579. teleportationBorderColor?: string;
  49580. /**
  49581. * Disable the mesh's animation sequence
  49582. */
  49583. disableAnimation?: boolean;
  49584. /**
  49585. * Disable lighting on the material or the ring and arrow
  49586. */
  49587. disableLighting?: boolean;
  49588. /**
  49589. * Override the default material of the torus and arrow
  49590. */
  49591. torusArrowMaterial?: Material;
  49592. };
  49593. /**
  49594. * A list of meshes to use as floor meshes.
  49595. * Meshes can be added and removed after initializing the feature using the
  49596. * addFloorMesh and removeFloorMesh functions
  49597. * If empty, rotation will still work
  49598. */
  49599. floorMeshes?: AbstractMesh[];
  49600. /**
  49601. * use this rendering group id for the meshes (optional)
  49602. */
  49603. renderingGroupId?: number;
  49604. /**
  49605. * Should teleportation move only to snap points
  49606. */
  49607. snapPointsOnly?: boolean;
  49608. /**
  49609. * An array of points to which the teleportation will snap to.
  49610. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49611. */
  49612. snapPositions?: Vector3[];
  49613. /**
  49614. * How close should the teleportation ray be in order to snap to position.
  49615. * Default to 0.8 units (meters)
  49616. */
  49617. snapToPositionRadius?: number;
  49618. /**
  49619. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49620. * If you want to support rotation, make sure your mesh has a direction indicator.
  49621. *
  49622. * When left untouched, the default mesh will be initialized.
  49623. */
  49624. teleportationTargetMesh?: AbstractMesh;
  49625. /**
  49626. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49627. */
  49628. timeToTeleport?: number;
  49629. /**
  49630. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49631. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49632. */
  49633. useMainComponentOnly?: boolean;
  49634. /**
  49635. * Should meshes created here be added to a utility layer or the main scene
  49636. */
  49637. useUtilityLayer?: boolean;
  49638. /**
  49639. * Babylon XR Input class for controller
  49640. */
  49641. xrInput: WebXRInput;
  49642. /**
  49643. * Meshes that the teleportation ray cannot go through
  49644. */
  49645. pickBlockerMeshes?: AbstractMesh[];
  49646. }
  49647. /**
  49648. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49649. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49650. * the input of the attached controllers.
  49651. */
  49652. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49653. private _options;
  49654. private _controllers;
  49655. private _currentTeleportationControllerId;
  49656. private _floorMeshes;
  49657. private _quadraticBezierCurve;
  49658. private _selectionFeature;
  49659. private _snapToPositions;
  49660. private _snappedToPoint;
  49661. private _teleportationRingMaterial?;
  49662. private _tmpRay;
  49663. private _tmpVector;
  49664. private _tmpQuaternion;
  49665. /**
  49666. * The module's name
  49667. */
  49668. static readonly Name: string;
  49669. /**
  49670. * The (Babylon) version of this module.
  49671. * This is an integer representing the implementation version.
  49672. * This number does not correspond to the webxr specs version
  49673. */
  49674. static readonly Version: number;
  49675. /**
  49676. * Is movement backwards enabled
  49677. */
  49678. backwardsMovementEnabled: boolean;
  49679. /**
  49680. * Distance to travel when moving backwards
  49681. */
  49682. backwardsTeleportationDistance: number;
  49683. /**
  49684. * The distance from the user to the inspection point in the direction of the controller
  49685. * A higher number will allow the user to move further
  49686. * defaults to 5 (meters, in xr units)
  49687. */
  49688. parabolicCheckRadius: number;
  49689. /**
  49690. * Should the module support parabolic ray on top of direct ray
  49691. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49692. * Very helpful when moving between floors / different heights
  49693. */
  49694. parabolicRayEnabled: boolean;
  49695. /**
  49696. * How much rotation should be applied when rotating right and left
  49697. */
  49698. rotationAngle: number;
  49699. /**
  49700. * Is rotation enabled when moving forward?
  49701. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49702. */
  49703. rotationEnabled: boolean;
  49704. /**
  49705. * constructs a new anchor system
  49706. * @param _xrSessionManager an instance of WebXRSessionManager
  49707. * @param _options configuration object for this feature
  49708. */
  49709. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49710. /**
  49711. * Get the snapPointsOnly flag
  49712. */
  49713. get snapPointsOnly(): boolean;
  49714. /**
  49715. * Sets the snapPointsOnly flag
  49716. * @param snapToPoints should teleportation be exclusively to snap points
  49717. */
  49718. set snapPointsOnly(snapToPoints: boolean);
  49719. /**
  49720. * Add a new mesh to the floor meshes array
  49721. * @param mesh the mesh to use as floor mesh
  49722. */
  49723. addFloorMesh(mesh: AbstractMesh): void;
  49724. /**
  49725. * Add a new snap-to point to fix teleportation to this position
  49726. * @param newSnapPoint The new Snap-To point
  49727. */
  49728. addSnapPoint(newSnapPoint: Vector3): void;
  49729. attach(): boolean;
  49730. detach(): boolean;
  49731. dispose(): void;
  49732. /**
  49733. * Remove a mesh from the floor meshes array
  49734. * @param mesh the mesh to remove
  49735. */
  49736. removeFloorMesh(mesh: AbstractMesh): void;
  49737. /**
  49738. * Remove a mesh from the floor meshes array using its name
  49739. * @param name the mesh name to remove
  49740. */
  49741. removeFloorMeshByName(name: string): void;
  49742. /**
  49743. * 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
  49744. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49745. * @returns was the point found and removed or not
  49746. */
  49747. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49748. /**
  49749. * This function sets a selection feature that will be disabled when
  49750. * the forward ray is shown and will be reattached when hidden.
  49751. * This is used to remove the selection rays when moving.
  49752. * @param selectionFeature the feature to disable when forward movement is enabled
  49753. */
  49754. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49755. protected _onXRFrame(_xrFrame: XRFrame): void;
  49756. private _attachController;
  49757. private _createDefaultTargetMesh;
  49758. private _detachController;
  49759. private _findClosestSnapPointWithRadius;
  49760. private _setTargetMeshPosition;
  49761. private _setTargetMeshVisibility;
  49762. private _showParabolicPath;
  49763. private _teleportForward;
  49764. }
  49765. }
  49766. declare module BABYLON {
  49767. /**
  49768. * Options for the default xr helper
  49769. */
  49770. export class WebXRDefaultExperienceOptions {
  49771. /**
  49772. * Enable or disable default UI to enter XR
  49773. */
  49774. disableDefaultUI?: boolean;
  49775. /**
  49776. * Should teleportation not initialize. defaults to false.
  49777. */
  49778. disableTeleportation?: boolean;
  49779. /**
  49780. * Floor meshes that will be used for teleport
  49781. */
  49782. floorMeshes?: Array<AbstractMesh>;
  49783. /**
  49784. * If set to true, the first frame will not be used to reset position
  49785. * The first frame is mainly used when copying transformation from the old camera
  49786. * Mainly used in AR
  49787. */
  49788. ignoreNativeCameraTransformation?: boolean;
  49789. /**
  49790. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49791. */
  49792. inputOptions?: IWebXRInputOptions;
  49793. /**
  49794. * optional configuration for the output canvas
  49795. */
  49796. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49797. /**
  49798. * optional UI options. This can be used among other to change session mode and reference space type
  49799. */
  49800. uiOptions?: WebXREnterExitUIOptions;
  49801. /**
  49802. * When loading teleportation and pointer select, use stable versions instead of latest.
  49803. */
  49804. useStablePlugins?: boolean;
  49805. /**
  49806. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49807. */
  49808. renderingGroupId?: number;
  49809. /**
  49810. * A list of optional features to init the session with
  49811. * If set to true, all features we support will be added
  49812. */
  49813. optionalFeatures?: boolean | string[];
  49814. }
  49815. /**
  49816. * Default experience which provides a similar setup to the previous webVRExperience
  49817. */
  49818. export class WebXRDefaultExperience {
  49819. /**
  49820. * Base experience
  49821. */
  49822. baseExperience: WebXRExperienceHelper;
  49823. /**
  49824. * Enables ui for entering/exiting xr
  49825. */
  49826. enterExitUI: WebXREnterExitUI;
  49827. /**
  49828. * Input experience extension
  49829. */
  49830. input: WebXRInput;
  49831. /**
  49832. * Enables laser pointer and selection
  49833. */
  49834. pointerSelection: WebXRControllerPointerSelection;
  49835. /**
  49836. * Default target xr should render to
  49837. */
  49838. renderTarget: WebXRRenderTarget;
  49839. /**
  49840. * Enables teleportation
  49841. */
  49842. teleportation: WebXRMotionControllerTeleportation;
  49843. private constructor();
  49844. /**
  49845. * Creates the default xr experience
  49846. * @param scene scene
  49847. * @param options options for basic configuration
  49848. * @returns resulting WebXRDefaultExperience
  49849. */
  49850. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49851. /**
  49852. * DIsposes of the experience helper
  49853. */
  49854. dispose(): void;
  49855. }
  49856. }
  49857. declare module BABYLON {
  49858. /**
  49859. * Options to modify the vr teleportation behavior.
  49860. */
  49861. export interface VRTeleportationOptions {
  49862. /**
  49863. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49864. */
  49865. floorMeshName?: string;
  49866. /**
  49867. * A list of meshes to be used as the teleportation floor. (default: empty)
  49868. */
  49869. floorMeshes?: Mesh[];
  49870. /**
  49871. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49872. */
  49873. teleportationMode?: number;
  49874. /**
  49875. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49876. */
  49877. teleportationTime?: number;
  49878. /**
  49879. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49880. */
  49881. teleportationSpeed?: number;
  49882. /**
  49883. * The easing function used in the animation or null for Linear. (default CircleEase)
  49884. */
  49885. easingFunction?: EasingFunction;
  49886. }
  49887. /**
  49888. * Options to modify the vr experience helper's behavior.
  49889. */
  49890. export interface VRExperienceHelperOptions extends WebVROptions {
  49891. /**
  49892. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49893. */
  49894. createDeviceOrientationCamera?: boolean;
  49895. /**
  49896. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49897. */
  49898. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49899. /**
  49900. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49901. */
  49902. laserToggle?: boolean;
  49903. /**
  49904. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49905. */
  49906. floorMeshes?: Mesh[];
  49907. /**
  49908. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49909. */
  49910. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49911. /**
  49912. * Defines if WebXR should be used instead of WebVR (if available)
  49913. */
  49914. useXR?: boolean;
  49915. }
  49916. /**
  49917. * Event containing information after VR has been entered
  49918. */
  49919. export class OnAfterEnteringVRObservableEvent {
  49920. /**
  49921. * If entering vr was successful
  49922. */
  49923. success: boolean;
  49924. }
  49925. /**
  49926. * Helps to quickly add VR support to an existing scene.
  49927. * See https://doc.babylonjs.com/how_to/webvr_helper
  49928. */
  49929. export class VRExperienceHelper {
  49930. /** Options to modify the vr experience helper's behavior. */
  49931. webVROptions: VRExperienceHelperOptions;
  49932. private _scene;
  49933. private _position;
  49934. private _btnVR;
  49935. private _btnVRDisplayed;
  49936. private _webVRsupported;
  49937. private _webVRready;
  49938. private _webVRrequesting;
  49939. private _webVRpresenting;
  49940. private _hasEnteredVR;
  49941. private _fullscreenVRpresenting;
  49942. private _inputElement;
  49943. private _webVRCamera;
  49944. private _vrDeviceOrientationCamera;
  49945. private _deviceOrientationCamera;
  49946. private _existingCamera;
  49947. private _onKeyDown;
  49948. private _onVrDisplayPresentChange;
  49949. private _onVRDisplayChanged;
  49950. private _onVRRequestPresentStart;
  49951. private _onVRRequestPresentComplete;
  49952. /**
  49953. * 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)
  49954. */
  49955. enableGazeEvenWhenNoPointerLock: boolean;
  49956. /**
  49957. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49958. */
  49959. exitVROnDoubleTap: boolean;
  49960. /**
  49961. * Observable raised right before entering VR.
  49962. */
  49963. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49964. /**
  49965. * Observable raised when entering VR has completed.
  49966. */
  49967. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49968. /**
  49969. * Observable raised when exiting VR.
  49970. */
  49971. onExitingVRObservable: Observable<VRExperienceHelper>;
  49972. /**
  49973. * Observable raised when controller mesh is loaded.
  49974. */
  49975. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49976. /** Return this.onEnteringVRObservable
  49977. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49978. */
  49979. get onEnteringVR(): Observable<VRExperienceHelper>;
  49980. /** Return this.onExitingVRObservable
  49981. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49982. */
  49983. get onExitingVR(): Observable<VRExperienceHelper>;
  49984. /** Return this.onControllerMeshLoadedObservable
  49985. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49986. */
  49987. get onControllerMeshLoaded(): Observable<WebVRController>;
  49988. private _rayLength;
  49989. private _useCustomVRButton;
  49990. private _teleportationRequested;
  49991. private _teleportActive;
  49992. private _floorMeshName;
  49993. private _floorMeshesCollection;
  49994. private _teleportationMode;
  49995. private _teleportationTime;
  49996. private _teleportationSpeed;
  49997. private _teleportationEasing;
  49998. private _rotationAllowed;
  49999. private _teleportBackwardsVector;
  50000. private _teleportationTarget;
  50001. private _isDefaultTeleportationTarget;
  50002. private _postProcessMove;
  50003. private _teleportationFillColor;
  50004. private _teleportationBorderColor;
  50005. private _rotationAngle;
  50006. private _haloCenter;
  50007. private _cameraGazer;
  50008. private _padSensibilityUp;
  50009. private _padSensibilityDown;
  50010. private _leftController;
  50011. private _rightController;
  50012. private _gazeColor;
  50013. private _laserColor;
  50014. private _pickedLaserColor;
  50015. private _pickedGazeColor;
  50016. /**
  50017. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50018. */
  50019. onNewMeshSelected: Observable<AbstractMesh>;
  50020. /**
  50021. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50022. * This observable will provide the mesh and the controller used to select the mesh
  50023. */
  50024. onMeshSelectedWithController: Observable<{
  50025. mesh: AbstractMesh;
  50026. controller: WebVRController;
  50027. }>;
  50028. /**
  50029. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50030. */
  50031. onNewMeshPicked: Observable<PickingInfo>;
  50032. private _circleEase;
  50033. /**
  50034. * Observable raised before camera teleportation
  50035. */
  50036. onBeforeCameraTeleport: Observable<Vector3>;
  50037. /**
  50038. * Observable raised after camera teleportation
  50039. */
  50040. onAfterCameraTeleport: Observable<Vector3>;
  50041. /**
  50042. * Observable raised when current selected mesh gets unselected
  50043. */
  50044. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50045. private _raySelectionPredicate;
  50046. /**
  50047. * To be optionaly changed by user to define custom ray selection
  50048. */
  50049. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50050. /**
  50051. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50052. */
  50053. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50054. /**
  50055. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50056. */
  50057. teleportationEnabled: boolean;
  50058. private _defaultHeight;
  50059. private _teleportationInitialized;
  50060. private _interactionsEnabled;
  50061. private _interactionsRequested;
  50062. private _displayGaze;
  50063. private _displayLaserPointer;
  50064. /**
  50065. * The mesh used to display where the user is going to teleport.
  50066. */
  50067. get teleportationTarget(): Mesh;
  50068. /**
  50069. * Sets the mesh to be used to display where the user is going to teleport.
  50070. */
  50071. set teleportationTarget(value: Mesh);
  50072. /**
  50073. * 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
  50074. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50075. * See https://doc.babylonjs.com/resources/baking_transformations
  50076. */
  50077. get gazeTrackerMesh(): Mesh;
  50078. set gazeTrackerMesh(value: Mesh);
  50079. /**
  50080. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50081. */
  50082. updateGazeTrackerScale: boolean;
  50083. /**
  50084. * If the gaze trackers color should be updated when selecting meshes
  50085. */
  50086. updateGazeTrackerColor: boolean;
  50087. /**
  50088. * If the controller laser color should be updated when selecting meshes
  50089. */
  50090. updateControllerLaserColor: boolean;
  50091. /**
  50092. * The gaze tracking mesh corresponding to the left controller
  50093. */
  50094. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50095. /**
  50096. * The gaze tracking mesh corresponding to the right controller
  50097. */
  50098. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50099. /**
  50100. * If the ray of the gaze should be displayed.
  50101. */
  50102. get displayGaze(): boolean;
  50103. /**
  50104. * Sets if the ray of the gaze should be displayed.
  50105. */
  50106. set displayGaze(value: boolean);
  50107. /**
  50108. * If the ray of the LaserPointer should be displayed.
  50109. */
  50110. get displayLaserPointer(): boolean;
  50111. /**
  50112. * Sets if the ray of the LaserPointer should be displayed.
  50113. */
  50114. set displayLaserPointer(value: boolean);
  50115. /**
  50116. * The deviceOrientationCamera used as the camera when not in VR.
  50117. */
  50118. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50119. /**
  50120. * Based on the current WebVR support, returns the current VR camera used.
  50121. */
  50122. get currentVRCamera(): Nullable<Camera>;
  50123. /**
  50124. * The webVRCamera which is used when in VR.
  50125. */
  50126. get webVRCamera(): WebVRFreeCamera;
  50127. /**
  50128. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50129. */
  50130. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50131. /**
  50132. * The html button that is used to trigger entering into VR.
  50133. */
  50134. get vrButton(): Nullable<HTMLButtonElement>;
  50135. private get _teleportationRequestInitiated();
  50136. /**
  50137. * Defines whether or not Pointer lock should be requested when switching to
  50138. * full screen.
  50139. */
  50140. requestPointerLockOnFullScreen: boolean;
  50141. /**
  50142. * If asking to force XR, this will be populated with the default xr experience
  50143. */
  50144. xr: WebXRDefaultExperience;
  50145. /**
  50146. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50147. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50148. */
  50149. xrTestDone: boolean;
  50150. /**
  50151. * Instantiates a VRExperienceHelper.
  50152. * Helps to quickly add VR support to an existing scene.
  50153. * @param scene The scene the VRExperienceHelper belongs to.
  50154. * @param webVROptions Options to modify the vr experience helper's behavior.
  50155. */
  50156. constructor(scene: Scene,
  50157. /** Options to modify the vr experience helper's behavior. */
  50158. webVROptions?: VRExperienceHelperOptions);
  50159. private completeVRInit;
  50160. private _onDefaultMeshLoaded;
  50161. private _onResize;
  50162. private _onFullscreenChange;
  50163. /**
  50164. * Gets a value indicating if we are currently in VR mode.
  50165. */
  50166. get isInVRMode(): boolean;
  50167. private onVrDisplayPresentChange;
  50168. private onVRDisplayChanged;
  50169. private moveButtonToBottomRight;
  50170. private displayVRButton;
  50171. private updateButtonVisibility;
  50172. private _cachedAngularSensibility;
  50173. /**
  50174. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50175. * Otherwise, will use the fullscreen API.
  50176. */
  50177. enterVR(): void;
  50178. /**
  50179. * Attempt to exit VR, or fullscreen.
  50180. */
  50181. exitVR(): void;
  50182. /**
  50183. * The position of the vr experience helper.
  50184. */
  50185. get position(): Vector3;
  50186. /**
  50187. * Sets the position of the vr experience helper.
  50188. */
  50189. set position(value: Vector3);
  50190. /**
  50191. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50192. */
  50193. enableInteractions(): void;
  50194. private get _noControllerIsActive();
  50195. private beforeRender;
  50196. private _isTeleportationFloor;
  50197. /**
  50198. * Adds a floor mesh to be used for teleportation.
  50199. * @param floorMesh the mesh to be used for teleportation.
  50200. */
  50201. addFloorMesh(floorMesh: Mesh): void;
  50202. /**
  50203. * Removes a floor mesh from being used for teleportation.
  50204. * @param floorMesh the mesh to be removed.
  50205. */
  50206. removeFloorMesh(floorMesh: Mesh): void;
  50207. /**
  50208. * Enables interactions and teleportation using the VR controllers and gaze.
  50209. * @param vrTeleportationOptions options to modify teleportation behavior.
  50210. */
  50211. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50212. private _onNewGamepadConnected;
  50213. private _tryEnableInteractionOnController;
  50214. private _onNewGamepadDisconnected;
  50215. private _enableInteractionOnController;
  50216. private _checkTeleportWithRay;
  50217. private _checkRotate;
  50218. private _checkTeleportBackwards;
  50219. private _enableTeleportationOnController;
  50220. private _createTeleportationCircles;
  50221. private _displayTeleportationTarget;
  50222. private _hideTeleportationTarget;
  50223. private _rotateCamera;
  50224. private _moveTeleportationSelectorTo;
  50225. private _workingVector;
  50226. private _workingQuaternion;
  50227. private _workingMatrix;
  50228. /**
  50229. * Time Constant Teleportation Mode
  50230. */
  50231. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50232. /**
  50233. * Speed Constant Teleportation Mode
  50234. */
  50235. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50236. /**
  50237. * Teleports the users feet to the desired location
  50238. * @param location The location where the user's feet should be placed
  50239. */
  50240. teleportCamera(location: Vector3): void;
  50241. private _convertNormalToDirectionOfRay;
  50242. private _castRayAndSelectObject;
  50243. private _notifySelectedMeshUnselected;
  50244. /**
  50245. * Permanently set new colors for the laser pointer
  50246. * @param color the new laser color
  50247. * @param pickedColor the new laser color when picked mesh detected
  50248. */
  50249. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50250. /**
  50251. * Set lighting enabled / disabled on the laser pointer of both controllers
  50252. * @param enabled should the lighting be enabled on the laser pointer
  50253. */
  50254. setLaserLightingState(enabled?: boolean): void;
  50255. /**
  50256. * Permanently set new colors for the gaze pointer
  50257. * @param color the new gaze color
  50258. * @param pickedColor the new gaze color when picked mesh detected
  50259. */
  50260. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50261. /**
  50262. * Sets the color of the laser ray from the vr controllers.
  50263. * @param color new color for the ray.
  50264. */
  50265. changeLaserColor(color: Color3): void;
  50266. /**
  50267. * Sets the color of the ray from the vr headsets gaze.
  50268. * @param color new color for the ray.
  50269. */
  50270. changeGazeColor(color: Color3): void;
  50271. /**
  50272. * Exits VR and disposes of the vr experience helper
  50273. */
  50274. dispose(): void;
  50275. /**
  50276. * Gets the name of the VRExperienceHelper class
  50277. * @returns "VRExperienceHelper"
  50278. */
  50279. getClassName(): string;
  50280. }
  50281. }
  50282. declare module BABYLON {
  50283. /**
  50284. * Contains an array of blocks representing the octree
  50285. */
  50286. export interface IOctreeContainer<T> {
  50287. /**
  50288. * Blocks within the octree
  50289. */
  50290. blocks: Array<OctreeBlock<T>>;
  50291. }
  50292. /**
  50293. * Class used to store a cell in an octree
  50294. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50295. */
  50296. export class OctreeBlock<T> {
  50297. /**
  50298. * Gets the content of the current block
  50299. */
  50300. entries: T[];
  50301. /**
  50302. * Gets the list of block children
  50303. */
  50304. blocks: Array<OctreeBlock<T>>;
  50305. private _depth;
  50306. private _maxDepth;
  50307. private _capacity;
  50308. private _minPoint;
  50309. private _maxPoint;
  50310. private _boundingVectors;
  50311. private _creationFunc;
  50312. /**
  50313. * Creates a new block
  50314. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50315. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50316. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50317. * @param depth defines the current depth of this block in the octree
  50318. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50319. * @param creationFunc defines a callback to call when an element is added to the block
  50320. */
  50321. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50322. /**
  50323. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50324. */
  50325. get capacity(): number;
  50326. /**
  50327. * Gets the minimum vector (in world space) of the block's bounding box
  50328. */
  50329. get minPoint(): Vector3;
  50330. /**
  50331. * Gets the maximum vector (in world space) of the block's bounding box
  50332. */
  50333. get maxPoint(): Vector3;
  50334. /**
  50335. * Add a new element to this block
  50336. * @param entry defines the element to add
  50337. */
  50338. addEntry(entry: T): void;
  50339. /**
  50340. * Remove an element from this block
  50341. * @param entry defines the element to remove
  50342. */
  50343. removeEntry(entry: T): void;
  50344. /**
  50345. * Add an array of elements to this block
  50346. * @param entries defines the array of elements to add
  50347. */
  50348. addEntries(entries: T[]): void;
  50349. /**
  50350. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50351. * @param frustumPlanes defines the frustum planes to test
  50352. * @param selection defines the array to store current content if selection is positive
  50353. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50354. */
  50355. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50356. /**
  50357. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50358. * @param sphereCenter defines the bounding sphere center
  50359. * @param sphereRadius defines the bounding sphere radius
  50360. * @param selection defines the array to store current content if selection is positive
  50361. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50362. */
  50363. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50364. /**
  50365. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50366. * @param ray defines the ray to test with
  50367. * @param selection defines the array to store current content if selection is positive
  50368. */
  50369. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50370. /**
  50371. * Subdivide the content into child blocks (this block will then be empty)
  50372. */
  50373. createInnerBlocks(): void;
  50374. /**
  50375. * @hidden
  50376. */
  50377. 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;
  50378. }
  50379. }
  50380. declare module BABYLON {
  50381. /**
  50382. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50383. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50384. */
  50385. export class Octree<T> {
  50386. /** 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.) */
  50387. maxDepth: number;
  50388. /**
  50389. * Blocks within the octree containing objects
  50390. */
  50391. blocks: Array<OctreeBlock<T>>;
  50392. /**
  50393. * Content stored in the octree
  50394. */
  50395. dynamicContent: T[];
  50396. private _maxBlockCapacity;
  50397. private _selectionContent;
  50398. private _creationFunc;
  50399. /**
  50400. * Creates a octree
  50401. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50402. * @param creationFunc function to be used to instatiate the octree
  50403. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50404. * @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.)
  50405. */
  50406. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50407. /** 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.) */
  50408. maxDepth?: number);
  50409. /**
  50410. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50411. * @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);
  50412. * @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);
  50413. * @param entries meshes to be added to the octree blocks
  50414. */
  50415. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50416. /**
  50417. * Adds a mesh to the octree
  50418. * @param entry Mesh to add to the octree
  50419. */
  50420. addMesh(entry: T): void;
  50421. /**
  50422. * Remove an element from the octree
  50423. * @param entry defines the element to remove
  50424. */
  50425. removeMesh(entry: T): void;
  50426. /**
  50427. * Selects an array of meshes within the frustum
  50428. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50429. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50430. * @returns array of meshes within the frustum
  50431. */
  50432. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50433. /**
  50434. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50435. * @param sphereCenter defines the bounding sphere center
  50436. * @param sphereRadius defines the bounding sphere radius
  50437. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50438. * @returns an array of objects that intersect the sphere
  50439. */
  50440. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50441. /**
  50442. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50443. * @param ray defines the ray to test with
  50444. * @returns array of intersected objects
  50445. */
  50446. intersectsRay(ray: Ray): SmartArray<T>;
  50447. /**
  50448. * Adds a mesh into the octree block if it intersects the block
  50449. */
  50450. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50451. /**
  50452. * Adds a submesh into the octree block if it intersects the block
  50453. */
  50454. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50455. }
  50456. }
  50457. declare module BABYLON {
  50458. interface Scene {
  50459. /**
  50460. * @hidden
  50461. * Backing Filed
  50462. */
  50463. _selectionOctree: Octree<AbstractMesh>;
  50464. /**
  50465. * Gets the octree used to boost mesh selection (picking)
  50466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50467. */
  50468. selectionOctree: Octree<AbstractMesh>;
  50469. /**
  50470. * Creates or updates the octree used to boost selection (picking)
  50471. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50472. * @param maxCapacity defines the maximum capacity per leaf
  50473. * @param maxDepth defines the maximum depth of the octree
  50474. * @returns an octree of AbstractMesh
  50475. */
  50476. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50477. }
  50478. interface AbstractMesh {
  50479. /**
  50480. * @hidden
  50481. * Backing Field
  50482. */
  50483. _submeshesOctree: Octree<SubMesh>;
  50484. /**
  50485. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50486. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50487. * @param maxCapacity defines the maximum size of each block (64 by default)
  50488. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50489. * @returns the new octree
  50490. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50491. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50492. */
  50493. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50494. }
  50495. /**
  50496. * Defines the octree scene component responsible to manage any octrees
  50497. * in a given scene.
  50498. */
  50499. export class OctreeSceneComponent {
  50500. /**
  50501. * The component name help to identify the component in the list of scene components.
  50502. */
  50503. readonly name: string;
  50504. /**
  50505. * The scene the component belongs to.
  50506. */
  50507. scene: Scene;
  50508. /**
  50509. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50510. */
  50511. readonly checksIsEnabled: boolean;
  50512. /**
  50513. * Creates a new instance of the component for the given scene
  50514. * @param scene Defines the scene to register the component in
  50515. */
  50516. constructor(scene: Scene);
  50517. /**
  50518. * Registers the component in a given scene
  50519. */
  50520. register(): void;
  50521. /**
  50522. * Return the list of active meshes
  50523. * @returns the list of active meshes
  50524. */
  50525. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50526. /**
  50527. * Return the list of active sub meshes
  50528. * @param mesh The mesh to get the candidates sub meshes from
  50529. * @returns the list of active sub meshes
  50530. */
  50531. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50532. private _tempRay;
  50533. /**
  50534. * Return the list of sub meshes intersecting with a given local ray
  50535. * @param mesh defines the mesh to find the submesh for
  50536. * @param localRay defines the ray in local space
  50537. * @returns the list of intersecting sub meshes
  50538. */
  50539. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50540. /**
  50541. * Return the list of sub meshes colliding with a collider
  50542. * @param mesh defines the mesh to find the submesh for
  50543. * @param collider defines the collider to evaluate the collision against
  50544. * @returns the list of colliding sub meshes
  50545. */
  50546. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50547. /**
  50548. * Rebuilds the elements related to this component in case of
  50549. * context lost for instance.
  50550. */
  50551. rebuild(): void;
  50552. /**
  50553. * Disposes the component and the associated ressources.
  50554. */
  50555. dispose(): void;
  50556. }
  50557. }
  50558. declare module BABYLON {
  50559. /**
  50560. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50561. */
  50562. export class Gizmo implements IDisposable {
  50563. /** The utility layer the gizmo will be added to */
  50564. gizmoLayer: UtilityLayerRenderer;
  50565. /**
  50566. * The root mesh of the gizmo
  50567. */
  50568. _rootMesh: Mesh;
  50569. private _attachedMesh;
  50570. private _attachedNode;
  50571. /**
  50572. * Ratio for the scale of the gizmo (Default: 1)
  50573. */
  50574. protected _scaleRatio: number;
  50575. /**
  50576. * boolean updated by pointermove when a gizmo mesh is hovered
  50577. */
  50578. protected _isHovered: boolean;
  50579. /**
  50580. * Ratio for the scale of the gizmo (Default: 1)
  50581. */
  50582. set scaleRatio(value: number);
  50583. get scaleRatio(): number;
  50584. /**
  50585. * True when the mouse pointer is hovered a gizmo mesh
  50586. */
  50587. get isHovered(): boolean;
  50588. /**
  50589. * If a custom mesh has been set (Default: false)
  50590. */
  50591. protected _customMeshSet: boolean;
  50592. /**
  50593. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50594. * * When set, interactions will be enabled
  50595. */
  50596. get attachedMesh(): Nullable<AbstractMesh>;
  50597. set attachedMesh(value: Nullable<AbstractMesh>);
  50598. /**
  50599. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50600. * * When set, interactions will be enabled
  50601. */
  50602. get attachedNode(): Nullable<Node>;
  50603. set attachedNode(value: Nullable<Node>);
  50604. /**
  50605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50606. * @param mesh The mesh to replace the default mesh of the gizmo
  50607. */
  50608. setCustomMesh(mesh: Mesh): void;
  50609. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50610. /**
  50611. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50612. */
  50613. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50614. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50615. /**
  50616. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50617. */
  50618. updateGizmoPositionToMatchAttachedMesh: boolean;
  50619. /**
  50620. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50621. */
  50622. updateScale: boolean;
  50623. protected _interactionsEnabled: boolean;
  50624. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50625. private _beforeRenderObserver;
  50626. private _tempQuaternion;
  50627. private _tempVector;
  50628. private _tempVector2;
  50629. private _tempMatrix1;
  50630. private _tempMatrix2;
  50631. private _rightHandtoLeftHandMatrix;
  50632. /**
  50633. * Creates a gizmo
  50634. * @param gizmoLayer The utility layer the gizmo will be added to
  50635. */
  50636. constructor(
  50637. /** The utility layer the gizmo will be added to */
  50638. gizmoLayer?: UtilityLayerRenderer);
  50639. /**
  50640. * Updates the gizmo to match the attached mesh's position/rotation
  50641. */
  50642. protected _update(): void;
  50643. /**
  50644. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50645. * @param value Node, TransformNode or mesh
  50646. */
  50647. protected _matrixChanged(): void;
  50648. /**
  50649. * Disposes of the gizmo
  50650. */
  50651. dispose(): void;
  50652. }
  50653. }
  50654. declare module BABYLON {
  50655. /**
  50656. * Single plane drag gizmo
  50657. */
  50658. export class PlaneDragGizmo extends Gizmo {
  50659. /**
  50660. * Drag behavior responsible for the gizmos dragging interactions
  50661. */
  50662. dragBehavior: PointerDragBehavior;
  50663. private _pointerObserver;
  50664. /**
  50665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50666. */
  50667. snapDistance: number;
  50668. /**
  50669. * Event that fires each time the gizmo snaps to a new location.
  50670. * * snapDistance is the the change in distance
  50671. */
  50672. onSnapObservable: Observable<{
  50673. snapDistance: number;
  50674. }>;
  50675. private _plane;
  50676. private _coloredMaterial;
  50677. private _hoverMaterial;
  50678. private _isEnabled;
  50679. private _parent;
  50680. /** @hidden */
  50681. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50682. /** @hidden */
  50683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50684. /**
  50685. * Creates a PlaneDragGizmo
  50686. * @param gizmoLayer The utility layer the gizmo will be added to
  50687. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50688. * @param color The color of the gizmo
  50689. */
  50690. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50691. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50692. /**
  50693. * If the gizmo is enabled
  50694. */
  50695. set isEnabled(value: boolean);
  50696. get isEnabled(): boolean;
  50697. /**
  50698. * Disposes of the gizmo
  50699. */
  50700. dispose(): void;
  50701. }
  50702. }
  50703. declare module BABYLON {
  50704. /**
  50705. * Gizmo that enables dragging a mesh along 3 axis
  50706. */
  50707. export class PositionGizmo extends Gizmo {
  50708. /**
  50709. * Internal gizmo used for interactions on the x axis
  50710. */
  50711. xGizmo: AxisDragGizmo;
  50712. /**
  50713. * Internal gizmo used for interactions on the y axis
  50714. */
  50715. yGizmo: AxisDragGizmo;
  50716. /**
  50717. * Internal gizmo used for interactions on the z axis
  50718. */
  50719. zGizmo: AxisDragGizmo;
  50720. /**
  50721. * Internal gizmo used for interactions on the yz plane
  50722. */
  50723. xPlaneGizmo: PlaneDragGizmo;
  50724. /**
  50725. * Internal gizmo used for interactions on the xz plane
  50726. */
  50727. yPlaneGizmo: PlaneDragGizmo;
  50728. /**
  50729. * Internal gizmo used for interactions on the xy plane
  50730. */
  50731. zPlaneGizmo: PlaneDragGizmo;
  50732. /**
  50733. * private variables
  50734. */
  50735. private _meshAttached;
  50736. private _nodeAttached;
  50737. private _snapDistance;
  50738. /** Fires an event when any of it's sub gizmos are dragged */
  50739. onDragStartObservable: Observable<unknown>;
  50740. /** Fires an event when any of it's sub gizmos are released from dragging */
  50741. onDragEndObservable: Observable<unknown>;
  50742. /**
  50743. * If set to true, planar drag is enabled
  50744. */
  50745. private _planarGizmoEnabled;
  50746. get attachedMesh(): Nullable<AbstractMesh>;
  50747. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50748. get attachedNode(): Nullable<Node>;
  50749. set attachedNode(node: Nullable<Node>);
  50750. /**
  50751. * True when the mouse pointer is hovering a gizmo mesh
  50752. */
  50753. get isHovered(): boolean;
  50754. /**
  50755. * Creates a PositionGizmo
  50756. * @param gizmoLayer The utility layer the gizmo will be added to
  50757. @param thickness display gizmo axis thickness
  50758. */
  50759. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50760. /**
  50761. * If the planar drag gizmo is enabled
  50762. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50763. */
  50764. set planarGizmoEnabled(value: boolean);
  50765. get planarGizmoEnabled(): boolean;
  50766. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50767. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50768. /**
  50769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50770. */
  50771. set snapDistance(value: number);
  50772. get snapDistance(): number;
  50773. /**
  50774. * Ratio for the scale of the gizmo (Default: 1)
  50775. */
  50776. set scaleRatio(value: number);
  50777. get scaleRatio(): number;
  50778. /**
  50779. * Disposes of the gizmo
  50780. */
  50781. dispose(): void;
  50782. /**
  50783. * CustomMeshes are not supported by this gizmo
  50784. * @param mesh The mesh to replace the default mesh of the gizmo
  50785. */
  50786. setCustomMesh(mesh: Mesh): void;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. /**
  50791. * Single axis drag gizmo
  50792. */
  50793. export class AxisDragGizmo extends Gizmo {
  50794. /**
  50795. * Drag behavior responsible for the gizmos dragging interactions
  50796. */
  50797. dragBehavior: PointerDragBehavior;
  50798. private _pointerObserver;
  50799. /**
  50800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50801. */
  50802. snapDistance: number;
  50803. /**
  50804. * Event that fires each time the gizmo snaps to a new location.
  50805. * * snapDistance is the the change in distance
  50806. */
  50807. onSnapObservable: Observable<{
  50808. snapDistance: number;
  50809. }>;
  50810. private _isEnabled;
  50811. private _parent;
  50812. private _arrow;
  50813. private _coloredMaterial;
  50814. private _hoverMaterial;
  50815. /** @hidden */
  50816. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50817. /** @hidden */
  50818. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50819. /**
  50820. * Creates an AxisDragGizmo
  50821. * @param gizmoLayer The utility layer the gizmo will be added to
  50822. * @param dragAxis The axis which the gizmo will be able to drag on
  50823. * @param color The color of the gizmo
  50824. * @param thickness display gizmo axis thickness
  50825. */
  50826. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50827. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50828. /**
  50829. * If the gizmo is enabled
  50830. */
  50831. set isEnabled(value: boolean);
  50832. get isEnabled(): boolean;
  50833. /**
  50834. * Disposes of the gizmo
  50835. */
  50836. dispose(): void;
  50837. }
  50838. }
  50839. declare module BABYLON.Debug {
  50840. /**
  50841. * The Axes viewer will show 3 axes in a specific point in space
  50842. */
  50843. export class AxesViewer {
  50844. private _xAxis;
  50845. private _yAxis;
  50846. private _zAxis;
  50847. private _scaleLinesFactor;
  50848. private _instanced;
  50849. /**
  50850. * Gets the hosting scene
  50851. */
  50852. scene: Nullable<Scene>;
  50853. /**
  50854. * Gets or sets a number used to scale line length
  50855. */
  50856. scaleLines: number;
  50857. /** Gets the node hierarchy used to render x-axis */
  50858. get xAxis(): TransformNode;
  50859. /** Gets the node hierarchy used to render y-axis */
  50860. get yAxis(): TransformNode;
  50861. /** Gets the node hierarchy used to render z-axis */
  50862. get zAxis(): TransformNode;
  50863. /**
  50864. * Creates a new AxesViewer
  50865. * @param scene defines the hosting scene
  50866. * @param scaleLines defines a number used to scale line length (1 by default)
  50867. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50868. * @param xAxis defines the node hierarchy used to render the x-axis
  50869. * @param yAxis defines the node hierarchy used to render the y-axis
  50870. * @param zAxis defines the node hierarchy used to render the z-axis
  50871. */
  50872. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50873. /**
  50874. * Force the viewer to update
  50875. * @param position defines the position of the viewer
  50876. * @param xaxis defines the x axis of the viewer
  50877. * @param yaxis defines the y axis of the viewer
  50878. * @param zaxis defines the z axis of the viewer
  50879. */
  50880. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50881. /**
  50882. * Creates an instance of this axes viewer.
  50883. * @returns a new axes viewer with instanced meshes
  50884. */
  50885. createInstance(): AxesViewer;
  50886. /** Releases resources */
  50887. dispose(): void;
  50888. private static _SetRenderingGroupId;
  50889. }
  50890. }
  50891. declare module BABYLON.Debug {
  50892. /**
  50893. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50894. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50895. */
  50896. export class BoneAxesViewer extends AxesViewer {
  50897. /**
  50898. * Gets or sets the target mesh where to display the axes viewer
  50899. */
  50900. mesh: Nullable<Mesh>;
  50901. /**
  50902. * Gets or sets the target bone where to display the axes viewer
  50903. */
  50904. bone: Nullable<Bone>;
  50905. /** Gets current position */
  50906. pos: Vector3;
  50907. /** Gets direction of X axis */
  50908. xaxis: Vector3;
  50909. /** Gets direction of Y axis */
  50910. yaxis: Vector3;
  50911. /** Gets direction of Z axis */
  50912. zaxis: Vector3;
  50913. /**
  50914. * Creates a new BoneAxesViewer
  50915. * @param scene defines the hosting scene
  50916. * @param bone defines the target bone
  50917. * @param mesh defines the target mesh
  50918. * @param scaleLines defines a scaling factor for line length (1 by default)
  50919. */
  50920. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50921. /**
  50922. * Force the viewer to update
  50923. */
  50924. update(): void;
  50925. /** Releases resources */
  50926. dispose(): void;
  50927. }
  50928. }
  50929. declare module BABYLON {
  50930. /**
  50931. * Interface used to define scene explorer extensibility option
  50932. */
  50933. export interface IExplorerExtensibilityOption {
  50934. /**
  50935. * Define the option label
  50936. */
  50937. label: string;
  50938. /**
  50939. * Defines the action to execute on click
  50940. */
  50941. action: (entity: any) => void;
  50942. }
  50943. /**
  50944. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50945. */
  50946. export interface IExplorerExtensibilityGroup {
  50947. /**
  50948. * Defines a predicate to test if a given type mut be extended
  50949. */
  50950. predicate: (entity: any) => boolean;
  50951. /**
  50952. * Gets the list of options added to a type
  50953. */
  50954. entries: IExplorerExtensibilityOption[];
  50955. }
  50956. /**
  50957. * Interface used to define the options to use to create the Inspector
  50958. */
  50959. export interface IInspectorOptions {
  50960. /**
  50961. * Display in overlay mode (default: false)
  50962. */
  50963. overlay?: boolean;
  50964. /**
  50965. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50966. */
  50967. globalRoot?: HTMLElement;
  50968. /**
  50969. * Display the Scene explorer
  50970. */
  50971. showExplorer?: boolean;
  50972. /**
  50973. * Display the property inspector
  50974. */
  50975. showInspector?: boolean;
  50976. /**
  50977. * Display in embed mode (both panes on the right)
  50978. */
  50979. embedMode?: boolean;
  50980. /**
  50981. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50982. */
  50983. handleResize?: boolean;
  50984. /**
  50985. * Allow the panes to popup (default: true)
  50986. */
  50987. enablePopup?: boolean;
  50988. /**
  50989. * Allow the panes to be closed by users (default: true)
  50990. */
  50991. enableClose?: boolean;
  50992. /**
  50993. * Optional list of extensibility entries
  50994. */
  50995. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50996. /**
  50997. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50998. */
  50999. inspectorURL?: string;
  51000. /**
  51001. * Optional initial tab (default to DebugLayerTab.Properties)
  51002. */
  51003. initialTab?: DebugLayerTab;
  51004. }
  51005. interface Scene {
  51006. /**
  51007. * @hidden
  51008. * Backing field
  51009. */
  51010. _debugLayer: DebugLayer;
  51011. /**
  51012. * Gets the debug layer (aka Inspector) associated with the scene
  51013. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51014. */
  51015. debugLayer: DebugLayer;
  51016. }
  51017. /**
  51018. * Enum of inspector action tab
  51019. */
  51020. export enum DebugLayerTab {
  51021. /**
  51022. * Properties tag (default)
  51023. */
  51024. Properties = 0,
  51025. /**
  51026. * Debug tab
  51027. */
  51028. Debug = 1,
  51029. /**
  51030. * Statistics tab
  51031. */
  51032. Statistics = 2,
  51033. /**
  51034. * Tools tab
  51035. */
  51036. Tools = 3,
  51037. /**
  51038. * Settings tab
  51039. */
  51040. Settings = 4
  51041. }
  51042. /**
  51043. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51044. * what is happening in your scene
  51045. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51046. */
  51047. export class DebugLayer {
  51048. /**
  51049. * Define the url to get the inspector script from.
  51050. * By default it uses the babylonjs CDN.
  51051. * @ignoreNaming
  51052. */
  51053. static InspectorURL: string;
  51054. private _scene;
  51055. private BJSINSPECTOR;
  51056. private _onPropertyChangedObservable?;
  51057. /**
  51058. * Observable triggered when a property is changed through the inspector.
  51059. */
  51060. get onPropertyChangedObservable(): any;
  51061. /**
  51062. * Instantiates a new debug layer.
  51063. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51064. * what is happening in your scene
  51065. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51066. * @param scene Defines the scene to inspect
  51067. */
  51068. constructor(scene: Scene);
  51069. /** Creates the inspector window. */
  51070. private _createInspector;
  51071. /**
  51072. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51073. * @param entity defines the entity to select
  51074. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51075. */
  51076. select(entity: any, lineContainerTitles?: string | string[]): void;
  51077. /** Get the inspector from bundle or global */
  51078. private _getGlobalInspector;
  51079. /**
  51080. * Get if the inspector is visible or not.
  51081. * @returns true if visible otherwise, false
  51082. */
  51083. isVisible(): boolean;
  51084. /**
  51085. * Hide the inspector and close its window.
  51086. */
  51087. hide(): void;
  51088. /**
  51089. * Update the scene in the inspector
  51090. */
  51091. setAsActiveScene(): void;
  51092. /**
  51093. * Launch the debugLayer.
  51094. * @param config Define the configuration of the inspector
  51095. * @return a promise fulfilled when the debug layer is visible
  51096. */
  51097. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51098. }
  51099. }
  51100. declare module BABYLON {
  51101. /**
  51102. * Class containing static functions to help procedurally build meshes
  51103. */
  51104. export class BoxBuilder {
  51105. /**
  51106. * Creates a box mesh
  51107. * * The parameter `size` sets the size (float) of each box side (default 1)
  51108. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51109. * * 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)
  51110. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51112. * * 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
  51113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51114. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51115. * @param name defines the name of the mesh
  51116. * @param options defines the options used to create the mesh
  51117. * @param scene defines the hosting scene
  51118. * @returns the box mesh
  51119. */
  51120. static CreateBox(name: string, options: {
  51121. size?: number;
  51122. width?: number;
  51123. height?: number;
  51124. depth?: number;
  51125. faceUV?: Vector4[];
  51126. faceColors?: Color4[];
  51127. sideOrientation?: number;
  51128. frontUVs?: Vector4;
  51129. backUVs?: Vector4;
  51130. wrap?: boolean;
  51131. topBaseAt?: number;
  51132. bottomBaseAt?: number;
  51133. updatable?: boolean;
  51134. }, scene?: Nullable<Scene>): Mesh;
  51135. }
  51136. }
  51137. declare module BABYLON.Debug {
  51138. /**
  51139. * Used to show the physics impostor around the specific mesh
  51140. */
  51141. export class PhysicsViewer {
  51142. /** @hidden */
  51143. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51144. /** @hidden */
  51145. protected _meshes: Array<Nullable<AbstractMesh>>;
  51146. /** @hidden */
  51147. protected _scene: Nullable<Scene>;
  51148. /** @hidden */
  51149. protected _numMeshes: number;
  51150. /** @hidden */
  51151. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51152. private _renderFunction;
  51153. private _utilityLayer;
  51154. private _debugBoxMesh;
  51155. private _debugSphereMesh;
  51156. private _debugCylinderMesh;
  51157. private _debugMaterial;
  51158. private _debugMeshMeshes;
  51159. /**
  51160. * Creates a new PhysicsViewer
  51161. * @param scene defines the hosting scene
  51162. */
  51163. constructor(scene: Scene);
  51164. /** @hidden */
  51165. protected _updateDebugMeshes(): void;
  51166. /**
  51167. * Renders a specified physic impostor
  51168. * @param impostor defines the impostor to render
  51169. * @param targetMesh defines the mesh represented by the impostor
  51170. * @returns the new debug mesh used to render the impostor
  51171. */
  51172. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51173. /**
  51174. * Hides a specified physic impostor
  51175. * @param impostor defines the impostor to hide
  51176. */
  51177. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51178. private _getDebugMaterial;
  51179. private _getDebugBoxMesh;
  51180. private _getDebugSphereMesh;
  51181. private _getDebugCylinderMesh;
  51182. private _getDebugMeshMesh;
  51183. private _getDebugMesh;
  51184. /** Releases all resources */
  51185. dispose(): void;
  51186. }
  51187. }
  51188. declare module BABYLON {
  51189. /**
  51190. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51191. * in order to better appreciate the issue one might have.
  51192. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51193. */
  51194. export class RayHelper {
  51195. /**
  51196. * Defines the ray we are currently tryin to visualize.
  51197. */
  51198. ray: Nullable<Ray>;
  51199. private _renderPoints;
  51200. private _renderLine;
  51201. private _renderFunction;
  51202. private _scene;
  51203. private _onAfterRenderObserver;
  51204. private _onAfterStepObserver;
  51205. private _attachedToMesh;
  51206. private _meshSpaceDirection;
  51207. private _meshSpaceOrigin;
  51208. /**
  51209. * Helper function to create a colored helper in a scene in one line.
  51210. * @param ray Defines the ray we are currently tryin to visualize
  51211. * @param scene Defines the scene the ray is used in
  51212. * @param color Defines the color we want to see the ray in
  51213. * @returns The newly created ray helper.
  51214. */
  51215. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51216. /**
  51217. * Instantiate a new ray helper.
  51218. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51219. * in order to better appreciate the issue one might have.
  51220. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51221. * @param ray Defines the ray we are currently tryin to visualize
  51222. */
  51223. constructor(ray: Ray);
  51224. /**
  51225. * Shows the ray we are willing to debug.
  51226. * @param scene Defines the scene the ray needs to be rendered in
  51227. * @param color Defines the color the ray needs to be rendered in
  51228. */
  51229. show(scene: Scene, color?: Color3): void;
  51230. /**
  51231. * Hides the ray we are debugging.
  51232. */
  51233. hide(): void;
  51234. private _render;
  51235. /**
  51236. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51237. * @param mesh Defines the mesh we want the helper attached to
  51238. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51239. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51240. * @param length Defines the length of the ray
  51241. */
  51242. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51243. /**
  51244. * Detach the ray helper from the mesh it has previously been attached to.
  51245. */
  51246. detachFromMesh(): void;
  51247. private _updateToMesh;
  51248. /**
  51249. * Dispose the helper and release its associated resources.
  51250. */
  51251. dispose(): void;
  51252. }
  51253. }
  51254. declare module BABYLON {
  51255. /**
  51256. * Defines the options associated with the creation of a SkeletonViewer.
  51257. */
  51258. export interface ISkeletonViewerOptions {
  51259. /** Should the system pause animations before building the Viewer? */
  51260. pauseAnimations: boolean;
  51261. /** Should the system return the skeleton to rest before building? */
  51262. returnToRest: boolean;
  51263. /** public Display Mode of the Viewer */
  51264. displayMode: number;
  51265. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51266. displayOptions: ISkeletonViewerDisplayOptions;
  51267. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51268. computeBonesUsingShaders: boolean;
  51269. /** Flag ignore non weighted bones */
  51270. useAllBones: boolean;
  51271. }
  51272. /**
  51273. * Defines how to display the various bone meshes for the viewer.
  51274. */
  51275. export interface ISkeletonViewerDisplayOptions {
  51276. /** How far down to start tapering the bone spurs */
  51277. midStep?: number;
  51278. /** How big is the midStep? */
  51279. midStepFactor?: number;
  51280. /** Base for the Sphere Size */
  51281. sphereBaseSize?: number;
  51282. /** The ratio of the sphere to the longest bone in units */
  51283. sphereScaleUnit?: number;
  51284. /** Ratio for the Sphere Size */
  51285. sphereFactor?: number;
  51286. /** Whether a spur should attach its far end to the child bone position */
  51287. spurFollowsChild?: boolean;
  51288. /** Whether to show local axes or not */
  51289. showLocalAxes?: boolean;
  51290. /** Length of each local axis */
  51291. localAxesSize?: number;
  51292. }
  51293. /**
  51294. * Defines the constructor options for the BoneWeight Shader.
  51295. */
  51296. export interface IBoneWeightShaderOptions {
  51297. /** Skeleton to Map */
  51298. skeleton: Skeleton;
  51299. /** Colors for Uninfluenced bones */
  51300. colorBase?: Color3;
  51301. /** Colors for 0.0-0.25 Weight bones */
  51302. colorZero?: Color3;
  51303. /** Color for 0.25-0.5 Weight Influence */
  51304. colorQuarter?: Color3;
  51305. /** Color for 0.5-0.75 Weight Influence */
  51306. colorHalf?: Color3;
  51307. /** Color for 0.75-1 Weight Influence */
  51308. colorFull?: Color3;
  51309. /** Color for Zero Weight Influence */
  51310. targetBoneIndex?: number;
  51311. }
  51312. /**
  51313. * Simple structure of the gradient steps for the Color Map.
  51314. */
  51315. export interface ISkeletonMapShaderColorMapKnot {
  51316. /** Color of the Knot */
  51317. color: Color3;
  51318. /** Location of the Knot */
  51319. location: number;
  51320. }
  51321. /**
  51322. * Defines the constructor options for the SkeletonMap Shader.
  51323. */
  51324. export interface ISkeletonMapShaderOptions {
  51325. /** Skeleton to Map */
  51326. skeleton: Skeleton;
  51327. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51328. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51329. }
  51330. }
  51331. declare module BABYLON {
  51332. /**
  51333. * Class containing static functions to help procedurally build meshes
  51334. */
  51335. export class RibbonBuilder {
  51336. /**
  51337. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51338. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51339. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51340. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51341. * * 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
  51342. * * 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
  51343. * * 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
  51344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51345. * * 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
  51346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51347. * * 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
  51348. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51349. * * 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
  51350. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51352. * @param name defines the name of the mesh
  51353. * @param options defines the options used to create the mesh
  51354. * @param scene defines the hosting scene
  51355. * @returns the ribbon mesh
  51356. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51357. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51358. */
  51359. static CreateRibbon(name: string, options: {
  51360. pathArray: Vector3[][];
  51361. closeArray?: boolean;
  51362. closePath?: boolean;
  51363. offset?: number;
  51364. updatable?: boolean;
  51365. sideOrientation?: number;
  51366. frontUVs?: Vector4;
  51367. backUVs?: Vector4;
  51368. instance?: Mesh;
  51369. invertUV?: boolean;
  51370. uvs?: Vector2[];
  51371. colors?: Color4[];
  51372. }, scene?: Nullable<Scene>): Mesh;
  51373. }
  51374. }
  51375. declare module BABYLON {
  51376. /**
  51377. * Class containing static functions to help procedurally build meshes
  51378. */
  51379. export class ShapeBuilder {
  51380. /**
  51381. * 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.
  51382. * * 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.
  51383. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51384. * * 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.
  51385. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51386. * * 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
  51387. * * 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
  51388. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51390. * * 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
  51391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51393. * @param name defines the name of the mesh
  51394. * @param options defines the options used to create the mesh
  51395. * @param scene defines the hosting scene
  51396. * @returns the extruded shape mesh
  51397. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51399. */
  51400. static ExtrudeShape(name: string, options: {
  51401. shape: Vector3[];
  51402. path: Vector3[];
  51403. scale?: number;
  51404. rotation?: number;
  51405. cap?: number;
  51406. updatable?: boolean;
  51407. sideOrientation?: number;
  51408. frontUVs?: Vector4;
  51409. backUVs?: Vector4;
  51410. instance?: Mesh;
  51411. invertUV?: boolean;
  51412. }, scene?: Nullable<Scene>): Mesh;
  51413. /**
  51414. * Creates an custom extruded shape mesh.
  51415. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51416. * * 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.
  51417. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51418. * * 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
  51419. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51420. * * 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
  51421. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51422. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51423. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51424. * * 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
  51425. * * 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
  51426. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51428. * * 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
  51429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51431. * @param name defines the name of the mesh
  51432. * @param options defines the options used to create the mesh
  51433. * @param scene defines the hosting scene
  51434. * @returns the custom extruded shape mesh
  51435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51438. */
  51439. static ExtrudeShapeCustom(name: string, options: {
  51440. shape: Vector3[];
  51441. path: Vector3[];
  51442. scaleFunction?: any;
  51443. rotationFunction?: any;
  51444. ribbonCloseArray?: boolean;
  51445. ribbonClosePath?: boolean;
  51446. cap?: number;
  51447. updatable?: boolean;
  51448. sideOrientation?: number;
  51449. frontUVs?: Vector4;
  51450. backUVs?: Vector4;
  51451. instance?: Mesh;
  51452. invertUV?: boolean;
  51453. }, scene?: Nullable<Scene>): Mesh;
  51454. private static _ExtrudeShapeGeneric;
  51455. }
  51456. }
  51457. declare module BABYLON.Debug {
  51458. /**
  51459. * Class used to render a debug view of a given skeleton
  51460. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51461. */
  51462. export class SkeletonViewer {
  51463. /** defines the skeleton to render */
  51464. skeleton: Skeleton;
  51465. /** defines the mesh attached to the skeleton */
  51466. mesh: AbstractMesh;
  51467. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51468. autoUpdateBonesMatrices: boolean;
  51469. /** defines the rendering group id to use with the viewer */
  51470. renderingGroupId: number;
  51471. /** is the options for the viewer */
  51472. options: Partial<ISkeletonViewerOptions>;
  51473. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51474. static readonly DISPLAY_LINES: number;
  51475. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51476. static readonly DISPLAY_SPHERES: number;
  51477. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51478. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51479. /** public static method to create a BoneWeight Shader
  51480. * @param options The constructor options
  51481. * @param scene The scene that the shader is scoped to
  51482. * @returns The created ShaderMaterial
  51483. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51484. */
  51485. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51486. /** public static method to create a BoneWeight Shader
  51487. * @param options The constructor options
  51488. * @param scene The scene that the shader is scoped to
  51489. * @returns The created ShaderMaterial
  51490. */
  51491. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51492. /** private static method to create a BoneWeight Shader
  51493. * @param size The size of the buffer to create (usually the bone count)
  51494. * @param colorMap The gradient data to generate
  51495. * @param scene The scene that the shader is scoped to
  51496. * @returns an Array of floats from the color gradient values
  51497. */
  51498. private static _CreateBoneMapColorBuffer;
  51499. /** If SkeletonViewer scene scope. */
  51500. private _scene;
  51501. /** Gets or sets the color used to render the skeleton */
  51502. color: Color3;
  51503. /** Array of the points of the skeleton fo the line view. */
  51504. private _debugLines;
  51505. /** The SkeletonViewers Mesh. */
  51506. private _debugMesh;
  51507. /** The local axes Meshes. */
  51508. private _localAxes;
  51509. /** If SkeletonViewer is enabled. */
  51510. private _isEnabled;
  51511. /** If SkeletonViewer is ready. */
  51512. private _ready;
  51513. /** SkeletonViewer render observable. */
  51514. private _obs;
  51515. /** The Utility Layer to render the gizmos in. */
  51516. private _utilityLayer;
  51517. private _boneIndices;
  51518. /** Gets the Scene. */
  51519. get scene(): Scene;
  51520. /** Gets the utilityLayer. */
  51521. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51522. /** Checks Ready Status. */
  51523. get isReady(): Boolean;
  51524. /** Sets Ready Status. */
  51525. set ready(value: boolean);
  51526. /** Gets the debugMesh */
  51527. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51528. /** Sets the debugMesh */
  51529. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51530. /** Gets the displayMode */
  51531. get displayMode(): number;
  51532. /** Sets the displayMode */
  51533. set displayMode(value: number);
  51534. /**
  51535. * Creates a new SkeletonViewer
  51536. * @param skeleton defines the skeleton to render
  51537. * @param mesh defines the mesh attached to the skeleton
  51538. * @param scene defines the hosting scene
  51539. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51540. * @param renderingGroupId defines the rendering group id to use with the viewer
  51541. * @param options All of the extra constructor options for the SkeletonViewer
  51542. */
  51543. constructor(
  51544. /** defines the skeleton to render */
  51545. skeleton: Skeleton,
  51546. /** defines the mesh attached to the skeleton */
  51547. mesh: AbstractMesh,
  51548. /** The Scene scope*/
  51549. scene: Scene,
  51550. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51551. autoUpdateBonesMatrices?: boolean,
  51552. /** defines the rendering group id to use with the viewer */
  51553. renderingGroupId?: number,
  51554. /** is the options for the viewer */
  51555. options?: Partial<ISkeletonViewerOptions>);
  51556. /** The Dynamic bindings for the update functions */
  51557. private _bindObs;
  51558. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51559. update(): void;
  51560. /** Gets or sets a boolean indicating if the viewer is enabled */
  51561. set isEnabled(value: boolean);
  51562. get isEnabled(): boolean;
  51563. private _getBonePosition;
  51564. private _getLinesForBonesWithLength;
  51565. private _getLinesForBonesNoLength;
  51566. /** function to revert the mesh and scene back to the initial state. */
  51567. private _revert;
  51568. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  51569. private _getAbsoluteBindPoseToRef;
  51570. /** function to build and bind sphere joint points and spur bone representations. */
  51571. private _buildSpheresAndSpurs;
  51572. private _buildLocalAxes;
  51573. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51574. private _displayLinesUpdate;
  51575. /** Changes the displayMode of the skeleton viewer
  51576. * @param mode The displayMode numerical value
  51577. */
  51578. changeDisplayMode(mode: number): void;
  51579. /** Sets a display option of the skeleton viewer
  51580. *
  51581. * | Option | Type | Default | Description |
  51582. * | ---------------- | ------- | ------- | ----------- |
  51583. * | 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`. |
  51584. * | 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`. |
  51585. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51586. * | 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`. |
  51587. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  51588. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51589. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51590. *
  51591. * @param option String of the option name
  51592. * @param value The numerical option value
  51593. */
  51594. changeDisplayOptions(option: string, value: number): void;
  51595. /** Release associated resources */
  51596. dispose(): void;
  51597. }
  51598. }
  51599. declare module BABYLON {
  51600. /**
  51601. * Enum for Device Types
  51602. */
  51603. export enum DeviceType {
  51604. /** Generic */
  51605. Generic = 0,
  51606. /** Keyboard */
  51607. Keyboard = 1,
  51608. /** Mouse */
  51609. Mouse = 2,
  51610. /** Touch Pointers */
  51611. Touch = 3,
  51612. /** PS4 Dual Shock */
  51613. DualShock = 4,
  51614. /** Xbox */
  51615. Xbox = 5,
  51616. /** Switch Controller */
  51617. Switch = 6
  51618. }
  51619. /**
  51620. * Enum for All Pointers (Touch/Mouse)
  51621. */
  51622. export enum PointerInput {
  51623. /** Horizontal Axis */
  51624. Horizontal = 0,
  51625. /** Vertical Axis */
  51626. Vertical = 1,
  51627. /** Left Click or Touch */
  51628. LeftClick = 2,
  51629. /** Middle Click */
  51630. MiddleClick = 3,
  51631. /** Right Click */
  51632. RightClick = 4,
  51633. /** Browser Back */
  51634. BrowserBack = 5,
  51635. /** Browser Forward */
  51636. BrowserForward = 6
  51637. }
  51638. /**
  51639. * Enum for Dual Shock Gamepad
  51640. */
  51641. export enum DualShockInput {
  51642. /** Cross */
  51643. Cross = 0,
  51644. /** Circle */
  51645. Circle = 1,
  51646. /** Square */
  51647. Square = 2,
  51648. /** Triangle */
  51649. Triangle = 3,
  51650. /** L1 */
  51651. L1 = 4,
  51652. /** R1 */
  51653. R1 = 5,
  51654. /** L2 */
  51655. L2 = 6,
  51656. /** R2 */
  51657. R2 = 7,
  51658. /** Share */
  51659. Share = 8,
  51660. /** Options */
  51661. Options = 9,
  51662. /** L3 */
  51663. L3 = 10,
  51664. /** R3 */
  51665. R3 = 11,
  51666. /** DPadUp */
  51667. DPadUp = 12,
  51668. /** DPadDown */
  51669. DPadDown = 13,
  51670. /** DPadLeft */
  51671. DPadLeft = 14,
  51672. /** DRight */
  51673. DPadRight = 15,
  51674. /** Home */
  51675. Home = 16,
  51676. /** TouchPad */
  51677. TouchPad = 17,
  51678. /** LStickXAxis */
  51679. LStickXAxis = 18,
  51680. /** LStickYAxis */
  51681. LStickYAxis = 19,
  51682. /** RStickXAxis */
  51683. RStickXAxis = 20,
  51684. /** RStickYAxis */
  51685. RStickYAxis = 21
  51686. }
  51687. /**
  51688. * Enum for Xbox Gamepad
  51689. */
  51690. export enum XboxInput {
  51691. /** A */
  51692. A = 0,
  51693. /** B */
  51694. B = 1,
  51695. /** X */
  51696. X = 2,
  51697. /** Y */
  51698. Y = 3,
  51699. /** LB */
  51700. LB = 4,
  51701. /** RB */
  51702. RB = 5,
  51703. /** LT */
  51704. LT = 6,
  51705. /** RT */
  51706. RT = 7,
  51707. /** Back */
  51708. Back = 8,
  51709. /** Start */
  51710. Start = 9,
  51711. /** LS */
  51712. LS = 10,
  51713. /** RS */
  51714. RS = 11,
  51715. /** DPadUp */
  51716. DPadUp = 12,
  51717. /** DPadDown */
  51718. DPadDown = 13,
  51719. /** DPadLeft */
  51720. DPadLeft = 14,
  51721. /** DRight */
  51722. DPadRight = 15,
  51723. /** Home */
  51724. Home = 16,
  51725. /** LStickXAxis */
  51726. LStickXAxis = 17,
  51727. /** LStickYAxis */
  51728. LStickYAxis = 18,
  51729. /** RStickXAxis */
  51730. RStickXAxis = 19,
  51731. /** RStickYAxis */
  51732. RStickYAxis = 20
  51733. }
  51734. /**
  51735. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51736. */
  51737. export enum SwitchInput {
  51738. /** B */
  51739. B = 0,
  51740. /** A */
  51741. A = 1,
  51742. /** Y */
  51743. Y = 2,
  51744. /** X */
  51745. X = 3,
  51746. /** L */
  51747. L = 4,
  51748. /** R */
  51749. R = 5,
  51750. /** ZL */
  51751. ZL = 6,
  51752. /** ZR */
  51753. ZR = 7,
  51754. /** Minus */
  51755. Minus = 8,
  51756. /** Plus */
  51757. Plus = 9,
  51758. /** LS */
  51759. LS = 10,
  51760. /** RS */
  51761. RS = 11,
  51762. /** DPadUp */
  51763. DPadUp = 12,
  51764. /** DPadDown */
  51765. DPadDown = 13,
  51766. /** DPadLeft */
  51767. DPadLeft = 14,
  51768. /** DRight */
  51769. DPadRight = 15,
  51770. /** Home */
  51771. Home = 16,
  51772. /** Capture */
  51773. Capture = 17,
  51774. /** LStickXAxis */
  51775. LStickXAxis = 18,
  51776. /** LStickYAxis */
  51777. LStickYAxis = 19,
  51778. /** RStickXAxis */
  51779. RStickXAxis = 20,
  51780. /** RStickYAxis */
  51781. RStickYAxis = 21
  51782. }
  51783. }
  51784. declare module BABYLON {
  51785. /**
  51786. * This class will take all inputs from Keyboard, Pointer, and
  51787. * any Gamepads and provide a polling system that all devices
  51788. * will use. This class assumes that there will only be one
  51789. * pointer device and one keyboard.
  51790. */
  51791. export class DeviceInputSystem implements IDisposable {
  51792. /**
  51793. * Callback to be triggered when a device is connected
  51794. */
  51795. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51796. /**
  51797. * Callback to be triggered when a device is disconnected
  51798. */
  51799. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51800. /**
  51801. * Callback to be triggered when event driven input is updated
  51802. */
  51803. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51804. private _inputs;
  51805. private _gamepads;
  51806. private _keyboardActive;
  51807. private _pointerActive;
  51808. private _elementToAttachTo;
  51809. private _keyboardDownEvent;
  51810. private _keyboardUpEvent;
  51811. private _pointerMoveEvent;
  51812. private _pointerDownEvent;
  51813. private _pointerUpEvent;
  51814. private _gamepadConnectedEvent;
  51815. private _gamepadDisconnectedEvent;
  51816. private static _MAX_KEYCODES;
  51817. private static _MAX_POINTER_INPUTS;
  51818. private constructor();
  51819. /**
  51820. * Creates a new DeviceInputSystem instance
  51821. * @param engine Engine to pull input element from
  51822. * @returns The new instance
  51823. */
  51824. static Create(engine: Engine): DeviceInputSystem;
  51825. /**
  51826. * Checks for current device input value, given an id and input index
  51827. * @param deviceName Id of connected device
  51828. * @param inputIndex Index of device input
  51829. * @returns Current value of input
  51830. */
  51831. /**
  51832. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51833. * @param deviceType Enum specifiying device type
  51834. * @param deviceSlot "Slot" or index that device is referenced in
  51835. * @param inputIndex Id of input to be checked
  51836. * @returns Current value of input
  51837. */
  51838. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51839. /**
  51840. * Dispose of all the eventlisteners
  51841. */
  51842. dispose(): void;
  51843. /**
  51844. * Add device and inputs to device array
  51845. * @param deviceType Enum specifiying device type
  51846. * @param deviceSlot "Slot" or index that device is referenced in
  51847. * @param numberOfInputs Number of input entries to create for given device
  51848. */
  51849. private _registerDevice;
  51850. /**
  51851. * Given a specific device name, remove that device from the device map
  51852. * @param deviceType Enum specifiying device type
  51853. * @param deviceSlot "Slot" or index that device is referenced in
  51854. */
  51855. private _unregisterDevice;
  51856. /**
  51857. * Handle all actions that come from keyboard interaction
  51858. */
  51859. private _handleKeyActions;
  51860. /**
  51861. * Handle all actions that come from pointer interaction
  51862. */
  51863. private _handlePointerActions;
  51864. /**
  51865. * Handle all actions that come from gamepad interaction
  51866. */
  51867. private _handleGamepadActions;
  51868. /**
  51869. * Update all non-event based devices with each frame
  51870. * @param deviceType Enum specifiying device type
  51871. * @param deviceSlot "Slot" or index that device is referenced in
  51872. * @param inputIndex Id of input to be checked
  51873. */
  51874. private _updateDevice;
  51875. /**
  51876. * Gets DeviceType from the device name
  51877. * @param deviceName Name of Device from DeviceInputSystem
  51878. * @returns DeviceType enum value
  51879. */
  51880. private _getGamepadDeviceType;
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * Type to handle enforcement of inputs
  51886. */
  51887. 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;
  51888. }
  51889. declare module BABYLON {
  51890. /**
  51891. * Class that handles all input for a specific device
  51892. */
  51893. export class DeviceSource<T extends DeviceType> {
  51894. /** Type of device */
  51895. readonly deviceType: DeviceType;
  51896. /** "Slot" or index that device is referenced in */
  51897. readonly deviceSlot: number;
  51898. /**
  51899. * Observable to handle device input changes per device
  51900. */
  51901. readonly onInputChangedObservable: Observable<{
  51902. inputIndex: DeviceInput<T>;
  51903. previousState: Nullable<number>;
  51904. currentState: Nullable<number>;
  51905. }>;
  51906. private readonly _deviceInputSystem;
  51907. /**
  51908. * Default Constructor
  51909. * @param deviceInputSystem Reference to DeviceInputSystem
  51910. * @param deviceType Type of device
  51911. * @param deviceSlot "Slot" or index that device is referenced in
  51912. */
  51913. constructor(deviceInputSystem: DeviceInputSystem,
  51914. /** Type of device */
  51915. deviceType: DeviceType,
  51916. /** "Slot" or index that device is referenced in */
  51917. deviceSlot?: number);
  51918. /**
  51919. * Get input for specific input
  51920. * @param inputIndex index of specific input on device
  51921. * @returns Input value from DeviceInputSystem
  51922. */
  51923. getInput(inputIndex: DeviceInput<T>): number;
  51924. }
  51925. /**
  51926. * Class to keep track of devices
  51927. */
  51928. export class DeviceSourceManager implements IDisposable {
  51929. /**
  51930. * Observable to be triggered when before a device is connected
  51931. */
  51932. readonly onBeforeDeviceConnectedObservable: Observable<{
  51933. deviceType: DeviceType;
  51934. deviceSlot: number;
  51935. }>;
  51936. /**
  51937. * Observable to be triggered when before a device is disconnected
  51938. */
  51939. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51940. deviceType: DeviceType;
  51941. deviceSlot: number;
  51942. }>;
  51943. /**
  51944. * Observable to be triggered when after a device is connected
  51945. */
  51946. readonly onAfterDeviceConnectedObservable: Observable<{
  51947. deviceType: DeviceType;
  51948. deviceSlot: number;
  51949. }>;
  51950. /**
  51951. * Observable to be triggered when after a device is disconnected
  51952. */
  51953. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51954. deviceType: DeviceType;
  51955. deviceSlot: number;
  51956. }>;
  51957. private readonly _devices;
  51958. private readonly _firstDevice;
  51959. private readonly _deviceInputSystem;
  51960. /**
  51961. * Default Constructor
  51962. * @param engine engine to pull input element from
  51963. */
  51964. constructor(engine: Engine);
  51965. /**
  51966. * Gets a DeviceSource, given a type and slot
  51967. * @param deviceType Enum specifying device type
  51968. * @param deviceSlot "Slot" or index that device is referenced in
  51969. * @returns DeviceSource object
  51970. */
  51971. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51972. /**
  51973. * Gets an array of DeviceSource objects for a given device type
  51974. * @param deviceType Enum specifying device type
  51975. * @returns Array of DeviceSource objects
  51976. */
  51977. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51978. /**
  51979. * Dispose of DeviceInputSystem and other parts
  51980. */
  51981. dispose(): void;
  51982. /**
  51983. * Function to add 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 _addDevice;
  51988. /**
  51989. * Function to remove device name to device list
  51990. * @param deviceType Enum specifying device type
  51991. * @param deviceSlot "Slot" or index that device is referenced in
  51992. */
  51993. private _removeDevice;
  51994. /**
  51995. * Updates array storing first connected device of each type
  51996. * @param type Type of Device
  51997. */
  51998. private _updateFirstDevices;
  51999. }
  52000. }
  52001. declare module BABYLON {
  52002. /**
  52003. * Options to create the null engine
  52004. */
  52005. export class NullEngineOptions {
  52006. /**
  52007. * Render width (Default: 512)
  52008. */
  52009. renderWidth: number;
  52010. /**
  52011. * Render height (Default: 256)
  52012. */
  52013. renderHeight: number;
  52014. /**
  52015. * Texture size (Default: 512)
  52016. */
  52017. textureSize: number;
  52018. /**
  52019. * If delta time between frames should be constant
  52020. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52021. */
  52022. deterministicLockstep: boolean;
  52023. /**
  52024. * Maximum about of steps between frames (Default: 4)
  52025. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52026. */
  52027. lockstepMaxSteps: number;
  52028. /**
  52029. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  52030. */
  52031. useHighPrecisionMatrix?: boolean;
  52032. }
  52033. /**
  52034. * The null engine class provides support for headless version of babylon.js.
  52035. * This can be used in server side scenario or for testing purposes
  52036. */
  52037. export class NullEngine extends Engine {
  52038. private _options;
  52039. /**
  52040. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52041. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52042. * @returns true if engine is in deterministic lock step mode
  52043. */
  52044. isDeterministicLockStep(): boolean;
  52045. /**
  52046. * Gets the max steps when engine is running in deterministic lock step
  52047. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52048. * @returns the max steps
  52049. */
  52050. getLockstepMaxSteps(): number;
  52051. /**
  52052. * Gets the current hardware scaling level.
  52053. * By default the hardware scaling level is computed from the window device ratio.
  52054. * 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.
  52055. * @returns a number indicating the current hardware scaling level
  52056. */
  52057. getHardwareScalingLevel(): number;
  52058. constructor(options?: NullEngineOptions);
  52059. /**
  52060. * Creates a vertex buffer
  52061. * @param vertices the data for the vertex buffer
  52062. * @returns the new WebGL static buffer
  52063. */
  52064. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52065. /**
  52066. * Creates a new index buffer
  52067. * @param indices defines the content of the index buffer
  52068. * @param updatable defines if the index buffer must be updatable
  52069. * @returns a new webGL buffer
  52070. */
  52071. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52072. /**
  52073. * Clear the current render buffer or the current render target (if any is set up)
  52074. * @param color defines the color to use
  52075. * @param backBuffer defines if the back buffer must be cleared
  52076. * @param depth defines if the depth buffer must be cleared
  52077. * @param stencil defines if the stencil buffer must be cleared
  52078. */
  52079. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52080. /**
  52081. * Gets the current render width
  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 width
  52084. */
  52085. getRenderWidth(useScreen?: boolean): number;
  52086. /**
  52087. * Gets the current render height
  52088. * @param useScreen defines if screen size must be used (or the current render target if any)
  52089. * @returns a number defining the current render height
  52090. */
  52091. getRenderHeight(useScreen?: boolean): number;
  52092. /**
  52093. * Set the WebGL's viewport
  52094. * @param viewport defines the viewport element to be used
  52095. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52096. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52097. */
  52098. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52099. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52100. /**
  52101. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52102. * @param pipelineContext defines the pipeline context to use
  52103. * @param uniformsNames defines the list of uniform names
  52104. * @returns an array of webGL uniform locations
  52105. */
  52106. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52107. /**
  52108. * Gets the lsit of active attributes for a given webGL program
  52109. * @param pipelineContext defines the pipeline context to use
  52110. * @param attributesNames defines the list of attribute names to get
  52111. * @returns an array of indices indicating the offset of each attribute
  52112. */
  52113. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52114. /**
  52115. * Binds an effect to the webGL context
  52116. * @param effect defines the effect to bind
  52117. */
  52118. bindSamplers(effect: Effect): void;
  52119. /**
  52120. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52121. * @param effect defines the effect to activate
  52122. */
  52123. enableEffect(effect: Effect): void;
  52124. /**
  52125. * Set various states to the webGL context
  52126. * @param culling defines backface culling state
  52127. * @param zOffset defines the value to apply to zOffset (0 by default)
  52128. * @param force defines if states must be applied even if cache is up to date
  52129. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52130. */
  52131. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52132. /**
  52133. * Set the value of an uniform to an array of int32
  52134. * @param uniform defines the webGL uniform location where to store the value
  52135. * @param array defines the array of int32 to store
  52136. * @returns true if value was set
  52137. */
  52138. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52139. /**
  52140. * Set the value of an uniform to an array of int32 (stored as vec2)
  52141. * @param uniform defines the webGL uniform location where to store the value
  52142. * @param array defines the array of int32 to store
  52143. * @returns true if value was set
  52144. */
  52145. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52146. /**
  52147. * Set the value of an uniform to an array of int32 (stored as vec3)
  52148. * @param uniform defines the webGL uniform location where to store the value
  52149. * @param array defines the array of int32 to store
  52150. * @returns true if value was set
  52151. */
  52152. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52153. /**
  52154. * Set the value of an uniform to an array of int32 (stored as vec4)
  52155. * @param uniform defines the webGL uniform location where to store the value
  52156. * @param array defines the array of int32 to store
  52157. * @returns true if value was set
  52158. */
  52159. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52160. /**
  52161. * Set the value of an uniform to an array of float32
  52162. * @param uniform defines the webGL uniform location where to store the value
  52163. * @param array defines the array of float32 to store
  52164. * @returns true if value was set
  52165. */
  52166. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52167. /**
  52168. * Set the value of an uniform to an array of float32 (stored as vec2)
  52169. * @param uniform defines the webGL uniform location where to store the value
  52170. * @param array defines the array of float32 to store
  52171. * @returns true if value was set
  52172. */
  52173. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52174. /**
  52175. * Set the value of an uniform to an array of float32 (stored as vec3)
  52176. * @param uniform defines the webGL uniform location where to store the value
  52177. * @param array defines the array of float32 to store
  52178. * @returns true if value was set
  52179. */
  52180. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52181. /**
  52182. * Set the value of an uniform to an array of float32 (stored as vec4)
  52183. * @param uniform defines the webGL uniform location where to store the value
  52184. * @param array defines the array of float32 to store
  52185. * @returns true if value was set
  52186. */
  52187. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52188. /**
  52189. * Set the value of an uniform to an array of number
  52190. * @param uniform defines the webGL uniform location where to store the value
  52191. * @param array defines the array of number to store
  52192. * @returns true if value was set
  52193. */
  52194. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52195. /**
  52196. * Set the value of an uniform to an array of number (stored as vec2)
  52197. * @param uniform defines the webGL uniform location where to store the value
  52198. * @param array defines the array of number to store
  52199. * @returns true if value was set
  52200. */
  52201. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52202. /**
  52203. * Set the value of an uniform to an array of number (stored as vec3)
  52204. * @param uniform defines the webGL uniform location where to store the value
  52205. * @param array defines the array of number to store
  52206. * @returns true if value was set
  52207. */
  52208. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52209. /**
  52210. * Set the value of an uniform to an array of number (stored as vec4)
  52211. * @param uniform defines the webGL uniform location where to store the value
  52212. * @param array defines the array of number to store
  52213. * @returns true if value was set
  52214. */
  52215. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52216. /**
  52217. * Set the value of an uniform to an array of float32 (stored as matrices)
  52218. * @param uniform defines the webGL uniform location where to store the value
  52219. * @param matrices defines the array of float32 to store
  52220. * @returns true if value was set
  52221. */
  52222. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52223. /**
  52224. * Set the value of an uniform to a matrix (3x3)
  52225. * @param uniform defines the webGL uniform location where to store the value
  52226. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52227. * @returns true if value was set
  52228. */
  52229. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52230. /**
  52231. * Set the value of an uniform to a matrix (2x2)
  52232. * @param uniform defines the webGL uniform location where to store the value
  52233. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52234. * @returns true if value was set
  52235. */
  52236. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52237. /**
  52238. * Set the value of an uniform to a number (float)
  52239. * @param uniform defines the webGL uniform location where to store the value
  52240. * @param value defines the float number to store
  52241. * @returns true if value was set
  52242. */
  52243. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52244. /**
  52245. * Set the value of an uniform to a vec2
  52246. * @param uniform defines the webGL uniform location where to store the value
  52247. * @param x defines the 1st component of the value
  52248. * @param y defines the 2nd component of the value
  52249. * @returns true if value was set
  52250. */
  52251. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52252. /**
  52253. * Set the value of an uniform to a vec3
  52254. * @param uniform defines the webGL uniform location where to store the value
  52255. * @param x defines the 1st component of the value
  52256. * @param y defines the 2nd component of the value
  52257. * @param z defines the 3rd component of the value
  52258. * @returns true if value was set
  52259. */
  52260. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52261. /**
  52262. * Set the value of an uniform to a boolean
  52263. * @param uniform defines the webGL uniform location where to store the value
  52264. * @param bool defines the boolean to store
  52265. * @returns true if value was set
  52266. */
  52267. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52268. /**
  52269. * Set the value of an uniform to a vec4
  52270. * @param uniform defines the webGL uniform location where to store the value
  52271. * @param x defines the 1st component of the value
  52272. * @param y defines the 2nd component of the value
  52273. * @param z defines the 3rd component of the value
  52274. * @param w defines the 4th component of the value
  52275. * @returns true if value was set
  52276. */
  52277. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52278. /**
  52279. * Sets the current alpha mode
  52280. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52281. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52282. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52283. */
  52284. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52285. /**
  52286. * Bind webGl buffers directly to the webGL context
  52287. * @param vertexBuffers defines the vertex buffer to bind
  52288. * @param indexBuffer defines the index buffer to bind
  52289. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52290. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52291. * @param effect defines the effect associated with the vertex buffer
  52292. */
  52293. bindBuffers(vertexBuffers: {
  52294. [key: string]: VertexBuffer;
  52295. }, indexBuffer: DataBuffer, effect: Effect): void;
  52296. /**
  52297. * Force the entire cache to be cleared
  52298. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52299. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52300. */
  52301. wipeCaches(bruteForce?: boolean): void;
  52302. /**
  52303. * Send a draw order
  52304. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52305. * @param indexStart defines the starting index
  52306. * @param indexCount defines the number of index to draw
  52307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52308. */
  52309. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52310. /**
  52311. * Draw a list of indexed primitives
  52312. * @param fillMode defines the primitive to use
  52313. * @param indexStart defines the starting index
  52314. * @param indexCount defines the number of index to draw
  52315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52316. */
  52317. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52318. /**
  52319. * Draw a list of unindexed primitives
  52320. * @param fillMode defines the primitive to use
  52321. * @param verticesStart defines the index of first vertex to draw
  52322. * @param verticesCount defines the count of vertices to draw
  52323. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52324. */
  52325. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52326. /** @hidden */
  52327. _createTexture(): WebGLTexture;
  52328. /** @hidden */
  52329. _releaseTexture(texture: InternalTexture): void;
  52330. /**
  52331. * Usually called from Texture.ts.
  52332. * Passed information to create a WebGLTexture
  52333. * @param urlArg defines a value which contains one of the following:
  52334. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52335. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52336. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52337. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52338. * @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)
  52339. * @param scene needed for loading to the correct scene
  52340. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52341. * @param onLoad optional callback to be called upon successful completion
  52342. * @param onError optional callback to be called upon failure
  52343. * @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
  52344. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52345. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52346. * @param forcedExtension defines the extension to use to pick the right loader
  52347. * @param mimeType defines an optional mime type
  52348. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52349. */
  52350. 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;
  52351. /**
  52352. * Creates a new render target texture
  52353. * @param size defines the size of the texture
  52354. * @param options defines the options used to create the texture
  52355. * @returns a new render target texture stored in an InternalTexture
  52356. */
  52357. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52358. /**
  52359. * Update the sampling mode of a given texture
  52360. * @param samplingMode defines the required sampling mode
  52361. * @param texture defines the texture to update
  52362. */
  52363. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52364. /**
  52365. * Binds the frame buffer to the specified texture.
  52366. * @param texture The texture to render to or null for the default canvas
  52367. * @param faceIndex The face of the texture to render to in case of cube texture
  52368. * @param requiredWidth The width of the target to render to
  52369. * @param requiredHeight The height of the target to render to
  52370. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52371. * @param lodLevel defines le lod level to bind to the frame buffer
  52372. */
  52373. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52374. /**
  52375. * Unbind the current render target texture from the webGL context
  52376. * @param texture defines the render target texture to unbind
  52377. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52378. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52379. */
  52380. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52381. /**
  52382. * Creates a dynamic vertex buffer
  52383. * @param vertices the data for the dynamic vertex buffer
  52384. * @returns the new WebGL dynamic buffer
  52385. */
  52386. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52387. /**
  52388. * Update the content of a dynamic texture
  52389. * @param texture defines the texture to update
  52390. * @param canvas defines the canvas containing the source
  52391. * @param invertY defines if data must be stored with Y axis inverted
  52392. * @param premulAlpha defines if alpha is stored as premultiplied
  52393. * @param format defines the format of the data
  52394. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52395. */
  52396. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52397. /**
  52398. * Gets a boolean indicating if all created effects are ready
  52399. * @returns true if all effects are ready
  52400. */
  52401. areAllEffectsReady(): boolean;
  52402. /**
  52403. * @hidden
  52404. * Get the current error code of the webGL context
  52405. * @returns the error code
  52406. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52407. */
  52408. getError(): number;
  52409. /** @hidden */
  52410. _getUnpackAlignement(): number;
  52411. /** @hidden */
  52412. _unpackFlipY(value: boolean): void;
  52413. /**
  52414. * Update a dynamic index buffer
  52415. * @param indexBuffer defines the target index buffer
  52416. * @param indices defines the data to update
  52417. * @param offset defines the offset in the target index buffer where update should start
  52418. */
  52419. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52420. /**
  52421. * Updates a dynamic vertex buffer.
  52422. * @param vertexBuffer the vertex buffer to update
  52423. * @param vertices the data used to update the vertex buffer
  52424. * @param byteOffset the byte offset of the data (optional)
  52425. * @param byteLength the byte length of the data (optional)
  52426. */
  52427. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52428. /** @hidden */
  52429. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52430. /** @hidden */
  52431. _bindTexture(channel: number, texture: InternalTexture): void;
  52432. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52433. /**
  52434. * 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
  52435. */
  52436. releaseEffects(): void;
  52437. displayLoadingUI(): void;
  52438. hideLoadingUI(): void;
  52439. /** @hidden */
  52440. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52441. /** @hidden */
  52442. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52443. /** @hidden */
  52444. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52445. /** @hidden */
  52446. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * @hidden
  52452. **/
  52453. export class _TimeToken {
  52454. _startTimeQuery: Nullable<WebGLQuery>;
  52455. _endTimeQuery: Nullable<WebGLQuery>;
  52456. _timeElapsedQuery: Nullable<WebGLQuery>;
  52457. _timeElapsedQueryEnded: boolean;
  52458. }
  52459. }
  52460. declare module BABYLON {
  52461. /** @hidden */
  52462. export class _OcclusionDataStorage {
  52463. /** @hidden */
  52464. occlusionInternalRetryCounter: number;
  52465. /** @hidden */
  52466. isOcclusionQueryInProgress: boolean;
  52467. /** @hidden */
  52468. isOccluded: boolean;
  52469. /** @hidden */
  52470. occlusionRetryCount: number;
  52471. /** @hidden */
  52472. occlusionType: number;
  52473. /** @hidden */
  52474. occlusionQueryAlgorithmType: number;
  52475. }
  52476. interface Engine {
  52477. /**
  52478. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52479. * @return the new query
  52480. */
  52481. createQuery(): WebGLQuery;
  52482. /**
  52483. * Delete and release a webGL query
  52484. * @param query defines the query to delete
  52485. * @return the current engine
  52486. */
  52487. deleteQuery(query: WebGLQuery): Engine;
  52488. /**
  52489. * Check if a given query has resolved and got its value
  52490. * @param query defines the query to check
  52491. * @returns true if the query got its value
  52492. */
  52493. isQueryResultAvailable(query: WebGLQuery): boolean;
  52494. /**
  52495. * Gets the value of a given query
  52496. * @param query defines the query to check
  52497. * @returns the value of the query
  52498. */
  52499. getQueryResult(query: WebGLQuery): number;
  52500. /**
  52501. * Initiates an occlusion query
  52502. * @param algorithmType defines the algorithm to use
  52503. * @param query defines the query to use
  52504. * @returns the current engine
  52505. * @see https://doc.babylonjs.com/features/occlusionquery
  52506. */
  52507. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52508. /**
  52509. * Ends an occlusion query
  52510. * @see https://doc.babylonjs.com/features/occlusionquery
  52511. * @param algorithmType defines the algorithm to use
  52512. * @returns the current engine
  52513. */
  52514. endOcclusionQuery(algorithmType: number): Engine;
  52515. /**
  52516. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52517. * Please note that only one query can be issued at a time
  52518. * @returns a time token used to track the time span
  52519. */
  52520. startTimeQuery(): Nullable<_TimeToken>;
  52521. /**
  52522. * Ends a time query
  52523. * @param token defines the token used to measure the time span
  52524. * @returns the time spent (in ns)
  52525. */
  52526. endTimeQuery(token: _TimeToken): int;
  52527. /** @hidden */
  52528. _currentNonTimestampToken: Nullable<_TimeToken>;
  52529. /** @hidden */
  52530. _createTimeQuery(): WebGLQuery;
  52531. /** @hidden */
  52532. _deleteTimeQuery(query: WebGLQuery): void;
  52533. /** @hidden */
  52534. _getGlAlgorithmType(algorithmType: number): number;
  52535. /** @hidden */
  52536. _getTimeQueryResult(query: WebGLQuery): any;
  52537. /** @hidden */
  52538. _getTimeQueryAvailability(query: WebGLQuery): any;
  52539. }
  52540. interface AbstractMesh {
  52541. /**
  52542. * Backing filed
  52543. * @hidden
  52544. */
  52545. __occlusionDataStorage: _OcclusionDataStorage;
  52546. /**
  52547. * Access property
  52548. * @hidden
  52549. */
  52550. _occlusionDataStorage: _OcclusionDataStorage;
  52551. /**
  52552. * 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.
  52553. * The default value is -1 which means don't break the query and wait till the result
  52554. * @see https://doc.babylonjs.com/features/occlusionquery
  52555. */
  52556. occlusionRetryCount: number;
  52557. /**
  52558. * 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:
  52559. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52560. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52561. * * 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.
  52562. * @see https://doc.babylonjs.com/features/occlusionquery
  52563. */
  52564. occlusionType: number;
  52565. /**
  52566. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52567. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52568. * * 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.
  52569. * @see https://doc.babylonjs.com/features/occlusionquery
  52570. */
  52571. occlusionQueryAlgorithmType: number;
  52572. /**
  52573. * 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
  52574. * @see https://doc.babylonjs.com/features/occlusionquery
  52575. */
  52576. isOccluded: boolean;
  52577. /**
  52578. * Flag to check the progress status of the query
  52579. * @see https://doc.babylonjs.com/features/occlusionquery
  52580. */
  52581. isOcclusionQueryInProgress: boolean;
  52582. }
  52583. }
  52584. declare module BABYLON {
  52585. /** @hidden */
  52586. export var _forceTransformFeedbackToBundle: boolean;
  52587. interface Engine {
  52588. /**
  52589. * Creates a webGL transform feedback object
  52590. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52591. * @returns the webGL transform feedback object
  52592. */
  52593. createTransformFeedback(): WebGLTransformFeedback;
  52594. /**
  52595. * Delete a webGL transform feedback object
  52596. * @param value defines the webGL transform feedback object to delete
  52597. */
  52598. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52599. /**
  52600. * Bind a webGL transform feedback object to the webgl context
  52601. * @param value defines the webGL transform feedback object to bind
  52602. */
  52603. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52604. /**
  52605. * Begins a transform feedback operation
  52606. * @param usePoints defines if points or triangles must be used
  52607. */
  52608. beginTransformFeedback(usePoints: boolean): void;
  52609. /**
  52610. * Ends a transform feedback operation
  52611. */
  52612. endTransformFeedback(): void;
  52613. /**
  52614. * Specify the varyings to use with transform feedback
  52615. * @param program defines the associated webGL program
  52616. * @param value defines the list of strings representing the varying names
  52617. */
  52618. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52619. /**
  52620. * Bind a webGL buffer for a transform feedback operation
  52621. * @param value defines the webGL buffer to bind
  52622. */
  52623. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52624. }
  52625. }
  52626. declare module BABYLON {
  52627. /**
  52628. * Class used to define an additional view for the engine
  52629. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52630. */
  52631. export class EngineView {
  52632. /** Defines the canvas where to render the view */
  52633. target: HTMLCanvasElement;
  52634. /** Defines an optional camera used to render the view (will use active camera else) */
  52635. camera?: Camera;
  52636. }
  52637. interface Engine {
  52638. /**
  52639. * Gets or sets the HTML element to use for attaching events
  52640. */
  52641. inputElement: Nullable<HTMLElement>;
  52642. /**
  52643. * Gets the current engine view
  52644. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52645. */
  52646. activeView: Nullable<EngineView>;
  52647. /** Gets or sets the list of views */
  52648. views: EngineView[];
  52649. /**
  52650. * Register a new child canvas
  52651. * @param canvas defines the canvas to register
  52652. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52653. * @returns the associated view
  52654. */
  52655. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52656. /**
  52657. * Remove a registered child canvas
  52658. * @param canvas defines the canvas to remove
  52659. * @returns the current engine
  52660. */
  52661. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. interface Engine {
  52666. /** @hidden */
  52667. _excludedCompressedTextures: string[];
  52668. /** @hidden */
  52669. _textureFormatInUse: string;
  52670. /**
  52671. * Gets the list of texture formats supported
  52672. */
  52673. readonly texturesSupported: Array<string>;
  52674. /**
  52675. * Gets the texture format in use
  52676. */
  52677. readonly textureFormatInUse: Nullable<string>;
  52678. /**
  52679. * Set the compressed texture extensions or file names to skip.
  52680. *
  52681. * @param skippedFiles defines the list of those texture files you want to skip
  52682. * Example: [".dds", ".env", "myfile.png"]
  52683. */
  52684. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52685. /**
  52686. * Set the compressed texture format to use, based on the formats you have, and the formats
  52687. * supported by the hardware / browser.
  52688. *
  52689. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52690. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52691. * to API arguments needed to compressed textures. This puts the burden on the container
  52692. * generator to house the arcane code for determining these for current & future formats.
  52693. *
  52694. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52695. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52696. *
  52697. * Note: The result of this call is not taken into account when a texture is base64.
  52698. *
  52699. * @param formatsAvailable defines the list of those format families you have created
  52700. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52701. *
  52702. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52703. * @returns The extension selected.
  52704. */
  52705. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52706. }
  52707. }
  52708. declare module BABYLON {
  52709. /**
  52710. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52711. */
  52712. export interface CubeMapInfo {
  52713. /**
  52714. * The pixel array for the front face.
  52715. * This is stored in format, left to right, up to down format.
  52716. */
  52717. front: Nullable<ArrayBufferView>;
  52718. /**
  52719. * The pixel array for the back face.
  52720. * This is stored in format, left to right, up to down format.
  52721. */
  52722. back: Nullable<ArrayBufferView>;
  52723. /**
  52724. * The pixel array for the left face.
  52725. * This is stored in format, left to right, up to down format.
  52726. */
  52727. left: Nullable<ArrayBufferView>;
  52728. /**
  52729. * The pixel array for the right face.
  52730. * This is stored in format, left to right, up to down format.
  52731. */
  52732. right: Nullable<ArrayBufferView>;
  52733. /**
  52734. * The pixel array for the up face.
  52735. * This is stored in format, left to right, up to down format.
  52736. */
  52737. up: Nullable<ArrayBufferView>;
  52738. /**
  52739. * The pixel array for the down face.
  52740. * This is stored in format, left to right, up to down format.
  52741. */
  52742. down: Nullable<ArrayBufferView>;
  52743. /**
  52744. * The size of the cubemap stored.
  52745. *
  52746. * Each faces will be size * size pixels.
  52747. */
  52748. size: number;
  52749. /**
  52750. * The format of the texture.
  52751. *
  52752. * RGBA, RGB.
  52753. */
  52754. format: number;
  52755. /**
  52756. * The type of the texture data.
  52757. *
  52758. * UNSIGNED_INT, FLOAT.
  52759. */
  52760. type: number;
  52761. /**
  52762. * Specifies whether the texture is in gamma space.
  52763. */
  52764. gammaSpace: boolean;
  52765. }
  52766. /**
  52767. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52768. */
  52769. export class PanoramaToCubeMapTools {
  52770. private static FACE_LEFT;
  52771. private static FACE_RIGHT;
  52772. private static FACE_FRONT;
  52773. private static FACE_BACK;
  52774. private static FACE_DOWN;
  52775. private static FACE_UP;
  52776. /**
  52777. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52778. *
  52779. * @param float32Array The source data.
  52780. * @param inputWidth The width of the input panorama.
  52781. * @param inputHeight The height of the input panorama.
  52782. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52783. * @return The cubemap data
  52784. */
  52785. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52786. private static CreateCubemapTexture;
  52787. private static CalcProjectionSpherical;
  52788. }
  52789. }
  52790. declare module BABYLON {
  52791. /**
  52792. * Helper class dealing with the extraction of spherical polynomial dataArray
  52793. * from a cube map.
  52794. */
  52795. export class CubeMapToSphericalPolynomialTools {
  52796. private static FileFaces;
  52797. /**
  52798. * Converts a texture to the according Spherical Polynomial data.
  52799. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52800. *
  52801. * @param texture The texture to extract the information from.
  52802. * @return The Spherical Polynomial data.
  52803. */
  52804. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52805. /**
  52806. * Converts a cubemap to the according Spherical Polynomial data.
  52807. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52808. *
  52809. * @param cubeInfo The Cube map to extract the information from.
  52810. * @return The Spherical Polynomial data.
  52811. */
  52812. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52813. }
  52814. }
  52815. declare module BABYLON {
  52816. interface BaseTexture {
  52817. /**
  52818. * Get the polynomial representation of the texture data.
  52819. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52820. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52821. */
  52822. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52823. }
  52824. }
  52825. declare module BABYLON {
  52826. /** @hidden */
  52827. export var rgbdEncodePixelShader: {
  52828. name: string;
  52829. shader: string;
  52830. };
  52831. }
  52832. declare module BABYLON {
  52833. /** @hidden */
  52834. export var rgbdDecodePixelShader: {
  52835. name: string;
  52836. shader: string;
  52837. };
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * Raw texture data and descriptor sufficient for WebGL texture upload
  52842. */
  52843. export interface EnvironmentTextureInfo {
  52844. /**
  52845. * Version of the environment map
  52846. */
  52847. version: number;
  52848. /**
  52849. * Width of image
  52850. */
  52851. width: number;
  52852. /**
  52853. * Irradiance information stored in the file.
  52854. */
  52855. irradiance: any;
  52856. /**
  52857. * Specular information stored in the file.
  52858. */
  52859. specular: any;
  52860. }
  52861. /**
  52862. * Defines One Image in the file. It requires only the position in the file
  52863. * as well as the length.
  52864. */
  52865. interface BufferImageData {
  52866. /**
  52867. * Length of the image data.
  52868. */
  52869. length: number;
  52870. /**
  52871. * Position of the data from the null terminator delimiting the end of the JSON.
  52872. */
  52873. position: number;
  52874. }
  52875. /**
  52876. * Defines the specular data enclosed in the file.
  52877. * This corresponds to the version 1 of the data.
  52878. */
  52879. export interface EnvironmentTextureSpecularInfoV1 {
  52880. /**
  52881. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52882. */
  52883. specularDataPosition?: number;
  52884. /**
  52885. * This contains all the images data needed to reconstruct the cubemap.
  52886. */
  52887. mipmaps: Array<BufferImageData>;
  52888. /**
  52889. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52890. */
  52891. lodGenerationScale: number;
  52892. }
  52893. /**
  52894. * Sets of helpers addressing the serialization and deserialization of environment texture
  52895. * stored in a BabylonJS env file.
  52896. * Those files are usually stored as .env files.
  52897. */
  52898. export class EnvironmentTextureTools {
  52899. /**
  52900. * Magic number identifying the env file.
  52901. */
  52902. private static _MagicBytes;
  52903. /**
  52904. * Gets the environment info from an env file.
  52905. * @param data The array buffer containing the .env bytes.
  52906. * @returns the environment file info (the json header) if successfully parsed.
  52907. */
  52908. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52909. /**
  52910. * Creates an environment texture from a loaded cube texture.
  52911. * @param texture defines the cube texture to convert in env file
  52912. * @return a promise containing the environment data if succesfull.
  52913. */
  52914. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52915. /**
  52916. * Creates a JSON representation of the spherical data.
  52917. * @param texture defines the texture containing the polynomials
  52918. * @return the JSON representation of the spherical info
  52919. */
  52920. private static _CreateEnvTextureIrradiance;
  52921. /**
  52922. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52923. * @param data the image data
  52924. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52925. * @return the views described by info providing access to the underlying buffer
  52926. */
  52927. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52928. /**
  52929. * Uploads the texture info contained in the env file to the GPU.
  52930. * @param texture defines the internal texture to upload to
  52931. * @param data defines the data to load
  52932. * @param info defines the texture info retrieved through the GetEnvInfo method
  52933. * @returns a promise
  52934. */
  52935. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52936. private static _OnImageReadyAsync;
  52937. /**
  52938. * Uploads the levels of image data to the GPU.
  52939. * @param texture defines the internal texture to upload to
  52940. * @param imageData defines the array buffer views of image data [mipmap][face]
  52941. * @returns a promise
  52942. */
  52943. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52944. /**
  52945. * Uploads spherical polynomials information to the texture.
  52946. * @param texture defines the texture we are trying to upload the information to
  52947. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52948. */
  52949. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52950. /** @hidden */
  52951. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52952. }
  52953. }
  52954. declare module BABYLON {
  52955. /**
  52956. * Class used to inline functions in shader code
  52957. */
  52958. export class ShaderCodeInliner {
  52959. private static readonly _RegexpFindFunctionNameAndType;
  52960. private _sourceCode;
  52961. private _functionDescr;
  52962. private _numMaxIterations;
  52963. /** Gets or sets the token used to mark the functions to inline */
  52964. inlineToken: string;
  52965. /** Gets or sets the debug mode */
  52966. debug: boolean;
  52967. /** Gets the code after the inlining process */
  52968. get code(): string;
  52969. /**
  52970. * Initializes the inliner
  52971. * @param sourceCode shader code source to inline
  52972. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52973. */
  52974. constructor(sourceCode: string, numMaxIterations?: number);
  52975. /**
  52976. * Start the processing of the shader code
  52977. */
  52978. processCode(): void;
  52979. private _collectFunctions;
  52980. private _processInlining;
  52981. private _extractBetweenMarkers;
  52982. private _skipWhitespaces;
  52983. private _removeComments;
  52984. private _replaceFunctionCallsByCode;
  52985. private _findBackward;
  52986. private _escapeRegExp;
  52987. private _replaceNames;
  52988. }
  52989. }
  52990. declare module BABYLON {
  52991. /**
  52992. * Container for accessors for natively-stored mesh data buffers.
  52993. */
  52994. class NativeDataBuffer extends DataBuffer {
  52995. /**
  52996. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52997. */
  52998. nativeIndexBuffer?: any;
  52999. /**
  53000. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53001. */
  53002. nativeVertexBuffer?: any;
  53003. }
  53004. /** @hidden */
  53005. class NativeTexture extends InternalTexture {
  53006. getInternalTexture(): InternalTexture;
  53007. getViewCount(): number;
  53008. }
  53009. /** @hidden */
  53010. export class NativeEngine extends Engine {
  53011. private readonly _native;
  53012. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53013. private readonly INVALID_HANDLE;
  53014. private _boundBuffersVertexArray;
  53015. private _currentDepthTest;
  53016. getHardwareScalingLevel(): number;
  53017. constructor();
  53018. dispose(): void;
  53019. /**
  53020. * Can be used to override the current requestAnimationFrame requester.
  53021. * @hidden
  53022. */
  53023. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53024. /**
  53025. * Override default engine behavior.
  53026. * @param color
  53027. * @param backBuffer
  53028. * @param depth
  53029. * @param stencil
  53030. */
  53031. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53032. /**
  53033. * Gets host document
  53034. * @returns the host document object
  53035. */
  53036. getHostDocument(): Nullable<Document>;
  53037. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53038. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53039. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53040. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  53041. [key: string]: VertexBuffer;
  53042. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  53043. bindBuffers(vertexBuffers: {
  53044. [key: string]: VertexBuffer;
  53045. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  53046. recordVertexArrayObject(vertexBuffers: {
  53047. [key: string]: VertexBuffer;
  53048. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53049. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53050. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53051. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53052. /**
  53053. * Draw a list of indexed primitives
  53054. * @param fillMode defines the primitive to use
  53055. * @param indexStart defines the starting index
  53056. * @param indexCount defines the number of index to draw
  53057. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53058. */
  53059. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53060. /**
  53061. * Draw a list of unindexed primitives
  53062. * @param fillMode defines the primitive to use
  53063. * @param verticesStart defines the index of first vertex to draw
  53064. * @param verticesCount defines the count of vertices to draw
  53065. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53066. */
  53067. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53068. createPipelineContext(): IPipelineContext;
  53069. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53070. /** @hidden */
  53071. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53072. /** @hidden */
  53073. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53074. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53075. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53076. protected _setProgram(program: WebGLProgram): void;
  53077. _releaseEffect(effect: Effect): void;
  53078. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53079. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53080. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53081. bindSamplers(effect: Effect): void;
  53082. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53083. getRenderWidth(useScreen?: boolean): number;
  53084. getRenderHeight(useScreen?: boolean): number;
  53085. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53086. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53087. /**
  53088. * Set the z offset to apply to current rendering
  53089. * @param value defines the offset to apply
  53090. */
  53091. setZOffset(value: number): void;
  53092. /**
  53093. * Gets the current value of the zOffset
  53094. * @returns the current zOffset state
  53095. */
  53096. getZOffset(): number;
  53097. /**
  53098. * Enable or disable depth buffering
  53099. * @param enable defines the state to set
  53100. */
  53101. setDepthBuffer(enable: boolean): void;
  53102. /**
  53103. * Gets a boolean indicating if depth writing is enabled
  53104. * @returns the current depth writing state
  53105. */
  53106. getDepthWrite(): boolean;
  53107. setDepthFunctionToGreater(): void;
  53108. setDepthFunctionToGreaterOrEqual(): void;
  53109. setDepthFunctionToLess(): void;
  53110. setDepthFunctionToLessOrEqual(): void;
  53111. /**
  53112. * Enable or disable depth writing
  53113. * @param enable defines the state to set
  53114. */
  53115. setDepthWrite(enable: boolean): void;
  53116. /**
  53117. * Enable or disable color writing
  53118. * @param enable defines the state to set
  53119. */
  53120. setColorWrite(enable: boolean): void;
  53121. /**
  53122. * Gets a boolean indicating if color writing is enabled
  53123. * @returns the current color writing state
  53124. */
  53125. getColorWrite(): boolean;
  53126. /**
  53127. * Sets alpha constants used by some alpha blending modes
  53128. * @param r defines the red component
  53129. * @param g defines the green component
  53130. * @param b defines the blue component
  53131. * @param a defines the alpha component
  53132. */
  53133. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53134. /**
  53135. * Sets the current alpha mode
  53136. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53137. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53138. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53139. */
  53140. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53141. /**
  53142. * Gets the current alpha mode
  53143. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53144. * @returns the current alpha mode
  53145. */
  53146. getAlphaMode(): number;
  53147. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53156. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53157. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53158. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53159. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53163. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53166. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53167. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53168. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53169. wipeCaches(bruteForce?: boolean): void;
  53170. _createTexture(): WebGLTexture;
  53171. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53172. /**
  53173. * Update the content of a dynamic texture
  53174. * @param texture defines the texture to update
  53175. * @param canvas defines the canvas containing the source
  53176. * @param invertY defines if data must be stored with Y axis inverted
  53177. * @param premulAlpha defines if alpha is stored as premultiplied
  53178. * @param format defines the format of the data
  53179. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53180. */
  53181. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53182. /**
  53183. * Usually called from Texture.ts.
  53184. * Passed information to create a WebGLTexture
  53185. * @param url defines a value which contains one of the following:
  53186. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53187. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53188. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53189. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53190. * @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)
  53191. * @param scene needed for loading to the correct scene
  53192. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53193. * @param onLoad optional callback to be called upon successful completion
  53194. * @param onError optional callback to be called upon failure
  53195. * @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
  53196. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53197. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53198. * @param forcedExtension defines the extension to use to pick the right loader
  53199. * @param mimeType defines an optional mime type
  53200. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53201. */
  53202. 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;
  53203. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  53204. _releaseFramebufferObjects(texture: InternalTexture): void;
  53205. /**
  53206. * Creates a cube texture
  53207. * @param rootUrl defines the url where the files to load is located
  53208. * @param scene defines the current scene
  53209. * @param files defines the list of files to load (1 per face)
  53210. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53211. * @param onLoad defines an optional callback raised when the texture is loaded
  53212. * @param onError defines an optional callback raised if there is an issue to load the texture
  53213. * @param format defines the format of the data
  53214. * @param forcedExtension defines the extension to use to pick the right loader
  53215. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53216. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53217. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53218. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53219. * @returns the cube texture as an InternalTexture
  53220. */
  53221. 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;
  53222. createRenderTargetTexture(size: number | {
  53223. width: number;
  53224. height: number;
  53225. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53226. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53227. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53228. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53229. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53230. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53231. /**
  53232. * Updates a dynamic vertex buffer.
  53233. * @param vertexBuffer the vertex buffer to update
  53234. * @param data the data used to update the vertex buffer
  53235. * @param byteOffset the byte offset of the data (optional)
  53236. * @param byteLength the byte length of the data (optional)
  53237. */
  53238. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53239. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53240. private _updateAnisotropicLevel;
  53241. private _getAddressMode;
  53242. /** @hidden */
  53243. _bindTexture(channel: number, texture: InternalTexture): void;
  53244. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53245. releaseEffects(): void;
  53246. /** @hidden */
  53247. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53248. /** @hidden */
  53249. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53250. /** @hidden */
  53251. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53252. /** @hidden */
  53253. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53254. private _getNativeSamplingMode;
  53255. private _getNativeTextureFormat;
  53256. private _getNativeAlphaMode;
  53257. private _getNativeAttribType;
  53258. }
  53259. }
  53260. declare module BABYLON {
  53261. /**
  53262. * Gather the list of clipboard event types as constants.
  53263. */
  53264. export class ClipboardEventTypes {
  53265. /**
  53266. * The clipboard event is fired when a copy command is active (pressed).
  53267. */
  53268. static readonly COPY: number;
  53269. /**
  53270. * The clipboard event is fired when a cut command is active (pressed).
  53271. */
  53272. static readonly CUT: number;
  53273. /**
  53274. * The clipboard event is fired when a paste command is active (pressed).
  53275. */
  53276. static readonly PASTE: number;
  53277. }
  53278. /**
  53279. * This class is used to store clipboard related info for the onClipboardObservable event.
  53280. */
  53281. export class ClipboardInfo {
  53282. /**
  53283. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53284. */
  53285. type: number;
  53286. /**
  53287. * Defines the related dom event
  53288. */
  53289. event: ClipboardEvent;
  53290. /**
  53291. *Creates an instance of ClipboardInfo.
  53292. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53293. * @param event Defines the related dom event
  53294. */
  53295. constructor(
  53296. /**
  53297. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53298. */
  53299. type: number,
  53300. /**
  53301. * Defines the related dom event
  53302. */
  53303. event: ClipboardEvent);
  53304. /**
  53305. * Get the clipboard event's type from the keycode.
  53306. * @param keyCode Defines the keyCode for the current keyboard event.
  53307. * @return {number}
  53308. */
  53309. static GetTypeFromCharacter(keyCode: number): number;
  53310. }
  53311. }
  53312. declare module BABYLON {
  53313. /**
  53314. * Google Daydream controller
  53315. */
  53316. export class DaydreamController extends WebVRController {
  53317. /**
  53318. * Base Url for the controller model.
  53319. */
  53320. static MODEL_BASE_URL: string;
  53321. /**
  53322. * File name for the controller model.
  53323. */
  53324. static MODEL_FILENAME: string;
  53325. /**
  53326. * Gamepad Id prefix used to identify Daydream Controller.
  53327. */
  53328. static readonly GAMEPAD_ID_PREFIX: string;
  53329. /**
  53330. * Creates a new DaydreamController from a gamepad
  53331. * @param vrGamepad the gamepad that the controller should be created from
  53332. */
  53333. constructor(vrGamepad: any);
  53334. /**
  53335. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53336. * @param scene scene in which to add meshes
  53337. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53338. */
  53339. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53340. /**
  53341. * Called once for each button that changed state since the last frame
  53342. * @param buttonIdx Which button index changed
  53343. * @param state New state of the button
  53344. * @param changes Which properties on the state changed since last frame
  53345. */
  53346. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53347. }
  53348. }
  53349. declare module BABYLON {
  53350. /**
  53351. * Gear VR Controller
  53352. */
  53353. export class GearVRController extends WebVRController {
  53354. /**
  53355. * Base Url for the controller model.
  53356. */
  53357. static MODEL_BASE_URL: string;
  53358. /**
  53359. * File name for the controller model.
  53360. */
  53361. static MODEL_FILENAME: string;
  53362. /**
  53363. * Gamepad Id prefix used to identify this controller.
  53364. */
  53365. static readonly GAMEPAD_ID_PREFIX: string;
  53366. private readonly _buttonIndexToObservableNameMap;
  53367. /**
  53368. * Creates a new GearVRController from a gamepad
  53369. * @param vrGamepad the gamepad that the controller should be created from
  53370. */
  53371. constructor(vrGamepad: any);
  53372. /**
  53373. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53374. * @param scene scene in which to add meshes
  53375. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53376. */
  53377. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53378. /**
  53379. * Called once for each button that changed state since the last frame
  53380. * @param buttonIdx Which button index changed
  53381. * @param state New state of the button
  53382. * @param changes Which properties on the state changed since last frame
  53383. */
  53384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53385. }
  53386. }
  53387. declare module BABYLON {
  53388. /**
  53389. * Generic Controller
  53390. */
  53391. export class GenericController extends WebVRController {
  53392. /**
  53393. * Base Url for the controller model.
  53394. */
  53395. static readonly MODEL_BASE_URL: string;
  53396. /**
  53397. * File name for the controller model.
  53398. */
  53399. static readonly MODEL_FILENAME: string;
  53400. /**
  53401. * Creates a new GenericController from a gamepad
  53402. * @param vrGamepad the gamepad that the controller should be created from
  53403. */
  53404. constructor(vrGamepad: any);
  53405. /**
  53406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53407. * @param scene scene in which to add meshes
  53408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53409. */
  53410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53411. /**
  53412. * Called once for each button that changed state since the last frame
  53413. * @param buttonIdx Which button index changed
  53414. * @param state New state of the button
  53415. * @param changes Which properties on the state changed since last frame
  53416. */
  53417. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53418. }
  53419. }
  53420. declare module BABYLON {
  53421. /**
  53422. * Oculus Touch Controller
  53423. */
  53424. export class OculusTouchController extends WebVRController {
  53425. /**
  53426. * Base Url for the controller model.
  53427. */
  53428. static MODEL_BASE_URL: string;
  53429. /**
  53430. * File name for the left controller model.
  53431. */
  53432. static MODEL_LEFT_FILENAME: string;
  53433. /**
  53434. * File name for the right controller model.
  53435. */
  53436. static MODEL_RIGHT_FILENAME: string;
  53437. /**
  53438. * Base Url for the Quest controller model.
  53439. */
  53440. static QUEST_MODEL_BASE_URL: string;
  53441. /**
  53442. * @hidden
  53443. * If the controllers are running on a device that needs the updated Quest controller models
  53444. */
  53445. static _IsQuest: boolean;
  53446. /**
  53447. * Fired when the secondary trigger on this controller is modified
  53448. */
  53449. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53450. /**
  53451. * Fired when the thumb rest on this controller is modified
  53452. */
  53453. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53454. /**
  53455. * Creates a new OculusTouchController from a gamepad
  53456. * @param vrGamepad the gamepad that the controller should be created from
  53457. */
  53458. constructor(vrGamepad: any);
  53459. /**
  53460. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53461. * @param scene scene in which to add meshes
  53462. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53463. */
  53464. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53465. /**
  53466. * Fired when the A button on this controller is modified
  53467. */
  53468. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53469. /**
  53470. * Fired when the B button on this controller is modified
  53471. */
  53472. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53473. /**
  53474. * Fired when the X button on this controller is modified
  53475. */
  53476. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53477. /**
  53478. * Fired when the Y button on this controller is modified
  53479. */
  53480. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53481. /**
  53482. * Called once for each button that changed state since the last frame
  53483. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53484. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53485. * 2) secondary trigger (same)
  53486. * 3) A (right) X (left), touch, pressed = value
  53487. * 4) B / Y
  53488. * 5) thumb rest
  53489. * @param buttonIdx Which button index changed
  53490. * @param state New state of the button
  53491. * @param changes Which properties on the state changed since last frame
  53492. */
  53493. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53494. }
  53495. }
  53496. declare module BABYLON {
  53497. /**
  53498. * Vive Controller
  53499. */
  53500. export class ViveController extends WebVRController {
  53501. /**
  53502. * Base Url for the controller model.
  53503. */
  53504. static MODEL_BASE_URL: string;
  53505. /**
  53506. * File name for the controller model.
  53507. */
  53508. static MODEL_FILENAME: string;
  53509. /**
  53510. * Creates a new ViveController from a gamepad
  53511. * @param vrGamepad the gamepad that the controller should be created from
  53512. */
  53513. constructor(vrGamepad: any);
  53514. /**
  53515. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53516. * @param scene scene in which to add meshes
  53517. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53518. */
  53519. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53520. /**
  53521. * Fired when the left button on this controller is modified
  53522. */
  53523. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53524. /**
  53525. * Fired when the right button on this controller is modified
  53526. */
  53527. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53528. /**
  53529. * Fired when the menu button on this controller is modified
  53530. */
  53531. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53532. /**
  53533. * Called once for each button that changed state since the last frame
  53534. * Vive mapping:
  53535. * 0: touchpad
  53536. * 1: trigger
  53537. * 2: left AND right buttons
  53538. * 3: menu button
  53539. * @param buttonIdx Which button index changed
  53540. * @param state New state of the button
  53541. * @param changes Which properties on the state changed since last frame
  53542. */
  53543. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53544. }
  53545. }
  53546. declare module BABYLON {
  53547. /**
  53548. * Defines the WindowsMotionController object that the state of the windows motion controller
  53549. */
  53550. export class WindowsMotionController extends WebVRController {
  53551. /**
  53552. * The base url used to load the left and right controller models
  53553. */
  53554. static MODEL_BASE_URL: string;
  53555. /**
  53556. * The name of the left controller model file
  53557. */
  53558. static MODEL_LEFT_FILENAME: string;
  53559. /**
  53560. * The name of the right controller model file
  53561. */
  53562. static MODEL_RIGHT_FILENAME: string;
  53563. /**
  53564. * The controller name prefix for this controller type
  53565. */
  53566. static readonly GAMEPAD_ID_PREFIX: string;
  53567. /**
  53568. * The controller id pattern for this controller type
  53569. */
  53570. private static readonly GAMEPAD_ID_PATTERN;
  53571. private _loadedMeshInfo;
  53572. protected readonly _mapping: {
  53573. buttons: string[];
  53574. buttonMeshNames: {
  53575. trigger: string;
  53576. menu: string;
  53577. grip: string;
  53578. thumbstick: string;
  53579. trackpad: string;
  53580. };
  53581. buttonObservableNames: {
  53582. trigger: string;
  53583. menu: string;
  53584. grip: string;
  53585. thumbstick: string;
  53586. trackpad: string;
  53587. };
  53588. axisMeshNames: string[];
  53589. pointingPoseMeshName: string;
  53590. };
  53591. /**
  53592. * Fired when the trackpad on this controller is clicked
  53593. */
  53594. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53595. /**
  53596. * Fired when the trackpad on this controller is modified
  53597. */
  53598. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53599. /**
  53600. * The current x and y values of this controller's trackpad
  53601. */
  53602. trackpad: StickValues;
  53603. /**
  53604. * Creates a new WindowsMotionController from a gamepad
  53605. * @param vrGamepad the gamepad that the controller should be created from
  53606. */
  53607. constructor(vrGamepad: any);
  53608. /**
  53609. * Fired when the trigger on this controller is modified
  53610. */
  53611. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53612. /**
  53613. * Fired when the menu button on this controller is modified
  53614. */
  53615. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53616. /**
  53617. * Fired when the grip button on this controller is modified
  53618. */
  53619. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53620. /**
  53621. * Fired when the thumbstick button on this controller is modified
  53622. */
  53623. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53624. /**
  53625. * Fired when the touchpad button on this controller is modified
  53626. */
  53627. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53628. /**
  53629. * Fired when the touchpad values on this controller are modified
  53630. */
  53631. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53632. protected _updateTrackpad(): void;
  53633. /**
  53634. * Called once per frame by the engine.
  53635. */
  53636. update(): void;
  53637. /**
  53638. * Called once for each button that changed state since the last frame
  53639. * @param buttonIdx Which button index changed
  53640. * @param state New state of the button
  53641. * @param changes Which properties on the state changed since last frame
  53642. */
  53643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53644. /**
  53645. * Moves the buttons on the controller mesh based on their current state
  53646. * @param buttonName the name of the button to move
  53647. * @param buttonValue the value of the button which determines the buttons new position
  53648. */
  53649. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53650. /**
  53651. * Moves the axis on the controller mesh based on its current state
  53652. * @param axis the index of the axis
  53653. * @param axisValue the value of the axis which determines the meshes new position
  53654. * @hidden
  53655. */
  53656. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53657. /**
  53658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53659. * @param scene scene in which to add meshes
  53660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53661. */
  53662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53663. /**
  53664. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53665. * can be transformed by button presses and axes values, based on this._mapping.
  53666. *
  53667. * @param scene scene in which the meshes exist
  53668. * @param meshes list of meshes that make up the controller model to process
  53669. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53670. */
  53671. private processModel;
  53672. private createMeshInfo;
  53673. /**
  53674. * Gets the ray of the controller in the direction the controller is pointing
  53675. * @param length the length the resulting ray should be
  53676. * @returns a ray in the direction the controller is pointing
  53677. */
  53678. getForwardRay(length?: number): Ray;
  53679. /**
  53680. * Disposes of the controller
  53681. */
  53682. dispose(): void;
  53683. }
  53684. /**
  53685. * This class represents a new windows motion controller in XR.
  53686. */
  53687. export class XRWindowsMotionController extends WindowsMotionController {
  53688. /**
  53689. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53690. */
  53691. protected readonly _mapping: {
  53692. buttons: string[];
  53693. buttonMeshNames: {
  53694. trigger: string;
  53695. menu: string;
  53696. grip: string;
  53697. thumbstick: string;
  53698. trackpad: string;
  53699. };
  53700. buttonObservableNames: {
  53701. trigger: string;
  53702. menu: string;
  53703. grip: string;
  53704. thumbstick: string;
  53705. trackpad: string;
  53706. };
  53707. axisMeshNames: string[];
  53708. pointingPoseMeshName: string;
  53709. };
  53710. /**
  53711. * Construct a new XR-Based windows motion controller
  53712. *
  53713. * @param gamepadInfo the gamepad object from the browser
  53714. */
  53715. constructor(gamepadInfo: any);
  53716. /**
  53717. * holds the thumbstick values (X,Y)
  53718. */
  53719. thumbstickValues: StickValues;
  53720. /**
  53721. * Fired when the thumbstick on this controller is clicked
  53722. */
  53723. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53724. /**
  53725. * Fired when the thumbstick on this controller is modified
  53726. */
  53727. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53728. /**
  53729. * Fired when the touchpad button on this controller is modified
  53730. */
  53731. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53732. /**
  53733. * Fired when the touchpad values on this controller are modified
  53734. */
  53735. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53736. /**
  53737. * Fired when the thumbstick button on this controller is modified
  53738. * here to prevent breaking changes
  53739. */
  53740. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53741. /**
  53742. * updating the thumbstick(!) and not the trackpad.
  53743. * This is named this way due to the difference between WebVR and XR and to avoid
  53744. * changing the parent class.
  53745. */
  53746. protected _updateTrackpad(): void;
  53747. /**
  53748. * Disposes the class with joy
  53749. */
  53750. dispose(): void;
  53751. }
  53752. }
  53753. declare module BABYLON {
  53754. /**
  53755. * Class containing static functions to help procedurally build meshes
  53756. */
  53757. export class PolyhedronBuilder {
  53758. /**
  53759. * Creates a polyhedron mesh
  53760. * * 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
  53761. * * The parameter `size` (positive float, default 1) sets the polygon size
  53762. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53763. * * 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`
  53764. * * 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
  53765. * * 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)`)
  53766. * * 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
  53767. * * 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
  53768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53769. * * 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
  53770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53771. * @param name defines the name of the mesh
  53772. * @param options defines the options used to create the mesh
  53773. * @param scene defines the hosting scene
  53774. * @returns the polyhedron mesh
  53775. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53776. */
  53777. static CreatePolyhedron(name: string, options: {
  53778. type?: number;
  53779. size?: number;
  53780. sizeX?: number;
  53781. sizeY?: number;
  53782. sizeZ?: number;
  53783. custom?: any;
  53784. faceUV?: Vector4[];
  53785. faceColors?: Color4[];
  53786. flat?: boolean;
  53787. updatable?: boolean;
  53788. sideOrientation?: number;
  53789. frontUVs?: Vector4;
  53790. backUVs?: Vector4;
  53791. }, scene?: Nullable<Scene>): Mesh;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /**
  53796. * Gizmo that enables scaling a mesh along 3 axis
  53797. */
  53798. export class ScaleGizmo extends Gizmo {
  53799. /**
  53800. * Internal gizmo used for interactions on the x axis
  53801. */
  53802. xGizmo: AxisScaleGizmo;
  53803. /**
  53804. * Internal gizmo used for interactions on the y axis
  53805. */
  53806. yGizmo: AxisScaleGizmo;
  53807. /**
  53808. * Internal gizmo used for interactions on the z axis
  53809. */
  53810. zGizmo: AxisScaleGizmo;
  53811. /**
  53812. * Internal gizmo used to scale all axis equally
  53813. */
  53814. uniformScaleGizmo: AxisScaleGizmo;
  53815. private _meshAttached;
  53816. private _nodeAttached;
  53817. private _snapDistance;
  53818. private _uniformScalingMesh;
  53819. private _octahedron;
  53820. private _sensitivity;
  53821. /** Fires an event when any of it's sub gizmos are dragged */
  53822. onDragStartObservable: Observable<unknown>;
  53823. /** Fires an event when any of it's sub gizmos are released from dragging */
  53824. onDragEndObservable: Observable<unknown>;
  53825. get attachedMesh(): Nullable<AbstractMesh>;
  53826. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53827. get attachedNode(): Nullable<Node>;
  53828. set attachedNode(node: Nullable<Node>);
  53829. /**
  53830. * True when the mouse pointer is hovering a gizmo mesh
  53831. */
  53832. get isHovered(): boolean;
  53833. /**
  53834. * Creates a ScaleGizmo
  53835. * @param gizmoLayer The utility layer the gizmo will be added to
  53836. * @param thickness display gizmo axis thickness
  53837. */
  53838. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53839. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53840. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53841. /**
  53842. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53843. */
  53844. set snapDistance(value: number);
  53845. get snapDistance(): number;
  53846. /**
  53847. * Ratio for the scale of the gizmo (Default: 1)
  53848. */
  53849. set scaleRatio(value: number);
  53850. get scaleRatio(): number;
  53851. /**
  53852. * Sensitivity factor for dragging (Default: 1)
  53853. */
  53854. set sensitivity(value: number);
  53855. get sensitivity(): number;
  53856. /**
  53857. * Disposes of the gizmo
  53858. */
  53859. dispose(): void;
  53860. }
  53861. }
  53862. declare module BABYLON {
  53863. /**
  53864. * Single axis scale gizmo
  53865. */
  53866. export class AxisScaleGizmo extends Gizmo {
  53867. /**
  53868. * Drag behavior responsible for the gizmos dragging interactions
  53869. */
  53870. dragBehavior: PointerDragBehavior;
  53871. private _pointerObserver;
  53872. /**
  53873. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53874. */
  53875. snapDistance: number;
  53876. /**
  53877. * Event that fires each time the gizmo snaps to a new location.
  53878. * * snapDistance is the the change in distance
  53879. */
  53880. onSnapObservable: Observable<{
  53881. snapDistance: number;
  53882. }>;
  53883. /**
  53884. * If the scaling operation should be done on all axis (default: false)
  53885. */
  53886. uniformScaling: boolean;
  53887. /**
  53888. * Custom sensitivity value for the drag strength
  53889. */
  53890. sensitivity: number;
  53891. private _isEnabled;
  53892. private _parent;
  53893. private _arrow;
  53894. private _coloredMaterial;
  53895. private _hoverMaterial;
  53896. /**
  53897. * Creates an AxisScaleGizmo
  53898. * @param gizmoLayer The utility layer the gizmo will be added to
  53899. * @param dragAxis The axis which the gizmo will be able to scale on
  53900. * @param color The color of the gizmo
  53901. * @param thickness display gizmo axis thickness
  53902. */
  53903. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53904. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53905. /**
  53906. * If the gizmo is enabled
  53907. */
  53908. set isEnabled(value: boolean);
  53909. get isEnabled(): boolean;
  53910. /**
  53911. * Disposes of the gizmo
  53912. */
  53913. dispose(): void;
  53914. /**
  53915. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53916. * @param mesh The mesh to replace the default mesh of the gizmo
  53917. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53918. */
  53919. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53920. }
  53921. }
  53922. declare module BABYLON {
  53923. /**
  53924. * Bounding box gizmo
  53925. */
  53926. export class BoundingBoxGizmo extends Gizmo {
  53927. private _lineBoundingBox;
  53928. private _rotateSpheresParent;
  53929. private _scaleBoxesParent;
  53930. private _boundingDimensions;
  53931. private _renderObserver;
  53932. private _pointerObserver;
  53933. private _scaleDragSpeed;
  53934. private _tmpQuaternion;
  53935. private _tmpVector;
  53936. private _tmpRotationMatrix;
  53937. /**
  53938. * 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)
  53939. */
  53940. ignoreChildren: boolean;
  53941. /**
  53942. * 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)
  53943. */
  53944. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53945. /**
  53946. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53947. */
  53948. rotationSphereSize: number;
  53949. /**
  53950. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53951. */
  53952. scaleBoxSize: number;
  53953. /**
  53954. * 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)
  53955. */
  53956. fixedDragMeshScreenSize: boolean;
  53957. /**
  53958. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53959. */
  53960. fixedDragMeshScreenSizeDistanceFactor: number;
  53961. /**
  53962. * Fired when a rotation sphere or scale box is dragged
  53963. */
  53964. onDragStartObservable: Observable<{}>;
  53965. /**
  53966. * Fired when a scale box is dragged
  53967. */
  53968. onScaleBoxDragObservable: Observable<{}>;
  53969. /**
  53970. * Fired when a scale box drag is ended
  53971. */
  53972. onScaleBoxDragEndObservable: Observable<{}>;
  53973. /**
  53974. * Fired when a rotation sphere is dragged
  53975. */
  53976. onRotationSphereDragObservable: Observable<{}>;
  53977. /**
  53978. * Fired when a rotation sphere drag is ended
  53979. */
  53980. onRotationSphereDragEndObservable: Observable<{}>;
  53981. /**
  53982. * 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)
  53983. */
  53984. scalePivot: Nullable<Vector3>;
  53985. /**
  53986. * Mesh used as a pivot to rotate the attached node
  53987. */
  53988. private _anchorMesh;
  53989. private _existingMeshScale;
  53990. private _dragMesh;
  53991. private pointerDragBehavior;
  53992. private coloredMaterial;
  53993. private hoverColoredMaterial;
  53994. /**
  53995. * Sets the color of the bounding box gizmo
  53996. * @param color the color to set
  53997. */
  53998. setColor(color: Color3): void;
  53999. /**
  54000. * Creates an BoundingBoxGizmo
  54001. * @param gizmoLayer The utility layer the gizmo will be added to
  54002. * @param color The color of the gizmo
  54003. */
  54004. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54005. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54006. private _selectNode;
  54007. /**
  54008. * Updates the bounding box information for the Gizmo
  54009. */
  54010. updateBoundingBox(): void;
  54011. private _updateRotationSpheres;
  54012. private _updateScaleBoxes;
  54013. /**
  54014. * Enables rotation on the specified axis and disables rotation on the others
  54015. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54016. */
  54017. setEnabledRotationAxis(axis: string): void;
  54018. /**
  54019. * Enables/disables scaling
  54020. * @param enable if scaling should be enabled
  54021. * @param homogeneousScaling defines if scaling should only be homogeneous
  54022. */
  54023. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54024. private _updateDummy;
  54025. /**
  54026. * Enables a pointer drag behavior on the bounding box of the gizmo
  54027. */
  54028. enableDragBehavior(): void;
  54029. /**
  54030. * Disposes of the gizmo
  54031. */
  54032. dispose(): void;
  54033. /**
  54034. * 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)
  54035. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54036. * @returns the bounding box mesh with the passed in mesh as a child
  54037. */
  54038. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54039. /**
  54040. * CustomMeshes are not supported by this gizmo
  54041. * @param mesh The mesh to replace the default mesh of the gizmo
  54042. */
  54043. setCustomMesh(mesh: Mesh): void;
  54044. }
  54045. }
  54046. declare module BABYLON {
  54047. /**
  54048. * Single plane rotation gizmo
  54049. */
  54050. export class PlaneRotationGizmo extends Gizmo {
  54051. /**
  54052. * Drag behavior responsible for the gizmos dragging interactions
  54053. */
  54054. dragBehavior: PointerDragBehavior;
  54055. private _pointerObserver;
  54056. /**
  54057. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54058. */
  54059. snapDistance: number;
  54060. /**
  54061. * Event that fires each time the gizmo snaps to a new location.
  54062. * * snapDistance is the the change in distance
  54063. */
  54064. onSnapObservable: Observable<{
  54065. snapDistance: number;
  54066. }>;
  54067. private _isEnabled;
  54068. private _parent;
  54069. /**
  54070. * Creates a PlaneRotationGizmo
  54071. * @param gizmoLayer The utility layer the gizmo will be added to
  54072. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54073. * @param color The color of the gizmo
  54074. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54075. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54076. * @param thickness display gizmo axis thickness
  54077. */
  54078. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54079. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54080. /**
  54081. * If the gizmo is enabled
  54082. */
  54083. set isEnabled(value: boolean);
  54084. get isEnabled(): boolean;
  54085. /**
  54086. * Disposes of the gizmo
  54087. */
  54088. dispose(): void;
  54089. }
  54090. }
  54091. declare module BABYLON {
  54092. /**
  54093. * Gizmo that enables rotating a mesh along 3 axis
  54094. */
  54095. export class RotationGizmo extends Gizmo {
  54096. /**
  54097. * Internal gizmo used for interactions on the x axis
  54098. */
  54099. xGizmo: PlaneRotationGizmo;
  54100. /**
  54101. * Internal gizmo used for interactions on the y axis
  54102. */
  54103. yGizmo: PlaneRotationGizmo;
  54104. /**
  54105. * Internal gizmo used for interactions on the z axis
  54106. */
  54107. zGizmo: PlaneRotationGizmo;
  54108. /** Fires an event when any of it's sub gizmos are dragged */
  54109. onDragStartObservable: Observable<unknown>;
  54110. /** Fires an event when any of it's sub gizmos are released from dragging */
  54111. onDragEndObservable: Observable<unknown>;
  54112. private _meshAttached;
  54113. private _nodeAttached;
  54114. get attachedMesh(): Nullable<AbstractMesh>;
  54115. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54116. get attachedNode(): Nullable<Node>;
  54117. set attachedNode(node: Nullable<Node>);
  54118. /**
  54119. * True when the mouse pointer is hovering a gizmo mesh
  54120. */
  54121. get isHovered(): boolean;
  54122. /**
  54123. * Creates a RotationGizmo
  54124. * @param gizmoLayer The utility layer the gizmo will be added to
  54125. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54126. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54127. * @param thickness display gizmo axis thickness
  54128. */
  54129. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  54130. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54131. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54132. /**
  54133. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54134. */
  54135. set snapDistance(value: number);
  54136. get snapDistance(): number;
  54137. /**
  54138. * Ratio for the scale of the gizmo (Default: 1)
  54139. */
  54140. set scaleRatio(value: number);
  54141. get scaleRatio(): number;
  54142. /**
  54143. * Disposes of the gizmo
  54144. */
  54145. dispose(): void;
  54146. /**
  54147. * CustomMeshes are not supported by this gizmo
  54148. * @param mesh The mesh to replace the default mesh of the gizmo
  54149. */
  54150. setCustomMesh(mesh: Mesh): void;
  54151. }
  54152. }
  54153. declare module BABYLON {
  54154. /**
  54155. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54156. */
  54157. export class GizmoManager implements IDisposable {
  54158. private scene;
  54159. /**
  54160. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54161. */
  54162. gizmos: {
  54163. positionGizmo: Nullable<PositionGizmo>;
  54164. rotationGizmo: Nullable<RotationGizmo>;
  54165. scaleGizmo: Nullable<ScaleGizmo>;
  54166. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54167. };
  54168. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54169. clearGizmoOnEmptyPointerEvent: boolean;
  54170. /** Fires an event when the manager is attached to a mesh */
  54171. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54172. /** Fires an event when the manager is attached to a node */
  54173. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54174. private _gizmosEnabled;
  54175. private _pointerObserver;
  54176. private _attachedMesh;
  54177. private _attachedNode;
  54178. private _boundingBoxColor;
  54179. private _defaultUtilityLayer;
  54180. private _defaultKeepDepthUtilityLayer;
  54181. private _thickness;
  54182. /**
  54183. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54184. */
  54185. boundingBoxDragBehavior: SixDofDragBehavior;
  54186. /**
  54187. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54188. */
  54189. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54190. /**
  54191. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54192. */
  54193. attachableNodes: Nullable<Array<Node>>;
  54194. /**
  54195. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54196. */
  54197. usePointerToAttachGizmos: boolean;
  54198. /**
  54199. * Utility layer that the bounding box gizmo belongs to
  54200. */
  54201. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54202. /**
  54203. * Utility layer that all gizmos besides bounding box belong to
  54204. */
  54205. get utilityLayer(): UtilityLayerRenderer;
  54206. /**
  54207. * True when the mouse pointer is hovering a gizmo mesh
  54208. */
  54209. get isHovered(): boolean;
  54210. /**
  54211. * Instatiates a gizmo manager
  54212. * @param scene the scene to overlay the gizmos on top of
  54213. * @param thickness display gizmo axis thickness
  54214. */
  54215. constructor(scene: Scene, thickness?: number);
  54216. /**
  54217. * Attaches a set of gizmos to the specified mesh
  54218. * @param mesh The mesh the gizmo's should be attached to
  54219. */
  54220. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54221. /**
  54222. * Attaches a set of gizmos to the specified node
  54223. * @param node The node the gizmo's should be attached to
  54224. */
  54225. attachToNode(node: Nullable<Node>): void;
  54226. /**
  54227. * If the position gizmo is enabled
  54228. */
  54229. set positionGizmoEnabled(value: boolean);
  54230. get positionGizmoEnabled(): boolean;
  54231. /**
  54232. * If the rotation gizmo is enabled
  54233. */
  54234. set rotationGizmoEnabled(value: boolean);
  54235. get rotationGizmoEnabled(): boolean;
  54236. /**
  54237. * If the scale gizmo is enabled
  54238. */
  54239. set scaleGizmoEnabled(value: boolean);
  54240. get scaleGizmoEnabled(): boolean;
  54241. /**
  54242. * If the boundingBox gizmo is enabled
  54243. */
  54244. set boundingBoxGizmoEnabled(value: boolean);
  54245. get boundingBoxGizmoEnabled(): boolean;
  54246. /**
  54247. * Disposes of the gizmo manager
  54248. */
  54249. dispose(): void;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * A directional light is defined by a direction (what a surprise!).
  54255. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54256. * 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.
  54257. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54258. */
  54259. export class DirectionalLight extends ShadowLight {
  54260. private _shadowFrustumSize;
  54261. /**
  54262. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54263. */
  54264. get shadowFrustumSize(): number;
  54265. /**
  54266. * Specifies a fix frustum size for the shadow generation.
  54267. */
  54268. set shadowFrustumSize(value: number);
  54269. private _shadowOrthoScale;
  54270. /**
  54271. * Gets the shadow projection scale against the optimal computed one.
  54272. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54273. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54274. */
  54275. get shadowOrthoScale(): number;
  54276. /**
  54277. * Sets the shadow projection scale against the optimal computed one.
  54278. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54279. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54280. */
  54281. set shadowOrthoScale(value: number);
  54282. /**
  54283. * Automatically compute the projection matrix to best fit (including all the casters)
  54284. * on each frame.
  54285. */
  54286. autoUpdateExtends: boolean;
  54287. /**
  54288. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54289. * on each frame. autoUpdateExtends must be set to true for this to work
  54290. */
  54291. autoCalcShadowZBounds: boolean;
  54292. private _orthoLeft;
  54293. private _orthoRight;
  54294. private _orthoTop;
  54295. private _orthoBottom;
  54296. /**
  54297. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54298. * The directional light is emitted from everywhere in the given direction.
  54299. * It can cast shadows.
  54300. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54301. * @param name The friendly name of the light
  54302. * @param direction The direction of the light
  54303. * @param scene The scene the light belongs to
  54304. */
  54305. constructor(name: string, direction: Vector3, scene: Scene);
  54306. /**
  54307. * Returns the string "DirectionalLight".
  54308. * @return The class name
  54309. */
  54310. getClassName(): string;
  54311. /**
  54312. * Returns the integer 1.
  54313. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54314. */
  54315. getTypeID(): number;
  54316. /**
  54317. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54318. * Returns the DirectionalLight Shadow projection matrix.
  54319. */
  54320. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54321. /**
  54322. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54323. * Returns the DirectionalLight Shadow projection matrix.
  54324. */
  54325. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54326. /**
  54327. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54328. * Returns the DirectionalLight Shadow projection matrix.
  54329. */
  54330. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54331. protected _buildUniformLayout(): void;
  54332. /**
  54333. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54334. * @param effect The effect to update
  54335. * @param lightIndex The index of the light in the effect to update
  54336. * @returns The directional light
  54337. */
  54338. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54339. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54340. /**
  54341. * Gets the minZ used for shadow according to both the scene and the light.
  54342. *
  54343. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54344. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54345. * @param activeCamera The camera we are returning the min for
  54346. * @returns the depth min z
  54347. */
  54348. getDepthMinZ(activeCamera: Camera): number;
  54349. /**
  54350. * Gets the maxZ used for shadow according to both the scene and the light.
  54351. *
  54352. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54353. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54354. * @param activeCamera The camera we are returning the max for
  54355. * @returns the depth max z
  54356. */
  54357. getDepthMaxZ(activeCamera: Camera): number;
  54358. /**
  54359. * Prepares the list of defines specific to the light type.
  54360. * @param defines the list of defines
  54361. * @param lightIndex defines the index of the light for the effect
  54362. */
  54363. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54364. }
  54365. }
  54366. declare module BABYLON {
  54367. /**
  54368. * Class containing static functions to help procedurally build meshes
  54369. */
  54370. export class HemisphereBuilder {
  54371. /**
  54372. * Creates a hemisphere mesh
  54373. * @param name defines the name of the mesh
  54374. * @param options defines the options used to create the mesh
  54375. * @param scene defines the hosting scene
  54376. * @returns the hemisphere mesh
  54377. */
  54378. static CreateHemisphere(name: string, options: {
  54379. segments?: number;
  54380. diameter?: number;
  54381. sideOrientation?: number;
  54382. }, scene: any): Mesh;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /**
  54387. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54388. * These values define a cone of light starting from the position, emitting toward the direction.
  54389. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54390. * and the exponent defines the speed of the decay of the light with distance (reach).
  54391. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54392. */
  54393. export class SpotLight extends ShadowLight {
  54394. private _angle;
  54395. private _innerAngle;
  54396. private _cosHalfAngle;
  54397. private _lightAngleScale;
  54398. private _lightAngleOffset;
  54399. /**
  54400. * Gets the cone angle of the spot light in Radians.
  54401. */
  54402. get angle(): number;
  54403. /**
  54404. * Sets the cone angle of the spot light in Radians.
  54405. */
  54406. set angle(value: number);
  54407. /**
  54408. * Only used in gltf falloff mode, this defines the angle where
  54409. * the directional falloff will start before cutting at angle which could be seen
  54410. * as outer angle.
  54411. */
  54412. get innerAngle(): number;
  54413. /**
  54414. * Only used in gltf falloff mode, this defines the angle where
  54415. * the directional falloff will start before cutting at angle which could be seen
  54416. * as outer angle.
  54417. */
  54418. set innerAngle(value: number);
  54419. private _shadowAngleScale;
  54420. /**
  54421. * Allows scaling the angle of the light for shadow generation only.
  54422. */
  54423. get shadowAngleScale(): number;
  54424. /**
  54425. * Allows scaling the angle of the light for shadow generation only.
  54426. */
  54427. set shadowAngleScale(value: number);
  54428. /**
  54429. * The light decay speed with the distance from the emission spot.
  54430. */
  54431. exponent: number;
  54432. private _projectionTextureMatrix;
  54433. /**
  54434. * Allows reading the projecton texture
  54435. */
  54436. get projectionTextureMatrix(): Matrix;
  54437. protected _projectionTextureLightNear: number;
  54438. /**
  54439. * Gets the near clip of the Spotlight for texture projection.
  54440. */
  54441. get projectionTextureLightNear(): number;
  54442. /**
  54443. * Sets the near clip of the Spotlight for texture projection.
  54444. */
  54445. set projectionTextureLightNear(value: number);
  54446. protected _projectionTextureLightFar: number;
  54447. /**
  54448. * Gets the far clip of the Spotlight for texture projection.
  54449. */
  54450. get projectionTextureLightFar(): number;
  54451. /**
  54452. * Sets the far clip of the Spotlight for texture projection.
  54453. */
  54454. set projectionTextureLightFar(value: number);
  54455. protected _projectionTextureUpDirection: Vector3;
  54456. /**
  54457. * Gets the Up vector of the Spotlight for texture projection.
  54458. */
  54459. get projectionTextureUpDirection(): Vector3;
  54460. /**
  54461. * Sets the Up vector of the Spotlight for texture projection.
  54462. */
  54463. set projectionTextureUpDirection(value: Vector3);
  54464. private _projectionTexture;
  54465. /**
  54466. * Gets the projection texture of the light.
  54467. */
  54468. get projectionTexture(): Nullable<BaseTexture>;
  54469. /**
  54470. * Sets the projection texture of the light.
  54471. */
  54472. set projectionTexture(value: Nullable<BaseTexture>);
  54473. private _projectionTextureViewLightDirty;
  54474. private _projectionTextureProjectionLightDirty;
  54475. private _projectionTextureDirty;
  54476. private _projectionTextureViewTargetVector;
  54477. private _projectionTextureViewLightMatrix;
  54478. private _projectionTextureProjectionLightMatrix;
  54479. private _projectionTextureScalingMatrix;
  54480. /**
  54481. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54482. * It can cast shadows.
  54483. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54484. * @param name The light friendly name
  54485. * @param position The position of the spot light in the scene
  54486. * @param direction The direction of the light in the scene
  54487. * @param angle The cone angle of the light in Radians
  54488. * @param exponent The light decay speed with the distance from the emission spot
  54489. * @param scene The scene the lights belongs to
  54490. */
  54491. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54492. /**
  54493. * Returns the string "SpotLight".
  54494. * @returns the class name
  54495. */
  54496. getClassName(): string;
  54497. /**
  54498. * Returns the integer 2.
  54499. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54500. */
  54501. getTypeID(): number;
  54502. /**
  54503. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54504. */
  54505. protected _setDirection(value: Vector3): void;
  54506. /**
  54507. * Overrides the position setter to recompute the projection texture view light Matrix.
  54508. */
  54509. protected _setPosition(value: Vector3): void;
  54510. /**
  54511. * 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.
  54512. * Returns the SpotLight.
  54513. */
  54514. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54515. protected _computeProjectionTextureViewLightMatrix(): void;
  54516. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54517. /**
  54518. * Main function for light texture projection matrix computing.
  54519. */
  54520. protected _computeProjectionTextureMatrix(): void;
  54521. protected _buildUniformLayout(): void;
  54522. private _computeAngleValues;
  54523. /**
  54524. * Sets the passed Effect "effect" with the Light textures.
  54525. * @param effect The effect to update
  54526. * @param lightIndex The index of the light in the effect to update
  54527. * @returns The light
  54528. */
  54529. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54530. /**
  54531. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54532. * @param effect The effect to update
  54533. * @param lightIndex The index of the light in the effect to update
  54534. * @returns The spot light
  54535. */
  54536. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54537. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54538. /**
  54539. * Disposes the light and the associated resources.
  54540. */
  54541. dispose(): void;
  54542. /**
  54543. * Prepares the list of defines specific to the light type.
  54544. * @param defines the list of defines
  54545. * @param lightIndex defines the index of the light for the effect
  54546. */
  54547. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54548. }
  54549. }
  54550. declare module BABYLON {
  54551. /**
  54552. * Gizmo that enables viewing a light
  54553. */
  54554. export class LightGizmo extends Gizmo {
  54555. private _lightMesh;
  54556. private _material;
  54557. private _cachedPosition;
  54558. private _cachedForward;
  54559. private _attachedMeshParent;
  54560. private _pointerObserver;
  54561. /**
  54562. * Event that fires each time the gizmo is clicked
  54563. */
  54564. onClickedObservable: Observable<Light>;
  54565. /**
  54566. * Creates a LightGizmo
  54567. * @param gizmoLayer The utility layer the gizmo will be added to
  54568. */
  54569. constructor(gizmoLayer?: UtilityLayerRenderer);
  54570. private _light;
  54571. /**
  54572. * The light that the gizmo is attached to
  54573. */
  54574. set light(light: Nullable<Light>);
  54575. get light(): Nullable<Light>;
  54576. /**
  54577. * Gets the material used to render the light gizmo
  54578. */
  54579. get material(): StandardMaterial;
  54580. /**
  54581. * @hidden
  54582. * Updates the gizmo to match the attached mesh's position/rotation
  54583. */
  54584. protected _update(): void;
  54585. private static _Scale;
  54586. /**
  54587. * Creates the lines for a light mesh
  54588. */
  54589. private static _CreateLightLines;
  54590. /**
  54591. * Disposes of the light gizmo
  54592. */
  54593. dispose(): void;
  54594. private static _CreateHemisphericLightMesh;
  54595. private static _CreatePointLightMesh;
  54596. private static _CreateSpotLightMesh;
  54597. private static _CreateDirectionalLightMesh;
  54598. }
  54599. }
  54600. declare module BABYLON {
  54601. /**
  54602. * Gizmo that enables viewing a camera
  54603. */
  54604. export class CameraGizmo extends Gizmo {
  54605. private _cameraMesh;
  54606. private _cameraLinesMesh;
  54607. private _material;
  54608. private _pointerObserver;
  54609. /**
  54610. * Event that fires each time the gizmo is clicked
  54611. */
  54612. onClickedObservable: Observable<Camera>;
  54613. /**
  54614. * Creates a CameraGizmo
  54615. * @param gizmoLayer The utility layer the gizmo will be added to
  54616. */
  54617. constructor(gizmoLayer?: UtilityLayerRenderer);
  54618. private _camera;
  54619. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54620. get displayFrustum(): boolean;
  54621. set displayFrustum(value: boolean);
  54622. /**
  54623. * The camera that the gizmo is attached to
  54624. */
  54625. set camera(camera: Nullable<Camera>);
  54626. get camera(): Nullable<Camera>;
  54627. /**
  54628. * Gets the material used to render the camera gizmo
  54629. */
  54630. get material(): StandardMaterial;
  54631. /**
  54632. * @hidden
  54633. * Updates the gizmo to match the attached mesh's position/rotation
  54634. */
  54635. protected _update(): void;
  54636. private static _Scale;
  54637. private _invProjection;
  54638. /**
  54639. * Disposes of the camera gizmo
  54640. */
  54641. dispose(): void;
  54642. private static _CreateCameraMesh;
  54643. private static _CreateCameraFrustum;
  54644. }
  54645. }
  54646. declare module BABYLON {
  54647. /** @hidden */
  54648. export var backgroundFragmentDeclaration: {
  54649. name: string;
  54650. shader: string;
  54651. };
  54652. }
  54653. declare module BABYLON {
  54654. /** @hidden */
  54655. export var backgroundUboDeclaration: {
  54656. name: string;
  54657. shader: string;
  54658. };
  54659. }
  54660. declare module BABYLON {
  54661. /** @hidden */
  54662. export var backgroundPixelShader: {
  54663. name: string;
  54664. shader: string;
  54665. };
  54666. }
  54667. declare module BABYLON {
  54668. /** @hidden */
  54669. export var backgroundVertexDeclaration: {
  54670. name: string;
  54671. shader: string;
  54672. };
  54673. }
  54674. declare module BABYLON {
  54675. /** @hidden */
  54676. export var backgroundVertexShader: {
  54677. name: string;
  54678. shader: string;
  54679. };
  54680. }
  54681. declare module BABYLON {
  54682. /**
  54683. * Background material used to create an efficient environement around your scene.
  54684. */
  54685. export class BackgroundMaterial extends PushMaterial {
  54686. /**
  54687. * Standard reflectance value at parallel view angle.
  54688. */
  54689. static StandardReflectance0: number;
  54690. /**
  54691. * Standard reflectance value at grazing angle.
  54692. */
  54693. static StandardReflectance90: number;
  54694. protected _primaryColor: Color3;
  54695. /**
  54696. * Key light Color (multiply against the environement texture)
  54697. */
  54698. primaryColor: Color3;
  54699. protected __perceptualColor: Nullable<Color3>;
  54700. /**
  54701. * Experimental Internal Use Only.
  54702. *
  54703. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54704. * This acts as a helper to set the primary color to a more "human friendly" value.
  54705. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54706. * output color as close as possible from the chosen value.
  54707. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54708. * part of lighting setup.)
  54709. */
  54710. get _perceptualColor(): Nullable<Color3>;
  54711. set _perceptualColor(value: Nullable<Color3>);
  54712. protected _primaryColorShadowLevel: float;
  54713. /**
  54714. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54715. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54716. */
  54717. get primaryColorShadowLevel(): float;
  54718. set primaryColorShadowLevel(value: float);
  54719. protected _primaryColorHighlightLevel: float;
  54720. /**
  54721. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54722. * The primary color is used at the level chosen to define what the white area would look.
  54723. */
  54724. get primaryColorHighlightLevel(): float;
  54725. set primaryColorHighlightLevel(value: float);
  54726. protected _reflectionTexture: Nullable<BaseTexture>;
  54727. /**
  54728. * Reflection Texture used in the material.
  54729. * Should be author in a specific way for the best result (refer to the documentation).
  54730. */
  54731. reflectionTexture: Nullable<BaseTexture>;
  54732. protected _reflectionBlur: float;
  54733. /**
  54734. * Reflection Texture level of blur.
  54735. *
  54736. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54737. * texture twice.
  54738. */
  54739. reflectionBlur: float;
  54740. protected _diffuseTexture: Nullable<BaseTexture>;
  54741. /**
  54742. * Diffuse Texture used in the material.
  54743. * Should be author in a specific way for the best result (refer to the documentation).
  54744. */
  54745. diffuseTexture: Nullable<BaseTexture>;
  54746. protected _shadowLights: Nullable<IShadowLight[]>;
  54747. /**
  54748. * Specify the list of lights casting shadow on the material.
  54749. * All scene shadow lights will be included if null.
  54750. */
  54751. shadowLights: Nullable<IShadowLight[]>;
  54752. protected _shadowLevel: float;
  54753. /**
  54754. * Helps adjusting the shadow to a softer level if required.
  54755. * 0 means black shadows and 1 means no shadows.
  54756. */
  54757. shadowLevel: float;
  54758. protected _sceneCenter: Vector3;
  54759. /**
  54760. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54761. * It is usually zero but might be interesting to modify according to your setup.
  54762. */
  54763. sceneCenter: Vector3;
  54764. protected _opacityFresnel: boolean;
  54765. /**
  54766. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54767. * This helps ensuring a nice transition when the camera goes under the ground.
  54768. */
  54769. opacityFresnel: boolean;
  54770. protected _reflectionFresnel: boolean;
  54771. /**
  54772. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54773. * This helps adding a mirror texture on the ground.
  54774. */
  54775. reflectionFresnel: boolean;
  54776. protected _reflectionFalloffDistance: number;
  54777. /**
  54778. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54779. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54780. */
  54781. reflectionFalloffDistance: number;
  54782. protected _reflectionAmount: number;
  54783. /**
  54784. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54785. */
  54786. reflectionAmount: number;
  54787. protected _reflectionReflectance0: number;
  54788. /**
  54789. * This specifies the weight of the reflection at grazing angle.
  54790. */
  54791. reflectionReflectance0: number;
  54792. protected _reflectionReflectance90: number;
  54793. /**
  54794. * This specifies the weight of the reflection at a perpendicular point of view.
  54795. */
  54796. reflectionReflectance90: number;
  54797. /**
  54798. * Sets the reflection reflectance fresnel values according to the default standard
  54799. * empirically know to work well :-)
  54800. */
  54801. set reflectionStandardFresnelWeight(value: number);
  54802. protected _useRGBColor: boolean;
  54803. /**
  54804. * Helps to directly use the maps channels instead of their level.
  54805. */
  54806. useRGBColor: boolean;
  54807. protected _enableNoise: boolean;
  54808. /**
  54809. * This helps reducing the banding effect that could occur on the background.
  54810. */
  54811. enableNoise: boolean;
  54812. /**
  54813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54814. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54815. * Recommended to be keep at 1.0 except for special cases.
  54816. */
  54817. get fovMultiplier(): number;
  54818. set fovMultiplier(value: number);
  54819. private _fovMultiplier;
  54820. /**
  54821. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54822. */
  54823. useEquirectangularFOV: boolean;
  54824. private _maxSimultaneousLights;
  54825. /**
  54826. * Number of Simultaneous lights allowed on the material.
  54827. */
  54828. maxSimultaneousLights: int;
  54829. private _shadowOnly;
  54830. /**
  54831. * Make the material only render shadows
  54832. */
  54833. shadowOnly: boolean;
  54834. /**
  54835. * Default configuration related to image processing available in the Background Material.
  54836. */
  54837. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54838. /**
  54839. * Keep track of the image processing observer to allow dispose and replace.
  54840. */
  54841. private _imageProcessingObserver;
  54842. /**
  54843. * Attaches a new image processing configuration to the PBR Material.
  54844. * @param configuration (if null the scene configuration will be use)
  54845. */
  54846. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54847. /**
  54848. * Gets the image processing configuration used either in this material.
  54849. */
  54850. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54851. /**
  54852. * Sets the Default image processing configuration used either in the this material.
  54853. *
  54854. * If sets to null, the scene one is in use.
  54855. */
  54856. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54857. /**
  54858. * Gets wether the color curves effect is enabled.
  54859. */
  54860. get cameraColorCurvesEnabled(): boolean;
  54861. /**
  54862. * Sets wether the color curves effect is enabled.
  54863. */
  54864. set cameraColorCurvesEnabled(value: boolean);
  54865. /**
  54866. * Gets wether the color grading effect is enabled.
  54867. */
  54868. get cameraColorGradingEnabled(): boolean;
  54869. /**
  54870. * Gets wether the color grading effect is enabled.
  54871. */
  54872. set cameraColorGradingEnabled(value: boolean);
  54873. /**
  54874. * Gets wether tonemapping is enabled or not.
  54875. */
  54876. get cameraToneMappingEnabled(): boolean;
  54877. /**
  54878. * Sets wether tonemapping is enabled or not
  54879. */
  54880. set cameraToneMappingEnabled(value: boolean);
  54881. /**
  54882. * The camera exposure used on this material.
  54883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54884. * This corresponds to a photographic exposure.
  54885. */
  54886. get cameraExposure(): float;
  54887. /**
  54888. * The camera exposure used on this material.
  54889. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54890. * This corresponds to a photographic exposure.
  54891. */
  54892. set cameraExposure(value: float);
  54893. /**
  54894. * Gets The camera contrast used on this material.
  54895. */
  54896. get cameraContrast(): float;
  54897. /**
  54898. * Sets The camera contrast used on this material.
  54899. */
  54900. set cameraContrast(value: float);
  54901. /**
  54902. * Gets the Color Grading 2D Lookup Texture.
  54903. */
  54904. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54905. /**
  54906. * Sets the Color Grading 2D Lookup Texture.
  54907. */
  54908. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54909. /**
  54910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54912. * 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;
  54913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54914. */
  54915. get cameraColorCurves(): Nullable<ColorCurves>;
  54916. /**
  54917. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54918. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54919. * 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;
  54920. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54921. */
  54922. set cameraColorCurves(value: Nullable<ColorCurves>);
  54923. /**
  54924. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54925. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54926. */
  54927. switchToBGR: boolean;
  54928. private _renderTargets;
  54929. private _reflectionControls;
  54930. private _white;
  54931. private _primaryShadowColor;
  54932. private _primaryHighlightColor;
  54933. /**
  54934. * Instantiates a Background Material in the given scene
  54935. * @param name The friendly name of the material
  54936. * @param scene The scene to add the material to
  54937. */
  54938. constructor(name: string, scene: Scene);
  54939. /**
  54940. * Gets a boolean indicating that current material needs to register RTT
  54941. */
  54942. get hasRenderTargetTextures(): boolean;
  54943. /**
  54944. * The entire material has been created in order to prevent overdraw.
  54945. * @returns false
  54946. */
  54947. needAlphaTesting(): boolean;
  54948. /**
  54949. * The entire material has been created in order to prevent overdraw.
  54950. * @returns true if blending is enable
  54951. */
  54952. needAlphaBlending(): boolean;
  54953. /**
  54954. * Checks wether the material is ready to be rendered for a given mesh.
  54955. * @param mesh The mesh to render
  54956. * @param subMesh The submesh to check against
  54957. * @param useInstances Specify wether or not the material is used with instances
  54958. * @returns true if all the dependencies are ready (Textures, Effects...)
  54959. */
  54960. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54961. /**
  54962. * Compute the primary color according to the chosen perceptual color.
  54963. */
  54964. private _computePrimaryColorFromPerceptualColor;
  54965. /**
  54966. * Compute the highlights and shadow colors according to their chosen levels.
  54967. */
  54968. private _computePrimaryColors;
  54969. /**
  54970. * Build the uniform buffer used in the material.
  54971. */
  54972. buildUniformLayout(): void;
  54973. /**
  54974. * Unbind the material.
  54975. */
  54976. unbind(): void;
  54977. /**
  54978. * Bind only the world matrix to the material.
  54979. * @param world The world matrix to bind.
  54980. */
  54981. bindOnlyWorldMatrix(world: Matrix): void;
  54982. /**
  54983. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54984. * @param world The world matrix to bind.
  54985. * @param subMesh The submesh to bind for.
  54986. */
  54987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54988. /**
  54989. * Checks to see if a texture is used in the material.
  54990. * @param texture - Base texture to use.
  54991. * @returns - Boolean specifying if a texture is used in the material.
  54992. */
  54993. hasTexture(texture: BaseTexture): boolean;
  54994. /**
  54995. * Dispose the material.
  54996. * @param forceDisposeEffect Force disposal of the associated effect.
  54997. * @param forceDisposeTextures Force disposal of the associated textures.
  54998. */
  54999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55000. /**
  55001. * Clones the material.
  55002. * @param name The cloned name.
  55003. * @returns The cloned material.
  55004. */
  55005. clone(name: string): BackgroundMaterial;
  55006. /**
  55007. * Serializes the current material to its JSON representation.
  55008. * @returns The JSON representation.
  55009. */
  55010. serialize(): any;
  55011. /**
  55012. * Gets the class name of the material
  55013. * @returns "BackgroundMaterial"
  55014. */
  55015. getClassName(): string;
  55016. /**
  55017. * Parse a JSON input to create back a background material.
  55018. * @param source The JSON data to parse
  55019. * @param scene The scene to create the parsed material in
  55020. * @param rootUrl The root url of the assets the material depends upon
  55021. * @returns the instantiated BackgroundMaterial.
  55022. */
  55023. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55024. }
  55025. }
  55026. declare module BABYLON {
  55027. /**
  55028. * Represents the different options available during the creation of
  55029. * a Environment helper.
  55030. *
  55031. * This can control the default ground, skybox and image processing setup of your scene.
  55032. */
  55033. export interface IEnvironmentHelperOptions {
  55034. /**
  55035. * Specifies whether or not to create a ground.
  55036. * True by default.
  55037. */
  55038. createGround: boolean;
  55039. /**
  55040. * Specifies the ground size.
  55041. * 15 by default.
  55042. */
  55043. groundSize: number;
  55044. /**
  55045. * The texture used on the ground for the main color.
  55046. * Comes from the BabylonJS CDN by default.
  55047. *
  55048. * Remarks: Can be either a texture or a url.
  55049. */
  55050. groundTexture: string | BaseTexture;
  55051. /**
  55052. * The color mixed in the ground texture by default.
  55053. * BabylonJS clearColor by default.
  55054. */
  55055. groundColor: Color3;
  55056. /**
  55057. * Specifies the ground opacity.
  55058. * 1 by default.
  55059. */
  55060. groundOpacity: number;
  55061. /**
  55062. * Enables the ground to receive shadows.
  55063. * True by default.
  55064. */
  55065. enableGroundShadow: boolean;
  55066. /**
  55067. * Helps preventing the shadow to be fully black on the ground.
  55068. * 0.5 by default.
  55069. */
  55070. groundShadowLevel: number;
  55071. /**
  55072. * Creates a mirror texture attach to the ground.
  55073. * false by default.
  55074. */
  55075. enableGroundMirror: boolean;
  55076. /**
  55077. * Specifies the ground mirror size ratio.
  55078. * 0.3 by default as the default kernel is 64.
  55079. */
  55080. groundMirrorSizeRatio: number;
  55081. /**
  55082. * Specifies the ground mirror blur kernel size.
  55083. * 64 by default.
  55084. */
  55085. groundMirrorBlurKernel: number;
  55086. /**
  55087. * Specifies the ground mirror visibility amount.
  55088. * 1 by default
  55089. */
  55090. groundMirrorAmount: number;
  55091. /**
  55092. * Specifies the ground mirror reflectance weight.
  55093. * This uses the standard weight of the background material to setup the fresnel effect
  55094. * of the mirror.
  55095. * 1 by default.
  55096. */
  55097. groundMirrorFresnelWeight: number;
  55098. /**
  55099. * Specifies the ground mirror Falloff distance.
  55100. * This can helps reducing the size of the reflection.
  55101. * 0 by Default.
  55102. */
  55103. groundMirrorFallOffDistance: number;
  55104. /**
  55105. * Specifies the ground mirror texture type.
  55106. * Unsigned Int by Default.
  55107. */
  55108. groundMirrorTextureType: number;
  55109. /**
  55110. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55111. * the shown objects.
  55112. */
  55113. groundYBias: number;
  55114. /**
  55115. * Specifies whether or not to create a skybox.
  55116. * True by default.
  55117. */
  55118. createSkybox: boolean;
  55119. /**
  55120. * Specifies the skybox size.
  55121. * 20 by default.
  55122. */
  55123. skyboxSize: number;
  55124. /**
  55125. * The texture used on the skybox for the main color.
  55126. * Comes from the BabylonJS CDN by default.
  55127. *
  55128. * Remarks: Can be either a texture or a url.
  55129. */
  55130. skyboxTexture: string | BaseTexture;
  55131. /**
  55132. * The color mixed in the skybox texture by default.
  55133. * BabylonJS clearColor by default.
  55134. */
  55135. skyboxColor: Color3;
  55136. /**
  55137. * The background rotation around the Y axis of the scene.
  55138. * This helps aligning the key lights of your scene with the background.
  55139. * 0 by default.
  55140. */
  55141. backgroundYRotation: number;
  55142. /**
  55143. * Compute automatically the size of the elements to best fit with the scene.
  55144. */
  55145. sizeAuto: boolean;
  55146. /**
  55147. * Default position of the rootMesh if autoSize is not true.
  55148. */
  55149. rootPosition: Vector3;
  55150. /**
  55151. * Sets up the image processing in the scene.
  55152. * true by default.
  55153. */
  55154. setupImageProcessing: boolean;
  55155. /**
  55156. * The texture used as your environment texture in the scene.
  55157. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55158. *
  55159. * Remarks: Can be either a texture or a url.
  55160. */
  55161. environmentTexture: string | BaseTexture;
  55162. /**
  55163. * The value of the exposure to apply to the scene.
  55164. * 0.6 by default if setupImageProcessing is true.
  55165. */
  55166. cameraExposure: number;
  55167. /**
  55168. * The value of the contrast to apply to the scene.
  55169. * 1.6 by default if setupImageProcessing is true.
  55170. */
  55171. cameraContrast: number;
  55172. /**
  55173. * Specifies whether or not tonemapping should be enabled in the scene.
  55174. * true by default if setupImageProcessing is true.
  55175. */
  55176. toneMappingEnabled: boolean;
  55177. }
  55178. /**
  55179. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55180. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55181. * It also helps with the default setup of your imageProcessing configuration.
  55182. */
  55183. export class EnvironmentHelper {
  55184. /**
  55185. * Default ground texture URL.
  55186. */
  55187. private static _groundTextureCDNUrl;
  55188. /**
  55189. * Default skybox texture URL.
  55190. */
  55191. private static _skyboxTextureCDNUrl;
  55192. /**
  55193. * Default environment texture URL.
  55194. */
  55195. private static _environmentTextureCDNUrl;
  55196. /**
  55197. * Creates the default options for the helper.
  55198. */
  55199. private static _getDefaultOptions;
  55200. private _rootMesh;
  55201. /**
  55202. * Gets the root mesh created by the helper.
  55203. */
  55204. get rootMesh(): Mesh;
  55205. private _skybox;
  55206. /**
  55207. * Gets the skybox created by the helper.
  55208. */
  55209. get skybox(): Nullable<Mesh>;
  55210. private _skyboxTexture;
  55211. /**
  55212. * Gets the skybox texture created by the helper.
  55213. */
  55214. get skyboxTexture(): Nullable<BaseTexture>;
  55215. private _skyboxMaterial;
  55216. /**
  55217. * Gets the skybox material created by the helper.
  55218. */
  55219. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55220. private _ground;
  55221. /**
  55222. * Gets the ground mesh created by the helper.
  55223. */
  55224. get ground(): Nullable<Mesh>;
  55225. private _groundTexture;
  55226. /**
  55227. * Gets the ground texture created by the helper.
  55228. */
  55229. get groundTexture(): Nullable<BaseTexture>;
  55230. private _groundMirror;
  55231. /**
  55232. * Gets the ground mirror created by the helper.
  55233. */
  55234. get groundMirror(): Nullable<MirrorTexture>;
  55235. /**
  55236. * Gets the ground mirror render list to helps pushing the meshes
  55237. * you wish in the ground reflection.
  55238. */
  55239. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55240. private _groundMaterial;
  55241. /**
  55242. * Gets the ground material created by the helper.
  55243. */
  55244. get groundMaterial(): Nullable<BackgroundMaterial>;
  55245. /**
  55246. * Stores the creation options.
  55247. */
  55248. private readonly _scene;
  55249. private _options;
  55250. /**
  55251. * This observable will be notified with any error during the creation of the environment,
  55252. * mainly texture creation errors.
  55253. */
  55254. onErrorObservable: Observable<{
  55255. message?: string;
  55256. exception?: any;
  55257. }>;
  55258. /**
  55259. * constructor
  55260. * @param options Defines the options we want to customize the helper
  55261. * @param scene The scene to add the material to
  55262. */
  55263. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55264. /**
  55265. * Updates the background according to the new options
  55266. * @param options
  55267. */
  55268. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55269. /**
  55270. * Sets the primary color of all the available elements.
  55271. * @param color the main color to affect to the ground and the background
  55272. */
  55273. setMainColor(color: Color3): void;
  55274. /**
  55275. * Setup the image processing according to the specified options.
  55276. */
  55277. private _setupImageProcessing;
  55278. /**
  55279. * Setup the environment texture according to the specified options.
  55280. */
  55281. private _setupEnvironmentTexture;
  55282. /**
  55283. * Setup the background according to the specified options.
  55284. */
  55285. private _setupBackground;
  55286. /**
  55287. * Get the scene sizes according to the setup.
  55288. */
  55289. private _getSceneSize;
  55290. /**
  55291. * Setup the ground according to the specified options.
  55292. */
  55293. private _setupGround;
  55294. /**
  55295. * Setup the ground material according to the specified options.
  55296. */
  55297. private _setupGroundMaterial;
  55298. /**
  55299. * Setup the ground diffuse texture according to the specified options.
  55300. */
  55301. private _setupGroundDiffuseTexture;
  55302. /**
  55303. * Setup the ground mirror texture according to the specified options.
  55304. */
  55305. private _setupGroundMirrorTexture;
  55306. /**
  55307. * Setup the ground to receive the mirror texture.
  55308. */
  55309. private _setupMirrorInGroundMaterial;
  55310. /**
  55311. * Setup the skybox according to the specified options.
  55312. */
  55313. private _setupSkybox;
  55314. /**
  55315. * Setup the skybox material according to the specified options.
  55316. */
  55317. private _setupSkyboxMaterial;
  55318. /**
  55319. * Setup the skybox reflection texture according to the specified options.
  55320. */
  55321. private _setupSkyboxReflectionTexture;
  55322. private _errorHandler;
  55323. /**
  55324. * Dispose all the elements created by the Helper.
  55325. */
  55326. dispose(): void;
  55327. }
  55328. }
  55329. declare module BABYLON {
  55330. /**
  55331. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55332. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55333. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55334. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55335. */
  55336. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55337. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55338. /**
  55339. * Define the source as a Monoscopic panoramic 360/180.
  55340. */
  55341. static readonly MODE_MONOSCOPIC: number;
  55342. /**
  55343. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55344. */
  55345. static readonly MODE_TOPBOTTOM: number;
  55346. /**
  55347. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55348. */
  55349. static readonly MODE_SIDEBYSIDE: number;
  55350. private _halfDome;
  55351. protected _useDirectMapping: boolean;
  55352. /**
  55353. * The texture being displayed on the sphere
  55354. */
  55355. protected _texture: T;
  55356. /**
  55357. * Gets the texture being displayed on the sphere
  55358. */
  55359. get texture(): T;
  55360. /**
  55361. * Sets the texture being displayed on the sphere
  55362. */
  55363. set texture(newTexture: T);
  55364. /**
  55365. * The skybox material
  55366. */
  55367. protected _material: BackgroundMaterial;
  55368. /**
  55369. * The surface used for the dome
  55370. */
  55371. protected _mesh: Mesh;
  55372. /**
  55373. * Gets the mesh used for the dome.
  55374. */
  55375. get mesh(): Mesh;
  55376. /**
  55377. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55378. */
  55379. private _halfDomeMask;
  55380. /**
  55381. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55382. * Also see the options.resolution property.
  55383. */
  55384. get fovMultiplier(): number;
  55385. set fovMultiplier(value: number);
  55386. protected _textureMode: number;
  55387. /**
  55388. * Gets or set the current texture mode for the texture. It can be:
  55389. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55390. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55391. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55392. */
  55393. get textureMode(): number;
  55394. /**
  55395. * Sets the current texture mode for the texture. It can be:
  55396. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55397. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55398. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55399. */
  55400. set textureMode(value: number);
  55401. /**
  55402. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55403. */
  55404. get halfDome(): boolean;
  55405. /**
  55406. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55407. */
  55408. set halfDome(enabled: boolean);
  55409. /**
  55410. * Oberserver used in Stereoscopic VR Mode.
  55411. */
  55412. private _onBeforeCameraRenderObserver;
  55413. /**
  55414. * Observable raised when an error occured while loading the 360 image
  55415. */
  55416. onLoadErrorObservable: Observable<string>;
  55417. /**
  55418. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55419. * @param name Element's name, child elements will append suffixes for their own names.
  55420. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55421. * @param options An object containing optional or exposed sub element properties
  55422. */
  55423. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55424. resolution?: number;
  55425. clickToPlay?: boolean;
  55426. autoPlay?: boolean;
  55427. loop?: boolean;
  55428. size?: number;
  55429. poster?: string;
  55430. faceForward?: boolean;
  55431. useDirectMapping?: boolean;
  55432. halfDomeMode?: boolean;
  55433. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55434. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55435. protected _changeTextureMode(value: number): void;
  55436. /**
  55437. * Releases resources associated with this node.
  55438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55440. */
  55441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55442. }
  55443. }
  55444. declare module BABYLON {
  55445. /**
  55446. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55447. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55448. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55449. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55450. */
  55451. export class PhotoDome extends TextureDome<Texture> {
  55452. /**
  55453. * Define the image as a Monoscopic panoramic 360 image.
  55454. */
  55455. static readonly MODE_MONOSCOPIC: number;
  55456. /**
  55457. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55458. */
  55459. static readonly MODE_TOPBOTTOM: number;
  55460. /**
  55461. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55462. */
  55463. static readonly MODE_SIDEBYSIDE: number;
  55464. /**
  55465. * Gets or sets the texture being displayed on the sphere
  55466. */
  55467. get photoTexture(): Texture;
  55468. /**
  55469. * sets the texture being displayed on the sphere
  55470. */
  55471. set photoTexture(value: Texture);
  55472. /**
  55473. * Gets the current video mode for the video. It can be:
  55474. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55475. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55476. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55477. */
  55478. get imageMode(): number;
  55479. /**
  55480. * Sets the current video mode for the video. It can be:
  55481. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55482. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55483. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55484. */
  55485. set imageMode(value: number);
  55486. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55487. }
  55488. }
  55489. declare module BABYLON {
  55490. /**
  55491. * Class used to host RGBD texture specific utilities
  55492. */
  55493. export class RGBDTextureTools {
  55494. /**
  55495. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55496. * @param texture the texture to expand.
  55497. */
  55498. static ExpandRGBDTexture(texture: Texture): void;
  55499. }
  55500. }
  55501. declare module BABYLON {
  55502. /**
  55503. * Class used to host texture specific utilities
  55504. */
  55505. export class BRDFTextureTools {
  55506. /**
  55507. * Prevents texture cache collision
  55508. */
  55509. private static _instanceNumber;
  55510. /**
  55511. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55512. * @param scene defines the hosting scene
  55513. * @returns the environment BRDF texture
  55514. */
  55515. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55516. private static _environmentBRDFBase64Texture;
  55517. }
  55518. }
  55519. declare module BABYLON {
  55520. /**
  55521. * @hidden
  55522. */
  55523. export interface IMaterialClearCoatDefines {
  55524. CLEARCOAT: boolean;
  55525. CLEARCOAT_DEFAULTIOR: boolean;
  55526. CLEARCOAT_TEXTURE: boolean;
  55527. CLEARCOAT_TEXTUREDIRECTUV: number;
  55528. CLEARCOAT_BUMP: boolean;
  55529. CLEARCOAT_BUMPDIRECTUV: number;
  55530. CLEARCOAT_REMAP_F0: boolean;
  55531. CLEARCOAT_TINT: boolean;
  55532. CLEARCOAT_TINT_TEXTURE: boolean;
  55533. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55534. /** @hidden */
  55535. _areTexturesDirty: boolean;
  55536. }
  55537. /**
  55538. * Define the code related to the clear coat parameters of the pbr material.
  55539. */
  55540. export class PBRClearCoatConfiguration {
  55541. /**
  55542. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55543. * The default fits with a polyurethane material.
  55544. */
  55545. private static readonly _DefaultIndexOfRefraction;
  55546. private _isEnabled;
  55547. /**
  55548. * Defines if the clear coat is enabled in the material.
  55549. */
  55550. isEnabled: boolean;
  55551. /**
  55552. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55553. */
  55554. intensity: number;
  55555. /**
  55556. * Defines the clear coat layer roughness.
  55557. */
  55558. roughness: number;
  55559. private _indexOfRefraction;
  55560. /**
  55561. * Defines the index of refraction of the clear coat.
  55562. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55563. * The default fits with a polyurethane material.
  55564. * Changing the default value is more performance intensive.
  55565. */
  55566. indexOfRefraction: number;
  55567. private _texture;
  55568. /**
  55569. * Stores the clear coat values in a texture.
  55570. */
  55571. texture: Nullable<BaseTexture>;
  55572. private _remapF0OnInterfaceChange;
  55573. /**
  55574. * Defines if the F0 value should be remapped to account for the interface change in the material.
  55575. */
  55576. remapF0OnInterfaceChange: boolean;
  55577. private _bumpTexture;
  55578. /**
  55579. * Define the clear coat specific bump texture.
  55580. */
  55581. bumpTexture: Nullable<BaseTexture>;
  55582. private _isTintEnabled;
  55583. /**
  55584. * Defines if the clear coat tint is enabled in the material.
  55585. */
  55586. isTintEnabled: boolean;
  55587. /**
  55588. * Defines the clear coat tint of the material.
  55589. * This is only use if tint is enabled
  55590. */
  55591. tintColor: Color3;
  55592. /**
  55593. * Defines the distance at which the tint color should be found in the
  55594. * clear coat media.
  55595. * This is only use if tint is enabled
  55596. */
  55597. tintColorAtDistance: number;
  55598. /**
  55599. * Defines the clear coat layer thickness.
  55600. * This is only use if tint is enabled
  55601. */
  55602. tintThickness: number;
  55603. private _tintTexture;
  55604. /**
  55605. * Stores the clear tint values in a texture.
  55606. * rgb is tint
  55607. * a is a thickness factor
  55608. */
  55609. tintTexture: Nullable<BaseTexture>;
  55610. /** @hidden */
  55611. private _internalMarkAllSubMeshesAsTexturesDirty;
  55612. /** @hidden */
  55613. _markAllSubMeshesAsTexturesDirty(): void;
  55614. /**
  55615. * Instantiate a new istance of clear coat configuration.
  55616. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55617. */
  55618. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55619. /**
  55620. * Gets wehter the submesh is ready to be used or not.
  55621. * @param defines the list of "defines" to update.
  55622. * @param scene defines the scene the material belongs to.
  55623. * @param engine defines the engine the material belongs to.
  55624. * @param disableBumpMap defines wether the material disables bump or not.
  55625. * @returns - boolean indicating that the submesh is ready or not.
  55626. */
  55627. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55628. /**
  55629. * Checks to see if a texture is used in the material.
  55630. * @param defines the list of "defines" to update.
  55631. * @param scene defines the scene to the material belongs to.
  55632. */
  55633. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55634. /**
  55635. * Binds the material data.
  55636. * @param uniformBuffer defines the Uniform buffer to fill in.
  55637. * @param scene defines the scene the material belongs to.
  55638. * @param engine defines the engine the material belongs to.
  55639. * @param disableBumpMap defines wether the material disables bump or not.
  55640. * @param isFrozen defines wether the material is frozen or not.
  55641. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55642. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55643. */
  55644. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55645. /**
  55646. * Checks to see if a texture is used in the material.
  55647. * @param texture - Base texture to use.
  55648. * @returns - Boolean specifying if a texture is used in the material.
  55649. */
  55650. hasTexture(texture: BaseTexture): boolean;
  55651. /**
  55652. * Returns an array of the actively used textures.
  55653. * @param activeTextures Array of BaseTextures
  55654. */
  55655. getActiveTextures(activeTextures: BaseTexture[]): void;
  55656. /**
  55657. * Returns the animatable textures.
  55658. * @param animatables Array of animatable textures.
  55659. */
  55660. getAnimatables(animatables: IAnimatable[]): void;
  55661. /**
  55662. * Disposes the resources of the material.
  55663. * @param forceDisposeTextures - Forces the disposal of all textures.
  55664. */
  55665. dispose(forceDisposeTextures?: boolean): void;
  55666. /**
  55667. * Get the current class name of the texture useful for serialization or dynamic coding.
  55668. * @returns "PBRClearCoatConfiguration"
  55669. */
  55670. getClassName(): string;
  55671. /**
  55672. * Add fallbacks to the effect fallbacks list.
  55673. * @param defines defines the Base texture to use.
  55674. * @param fallbacks defines the current fallback list.
  55675. * @param currentRank defines the current fallback rank.
  55676. * @returns the new fallback rank.
  55677. */
  55678. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55679. /**
  55680. * Add the required uniforms to the current list.
  55681. * @param uniforms defines the current uniform list.
  55682. */
  55683. static AddUniforms(uniforms: string[]): void;
  55684. /**
  55685. * Add the required samplers to the current list.
  55686. * @param samplers defines the current sampler list.
  55687. */
  55688. static AddSamplers(samplers: string[]): void;
  55689. /**
  55690. * Add the required uniforms to the current buffer.
  55691. * @param uniformBuffer defines the current uniform buffer.
  55692. */
  55693. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55694. /**
  55695. * Makes a duplicate of the current configuration into another one.
  55696. * @param clearCoatConfiguration define the config where to copy the info
  55697. */
  55698. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55699. /**
  55700. * Serializes this clear coat configuration.
  55701. * @returns - An object with the serialized config.
  55702. */
  55703. serialize(): any;
  55704. /**
  55705. * Parses a anisotropy Configuration from a serialized object.
  55706. * @param source - Serialized object.
  55707. * @param scene Defines the scene we are parsing for
  55708. * @param rootUrl Defines the rootUrl to load from
  55709. */
  55710. parse(source: any, scene: Scene, rootUrl: string): void;
  55711. }
  55712. }
  55713. declare module BABYLON {
  55714. /**
  55715. * @hidden
  55716. */
  55717. export interface IMaterialAnisotropicDefines {
  55718. ANISOTROPIC: boolean;
  55719. ANISOTROPIC_TEXTURE: boolean;
  55720. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55721. MAINUV1: boolean;
  55722. _areTexturesDirty: boolean;
  55723. _needUVs: boolean;
  55724. }
  55725. /**
  55726. * Define the code related to the anisotropic parameters of the pbr material.
  55727. */
  55728. export class PBRAnisotropicConfiguration {
  55729. private _isEnabled;
  55730. /**
  55731. * Defines if the anisotropy is enabled in the material.
  55732. */
  55733. isEnabled: boolean;
  55734. /**
  55735. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55736. */
  55737. intensity: number;
  55738. /**
  55739. * Defines if the effect is along the tangents, bitangents or in between.
  55740. * By default, the effect is "strectching" the highlights along the tangents.
  55741. */
  55742. direction: Vector2;
  55743. private _texture;
  55744. /**
  55745. * Stores the anisotropy values in a texture.
  55746. * rg is direction (like normal from -1 to 1)
  55747. * b is a intensity
  55748. */
  55749. texture: Nullable<BaseTexture>;
  55750. /** @hidden */
  55751. private _internalMarkAllSubMeshesAsTexturesDirty;
  55752. /** @hidden */
  55753. _markAllSubMeshesAsTexturesDirty(): void;
  55754. /**
  55755. * Instantiate a new istance of anisotropy configuration.
  55756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55757. */
  55758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55759. /**
  55760. * Specifies that the submesh is ready to be used.
  55761. * @param defines the list of "defines" to update.
  55762. * @param scene defines the scene the material belongs to.
  55763. * @returns - boolean indicating that the submesh is ready or not.
  55764. */
  55765. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55766. /**
  55767. * Checks to see if a texture is used in the material.
  55768. * @param defines the list of "defines" to update.
  55769. * @param mesh the mesh we are preparing the defines for.
  55770. * @param scene defines the scene the material belongs to.
  55771. */
  55772. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55773. /**
  55774. * Binds the material data.
  55775. * @param uniformBuffer defines the Uniform buffer to fill in.
  55776. * @param scene defines the scene the material belongs to.
  55777. * @param isFrozen defines wether the material is frozen or not.
  55778. */
  55779. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55780. /**
  55781. * Checks to see if a texture is used in the material.
  55782. * @param texture - Base texture to use.
  55783. * @returns - Boolean specifying if a texture is used in the material.
  55784. */
  55785. hasTexture(texture: BaseTexture): boolean;
  55786. /**
  55787. * Returns an array of the actively used textures.
  55788. * @param activeTextures Array of BaseTextures
  55789. */
  55790. getActiveTextures(activeTextures: BaseTexture[]): void;
  55791. /**
  55792. * Returns the animatable textures.
  55793. * @param animatables Array of animatable textures.
  55794. */
  55795. getAnimatables(animatables: IAnimatable[]): void;
  55796. /**
  55797. * Disposes the resources of the material.
  55798. * @param forceDisposeTextures - Forces the disposal of all textures.
  55799. */
  55800. dispose(forceDisposeTextures?: boolean): void;
  55801. /**
  55802. * Get the current class name of the texture useful for serialization or dynamic coding.
  55803. * @returns "PBRAnisotropicConfiguration"
  55804. */
  55805. getClassName(): string;
  55806. /**
  55807. * Add fallbacks to the effect fallbacks list.
  55808. * @param defines defines the Base texture to use.
  55809. * @param fallbacks defines the current fallback list.
  55810. * @param currentRank defines the current fallback rank.
  55811. * @returns the new fallback rank.
  55812. */
  55813. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55814. /**
  55815. * Add the required uniforms to the current list.
  55816. * @param uniforms defines the current uniform list.
  55817. */
  55818. static AddUniforms(uniforms: string[]): void;
  55819. /**
  55820. * Add the required uniforms to the current buffer.
  55821. * @param uniformBuffer defines the current uniform buffer.
  55822. */
  55823. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55824. /**
  55825. * Add the required samplers to the current list.
  55826. * @param samplers defines the current sampler list.
  55827. */
  55828. static AddSamplers(samplers: string[]): void;
  55829. /**
  55830. * Makes a duplicate of the current configuration into another one.
  55831. * @param anisotropicConfiguration define the config where to copy the info
  55832. */
  55833. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55834. /**
  55835. * Serializes this anisotropy configuration.
  55836. * @returns - An object with the serialized config.
  55837. */
  55838. serialize(): any;
  55839. /**
  55840. * Parses a anisotropy Configuration from a serialized object.
  55841. * @param source - Serialized object.
  55842. * @param scene Defines the scene we are parsing for
  55843. * @param rootUrl Defines the rootUrl to load from
  55844. */
  55845. parse(source: any, scene: Scene, rootUrl: string): void;
  55846. }
  55847. }
  55848. declare module BABYLON {
  55849. /**
  55850. * @hidden
  55851. */
  55852. export interface IMaterialBRDFDefines {
  55853. BRDF_V_HEIGHT_CORRELATED: boolean;
  55854. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55855. SPHERICAL_HARMONICS: boolean;
  55856. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55857. /** @hidden */
  55858. _areMiscDirty: boolean;
  55859. }
  55860. /**
  55861. * Define the code related to the BRDF parameters of the pbr material.
  55862. */
  55863. export class PBRBRDFConfiguration {
  55864. /**
  55865. * Default value used for the energy conservation.
  55866. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55867. */
  55868. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55869. /**
  55870. * Default value used for the Smith Visibility Height Correlated mode.
  55871. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55872. */
  55873. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55874. /**
  55875. * Default value used for the IBL diffuse part.
  55876. * This can help switching back to the polynomials mode globally which is a tiny bit
  55877. * less GPU intensive at the drawback of a lower quality.
  55878. */
  55879. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55880. /**
  55881. * Default value used for activating energy conservation for the specular workflow.
  55882. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55883. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55884. */
  55885. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55886. private _useEnergyConservation;
  55887. /**
  55888. * Defines if the material uses energy conservation.
  55889. */
  55890. useEnergyConservation: boolean;
  55891. private _useSmithVisibilityHeightCorrelated;
  55892. /**
  55893. * LEGACY Mode set to false
  55894. * Defines if the material uses height smith correlated visibility term.
  55895. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55896. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55897. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55898. * Not relying on height correlated will also disable energy conservation.
  55899. */
  55900. useSmithVisibilityHeightCorrelated: boolean;
  55901. private _useSphericalHarmonics;
  55902. /**
  55903. * LEGACY Mode set to false
  55904. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55905. * diffuse part of the IBL.
  55906. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55907. * to the ground truth.
  55908. */
  55909. useSphericalHarmonics: boolean;
  55910. private _useSpecularGlossinessInputEnergyConservation;
  55911. /**
  55912. * Defines if the material uses energy conservation, when the specular workflow is active.
  55913. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55914. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55915. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55916. */
  55917. useSpecularGlossinessInputEnergyConservation: boolean;
  55918. /** @hidden */
  55919. private _internalMarkAllSubMeshesAsMiscDirty;
  55920. /** @hidden */
  55921. _markAllSubMeshesAsMiscDirty(): void;
  55922. /**
  55923. * Instantiate a new istance of clear coat configuration.
  55924. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55925. */
  55926. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55927. /**
  55928. * Checks to see if a texture is used in the material.
  55929. * @param defines the list of "defines" to update.
  55930. */
  55931. prepareDefines(defines: IMaterialBRDFDefines): void;
  55932. /**
  55933. * Get the current class name of the texture useful for serialization or dynamic coding.
  55934. * @returns "PBRClearCoatConfiguration"
  55935. */
  55936. getClassName(): string;
  55937. /**
  55938. * Makes a duplicate of the current configuration into another one.
  55939. * @param brdfConfiguration define the config where to copy the info
  55940. */
  55941. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55942. /**
  55943. * Serializes this BRDF configuration.
  55944. * @returns - An object with the serialized config.
  55945. */
  55946. serialize(): any;
  55947. /**
  55948. * Parses a anisotropy Configuration from a serialized object.
  55949. * @param source - Serialized object.
  55950. * @param scene Defines the scene we are parsing for
  55951. * @param rootUrl Defines the rootUrl to load from
  55952. */
  55953. parse(source: any, scene: Scene, rootUrl: string): void;
  55954. }
  55955. }
  55956. declare module BABYLON {
  55957. /**
  55958. * @hidden
  55959. */
  55960. export interface IMaterialSheenDefines {
  55961. SHEEN: boolean;
  55962. SHEEN_TEXTURE: boolean;
  55963. SHEEN_TEXTUREDIRECTUV: number;
  55964. SHEEN_LINKWITHALBEDO: boolean;
  55965. SHEEN_ROUGHNESS: boolean;
  55966. SHEEN_ALBEDOSCALING: boolean;
  55967. /** @hidden */
  55968. _areTexturesDirty: boolean;
  55969. }
  55970. /**
  55971. * Define the code related to the Sheen parameters of the pbr material.
  55972. */
  55973. export class PBRSheenConfiguration {
  55974. private _isEnabled;
  55975. /**
  55976. * Defines if the material uses sheen.
  55977. */
  55978. isEnabled: boolean;
  55979. private _linkSheenWithAlbedo;
  55980. /**
  55981. * Defines if the sheen is linked to the sheen color.
  55982. */
  55983. linkSheenWithAlbedo: boolean;
  55984. /**
  55985. * Defines the sheen intensity.
  55986. */
  55987. intensity: number;
  55988. /**
  55989. * Defines the sheen color.
  55990. */
  55991. color: Color3;
  55992. private _texture;
  55993. /**
  55994. * Stores the sheen tint values in a texture.
  55995. * rgb is tint
  55996. * a is a intensity or roughness if roughness has been defined
  55997. */
  55998. texture: Nullable<BaseTexture>;
  55999. private _roughness;
  56000. /**
  56001. * Defines the sheen roughness.
  56002. * It is not taken into account if linkSheenWithAlbedo is true.
  56003. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56004. */
  56005. roughness: Nullable<number>;
  56006. private _albedoScaling;
  56007. /**
  56008. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56009. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56010. * making it easier to setup and tweak the effect
  56011. */
  56012. albedoScaling: boolean;
  56013. /** @hidden */
  56014. private _internalMarkAllSubMeshesAsTexturesDirty;
  56015. /** @hidden */
  56016. _markAllSubMeshesAsTexturesDirty(): void;
  56017. /**
  56018. * Instantiate a new istance of clear coat configuration.
  56019. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56020. */
  56021. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56022. /**
  56023. * Specifies that the submesh is ready to be used.
  56024. * @param defines the list of "defines" to update.
  56025. * @param scene defines the scene the material belongs to.
  56026. * @returns - boolean indicating that the submesh is ready or not.
  56027. */
  56028. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56029. /**
  56030. * Checks to see if a texture is used in the material.
  56031. * @param defines the list of "defines" to update.
  56032. * @param scene defines the scene the material belongs to.
  56033. */
  56034. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56035. /**
  56036. * Binds the material data.
  56037. * @param uniformBuffer defines the Uniform buffer to fill in.
  56038. * @param scene defines the scene the material belongs to.
  56039. * @param isFrozen defines wether the material is frozen or not.
  56040. */
  56041. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56042. /**
  56043. * Checks to see if a texture is used in the material.
  56044. * @param texture - Base texture to use.
  56045. * @returns - Boolean specifying if a texture is used in the material.
  56046. */
  56047. hasTexture(texture: BaseTexture): boolean;
  56048. /**
  56049. * Returns an array of the actively used textures.
  56050. * @param activeTextures Array of BaseTextures
  56051. */
  56052. getActiveTextures(activeTextures: BaseTexture[]): void;
  56053. /**
  56054. * Returns the animatable textures.
  56055. * @param animatables Array of animatable textures.
  56056. */
  56057. getAnimatables(animatables: IAnimatable[]): void;
  56058. /**
  56059. * Disposes the resources of the material.
  56060. * @param forceDisposeTextures - Forces the disposal of all textures.
  56061. */
  56062. dispose(forceDisposeTextures?: boolean): void;
  56063. /**
  56064. * Get the current class name of the texture useful for serialization or dynamic coding.
  56065. * @returns "PBRSheenConfiguration"
  56066. */
  56067. getClassName(): string;
  56068. /**
  56069. * Add fallbacks to the effect fallbacks list.
  56070. * @param defines defines the Base texture to use.
  56071. * @param fallbacks defines the current fallback list.
  56072. * @param currentRank defines the current fallback rank.
  56073. * @returns the new fallback rank.
  56074. */
  56075. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56076. /**
  56077. * Add the required uniforms to the current list.
  56078. * @param uniforms defines the current uniform list.
  56079. */
  56080. static AddUniforms(uniforms: string[]): void;
  56081. /**
  56082. * Add the required uniforms to the current buffer.
  56083. * @param uniformBuffer defines the current uniform buffer.
  56084. */
  56085. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56086. /**
  56087. * Add the required samplers to the current list.
  56088. * @param samplers defines the current sampler list.
  56089. */
  56090. static AddSamplers(samplers: string[]): void;
  56091. /**
  56092. * Makes a duplicate of the current configuration into another one.
  56093. * @param sheenConfiguration define the config where to copy the info
  56094. */
  56095. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56096. /**
  56097. * Serializes this BRDF configuration.
  56098. * @returns - An object with the serialized config.
  56099. */
  56100. serialize(): any;
  56101. /**
  56102. * Parses a anisotropy Configuration from a serialized object.
  56103. * @param source - Serialized object.
  56104. * @param scene Defines the scene we are parsing for
  56105. * @param rootUrl Defines the rootUrl to load from
  56106. */
  56107. parse(source: any, scene: Scene, rootUrl: string): void;
  56108. }
  56109. }
  56110. declare module BABYLON {
  56111. /**
  56112. * @hidden
  56113. */
  56114. export interface IMaterialSubSurfaceDefines {
  56115. SUBSURFACE: boolean;
  56116. SS_REFRACTION: boolean;
  56117. SS_TRANSLUCENCY: boolean;
  56118. SS_SCATTERING: boolean;
  56119. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56120. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56121. SS_REFRACTIONMAP_3D: boolean;
  56122. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56123. SS_LODINREFRACTIONALPHA: boolean;
  56124. SS_GAMMAREFRACTION: boolean;
  56125. SS_RGBDREFRACTION: boolean;
  56126. SS_LINEARSPECULARREFRACTION: boolean;
  56127. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56128. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56129. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56130. /** @hidden */
  56131. _areTexturesDirty: boolean;
  56132. }
  56133. /**
  56134. * Define the code related to the sub surface parameters of the pbr material.
  56135. */
  56136. export class PBRSubSurfaceConfiguration {
  56137. private _isRefractionEnabled;
  56138. /**
  56139. * Defines if the refraction is enabled in the material.
  56140. */
  56141. isRefractionEnabled: boolean;
  56142. private _isTranslucencyEnabled;
  56143. /**
  56144. * Defines if the translucency is enabled in the material.
  56145. */
  56146. isTranslucencyEnabled: boolean;
  56147. private _isScatteringEnabled;
  56148. /**
  56149. * Defines if the sub surface scattering is enabled in the material.
  56150. */
  56151. isScatteringEnabled: boolean;
  56152. private _scatteringDiffusionProfileIndex;
  56153. /**
  56154. * Diffusion profile for subsurface scattering.
  56155. * Useful for better scattering in the skins or foliages.
  56156. */
  56157. get scatteringDiffusionProfile(): Nullable<Color3>;
  56158. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56159. /**
  56160. * Defines the refraction intensity of the material.
  56161. * The refraction when enabled replaces the Diffuse part of the material.
  56162. * The intensity helps transitionning between diffuse and refraction.
  56163. */
  56164. refractionIntensity: number;
  56165. /**
  56166. * Defines the translucency intensity of the material.
  56167. * When translucency has been enabled, this defines how much of the "translucency"
  56168. * is addded to the diffuse part of the material.
  56169. */
  56170. translucencyIntensity: number;
  56171. /**
  56172. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56173. */
  56174. useAlbedoToTintRefraction: boolean;
  56175. private _thicknessTexture;
  56176. /**
  56177. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56178. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56179. * 0 would mean minimumThickness
  56180. * 1 would mean maximumThickness
  56181. * The other channels might be use as a mask to vary the different effects intensity.
  56182. */
  56183. thicknessTexture: Nullable<BaseTexture>;
  56184. private _refractionTexture;
  56185. /**
  56186. * Defines the texture to use for refraction.
  56187. */
  56188. refractionTexture: Nullable<BaseTexture>;
  56189. private _indexOfRefraction;
  56190. /**
  56191. * Index of refraction of the material base layer.
  56192. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56193. *
  56194. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56195. *
  56196. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56197. */
  56198. indexOfRefraction: number;
  56199. private _volumeIndexOfRefraction;
  56200. /**
  56201. * Index of refraction of the material's volume.
  56202. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56203. *
  56204. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56205. * the volume will use the same IOR as the surface.
  56206. */
  56207. get volumeIndexOfRefraction(): number;
  56208. set volumeIndexOfRefraction(value: number);
  56209. private _invertRefractionY;
  56210. /**
  56211. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56212. */
  56213. invertRefractionY: boolean;
  56214. private _linkRefractionWithTransparency;
  56215. /**
  56216. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56217. * Materials half opaque for instance using refraction could benefit from this control.
  56218. */
  56219. linkRefractionWithTransparency: boolean;
  56220. /**
  56221. * Defines the minimum thickness stored in the thickness map.
  56222. * If no thickness map is defined, this value will be used to simulate thickness.
  56223. */
  56224. minimumThickness: number;
  56225. /**
  56226. * Defines the maximum thickness stored in the thickness map.
  56227. */
  56228. maximumThickness: number;
  56229. /**
  56230. * Defines the volume tint of the material.
  56231. * This is used for both translucency and scattering.
  56232. */
  56233. tintColor: Color3;
  56234. /**
  56235. * Defines the distance at which the tint color should be found in the media.
  56236. * This is used for refraction only.
  56237. */
  56238. tintColorAtDistance: number;
  56239. /**
  56240. * Defines how far each channel transmit through the media.
  56241. * It is defined as a color to simplify it selection.
  56242. */
  56243. diffusionDistance: Color3;
  56244. private _useMaskFromThicknessTexture;
  56245. /**
  56246. * Stores the intensity of the different subsurface effects in the thickness texture.
  56247. * * the green channel is the translucency intensity.
  56248. * * the blue channel is the scattering intensity.
  56249. * * the alpha channel is the refraction intensity.
  56250. */
  56251. useMaskFromThicknessTexture: boolean;
  56252. private _scene;
  56253. /** @hidden */
  56254. private _internalMarkAllSubMeshesAsTexturesDirty;
  56255. private _internalMarkScenePrePassDirty;
  56256. /** @hidden */
  56257. _markAllSubMeshesAsTexturesDirty(): void;
  56258. /** @hidden */
  56259. _markScenePrePassDirty(): void;
  56260. /**
  56261. * Instantiate a new istance of sub surface configuration.
  56262. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56263. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56264. * @param scene The scene
  56265. */
  56266. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56267. /**
  56268. * Gets wehter the submesh is ready to be used or not.
  56269. * @param defines the list of "defines" to update.
  56270. * @param scene defines the scene the material belongs to.
  56271. * @returns - boolean indicating that the submesh is ready or not.
  56272. */
  56273. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56274. /**
  56275. * Checks to see if a texture is used in the material.
  56276. * @param defines the list of "defines" to update.
  56277. * @param scene defines the scene to the material belongs to.
  56278. */
  56279. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56280. /**
  56281. * Binds the material data.
  56282. * @param uniformBuffer defines the Uniform buffer to fill in.
  56283. * @param scene defines the scene the material belongs to.
  56284. * @param engine defines the engine the material belongs to.
  56285. * @param isFrozen defines whether the material is frozen or not.
  56286. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56287. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56288. */
  56289. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56290. /**
  56291. * Unbinds the material from the mesh.
  56292. * @param activeEffect defines the effect that should be unbound from.
  56293. * @returns true if unbound, otherwise false
  56294. */
  56295. unbind(activeEffect: Effect): boolean;
  56296. /**
  56297. * Returns the texture used for refraction or null if none is used.
  56298. * @param scene defines the scene the material belongs to.
  56299. * @returns - Refraction texture if present. If no refraction texture and refraction
  56300. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56301. */
  56302. private _getRefractionTexture;
  56303. /**
  56304. * Returns true if alpha blending should be disabled.
  56305. */
  56306. get disableAlphaBlending(): boolean;
  56307. /**
  56308. * Fills the list of render target textures.
  56309. * @param renderTargets the list of render targets to update
  56310. */
  56311. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56312. /**
  56313. * Checks to see if a texture is used in the material.
  56314. * @param texture - Base texture to use.
  56315. * @returns - Boolean specifying if a texture is used in the material.
  56316. */
  56317. hasTexture(texture: BaseTexture): boolean;
  56318. /**
  56319. * Gets a boolean indicating that current material needs to register RTT
  56320. * @returns true if this uses a render target otherwise false.
  56321. */
  56322. hasRenderTargetTextures(): boolean;
  56323. /**
  56324. * Returns an array of the actively used textures.
  56325. * @param activeTextures Array of BaseTextures
  56326. */
  56327. getActiveTextures(activeTextures: BaseTexture[]): void;
  56328. /**
  56329. * Returns the animatable textures.
  56330. * @param animatables Array of animatable textures.
  56331. */
  56332. getAnimatables(animatables: IAnimatable[]): void;
  56333. /**
  56334. * Disposes the resources of the material.
  56335. * @param forceDisposeTextures - Forces the disposal of all textures.
  56336. */
  56337. dispose(forceDisposeTextures?: boolean): void;
  56338. /**
  56339. * Get the current class name of the texture useful for serialization or dynamic coding.
  56340. * @returns "PBRSubSurfaceConfiguration"
  56341. */
  56342. getClassName(): string;
  56343. /**
  56344. * Add fallbacks to the effect fallbacks list.
  56345. * @param defines defines the Base texture to use.
  56346. * @param fallbacks defines the current fallback list.
  56347. * @param currentRank defines the current fallback rank.
  56348. * @returns the new fallback rank.
  56349. */
  56350. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56351. /**
  56352. * Add the required uniforms to the current list.
  56353. * @param uniforms defines the current uniform list.
  56354. */
  56355. static AddUniforms(uniforms: string[]): void;
  56356. /**
  56357. * Add the required samplers to the current list.
  56358. * @param samplers defines the current sampler list.
  56359. */
  56360. static AddSamplers(samplers: string[]): void;
  56361. /**
  56362. * Add the required uniforms to the current buffer.
  56363. * @param uniformBuffer defines the current uniform buffer.
  56364. */
  56365. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56366. /**
  56367. * Makes a duplicate of the current configuration into another one.
  56368. * @param configuration define the config where to copy the info
  56369. */
  56370. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56371. /**
  56372. * Serializes this Sub Surface configuration.
  56373. * @returns - An object with the serialized config.
  56374. */
  56375. serialize(): any;
  56376. /**
  56377. * Parses a anisotropy Configuration from a serialized object.
  56378. * @param source - Serialized object.
  56379. * @param scene Defines the scene we are parsing for
  56380. * @param rootUrl Defines the rootUrl to load from
  56381. */
  56382. parse(source: any, scene: Scene, rootUrl: string): void;
  56383. }
  56384. }
  56385. declare module BABYLON {
  56386. /** @hidden */
  56387. export var pbrFragmentDeclaration: {
  56388. name: string;
  56389. shader: string;
  56390. };
  56391. }
  56392. declare module BABYLON {
  56393. /** @hidden */
  56394. export var pbrUboDeclaration: {
  56395. name: string;
  56396. shader: string;
  56397. };
  56398. }
  56399. declare module BABYLON {
  56400. /** @hidden */
  56401. export var pbrFragmentExtraDeclaration: {
  56402. name: string;
  56403. shader: string;
  56404. };
  56405. }
  56406. declare module BABYLON {
  56407. /** @hidden */
  56408. export var pbrFragmentSamplersDeclaration: {
  56409. name: string;
  56410. shader: string;
  56411. };
  56412. }
  56413. declare module BABYLON {
  56414. /** @hidden */
  56415. export var subSurfaceScatteringFunctions: {
  56416. name: string;
  56417. shader: string;
  56418. };
  56419. }
  56420. declare module BABYLON {
  56421. /** @hidden */
  56422. export var importanceSampling: {
  56423. name: string;
  56424. shader: string;
  56425. };
  56426. }
  56427. declare module BABYLON {
  56428. /** @hidden */
  56429. export var pbrHelperFunctions: {
  56430. name: string;
  56431. shader: string;
  56432. };
  56433. }
  56434. declare module BABYLON {
  56435. /** @hidden */
  56436. export var harmonicsFunctions: {
  56437. name: string;
  56438. shader: string;
  56439. };
  56440. }
  56441. declare module BABYLON {
  56442. /** @hidden */
  56443. export var pbrDirectLightingSetupFunctions: {
  56444. name: string;
  56445. shader: string;
  56446. };
  56447. }
  56448. declare module BABYLON {
  56449. /** @hidden */
  56450. export var pbrDirectLightingFalloffFunctions: {
  56451. name: string;
  56452. shader: string;
  56453. };
  56454. }
  56455. declare module BABYLON {
  56456. /** @hidden */
  56457. export var pbrBRDFFunctions: {
  56458. name: string;
  56459. shader: string;
  56460. };
  56461. }
  56462. declare module BABYLON {
  56463. /** @hidden */
  56464. export var hdrFilteringFunctions: {
  56465. name: string;
  56466. shader: string;
  56467. };
  56468. }
  56469. declare module BABYLON {
  56470. /** @hidden */
  56471. export var pbrDirectLightingFunctions: {
  56472. name: string;
  56473. shader: string;
  56474. };
  56475. }
  56476. declare module BABYLON {
  56477. /** @hidden */
  56478. export var pbrIBLFunctions: {
  56479. name: string;
  56480. shader: string;
  56481. };
  56482. }
  56483. declare module BABYLON {
  56484. /** @hidden */
  56485. export var pbrBlockAlbedoOpacity: {
  56486. name: string;
  56487. shader: string;
  56488. };
  56489. }
  56490. declare module BABYLON {
  56491. /** @hidden */
  56492. export var pbrBlockReflectivity: {
  56493. name: string;
  56494. shader: string;
  56495. };
  56496. }
  56497. declare module BABYLON {
  56498. /** @hidden */
  56499. export var pbrBlockAmbientOcclusion: {
  56500. name: string;
  56501. shader: string;
  56502. };
  56503. }
  56504. declare module BABYLON {
  56505. /** @hidden */
  56506. export var pbrBlockAlphaFresnel: {
  56507. name: string;
  56508. shader: string;
  56509. };
  56510. }
  56511. declare module BABYLON {
  56512. /** @hidden */
  56513. export var pbrBlockAnisotropic: {
  56514. name: string;
  56515. shader: string;
  56516. };
  56517. }
  56518. declare module BABYLON {
  56519. /** @hidden */
  56520. export var pbrBlockReflection: {
  56521. name: string;
  56522. shader: string;
  56523. };
  56524. }
  56525. declare module BABYLON {
  56526. /** @hidden */
  56527. export var pbrBlockSheen: {
  56528. name: string;
  56529. shader: string;
  56530. };
  56531. }
  56532. declare module BABYLON {
  56533. /** @hidden */
  56534. export var pbrBlockClearcoat: {
  56535. name: string;
  56536. shader: string;
  56537. };
  56538. }
  56539. declare module BABYLON {
  56540. /** @hidden */
  56541. export var pbrBlockSubSurface: {
  56542. name: string;
  56543. shader: string;
  56544. };
  56545. }
  56546. declare module BABYLON {
  56547. /** @hidden */
  56548. export var pbrBlockNormalGeometric: {
  56549. name: string;
  56550. shader: string;
  56551. };
  56552. }
  56553. declare module BABYLON {
  56554. /** @hidden */
  56555. export var pbrBlockNormalFinal: {
  56556. name: string;
  56557. shader: string;
  56558. };
  56559. }
  56560. declare module BABYLON {
  56561. /** @hidden */
  56562. export var pbrBlockLightmapInit: {
  56563. name: string;
  56564. shader: string;
  56565. };
  56566. }
  56567. declare module BABYLON {
  56568. /** @hidden */
  56569. export var pbrBlockGeometryInfo: {
  56570. name: string;
  56571. shader: string;
  56572. };
  56573. }
  56574. declare module BABYLON {
  56575. /** @hidden */
  56576. export var pbrBlockReflectance0: {
  56577. name: string;
  56578. shader: string;
  56579. };
  56580. }
  56581. declare module BABYLON {
  56582. /** @hidden */
  56583. export var pbrBlockReflectance: {
  56584. name: string;
  56585. shader: string;
  56586. };
  56587. }
  56588. declare module BABYLON {
  56589. /** @hidden */
  56590. export var pbrBlockDirectLighting: {
  56591. name: string;
  56592. shader: string;
  56593. };
  56594. }
  56595. declare module BABYLON {
  56596. /** @hidden */
  56597. export var pbrBlockFinalLitComponents: {
  56598. name: string;
  56599. shader: string;
  56600. };
  56601. }
  56602. declare module BABYLON {
  56603. /** @hidden */
  56604. export var pbrBlockFinalUnlitComponents: {
  56605. name: string;
  56606. shader: string;
  56607. };
  56608. }
  56609. declare module BABYLON {
  56610. /** @hidden */
  56611. export var pbrBlockFinalColorComposition: {
  56612. name: string;
  56613. shader: string;
  56614. };
  56615. }
  56616. declare module BABYLON {
  56617. /** @hidden */
  56618. export var pbrBlockImageProcessing: {
  56619. name: string;
  56620. shader: string;
  56621. };
  56622. }
  56623. declare module BABYLON {
  56624. /** @hidden */
  56625. export var pbrDebug: {
  56626. name: string;
  56627. shader: string;
  56628. };
  56629. }
  56630. declare module BABYLON {
  56631. /** @hidden */
  56632. export var pbrPixelShader: {
  56633. name: string;
  56634. shader: string;
  56635. };
  56636. }
  56637. declare module BABYLON {
  56638. /** @hidden */
  56639. export var pbrVertexDeclaration: {
  56640. name: string;
  56641. shader: string;
  56642. };
  56643. }
  56644. declare module BABYLON {
  56645. /** @hidden */
  56646. export var pbrVertexShader: {
  56647. name: string;
  56648. shader: string;
  56649. };
  56650. }
  56651. declare module BABYLON {
  56652. /**
  56653. * Manages the defines for the PBR Material.
  56654. * @hidden
  56655. */
  56656. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56657. PBR: boolean;
  56658. NUM_SAMPLES: string;
  56659. REALTIME_FILTERING: boolean;
  56660. MAINUV1: boolean;
  56661. MAINUV2: boolean;
  56662. UV1: boolean;
  56663. UV2: boolean;
  56664. ALBEDO: boolean;
  56665. GAMMAALBEDO: boolean;
  56666. ALBEDODIRECTUV: number;
  56667. VERTEXCOLOR: boolean;
  56668. DETAIL: boolean;
  56669. DETAILDIRECTUV: number;
  56670. DETAIL_NORMALBLENDMETHOD: number;
  56671. AMBIENT: boolean;
  56672. AMBIENTDIRECTUV: number;
  56673. AMBIENTINGRAYSCALE: boolean;
  56674. OPACITY: boolean;
  56675. VERTEXALPHA: boolean;
  56676. OPACITYDIRECTUV: number;
  56677. OPACITYRGB: boolean;
  56678. ALPHATEST: boolean;
  56679. DEPTHPREPASS: boolean;
  56680. ALPHABLEND: boolean;
  56681. ALPHAFROMALBEDO: boolean;
  56682. ALPHATESTVALUE: string;
  56683. SPECULAROVERALPHA: boolean;
  56684. RADIANCEOVERALPHA: boolean;
  56685. ALPHAFRESNEL: boolean;
  56686. LINEARALPHAFRESNEL: boolean;
  56687. PREMULTIPLYALPHA: boolean;
  56688. EMISSIVE: boolean;
  56689. EMISSIVEDIRECTUV: number;
  56690. REFLECTIVITY: boolean;
  56691. REFLECTIVITYDIRECTUV: number;
  56692. SPECULARTERM: boolean;
  56693. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56694. MICROSURFACEAUTOMATIC: boolean;
  56695. LODBASEDMICROSFURACE: boolean;
  56696. MICROSURFACEMAP: boolean;
  56697. MICROSURFACEMAPDIRECTUV: number;
  56698. METALLICWORKFLOW: boolean;
  56699. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56700. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56701. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56702. AOSTOREINMETALMAPRED: boolean;
  56703. METALLIC_REFLECTANCE: boolean;
  56704. METALLIC_REFLECTANCEDIRECTUV: number;
  56705. ENVIRONMENTBRDF: boolean;
  56706. ENVIRONMENTBRDF_RGBD: boolean;
  56707. NORMAL: boolean;
  56708. TANGENT: boolean;
  56709. BUMP: boolean;
  56710. BUMPDIRECTUV: number;
  56711. OBJECTSPACE_NORMALMAP: boolean;
  56712. PARALLAX: boolean;
  56713. PARALLAXOCCLUSION: boolean;
  56714. NORMALXYSCALE: boolean;
  56715. LIGHTMAP: boolean;
  56716. LIGHTMAPDIRECTUV: number;
  56717. USELIGHTMAPASSHADOWMAP: boolean;
  56718. GAMMALIGHTMAP: boolean;
  56719. RGBDLIGHTMAP: boolean;
  56720. REFLECTION: boolean;
  56721. REFLECTIONMAP_3D: boolean;
  56722. REFLECTIONMAP_SPHERICAL: boolean;
  56723. REFLECTIONMAP_PLANAR: boolean;
  56724. REFLECTIONMAP_CUBIC: boolean;
  56725. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56726. REFLECTIONMAP_PROJECTION: boolean;
  56727. REFLECTIONMAP_SKYBOX: boolean;
  56728. REFLECTIONMAP_EXPLICIT: boolean;
  56729. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56730. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56731. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56732. INVERTCUBICMAP: boolean;
  56733. USESPHERICALFROMREFLECTIONMAP: boolean;
  56734. USEIRRADIANCEMAP: boolean;
  56735. SPHERICAL_HARMONICS: boolean;
  56736. USESPHERICALINVERTEX: boolean;
  56737. REFLECTIONMAP_OPPOSITEZ: boolean;
  56738. LODINREFLECTIONALPHA: boolean;
  56739. GAMMAREFLECTION: boolean;
  56740. RGBDREFLECTION: boolean;
  56741. LINEARSPECULARREFLECTION: boolean;
  56742. RADIANCEOCCLUSION: boolean;
  56743. HORIZONOCCLUSION: boolean;
  56744. INSTANCES: boolean;
  56745. THIN_INSTANCES: boolean;
  56746. PREPASS: boolean;
  56747. PREPASS_IRRADIANCE: boolean;
  56748. PREPASS_IRRADIANCE_INDEX: number;
  56749. PREPASS_ALBEDO: boolean;
  56750. PREPASS_ALBEDO_INDEX: number;
  56751. PREPASS_DEPTHNORMAL: boolean;
  56752. PREPASS_DEPTHNORMAL_INDEX: number;
  56753. PREPASS_POSITION: boolean;
  56754. PREPASS_POSITION_INDEX: number;
  56755. PREPASS_VELOCITY: boolean;
  56756. PREPASS_VELOCITY_INDEX: number;
  56757. PREPASS_REFLECTIVITY: boolean;
  56758. PREPASS_REFLECTIVITY_INDEX: number;
  56759. SCENE_MRT_COUNT: number;
  56760. NUM_BONE_INFLUENCERS: number;
  56761. BonesPerMesh: number;
  56762. BONETEXTURE: boolean;
  56763. BONES_VELOCITY_ENABLED: boolean;
  56764. NONUNIFORMSCALING: boolean;
  56765. MORPHTARGETS: boolean;
  56766. MORPHTARGETS_NORMAL: boolean;
  56767. MORPHTARGETS_TANGENT: boolean;
  56768. MORPHTARGETS_UV: boolean;
  56769. NUM_MORPH_INFLUENCERS: number;
  56770. IMAGEPROCESSING: boolean;
  56771. VIGNETTE: boolean;
  56772. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56773. VIGNETTEBLENDMODEOPAQUE: boolean;
  56774. TONEMAPPING: boolean;
  56775. TONEMAPPING_ACES: boolean;
  56776. CONTRAST: boolean;
  56777. COLORCURVES: boolean;
  56778. COLORGRADING: boolean;
  56779. COLORGRADING3D: boolean;
  56780. SAMPLER3DGREENDEPTH: boolean;
  56781. SAMPLER3DBGRMAP: boolean;
  56782. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56783. EXPOSURE: boolean;
  56784. MULTIVIEW: boolean;
  56785. USEPHYSICALLIGHTFALLOFF: boolean;
  56786. USEGLTFLIGHTFALLOFF: boolean;
  56787. TWOSIDEDLIGHTING: boolean;
  56788. SHADOWFLOAT: boolean;
  56789. CLIPPLANE: boolean;
  56790. CLIPPLANE2: boolean;
  56791. CLIPPLANE3: boolean;
  56792. CLIPPLANE4: boolean;
  56793. CLIPPLANE5: boolean;
  56794. CLIPPLANE6: boolean;
  56795. POINTSIZE: boolean;
  56796. FOG: boolean;
  56797. LOGARITHMICDEPTH: boolean;
  56798. FORCENORMALFORWARD: boolean;
  56799. SPECULARAA: boolean;
  56800. CLEARCOAT: boolean;
  56801. CLEARCOAT_DEFAULTIOR: boolean;
  56802. CLEARCOAT_TEXTURE: boolean;
  56803. CLEARCOAT_TEXTUREDIRECTUV: number;
  56804. CLEARCOAT_BUMP: boolean;
  56805. CLEARCOAT_BUMPDIRECTUV: number;
  56806. CLEARCOAT_REMAP_F0: boolean;
  56807. CLEARCOAT_TINT: boolean;
  56808. CLEARCOAT_TINT_TEXTURE: boolean;
  56809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56810. ANISOTROPIC: boolean;
  56811. ANISOTROPIC_TEXTURE: boolean;
  56812. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56813. BRDF_V_HEIGHT_CORRELATED: boolean;
  56814. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56815. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56816. SHEEN: boolean;
  56817. SHEEN_TEXTURE: boolean;
  56818. SHEEN_TEXTUREDIRECTUV: number;
  56819. SHEEN_LINKWITHALBEDO: boolean;
  56820. SHEEN_ROUGHNESS: boolean;
  56821. SHEEN_ALBEDOSCALING: boolean;
  56822. SUBSURFACE: boolean;
  56823. SS_REFRACTION: boolean;
  56824. SS_TRANSLUCENCY: boolean;
  56825. SS_SCATTERING: boolean;
  56826. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56827. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56828. SS_REFRACTIONMAP_3D: boolean;
  56829. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56830. SS_LODINREFRACTIONALPHA: boolean;
  56831. SS_GAMMAREFRACTION: boolean;
  56832. SS_RGBDREFRACTION: boolean;
  56833. SS_LINEARSPECULARREFRACTION: boolean;
  56834. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56835. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56836. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56837. UNLIT: boolean;
  56838. DEBUGMODE: number;
  56839. /**
  56840. * Initializes the PBR Material defines.
  56841. */
  56842. constructor();
  56843. /**
  56844. * Resets the PBR Material defines.
  56845. */
  56846. reset(): void;
  56847. }
  56848. /**
  56849. * The Physically based material base class of BJS.
  56850. *
  56851. * This offers the main features of a standard PBR material.
  56852. * For more information, please refer to the documentation :
  56853. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56854. */
  56855. export abstract class PBRBaseMaterial extends PushMaterial {
  56856. /**
  56857. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56858. */
  56859. static readonly PBRMATERIAL_OPAQUE: number;
  56860. /**
  56861. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56862. */
  56863. static readonly PBRMATERIAL_ALPHATEST: number;
  56864. /**
  56865. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56866. */
  56867. static readonly PBRMATERIAL_ALPHABLEND: number;
  56868. /**
  56869. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56870. * They are also discarded below the alpha cutoff threshold to improve performances.
  56871. */
  56872. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56873. /**
  56874. * Defines the default value of how much AO map is occluding the analytical lights
  56875. * (point spot...).
  56876. */
  56877. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56878. /**
  56879. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56880. */
  56881. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56882. /**
  56883. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56884. * to enhance interoperability with other engines.
  56885. */
  56886. static readonly LIGHTFALLOFF_GLTF: number;
  56887. /**
  56888. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56889. * to enhance interoperability with other materials.
  56890. */
  56891. static readonly LIGHTFALLOFF_STANDARD: number;
  56892. /**
  56893. * Intensity of the direct lights e.g. the four lights available in your scene.
  56894. * This impacts both the direct diffuse and specular highlights.
  56895. */
  56896. protected _directIntensity: number;
  56897. /**
  56898. * Intensity of the emissive part of the material.
  56899. * This helps controlling the emissive effect without modifying the emissive color.
  56900. */
  56901. protected _emissiveIntensity: number;
  56902. /**
  56903. * Intensity of the environment e.g. how much the environment will light the object
  56904. * either through harmonics for rough material or through the refelction for shiny ones.
  56905. */
  56906. protected _environmentIntensity: number;
  56907. /**
  56908. * This is a special control allowing the reduction of the specular highlights coming from the
  56909. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56910. */
  56911. protected _specularIntensity: number;
  56912. /**
  56913. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56914. */
  56915. private _lightingInfos;
  56916. /**
  56917. * Debug Control allowing disabling the bump map on this material.
  56918. */
  56919. protected _disableBumpMap: boolean;
  56920. /**
  56921. * AKA Diffuse Texture in standard nomenclature.
  56922. */
  56923. protected _albedoTexture: Nullable<BaseTexture>;
  56924. /**
  56925. * AKA Occlusion Texture in other nomenclature.
  56926. */
  56927. protected _ambientTexture: Nullable<BaseTexture>;
  56928. /**
  56929. * AKA Occlusion Texture Intensity in other nomenclature.
  56930. */
  56931. protected _ambientTextureStrength: number;
  56932. /**
  56933. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56934. * 1 means it completely occludes it
  56935. * 0 mean it has no impact
  56936. */
  56937. protected _ambientTextureImpactOnAnalyticalLights: number;
  56938. /**
  56939. * Stores the alpha values in a texture.
  56940. */
  56941. protected _opacityTexture: Nullable<BaseTexture>;
  56942. /**
  56943. * Stores the reflection values in a texture.
  56944. */
  56945. protected _reflectionTexture: Nullable<BaseTexture>;
  56946. /**
  56947. * Stores the emissive values in a texture.
  56948. */
  56949. protected _emissiveTexture: Nullable<BaseTexture>;
  56950. /**
  56951. * AKA Specular texture in other nomenclature.
  56952. */
  56953. protected _reflectivityTexture: Nullable<BaseTexture>;
  56954. /**
  56955. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56956. */
  56957. protected _metallicTexture: Nullable<BaseTexture>;
  56958. /**
  56959. * Specifies the metallic scalar of the metallic/roughness workflow.
  56960. * Can also be used to scale the metalness values of the metallic texture.
  56961. */
  56962. protected _metallic: Nullable<number>;
  56963. /**
  56964. * Specifies the roughness scalar of the metallic/roughness workflow.
  56965. * Can also be used to scale the roughness values of the metallic texture.
  56966. */
  56967. protected _roughness: Nullable<number>;
  56968. /**
  56969. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56970. * By default the indexOfrefraction is used to compute F0;
  56971. *
  56972. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56973. *
  56974. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56975. * F90 = metallicReflectanceColor;
  56976. */
  56977. protected _metallicF0Factor: number;
  56978. /**
  56979. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56980. * By default the F90 is always 1;
  56981. *
  56982. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56983. *
  56984. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56985. * F90 = metallicReflectanceColor;
  56986. */
  56987. protected _metallicReflectanceColor: Color3;
  56988. /**
  56989. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56990. * This is multiply against the scalar values defined in the material.
  56991. */
  56992. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56993. /**
  56994. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56995. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56996. */
  56997. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56998. /**
  56999. * Stores surface normal data used to displace a mesh in a texture.
  57000. */
  57001. protected _bumpTexture: Nullable<BaseTexture>;
  57002. /**
  57003. * Stores the pre-calculated light information of a mesh in a texture.
  57004. */
  57005. protected _lightmapTexture: Nullable<BaseTexture>;
  57006. /**
  57007. * The color of a material in ambient lighting.
  57008. */
  57009. protected _ambientColor: Color3;
  57010. /**
  57011. * AKA Diffuse Color in other nomenclature.
  57012. */
  57013. protected _albedoColor: Color3;
  57014. /**
  57015. * AKA Specular Color in other nomenclature.
  57016. */
  57017. protected _reflectivityColor: Color3;
  57018. /**
  57019. * The color applied when light is reflected from a material.
  57020. */
  57021. protected _reflectionColor: Color3;
  57022. /**
  57023. * The color applied when light is emitted from a material.
  57024. */
  57025. protected _emissiveColor: Color3;
  57026. /**
  57027. * AKA Glossiness in other nomenclature.
  57028. */
  57029. protected _microSurface: number;
  57030. /**
  57031. * Specifies that the material will use the light map as a show map.
  57032. */
  57033. protected _useLightmapAsShadowmap: boolean;
  57034. /**
  57035. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57036. * makes the reflect vector face the model (under horizon).
  57037. */
  57038. protected _useHorizonOcclusion: boolean;
  57039. /**
  57040. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57041. * too much the area relying on ambient texture to define their ambient occlusion.
  57042. */
  57043. protected _useRadianceOcclusion: boolean;
  57044. /**
  57045. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57046. */
  57047. protected _useAlphaFromAlbedoTexture: boolean;
  57048. /**
  57049. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57050. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57051. */
  57052. protected _useSpecularOverAlpha: boolean;
  57053. /**
  57054. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57055. */
  57056. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57057. /**
  57058. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57059. */
  57060. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57061. /**
  57062. * Specifies if the metallic texture contains the roughness information in its green channel.
  57063. */
  57064. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57065. /**
  57066. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57067. */
  57068. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57069. /**
  57070. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57071. */
  57072. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57073. /**
  57074. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57075. */
  57076. protected _useAmbientInGrayScale: boolean;
  57077. /**
  57078. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57079. * The material will try to infer what glossiness each pixel should be.
  57080. */
  57081. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57082. /**
  57083. * Defines the falloff type used in this material.
  57084. * It by default is Physical.
  57085. */
  57086. protected _lightFalloff: number;
  57087. /**
  57088. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57089. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57090. */
  57091. protected _useRadianceOverAlpha: boolean;
  57092. /**
  57093. * Allows using an object space normal map (instead of tangent space).
  57094. */
  57095. protected _useObjectSpaceNormalMap: boolean;
  57096. /**
  57097. * Allows using the bump map in parallax mode.
  57098. */
  57099. protected _useParallax: boolean;
  57100. /**
  57101. * Allows using the bump map in parallax occlusion mode.
  57102. */
  57103. protected _useParallaxOcclusion: boolean;
  57104. /**
  57105. * Controls the scale bias of the parallax mode.
  57106. */
  57107. protected _parallaxScaleBias: number;
  57108. /**
  57109. * If sets to true, disables all the lights affecting the material.
  57110. */
  57111. protected _disableLighting: boolean;
  57112. /**
  57113. * Number of Simultaneous lights allowed on the material.
  57114. */
  57115. protected _maxSimultaneousLights: number;
  57116. /**
  57117. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57118. */
  57119. protected _invertNormalMapX: boolean;
  57120. /**
  57121. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57122. */
  57123. protected _invertNormalMapY: boolean;
  57124. /**
  57125. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57126. */
  57127. protected _twoSidedLighting: boolean;
  57128. /**
  57129. * Defines the alpha limits in alpha test mode.
  57130. */
  57131. protected _alphaCutOff: number;
  57132. /**
  57133. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57134. */
  57135. protected _forceAlphaTest: boolean;
  57136. /**
  57137. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57138. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57139. */
  57140. protected _useAlphaFresnel: boolean;
  57141. /**
  57142. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57143. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57144. */
  57145. protected _useLinearAlphaFresnel: boolean;
  57146. /**
  57147. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57148. * from cos thetav and roughness:
  57149. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57150. */
  57151. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57152. /**
  57153. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57154. */
  57155. protected _forceIrradianceInFragment: boolean;
  57156. private _realTimeFiltering;
  57157. /**
  57158. * Enables realtime filtering on the texture.
  57159. */
  57160. get realTimeFiltering(): boolean;
  57161. set realTimeFiltering(b: boolean);
  57162. private _realTimeFilteringQuality;
  57163. /**
  57164. * Quality switch for realtime filtering
  57165. */
  57166. get realTimeFilteringQuality(): number;
  57167. set realTimeFilteringQuality(n: number);
  57168. /**
  57169. * Can this material render to several textures at once
  57170. */
  57171. get canRenderToMRT(): boolean;
  57172. /**
  57173. * Force normal to face away from face.
  57174. */
  57175. protected _forceNormalForward: boolean;
  57176. /**
  57177. * Enables specular anti aliasing in the PBR shader.
  57178. * It will both interacts on the Geometry for analytical and IBL lighting.
  57179. * It also prefilter the roughness map based on the bump values.
  57180. */
  57181. protected _enableSpecularAntiAliasing: boolean;
  57182. /**
  57183. * Default configuration related to image processing available in the PBR Material.
  57184. */
  57185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57186. /**
  57187. * Keep track of the image processing observer to allow dispose and replace.
  57188. */
  57189. private _imageProcessingObserver;
  57190. /**
  57191. * Attaches a new image processing configuration to the PBR Material.
  57192. * @param configuration
  57193. */
  57194. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57195. /**
  57196. * Stores the available render targets.
  57197. */
  57198. private _renderTargets;
  57199. /**
  57200. * Sets the global ambient color for the material used in lighting calculations.
  57201. */
  57202. private _globalAmbientColor;
  57203. /**
  57204. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57205. */
  57206. private _useLogarithmicDepth;
  57207. /**
  57208. * If set to true, no lighting calculations will be applied.
  57209. */
  57210. private _unlit;
  57211. private _debugMode;
  57212. /**
  57213. * @hidden
  57214. * This is reserved for the inspector.
  57215. * Defines the material debug mode.
  57216. * It helps seeing only some components of the material while troubleshooting.
  57217. */
  57218. debugMode: number;
  57219. /**
  57220. * @hidden
  57221. * This is reserved for the inspector.
  57222. * Specify from where on screen the debug mode should start.
  57223. * The value goes from -1 (full screen) to 1 (not visible)
  57224. * It helps with side by side comparison against the final render
  57225. * This defaults to -1
  57226. */
  57227. private debugLimit;
  57228. /**
  57229. * @hidden
  57230. * This is reserved for the inspector.
  57231. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57232. * You can use the factor to better multiply the final value.
  57233. */
  57234. private debugFactor;
  57235. /**
  57236. * Defines the clear coat layer parameters for the material.
  57237. */
  57238. readonly clearCoat: PBRClearCoatConfiguration;
  57239. /**
  57240. * Defines the anisotropic parameters for the material.
  57241. */
  57242. readonly anisotropy: PBRAnisotropicConfiguration;
  57243. /**
  57244. * Defines the BRDF parameters for the material.
  57245. */
  57246. readonly brdf: PBRBRDFConfiguration;
  57247. /**
  57248. * Defines the Sheen parameters for the material.
  57249. */
  57250. readonly sheen: PBRSheenConfiguration;
  57251. /**
  57252. * Defines the SubSurface parameters for the material.
  57253. */
  57254. readonly subSurface: PBRSubSurfaceConfiguration;
  57255. /**
  57256. * Defines additionnal PrePass parameters for the material.
  57257. */
  57258. readonly prePassConfiguration: PrePassConfiguration;
  57259. /**
  57260. * Defines the detail map parameters for the material.
  57261. */
  57262. readonly detailMap: DetailMapConfiguration;
  57263. protected _rebuildInParallel: boolean;
  57264. /**
  57265. * Instantiates a new PBRMaterial instance.
  57266. *
  57267. * @param name The material name
  57268. * @param scene The scene the material will be use in.
  57269. */
  57270. constructor(name: string, scene: Scene);
  57271. /**
  57272. * Gets a boolean indicating that current material needs to register RTT
  57273. */
  57274. get hasRenderTargetTextures(): boolean;
  57275. /**
  57276. * Gets the name of the material class.
  57277. */
  57278. getClassName(): string;
  57279. /**
  57280. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57281. */
  57282. get useLogarithmicDepth(): boolean;
  57283. /**
  57284. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57285. */
  57286. set useLogarithmicDepth(value: boolean);
  57287. /**
  57288. * Returns true if alpha blending should be disabled.
  57289. */
  57290. protected get _disableAlphaBlending(): boolean;
  57291. /**
  57292. * Specifies whether or not this material should be rendered in alpha blend mode.
  57293. */
  57294. needAlphaBlending(): boolean;
  57295. /**
  57296. * Specifies whether or not this material should be rendered in alpha test mode.
  57297. */
  57298. needAlphaTesting(): boolean;
  57299. /**
  57300. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57301. */
  57302. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57303. /**
  57304. * Gets the texture used for the alpha test.
  57305. */
  57306. getAlphaTestTexture(): Nullable<BaseTexture>;
  57307. /**
  57308. * Specifies that the submesh is ready to be used.
  57309. * @param mesh - BJS mesh.
  57310. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57311. * @param useInstances - Specifies that instances should be used.
  57312. * @returns - boolean indicating that the submesh is ready or not.
  57313. */
  57314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57315. /**
  57316. * Specifies if the material uses metallic roughness workflow.
  57317. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57318. */
  57319. isMetallicWorkflow(): boolean;
  57320. private _prepareEffect;
  57321. private _prepareDefines;
  57322. /**
  57323. * Force shader compilation
  57324. */
  57325. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57326. /**
  57327. * Initializes the uniform buffer layout for the shader.
  57328. */
  57329. buildUniformLayout(): void;
  57330. /**
  57331. * Unbinds the material from the mesh
  57332. */
  57333. unbind(): void;
  57334. /**
  57335. * Binds the submesh data.
  57336. * @param world - The world matrix.
  57337. * @param mesh - The BJS mesh.
  57338. * @param subMesh - A submesh of the BJS mesh.
  57339. */
  57340. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57341. /**
  57342. * Returns the animatable textures.
  57343. * @returns - Array of animatable textures.
  57344. */
  57345. getAnimatables(): IAnimatable[];
  57346. /**
  57347. * Returns the texture used for reflections.
  57348. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57349. */
  57350. private _getReflectionTexture;
  57351. /**
  57352. * Returns an array of the actively used textures.
  57353. * @returns - Array of BaseTextures
  57354. */
  57355. getActiveTextures(): BaseTexture[];
  57356. /**
  57357. * Checks to see if a texture is used in the material.
  57358. * @param texture - Base texture to use.
  57359. * @returns - Boolean specifying if a texture is used in the material.
  57360. */
  57361. hasTexture(texture: BaseTexture): boolean;
  57362. /**
  57363. * Sets the required values to the prepass renderer.
  57364. * @param prePassRenderer defines the prepass renderer to setup
  57365. */
  57366. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57367. /**
  57368. * Disposes the resources of the material.
  57369. * @param forceDisposeEffect - Forces the disposal of effects.
  57370. * @param forceDisposeTextures - Forces the disposal of all textures.
  57371. */
  57372. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57373. }
  57374. }
  57375. declare module BABYLON {
  57376. /**
  57377. * The Physically based material of BJS.
  57378. *
  57379. * This offers the main features of a standard PBR material.
  57380. * For more information, please refer to the documentation :
  57381. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57382. */
  57383. export class PBRMaterial extends PBRBaseMaterial {
  57384. /**
  57385. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57386. */
  57387. static readonly PBRMATERIAL_OPAQUE: number;
  57388. /**
  57389. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57390. */
  57391. static readonly PBRMATERIAL_ALPHATEST: number;
  57392. /**
  57393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57394. */
  57395. static readonly PBRMATERIAL_ALPHABLEND: number;
  57396. /**
  57397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57398. * They are also discarded below the alpha cutoff threshold to improve performances.
  57399. */
  57400. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57401. /**
  57402. * Defines the default value of how much AO map is occluding the analytical lights
  57403. * (point spot...).
  57404. */
  57405. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57406. /**
  57407. * Intensity of the direct lights e.g. the four lights available in your scene.
  57408. * This impacts both the direct diffuse and specular highlights.
  57409. */
  57410. directIntensity: number;
  57411. /**
  57412. * Intensity of the emissive part of the material.
  57413. * This helps controlling the emissive effect without modifying the emissive color.
  57414. */
  57415. emissiveIntensity: number;
  57416. /**
  57417. * Intensity of the environment e.g. how much the environment will light the object
  57418. * either through harmonics for rough material or through the refelction for shiny ones.
  57419. */
  57420. environmentIntensity: number;
  57421. /**
  57422. * This is a special control allowing the reduction of the specular highlights coming from the
  57423. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57424. */
  57425. specularIntensity: number;
  57426. /**
  57427. * Debug Control allowing disabling the bump map on this material.
  57428. */
  57429. disableBumpMap: boolean;
  57430. /**
  57431. * AKA Diffuse Texture in standard nomenclature.
  57432. */
  57433. albedoTexture: BaseTexture;
  57434. /**
  57435. * AKA Occlusion Texture in other nomenclature.
  57436. */
  57437. ambientTexture: BaseTexture;
  57438. /**
  57439. * AKA Occlusion Texture Intensity in other nomenclature.
  57440. */
  57441. ambientTextureStrength: number;
  57442. /**
  57443. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57444. * 1 means it completely occludes it
  57445. * 0 mean it has no impact
  57446. */
  57447. ambientTextureImpactOnAnalyticalLights: number;
  57448. /**
  57449. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57450. */
  57451. opacityTexture: BaseTexture;
  57452. /**
  57453. * Stores the reflection values in a texture.
  57454. */
  57455. reflectionTexture: Nullable<BaseTexture>;
  57456. /**
  57457. * Stores the emissive values in a texture.
  57458. */
  57459. emissiveTexture: BaseTexture;
  57460. /**
  57461. * AKA Specular texture in other nomenclature.
  57462. */
  57463. reflectivityTexture: BaseTexture;
  57464. /**
  57465. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57466. */
  57467. metallicTexture: BaseTexture;
  57468. /**
  57469. * Specifies the metallic scalar of the metallic/roughness workflow.
  57470. * Can also be used to scale the metalness values of the metallic texture.
  57471. */
  57472. metallic: Nullable<number>;
  57473. /**
  57474. * Specifies the roughness scalar of the metallic/roughness workflow.
  57475. * Can also be used to scale the roughness values of the metallic texture.
  57476. */
  57477. roughness: Nullable<number>;
  57478. /**
  57479. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57480. * By default the indexOfrefraction is used to compute F0;
  57481. *
  57482. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57483. *
  57484. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57485. * F90 = metallicReflectanceColor;
  57486. */
  57487. metallicF0Factor: number;
  57488. /**
  57489. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57490. * By default the F90 is always 1;
  57491. *
  57492. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57493. *
  57494. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57495. * F90 = metallicReflectanceColor;
  57496. */
  57497. metallicReflectanceColor: Color3;
  57498. /**
  57499. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57500. * This is multiply against the scalar values defined in the material.
  57501. */
  57502. metallicReflectanceTexture: Nullable<BaseTexture>;
  57503. /**
  57504. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57505. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57506. */
  57507. microSurfaceTexture: BaseTexture;
  57508. /**
  57509. * Stores surface normal data used to displace a mesh in a texture.
  57510. */
  57511. bumpTexture: BaseTexture;
  57512. /**
  57513. * Stores the pre-calculated light information of a mesh in a texture.
  57514. */
  57515. lightmapTexture: BaseTexture;
  57516. /**
  57517. * Stores the refracted light information in a texture.
  57518. */
  57519. get refractionTexture(): Nullable<BaseTexture>;
  57520. set refractionTexture(value: Nullable<BaseTexture>);
  57521. /**
  57522. * The color of a material in ambient lighting.
  57523. */
  57524. ambientColor: Color3;
  57525. /**
  57526. * AKA Diffuse Color in other nomenclature.
  57527. */
  57528. albedoColor: Color3;
  57529. /**
  57530. * AKA Specular Color in other nomenclature.
  57531. */
  57532. reflectivityColor: Color3;
  57533. /**
  57534. * The color reflected from the material.
  57535. */
  57536. reflectionColor: Color3;
  57537. /**
  57538. * The color emitted from the material.
  57539. */
  57540. emissiveColor: Color3;
  57541. /**
  57542. * AKA Glossiness in other nomenclature.
  57543. */
  57544. microSurface: number;
  57545. /**
  57546. * Index of refraction of the material base layer.
  57547. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57548. *
  57549. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57550. *
  57551. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57552. */
  57553. get indexOfRefraction(): number;
  57554. set indexOfRefraction(value: number);
  57555. /**
  57556. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57557. */
  57558. get invertRefractionY(): boolean;
  57559. set invertRefractionY(value: boolean);
  57560. /**
  57561. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57562. * Materials half opaque for instance using refraction could benefit from this control.
  57563. */
  57564. get linkRefractionWithTransparency(): boolean;
  57565. set linkRefractionWithTransparency(value: boolean);
  57566. /**
  57567. * If true, the light map contains occlusion information instead of lighting info.
  57568. */
  57569. useLightmapAsShadowmap: boolean;
  57570. /**
  57571. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57572. */
  57573. useAlphaFromAlbedoTexture: boolean;
  57574. /**
  57575. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57576. */
  57577. forceAlphaTest: boolean;
  57578. /**
  57579. * Defines the alpha limits in alpha test mode.
  57580. */
  57581. alphaCutOff: number;
  57582. /**
  57583. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57584. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57585. */
  57586. useSpecularOverAlpha: boolean;
  57587. /**
  57588. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57589. */
  57590. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57591. /**
  57592. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57593. */
  57594. useRoughnessFromMetallicTextureAlpha: boolean;
  57595. /**
  57596. * Specifies if the metallic texture contains the roughness information in its green channel.
  57597. */
  57598. useRoughnessFromMetallicTextureGreen: boolean;
  57599. /**
  57600. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57601. */
  57602. useMetallnessFromMetallicTextureBlue: boolean;
  57603. /**
  57604. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57605. */
  57606. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57607. /**
  57608. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57609. */
  57610. useAmbientInGrayScale: boolean;
  57611. /**
  57612. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57613. * The material will try to infer what glossiness each pixel should be.
  57614. */
  57615. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57616. /**
  57617. * BJS is using an harcoded light falloff based on a manually sets up range.
  57618. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57619. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57620. */
  57621. get usePhysicalLightFalloff(): boolean;
  57622. /**
  57623. * BJS is using an harcoded light falloff based on a manually sets up range.
  57624. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57625. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57626. */
  57627. set usePhysicalLightFalloff(value: boolean);
  57628. /**
  57629. * In order to support the falloff compatibility with gltf, a special mode has been added
  57630. * to reproduce the gltf light falloff.
  57631. */
  57632. get useGLTFLightFalloff(): boolean;
  57633. /**
  57634. * In order to support the falloff compatibility with gltf, a special mode has been added
  57635. * to reproduce the gltf light falloff.
  57636. */
  57637. set useGLTFLightFalloff(value: boolean);
  57638. /**
  57639. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57640. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57641. */
  57642. useRadianceOverAlpha: boolean;
  57643. /**
  57644. * Allows using an object space normal map (instead of tangent space).
  57645. */
  57646. useObjectSpaceNormalMap: boolean;
  57647. /**
  57648. * Allows using the bump map in parallax mode.
  57649. */
  57650. useParallax: boolean;
  57651. /**
  57652. * Allows using the bump map in parallax occlusion mode.
  57653. */
  57654. useParallaxOcclusion: boolean;
  57655. /**
  57656. * Controls the scale bias of the parallax mode.
  57657. */
  57658. parallaxScaleBias: number;
  57659. /**
  57660. * If sets to true, disables all the lights affecting the material.
  57661. */
  57662. disableLighting: boolean;
  57663. /**
  57664. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57665. */
  57666. forceIrradianceInFragment: boolean;
  57667. /**
  57668. * Number of Simultaneous lights allowed on the material.
  57669. */
  57670. maxSimultaneousLights: number;
  57671. /**
  57672. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57673. */
  57674. invertNormalMapX: boolean;
  57675. /**
  57676. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57677. */
  57678. invertNormalMapY: boolean;
  57679. /**
  57680. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57681. */
  57682. twoSidedLighting: boolean;
  57683. /**
  57684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57685. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57686. */
  57687. useAlphaFresnel: boolean;
  57688. /**
  57689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57690. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57691. */
  57692. useLinearAlphaFresnel: boolean;
  57693. /**
  57694. * Let user defines the brdf lookup texture used for IBL.
  57695. * A default 8bit version is embedded but you could point at :
  57696. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57697. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57698. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57699. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57700. */
  57701. environmentBRDFTexture: Nullable<BaseTexture>;
  57702. /**
  57703. * Force normal to face away from face.
  57704. */
  57705. forceNormalForward: boolean;
  57706. /**
  57707. * Enables specular anti aliasing in the PBR shader.
  57708. * It will both interacts on the Geometry for analytical and IBL lighting.
  57709. * It also prefilter the roughness map based on the bump values.
  57710. */
  57711. enableSpecularAntiAliasing: boolean;
  57712. /**
  57713. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57714. * makes the reflect vector face the model (under horizon).
  57715. */
  57716. useHorizonOcclusion: boolean;
  57717. /**
  57718. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57719. * too much the area relying on ambient texture to define their ambient occlusion.
  57720. */
  57721. useRadianceOcclusion: boolean;
  57722. /**
  57723. * If set to true, no lighting calculations will be applied.
  57724. */
  57725. unlit: boolean;
  57726. /**
  57727. * Gets the image processing configuration used either in this material.
  57728. */
  57729. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57730. /**
  57731. * Sets the Default image processing configuration used either in the this material.
  57732. *
  57733. * If sets to null, the scene one is in use.
  57734. */
  57735. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57736. /**
  57737. * Gets wether the color curves effect is enabled.
  57738. */
  57739. get cameraColorCurvesEnabled(): boolean;
  57740. /**
  57741. * Sets wether the color curves effect is enabled.
  57742. */
  57743. set cameraColorCurvesEnabled(value: boolean);
  57744. /**
  57745. * Gets wether the color grading effect is enabled.
  57746. */
  57747. get cameraColorGradingEnabled(): boolean;
  57748. /**
  57749. * Gets wether the color grading effect is enabled.
  57750. */
  57751. set cameraColorGradingEnabled(value: boolean);
  57752. /**
  57753. * Gets wether tonemapping is enabled or not.
  57754. */
  57755. get cameraToneMappingEnabled(): boolean;
  57756. /**
  57757. * Sets wether tonemapping is enabled or not
  57758. */
  57759. set cameraToneMappingEnabled(value: boolean);
  57760. /**
  57761. * The camera exposure used on this material.
  57762. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57763. * This corresponds to a photographic exposure.
  57764. */
  57765. get cameraExposure(): number;
  57766. /**
  57767. * The camera exposure used on this material.
  57768. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57769. * This corresponds to a photographic exposure.
  57770. */
  57771. set cameraExposure(value: number);
  57772. /**
  57773. * Gets The camera contrast used on this material.
  57774. */
  57775. get cameraContrast(): number;
  57776. /**
  57777. * Sets The camera contrast used on this material.
  57778. */
  57779. set cameraContrast(value: number);
  57780. /**
  57781. * Gets the Color Grading 2D Lookup Texture.
  57782. */
  57783. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57784. /**
  57785. * Sets the Color Grading 2D Lookup Texture.
  57786. */
  57787. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57788. /**
  57789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57791. * 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;
  57792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57793. */
  57794. get cameraColorCurves(): Nullable<ColorCurves>;
  57795. /**
  57796. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57797. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57798. * 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;
  57799. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57800. */
  57801. set cameraColorCurves(value: Nullable<ColorCurves>);
  57802. /**
  57803. * Instantiates a new PBRMaterial instance.
  57804. *
  57805. * @param name The material name
  57806. * @param scene The scene the material will be use in.
  57807. */
  57808. constructor(name: string, scene: Scene);
  57809. /**
  57810. * Returns the name of this material class.
  57811. */
  57812. getClassName(): string;
  57813. /**
  57814. * Makes a duplicate of the current material.
  57815. * @param name - name to use for the new material.
  57816. */
  57817. clone(name: string): PBRMaterial;
  57818. /**
  57819. * Serializes this PBR Material.
  57820. * @returns - An object with the serialized material.
  57821. */
  57822. serialize(): any;
  57823. /**
  57824. * Parses a PBR Material from a serialized object.
  57825. * @param source - Serialized object.
  57826. * @param scene - BJS scene instance.
  57827. * @param rootUrl - url for the scene object
  57828. * @returns - PBRMaterial
  57829. */
  57830. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57831. }
  57832. }
  57833. declare module BABYLON {
  57834. /**
  57835. * Direct draw surface info
  57836. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57837. */
  57838. export interface DDSInfo {
  57839. /**
  57840. * Width of the texture
  57841. */
  57842. width: number;
  57843. /**
  57844. * Width of the texture
  57845. */
  57846. height: number;
  57847. /**
  57848. * Number of Mipmaps for the texture
  57849. * @see https://en.wikipedia.org/wiki/Mipmap
  57850. */
  57851. mipmapCount: number;
  57852. /**
  57853. * If the textures format is a known fourCC format
  57854. * @see https://www.fourcc.org/
  57855. */
  57856. isFourCC: boolean;
  57857. /**
  57858. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57859. */
  57860. isRGB: boolean;
  57861. /**
  57862. * If the texture is a lumincance format
  57863. */
  57864. isLuminance: boolean;
  57865. /**
  57866. * If this is a cube texture
  57867. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57868. */
  57869. isCube: boolean;
  57870. /**
  57871. * If the texture is a compressed format eg. FOURCC_DXT1
  57872. */
  57873. isCompressed: boolean;
  57874. /**
  57875. * The dxgiFormat of the texture
  57876. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57877. */
  57878. dxgiFormat: number;
  57879. /**
  57880. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57881. */
  57882. textureType: number;
  57883. /**
  57884. * Sphericle polynomial created for the dds texture
  57885. */
  57886. sphericalPolynomial?: SphericalPolynomial;
  57887. }
  57888. /**
  57889. * Class used to provide DDS decompression tools
  57890. */
  57891. export class DDSTools {
  57892. /**
  57893. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57894. */
  57895. static StoreLODInAlphaChannel: boolean;
  57896. /**
  57897. * Gets DDS information from an array buffer
  57898. * @param data defines the array buffer view to read data from
  57899. * @returns the DDS information
  57900. */
  57901. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57902. private static _FloatView;
  57903. private static _Int32View;
  57904. private static _ToHalfFloat;
  57905. private static _FromHalfFloat;
  57906. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57907. private static _GetHalfFloatRGBAArrayBuffer;
  57908. private static _GetFloatRGBAArrayBuffer;
  57909. private static _GetFloatAsUIntRGBAArrayBuffer;
  57910. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57911. private static _GetRGBAArrayBuffer;
  57912. private static _ExtractLongWordOrder;
  57913. private static _GetRGBArrayBuffer;
  57914. private static _GetLuminanceArrayBuffer;
  57915. /**
  57916. * Uploads DDS Levels to a Babylon Texture
  57917. * @hidden
  57918. */
  57919. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57920. }
  57921. interface ThinEngine {
  57922. /**
  57923. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57924. * @param rootUrl defines the url where the file to load is located
  57925. * @param scene defines the current scene
  57926. * @param lodScale defines scale to apply to the mip map selection
  57927. * @param lodOffset defines offset to apply to the mip map selection
  57928. * @param onLoad defines an optional callback raised when the texture is loaded
  57929. * @param onError defines an optional callback raised if there is an issue to load the texture
  57930. * @param format defines the format of the data
  57931. * @param forcedExtension defines the extension to use to pick the right loader
  57932. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57933. * @returns the cube texture as an InternalTexture
  57934. */
  57935. 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;
  57936. }
  57937. }
  57938. declare module BABYLON {
  57939. /**
  57940. * Implementation of the DDS Texture Loader.
  57941. * @hidden
  57942. */
  57943. export class _DDSTextureLoader implements IInternalTextureLoader {
  57944. /**
  57945. * Defines wether the loader supports cascade loading the different faces.
  57946. */
  57947. readonly supportCascades: boolean;
  57948. /**
  57949. * This returns if the loader support the current file information.
  57950. * @param extension defines the file extension of the file being loaded
  57951. * @returns true if the loader can load the specified file
  57952. */
  57953. canLoad(extension: string): boolean;
  57954. /**
  57955. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57956. * @param data contains the texture data
  57957. * @param texture defines the BabylonJS internal texture
  57958. * @param createPolynomials will be true if polynomials have been requested
  57959. * @param onLoad defines the callback to trigger once the texture is ready
  57960. * @param onError defines the callback to trigger in case of error
  57961. */
  57962. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57963. /**
  57964. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57965. * @param data contains the texture data
  57966. * @param texture defines the BabylonJS internal texture
  57967. * @param callback defines the method to call once ready to upload
  57968. */
  57969. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57970. }
  57971. }
  57972. declare module BABYLON {
  57973. /**
  57974. * Implementation of the ENV Texture Loader.
  57975. * @hidden
  57976. */
  57977. export class _ENVTextureLoader implements IInternalTextureLoader {
  57978. /**
  57979. * Defines wether the loader supports cascade loading the different faces.
  57980. */
  57981. readonly supportCascades: boolean;
  57982. /**
  57983. * This returns if the loader support the current file information.
  57984. * @param extension defines the file extension of the file being loaded
  57985. * @returns true if the loader can load the specified file
  57986. */
  57987. canLoad(extension: string): boolean;
  57988. /**
  57989. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57990. * @param data contains the texture data
  57991. * @param texture defines the BabylonJS internal texture
  57992. * @param createPolynomials will be true if polynomials have been requested
  57993. * @param onLoad defines the callback to trigger once the texture is ready
  57994. * @param onError defines the callback to trigger in case of error
  57995. */
  57996. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57997. /**
  57998. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57999. * @param data contains the texture data
  58000. * @param texture defines the BabylonJS internal texture
  58001. * @param callback defines the method to call once ready to upload
  58002. */
  58003. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58004. }
  58005. }
  58006. declare module BABYLON {
  58007. /**
  58008. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58009. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58010. */
  58011. export class KhronosTextureContainer {
  58012. /** contents of the KTX container file */
  58013. data: ArrayBufferView;
  58014. private static HEADER_LEN;
  58015. private static COMPRESSED_2D;
  58016. private static COMPRESSED_3D;
  58017. private static TEX_2D;
  58018. private static TEX_3D;
  58019. /**
  58020. * Gets the openGL type
  58021. */
  58022. glType: number;
  58023. /**
  58024. * Gets the openGL type size
  58025. */
  58026. glTypeSize: number;
  58027. /**
  58028. * Gets the openGL format
  58029. */
  58030. glFormat: number;
  58031. /**
  58032. * Gets the openGL internal format
  58033. */
  58034. glInternalFormat: number;
  58035. /**
  58036. * Gets the base internal format
  58037. */
  58038. glBaseInternalFormat: number;
  58039. /**
  58040. * Gets image width in pixel
  58041. */
  58042. pixelWidth: number;
  58043. /**
  58044. * Gets image height in pixel
  58045. */
  58046. pixelHeight: number;
  58047. /**
  58048. * Gets image depth in pixels
  58049. */
  58050. pixelDepth: number;
  58051. /**
  58052. * Gets the number of array elements
  58053. */
  58054. numberOfArrayElements: number;
  58055. /**
  58056. * Gets the number of faces
  58057. */
  58058. numberOfFaces: number;
  58059. /**
  58060. * Gets the number of mipmap levels
  58061. */
  58062. numberOfMipmapLevels: number;
  58063. /**
  58064. * Gets the bytes of key value data
  58065. */
  58066. bytesOfKeyValueData: number;
  58067. /**
  58068. * Gets the load type
  58069. */
  58070. loadType: number;
  58071. /**
  58072. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58073. */
  58074. isInvalid: boolean;
  58075. /**
  58076. * Creates a new KhronosTextureContainer
  58077. * @param data contents of the KTX container file
  58078. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58079. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58080. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58081. */
  58082. constructor(
  58083. /** contents of the KTX container file */
  58084. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58085. /**
  58086. * Uploads KTX content to a Babylon Texture.
  58087. * It is assumed that the texture has already been created & is currently bound
  58088. * @hidden
  58089. */
  58090. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58091. private _upload2DCompressedLevels;
  58092. /**
  58093. * Checks if the given data starts with a KTX file identifier.
  58094. * @param data the data to check
  58095. * @returns true if the data is a KTX file or false otherwise
  58096. */
  58097. static IsValid(data: ArrayBufferView): boolean;
  58098. }
  58099. }
  58100. declare module BABYLON {
  58101. /**
  58102. * Helper class to push actions to a pool of workers.
  58103. */
  58104. export class WorkerPool implements IDisposable {
  58105. private _workerInfos;
  58106. private _pendingActions;
  58107. /**
  58108. * Constructor
  58109. * @param workers Array of workers to use for actions
  58110. */
  58111. constructor(workers: Array<Worker>);
  58112. /**
  58113. * Terminates all workers and clears any pending actions.
  58114. */
  58115. dispose(): void;
  58116. /**
  58117. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58118. * pended until a worker has completed its action.
  58119. * @param action The action to perform. Call onComplete when the action is complete.
  58120. */
  58121. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58122. private _execute;
  58123. }
  58124. }
  58125. declare module BABYLON {
  58126. /**
  58127. * Class for loading KTX2 files
  58128. */
  58129. export class KhronosTextureContainer2 {
  58130. private static _WorkerPoolPromise?;
  58131. private static _Initialized;
  58132. private static _Ktx2Decoder;
  58133. /**
  58134. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58135. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58136. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58137. * Urls you can change:
  58138. * URLConfig.jsDecoderModule
  58139. * URLConfig.wasmUASTCToASTC
  58140. * URLConfig.wasmUASTCToBC7
  58141. * URLConfig.jsMSCTranscoder
  58142. * URLConfig.wasmMSCTranscoder
  58143. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58144. */
  58145. static URLConfig: {
  58146. jsDecoderModule: string;
  58147. wasmUASTCToASTC: null;
  58148. wasmUASTCToBC7: null;
  58149. jsMSCTranscoder: null;
  58150. wasmMSCTranscoder: null;
  58151. };
  58152. /**
  58153. * Default number of workers used to handle data decoding
  58154. */
  58155. static DefaultNumWorkers: number;
  58156. private static GetDefaultNumWorkers;
  58157. private _engine;
  58158. private static _CreateWorkerPool;
  58159. /**
  58160. * Constructor
  58161. * @param engine The engine to use
  58162. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58163. */
  58164. constructor(engine: ThinEngine, numWorkers?: number);
  58165. /** @hidden */
  58166. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58167. /**
  58168. * Stop all async operations and release resources.
  58169. */
  58170. dispose(): void;
  58171. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58172. /**
  58173. * Checks if the given data starts with a KTX2 file identifier.
  58174. * @param data the data to check
  58175. * @returns true if the data is a KTX2 file or false otherwise
  58176. */
  58177. static IsValid(data: ArrayBufferView): boolean;
  58178. }
  58179. }
  58180. declare module BABYLON {
  58181. /**
  58182. * Implementation of the KTX Texture Loader.
  58183. * @hidden
  58184. */
  58185. export class _KTXTextureLoader implements IInternalTextureLoader {
  58186. /**
  58187. * Defines wether the loader supports cascade loading the different faces.
  58188. */
  58189. readonly supportCascades: boolean;
  58190. /**
  58191. * This returns if the loader support the current file information.
  58192. * @param extension defines the file extension of the file being loaded
  58193. * @param mimeType defines the optional mime type of the file being loaded
  58194. * @returns true if the loader can load the specified file
  58195. */
  58196. canLoad(extension: string, mimeType?: string): boolean;
  58197. /**
  58198. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58199. * @param data contains the texture data
  58200. * @param texture defines the BabylonJS internal texture
  58201. * @param createPolynomials will be true if polynomials have been requested
  58202. * @param onLoad defines the callback to trigger once the texture is ready
  58203. * @param onError defines the callback to trigger in case of error
  58204. */
  58205. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58206. /**
  58207. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58208. * @param data contains the texture data
  58209. * @param texture defines the BabylonJS internal texture
  58210. * @param callback defines the method to call once ready to upload
  58211. */
  58212. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58213. }
  58214. }
  58215. declare module BABYLON {
  58216. /** @hidden */
  58217. export var _forceSceneHelpersToBundle: boolean;
  58218. interface Scene {
  58219. /**
  58220. * Creates a default light for the scene.
  58221. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58222. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58223. */
  58224. createDefaultLight(replace?: boolean): void;
  58225. /**
  58226. * Creates a default camera for the scene.
  58227. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58228. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58229. * @param replace has default false, when true replaces the active camera in the scene
  58230. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58231. */
  58232. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58233. /**
  58234. * Creates a default camera and a default light.
  58235. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58236. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58237. * @param replace has the default false, when true replaces the active camera/light in the scene
  58238. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58239. */
  58240. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58241. /**
  58242. * Creates a new sky box
  58243. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58244. * @param environmentTexture defines the texture to use as environment texture
  58245. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58246. * @param scale defines the overall scale of the skybox
  58247. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58248. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58249. * @returns a new mesh holding the sky box
  58250. */
  58251. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58252. /**
  58253. * Creates a new environment
  58254. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58255. * @param options defines the options you can use to configure the environment
  58256. * @returns the new EnvironmentHelper
  58257. */
  58258. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58259. /**
  58260. * Creates a new VREXperienceHelper
  58261. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58262. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58263. * @returns a new VREXperienceHelper
  58264. */
  58265. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58266. /**
  58267. * Creates a new WebXRDefaultExperience
  58268. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58269. * @param options experience options
  58270. * @returns a promise for a new WebXRDefaultExperience
  58271. */
  58272. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58273. }
  58274. }
  58275. declare module BABYLON {
  58276. /**
  58277. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58278. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58279. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58280. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58281. */
  58282. export class VideoDome extends TextureDome<VideoTexture> {
  58283. /**
  58284. * Define the video source as a Monoscopic panoramic 360 video.
  58285. */
  58286. static readonly MODE_MONOSCOPIC: number;
  58287. /**
  58288. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58289. */
  58290. static readonly MODE_TOPBOTTOM: number;
  58291. /**
  58292. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58293. */
  58294. static readonly MODE_SIDEBYSIDE: number;
  58295. /**
  58296. * Get the video texture associated with this video dome
  58297. */
  58298. get videoTexture(): VideoTexture;
  58299. /**
  58300. * Get the video mode of this dome
  58301. */
  58302. get videoMode(): number;
  58303. /**
  58304. * Set the video mode of this dome.
  58305. * @see textureMode
  58306. */
  58307. set videoMode(value: number);
  58308. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58309. }
  58310. }
  58311. declare module BABYLON {
  58312. /**
  58313. * This class can be used to get instrumentation data from a Babylon engine
  58314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58315. */
  58316. export class EngineInstrumentation implements IDisposable {
  58317. /**
  58318. * Define the instrumented engine.
  58319. */
  58320. engine: Engine;
  58321. private _captureGPUFrameTime;
  58322. private _gpuFrameTimeToken;
  58323. private _gpuFrameTime;
  58324. private _captureShaderCompilationTime;
  58325. private _shaderCompilationTime;
  58326. private _onBeginFrameObserver;
  58327. private _onEndFrameObserver;
  58328. private _onBeforeShaderCompilationObserver;
  58329. private _onAfterShaderCompilationObserver;
  58330. /**
  58331. * Gets the perf counter used for GPU frame time
  58332. */
  58333. get gpuFrameTimeCounter(): PerfCounter;
  58334. /**
  58335. * Gets the GPU frame time capture status
  58336. */
  58337. get captureGPUFrameTime(): boolean;
  58338. /**
  58339. * Enable or disable the GPU frame time capture
  58340. */
  58341. set captureGPUFrameTime(value: boolean);
  58342. /**
  58343. * Gets the perf counter used for shader compilation time
  58344. */
  58345. get shaderCompilationTimeCounter(): PerfCounter;
  58346. /**
  58347. * Gets the shader compilation time capture status
  58348. */
  58349. get captureShaderCompilationTime(): boolean;
  58350. /**
  58351. * Enable or disable the shader compilation time capture
  58352. */
  58353. set captureShaderCompilationTime(value: boolean);
  58354. /**
  58355. * Instantiates a new engine instrumentation.
  58356. * This class can be used to get instrumentation data from a Babylon engine
  58357. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58358. * @param engine Defines the engine to instrument
  58359. */
  58360. constructor(
  58361. /**
  58362. * Define the instrumented engine.
  58363. */
  58364. engine: Engine);
  58365. /**
  58366. * Dispose and release associated resources.
  58367. */
  58368. dispose(): void;
  58369. }
  58370. }
  58371. declare module BABYLON {
  58372. /**
  58373. * This class can be used to get instrumentation data from a Babylon engine
  58374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58375. */
  58376. export class SceneInstrumentation implements IDisposable {
  58377. /**
  58378. * Defines the scene to instrument
  58379. */
  58380. scene: Scene;
  58381. private _captureActiveMeshesEvaluationTime;
  58382. private _activeMeshesEvaluationTime;
  58383. private _captureRenderTargetsRenderTime;
  58384. private _renderTargetsRenderTime;
  58385. private _captureFrameTime;
  58386. private _frameTime;
  58387. private _captureRenderTime;
  58388. private _renderTime;
  58389. private _captureInterFrameTime;
  58390. private _interFrameTime;
  58391. private _captureParticlesRenderTime;
  58392. private _particlesRenderTime;
  58393. private _captureSpritesRenderTime;
  58394. private _spritesRenderTime;
  58395. private _capturePhysicsTime;
  58396. private _physicsTime;
  58397. private _captureAnimationsTime;
  58398. private _animationsTime;
  58399. private _captureCameraRenderTime;
  58400. private _cameraRenderTime;
  58401. private _onBeforeActiveMeshesEvaluationObserver;
  58402. private _onAfterActiveMeshesEvaluationObserver;
  58403. private _onBeforeRenderTargetsRenderObserver;
  58404. private _onAfterRenderTargetsRenderObserver;
  58405. private _onAfterRenderObserver;
  58406. private _onBeforeDrawPhaseObserver;
  58407. private _onAfterDrawPhaseObserver;
  58408. private _onBeforeAnimationsObserver;
  58409. private _onBeforeParticlesRenderingObserver;
  58410. private _onAfterParticlesRenderingObserver;
  58411. private _onBeforeSpritesRenderingObserver;
  58412. private _onAfterSpritesRenderingObserver;
  58413. private _onBeforePhysicsObserver;
  58414. private _onAfterPhysicsObserver;
  58415. private _onAfterAnimationsObserver;
  58416. private _onBeforeCameraRenderObserver;
  58417. private _onAfterCameraRenderObserver;
  58418. /**
  58419. * Gets the perf counter used for active meshes evaluation time
  58420. */
  58421. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58422. /**
  58423. * Gets the active meshes evaluation time capture status
  58424. */
  58425. get captureActiveMeshesEvaluationTime(): boolean;
  58426. /**
  58427. * Enable or disable the active meshes evaluation time capture
  58428. */
  58429. set captureActiveMeshesEvaluationTime(value: boolean);
  58430. /**
  58431. * Gets the perf counter used for render targets render time
  58432. */
  58433. get renderTargetsRenderTimeCounter(): PerfCounter;
  58434. /**
  58435. * Gets the render targets render time capture status
  58436. */
  58437. get captureRenderTargetsRenderTime(): boolean;
  58438. /**
  58439. * Enable or disable the render targets render time capture
  58440. */
  58441. set captureRenderTargetsRenderTime(value: boolean);
  58442. /**
  58443. * Gets the perf counter used for particles render time
  58444. */
  58445. get particlesRenderTimeCounter(): PerfCounter;
  58446. /**
  58447. * Gets the particles render time capture status
  58448. */
  58449. get captureParticlesRenderTime(): boolean;
  58450. /**
  58451. * Enable or disable the particles render time capture
  58452. */
  58453. set captureParticlesRenderTime(value: boolean);
  58454. /**
  58455. * Gets the perf counter used for sprites render time
  58456. */
  58457. get spritesRenderTimeCounter(): PerfCounter;
  58458. /**
  58459. * Gets the sprites render time capture status
  58460. */
  58461. get captureSpritesRenderTime(): boolean;
  58462. /**
  58463. * Enable or disable the sprites render time capture
  58464. */
  58465. set captureSpritesRenderTime(value: boolean);
  58466. /**
  58467. * Gets the perf counter used for physics time
  58468. */
  58469. get physicsTimeCounter(): PerfCounter;
  58470. /**
  58471. * Gets the physics time capture status
  58472. */
  58473. get capturePhysicsTime(): boolean;
  58474. /**
  58475. * Enable or disable the physics time capture
  58476. */
  58477. set capturePhysicsTime(value: boolean);
  58478. /**
  58479. * Gets the perf counter used for animations time
  58480. */
  58481. get animationsTimeCounter(): PerfCounter;
  58482. /**
  58483. * Gets the animations time capture status
  58484. */
  58485. get captureAnimationsTime(): boolean;
  58486. /**
  58487. * Enable or disable the animations time capture
  58488. */
  58489. set captureAnimationsTime(value: boolean);
  58490. /**
  58491. * Gets the perf counter used for frame time capture
  58492. */
  58493. get frameTimeCounter(): PerfCounter;
  58494. /**
  58495. * Gets the frame time capture status
  58496. */
  58497. get captureFrameTime(): boolean;
  58498. /**
  58499. * Enable or disable the frame time capture
  58500. */
  58501. set captureFrameTime(value: boolean);
  58502. /**
  58503. * Gets the perf counter used for inter-frames time capture
  58504. */
  58505. get interFrameTimeCounter(): PerfCounter;
  58506. /**
  58507. * Gets the inter-frames time capture status
  58508. */
  58509. get captureInterFrameTime(): boolean;
  58510. /**
  58511. * Enable or disable the inter-frames time capture
  58512. */
  58513. set captureInterFrameTime(value: boolean);
  58514. /**
  58515. * Gets the perf counter used for render time capture
  58516. */
  58517. get renderTimeCounter(): PerfCounter;
  58518. /**
  58519. * Gets the render time capture status
  58520. */
  58521. get captureRenderTime(): boolean;
  58522. /**
  58523. * Enable or disable the render time capture
  58524. */
  58525. set captureRenderTime(value: boolean);
  58526. /**
  58527. * Gets the perf counter used for camera render time capture
  58528. */
  58529. get cameraRenderTimeCounter(): PerfCounter;
  58530. /**
  58531. * Gets the camera render time capture status
  58532. */
  58533. get captureCameraRenderTime(): boolean;
  58534. /**
  58535. * Enable or disable the camera render time capture
  58536. */
  58537. set captureCameraRenderTime(value: boolean);
  58538. /**
  58539. * Gets the perf counter used for draw calls
  58540. */
  58541. get drawCallsCounter(): PerfCounter;
  58542. /**
  58543. * Instantiates a new scene instrumentation.
  58544. * This class can be used to get instrumentation data from a Babylon engine
  58545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58546. * @param scene Defines the scene to instrument
  58547. */
  58548. constructor(
  58549. /**
  58550. * Defines the scene to instrument
  58551. */
  58552. scene: Scene);
  58553. /**
  58554. * Dispose and release associated resources.
  58555. */
  58556. dispose(): void;
  58557. }
  58558. }
  58559. declare module BABYLON {
  58560. /** @hidden */
  58561. export var glowMapGenerationPixelShader: {
  58562. name: string;
  58563. shader: string;
  58564. };
  58565. }
  58566. declare module BABYLON {
  58567. /** @hidden */
  58568. export var glowMapGenerationVertexShader: {
  58569. name: string;
  58570. shader: string;
  58571. };
  58572. }
  58573. declare module BABYLON {
  58574. /**
  58575. * Effect layer options. This helps customizing the behaviour
  58576. * of the effect layer.
  58577. */
  58578. export interface IEffectLayerOptions {
  58579. /**
  58580. * Multiplication factor apply to the canvas size to compute the render target size
  58581. * used to generated the objects (the smaller the faster).
  58582. */
  58583. mainTextureRatio: number;
  58584. /**
  58585. * Enforces a fixed size texture to ensure effect stability across devices.
  58586. */
  58587. mainTextureFixedSize?: number;
  58588. /**
  58589. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58590. */
  58591. alphaBlendingMode: number;
  58592. /**
  58593. * The camera attached to the layer.
  58594. */
  58595. camera: Nullable<Camera>;
  58596. /**
  58597. * The rendering group to draw the layer in.
  58598. */
  58599. renderingGroupId: number;
  58600. }
  58601. /**
  58602. * The effect layer Helps adding post process effect blended with the main pass.
  58603. *
  58604. * This can be for instance use to generate glow or higlight effects on the scene.
  58605. *
  58606. * The effect layer class can not be used directly and is intented to inherited from to be
  58607. * customized per effects.
  58608. */
  58609. export abstract class EffectLayer {
  58610. private _vertexBuffers;
  58611. private _indexBuffer;
  58612. private _cachedDefines;
  58613. private _effectLayerMapGenerationEffect;
  58614. private _effectLayerOptions;
  58615. private _mergeEffect;
  58616. protected _scene: Scene;
  58617. protected _engine: Engine;
  58618. protected _maxSize: number;
  58619. protected _mainTextureDesiredSize: ISize;
  58620. protected _mainTexture: RenderTargetTexture;
  58621. protected _shouldRender: boolean;
  58622. protected _postProcesses: PostProcess[];
  58623. protected _textures: BaseTexture[];
  58624. protected _emissiveTextureAndColor: {
  58625. texture: Nullable<BaseTexture>;
  58626. color: Color4;
  58627. };
  58628. /**
  58629. * The name of the layer
  58630. */
  58631. name: string;
  58632. /**
  58633. * The clear color of the texture used to generate the glow map.
  58634. */
  58635. neutralColor: Color4;
  58636. /**
  58637. * Specifies whether the highlight layer is enabled or not.
  58638. */
  58639. isEnabled: boolean;
  58640. /**
  58641. * Gets the camera attached to the layer.
  58642. */
  58643. get camera(): Nullable<Camera>;
  58644. /**
  58645. * Gets the rendering group id the layer should render in.
  58646. */
  58647. get renderingGroupId(): number;
  58648. set renderingGroupId(renderingGroupId: number);
  58649. /**
  58650. * An event triggered when the effect layer has been disposed.
  58651. */
  58652. onDisposeObservable: Observable<EffectLayer>;
  58653. /**
  58654. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58655. */
  58656. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58657. /**
  58658. * An event triggered when the generated texture is being merged in the scene.
  58659. */
  58660. onBeforeComposeObservable: Observable<EffectLayer>;
  58661. /**
  58662. * An event triggered when the mesh is rendered into the effect render target.
  58663. */
  58664. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58665. /**
  58666. * An event triggered after the mesh has been rendered into the effect render target.
  58667. */
  58668. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58669. /**
  58670. * An event triggered when the generated texture has been merged in the scene.
  58671. */
  58672. onAfterComposeObservable: Observable<EffectLayer>;
  58673. /**
  58674. * An event triggered when the efffect layer changes its size.
  58675. */
  58676. onSizeChangedObservable: Observable<EffectLayer>;
  58677. /** @hidden */
  58678. static _SceneComponentInitialization: (scene: Scene) => void;
  58679. /**
  58680. * Instantiates a new effect Layer and references it in the scene.
  58681. * @param name The name of the layer
  58682. * @param scene The scene to use the layer in
  58683. */
  58684. constructor(
  58685. /** The Friendly of the effect in the scene */
  58686. name: string, scene: Scene);
  58687. /**
  58688. * Get the effect name of the layer.
  58689. * @return The effect name
  58690. */
  58691. abstract getEffectName(): string;
  58692. /**
  58693. * Checks for the readiness of the element composing the layer.
  58694. * @param subMesh the mesh to check for
  58695. * @param useInstances specify whether or not to use instances to render the mesh
  58696. * @return true if ready otherwise, false
  58697. */
  58698. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58699. /**
  58700. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58701. * @returns true if the effect requires stencil during the main canvas render pass.
  58702. */
  58703. abstract needStencil(): boolean;
  58704. /**
  58705. * Create the merge effect. This is the shader use to blit the information back
  58706. * to the main canvas at the end of the scene rendering.
  58707. * @returns The effect containing the shader used to merge the effect on the main canvas
  58708. */
  58709. protected abstract _createMergeEffect(): Effect;
  58710. /**
  58711. * Creates the render target textures and post processes used in the effect layer.
  58712. */
  58713. protected abstract _createTextureAndPostProcesses(): void;
  58714. /**
  58715. * Implementation specific of rendering the generating effect on the main canvas.
  58716. * @param effect The effect used to render through
  58717. */
  58718. protected abstract _internalRender(effect: Effect): void;
  58719. /**
  58720. * Sets the required values for both the emissive texture and and the main color.
  58721. */
  58722. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58723. /**
  58724. * Free any resources and references associated to a mesh.
  58725. * Internal use
  58726. * @param mesh The mesh to free.
  58727. */
  58728. abstract _disposeMesh(mesh: Mesh): void;
  58729. /**
  58730. * Serializes this layer (Glow or Highlight for example)
  58731. * @returns a serialized layer object
  58732. */
  58733. abstract serialize?(): any;
  58734. /**
  58735. * Initializes the effect layer with the required options.
  58736. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58737. */
  58738. protected _init(options: Partial<IEffectLayerOptions>): void;
  58739. /**
  58740. * Generates the index buffer of the full screen quad blending to the main canvas.
  58741. */
  58742. private _generateIndexBuffer;
  58743. /**
  58744. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58745. */
  58746. private _generateVertexBuffer;
  58747. /**
  58748. * Sets the main texture desired size which is the closest power of two
  58749. * of the engine canvas size.
  58750. */
  58751. private _setMainTextureSize;
  58752. /**
  58753. * Creates the main texture for the effect layer.
  58754. */
  58755. protected _createMainTexture(): void;
  58756. /**
  58757. * Adds specific effects defines.
  58758. * @param defines The defines to add specifics to.
  58759. */
  58760. protected _addCustomEffectDefines(defines: string[]): void;
  58761. /**
  58762. * Checks for the readiness of the element composing the layer.
  58763. * @param subMesh the mesh to check for
  58764. * @param useInstances specify whether or not to use instances to render the mesh
  58765. * @param emissiveTexture the associated emissive texture used to generate the glow
  58766. * @return true if ready otherwise, false
  58767. */
  58768. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58769. /**
  58770. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58771. */
  58772. render(): void;
  58773. /**
  58774. * Determine if a given mesh will be used in the current effect.
  58775. * @param mesh mesh to test
  58776. * @returns true if the mesh will be used
  58777. */
  58778. hasMesh(mesh: AbstractMesh): boolean;
  58779. /**
  58780. * Returns true if the layer contains information to display, otherwise false.
  58781. * @returns true if the glow layer should be rendered
  58782. */
  58783. shouldRender(): boolean;
  58784. /**
  58785. * Returns true if the mesh should render, otherwise false.
  58786. * @param mesh The mesh to render
  58787. * @returns true if it should render otherwise false
  58788. */
  58789. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58790. /**
  58791. * Returns true if the mesh can be rendered, otherwise false.
  58792. * @param mesh The mesh to render
  58793. * @param material The material used on the mesh
  58794. * @returns true if it can be rendered otherwise false
  58795. */
  58796. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58797. /**
  58798. * Returns true if the mesh should render, otherwise false.
  58799. * @param mesh The mesh to render
  58800. * @returns true if it should render otherwise false
  58801. */
  58802. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58803. /**
  58804. * Renders the submesh passed in parameter to the generation map.
  58805. */
  58806. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58807. /**
  58808. * Defines whether the current material of the mesh should be use to render the effect.
  58809. * @param mesh defines the current mesh to render
  58810. */
  58811. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58812. /**
  58813. * Rebuild the required buffers.
  58814. * @hidden Internal use only.
  58815. */
  58816. _rebuild(): void;
  58817. /**
  58818. * Dispose only the render target textures and post process.
  58819. */
  58820. private _disposeTextureAndPostProcesses;
  58821. /**
  58822. * Dispose the highlight layer and free resources.
  58823. */
  58824. dispose(): void;
  58825. /**
  58826. * Gets the class name of the effect layer
  58827. * @returns the string with the class name of the effect layer
  58828. */
  58829. getClassName(): string;
  58830. /**
  58831. * Creates an effect layer from parsed effect layer data
  58832. * @param parsedEffectLayer defines effect layer data
  58833. * @param scene defines the current scene
  58834. * @param rootUrl defines the root URL containing the effect layer information
  58835. * @returns a parsed effect Layer
  58836. */
  58837. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. interface AbstractScene {
  58842. /**
  58843. * The list of effect layers (highlights/glow) added to the scene
  58844. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58845. * @see https://doc.babylonjs.com/how_to/glow_layer
  58846. */
  58847. effectLayers: Array<EffectLayer>;
  58848. /**
  58849. * Removes the given effect layer from this scene.
  58850. * @param toRemove defines the effect layer to remove
  58851. * @returns the index of the removed effect layer
  58852. */
  58853. removeEffectLayer(toRemove: EffectLayer): number;
  58854. /**
  58855. * Adds the given effect layer to this scene
  58856. * @param newEffectLayer defines the effect layer to add
  58857. */
  58858. addEffectLayer(newEffectLayer: EffectLayer): void;
  58859. }
  58860. /**
  58861. * Defines the layer scene component responsible to manage any effect layers
  58862. * in a given scene.
  58863. */
  58864. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58865. /**
  58866. * The component name helpfull to identify the component in the list of scene components.
  58867. */
  58868. readonly name: string;
  58869. /**
  58870. * The scene the component belongs to.
  58871. */
  58872. scene: Scene;
  58873. private _engine;
  58874. private _renderEffects;
  58875. private _needStencil;
  58876. private _previousStencilState;
  58877. /**
  58878. * Creates a new instance of the component for the given scene
  58879. * @param scene Defines the scene to register the component in
  58880. */
  58881. constructor(scene: Scene);
  58882. /**
  58883. * Registers the component in a given scene
  58884. */
  58885. register(): void;
  58886. /**
  58887. * Rebuilds the elements related to this component in case of
  58888. * context lost for instance.
  58889. */
  58890. rebuild(): void;
  58891. /**
  58892. * Serializes the component data to the specified json object
  58893. * @param serializationObject The object to serialize to
  58894. */
  58895. serialize(serializationObject: any): void;
  58896. /**
  58897. * Adds all the elements from the container to the scene
  58898. * @param container the container holding the elements
  58899. */
  58900. addFromContainer(container: AbstractScene): void;
  58901. /**
  58902. * Removes all the elements in the container from the scene
  58903. * @param container contains the elements to remove
  58904. * @param dispose if the removed element should be disposed (default: false)
  58905. */
  58906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58907. /**
  58908. * Disposes the component and the associated ressources.
  58909. */
  58910. dispose(): void;
  58911. private _isReadyForMesh;
  58912. private _renderMainTexture;
  58913. private _setStencil;
  58914. private _setStencilBack;
  58915. private _draw;
  58916. private _drawCamera;
  58917. private _drawRenderingGroup;
  58918. }
  58919. }
  58920. declare module BABYLON {
  58921. /** @hidden */
  58922. export var glowMapMergePixelShader: {
  58923. name: string;
  58924. shader: string;
  58925. };
  58926. }
  58927. declare module BABYLON {
  58928. /** @hidden */
  58929. export var glowMapMergeVertexShader: {
  58930. name: string;
  58931. shader: string;
  58932. };
  58933. }
  58934. declare module BABYLON {
  58935. interface AbstractScene {
  58936. /**
  58937. * Return a the first highlight layer of the scene with a given name.
  58938. * @param name The name of the highlight layer to look for.
  58939. * @return The highlight layer if found otherwise null.
  58940. */
  58941. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58942. }
  58943. /**
  58944. * Glow layer options. This helps customizing the behaviour
  58945. * of the glow layer.
  58946. */
  58947. export interface IGlowLayerOptions {
  58948. /**
  58949. * Multiplication factor apply to the canvas size to compute the render target size
  58950. * used to generated the glowing objects (the smaller the faster).
  58951. */
  58952. mainTextureRatio: number;
  58953. /**
  58954. * Enforces a fixed size texture to ensure resize independant blur.
  58955. */
  58956. mainTextureFixedSize?: number;
  58957. /**
  58958. * How big is the kernel of the blur texture.
  58959. */
  58960. blurKernelSize: number;
  58961. /**
  58962. * The camera attached to the layer.
  58963. */
  58964. camera: Nullable<Camera>;
  58965. /**
  58966. * Enable MSAA by chosing the number of samples.
  58967. */
  58968. mainTextureSamples?: number;
  58969. /**
  58970. * The rendering group to draw the layer in.
  58971. */
  58972. renderingGroupId: number;
  58973. }
  58974. /**
  58975. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58976. *
  58977. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58978. *
  58979. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58980. */
  58981. export class GlowLayer extends EffectLayer {
  58982. /**
  58983. * Effect Name of the layer.
  58984. */
  58985. static readonly EffectName: string;
  58986. /**
  58987. * The default blur kernel size used for the glow.
  58988. */
  58989. static DefaultBlurKernelSize: number;
  58990. /**
  58991. * The default texture size ratio used for the glow.
  58992. */
  58993. static DefaultTextureRatio: number;
  58994. /**
  58995. * Sets the kernel size of the blur.
  58996. */
  58997. set blurKernelSize(value: number);
  58998. /**
  58999. * Gets the kernel size of the blur.
  59000. */
  59001. get blurKernelSize(): number;
  59002. /**
  59003. * Sets the glow intensity.
  59004. */
  59005. set intensity(value: number);
  59006. /**
  59007. * Gets the glow intensity.
  59008. */
  59009. get intensity(): number;
  59010. private _options;
  59011. private _intensity;
  59012. private _horizontalBlurPostprocess1;
  59013. private _verticalBlurPostprocess1;
  59014. private _horizontalBlurPostprocess2;
  59015. private _verticalBlurPostprocess2;
  59016. private _blurTexture1;
  59017. private _blurTexture2;
  59018. private _postProcesses1;
  59019. private _postProcesses2;
  59020. private _includedOnlyMeshes;
  59021. private _excludedMeshes;
  59022. private _meshesUsingTheirOwnMaterials;
  59023. /**
  59024. * Callback used to let the user override the color selection on a per mesh basis
  59025. */
  59026. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59027. /**
  59028. * Callback used to let the user override the texture selection on a per mesh basis
  59029. */
  59030. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59031. /**
  59032. * Instantiates a new glow Layer and references it to the scene.
  59033. * @param name The name of the layer
  59034. * @param scene The scene to use the layer in
  59035. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59036. */
  59037. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59038. /**
  59039. * Get the effect name of the layer.
  59040. * @return The effect name
  59041. */
  59042. getEffectName(): string;
  59043. /**
  59044. * Create the merge effect. This is the shader use to blit the information back
  59045. * to the main canvas at the end of the scene rendering.
  59046. */
  59047. protected _createMergeEffect(): Effect;
  59048. /**
  59049. * Creates the render target textures and post processes used in the glow layer.
  59050. */
  59051. protected _createTextureAndPostProcesses(): void;
  59052. /**
  59053. * Checks for the readiness of the element composing the layer.
  59054. * @param subMesh the mesh to check for
  59055. * @param useInstances specify wether or not to use instances to render the mesh
  59056. * @param emissiveTexture the associated emissive texture used to generate the glow
  59057. * @return true if ready otherwise, false
  59058. */
  59059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59060. /**
  59061. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59062. */
  59063. needStencil(): boolean;
  59064. /**
  59065. * Returns true if the mesh can be rendered, otherwise false.
  59066. * @param mesh The mesh to render
  59067. * @param material The material used on the mesh
  59068. * @returns true if it can be rendered otherwise false
  59069. */
  59070. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59071. /**
  59072. * Implementation specific of rendering the generating effect on the main canvas.
  59073. * @param effect The effect used to render through
  59074. */
  59075. protected _internalRender(effect: Effect): void;
  59076. /**
  59077. * Sets the required values for both the emissive texture and and the main color.
  59078. */
  59079. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59080. /**
  59081. * Returns true if the mesh should render, otherwise false.
  59082. * @param mesh The mesh to render
  59083. * @returns true if it should render otherwise false
  59084. */
  59085. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59086. /**
  59087. * Adds specific effects defines.
  59088. * @param defines The defines to add specifics to.
  59089. */
  59090. protected _addCustomEffectDefines(defines: string[]): void;
  59091. /**
  59092. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59093. * @param mesh The mesh to exclude from the glow layer
  59094. */
  59095. addExcludedMesh(mesh: Mesh): void;
  59096. /**
  59097. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59098. * @param mesh The mesh to remove
  59099. */
  59100. removeExcludedMesh(mesh: Mesh): void;
  59101. /**
  59102. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59103. * @param mesh The mesh to include in the glow layer
  59104. */
  59105. addIncludedOnlyMesh(mesh: Mesh): void;
  59106. /**
  59107. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59108. * @param mesh The mesh to remove
  59109. */
  59110. removeIncludedOnlyMesh(mesh: Mesh): void;
  59111. /**
  59112. * Determine if a given mesh will be used in the glow layer
  59113. * @param mesh The mesh to test
  59114. * @returns true if the mesh will be highlighted by the current glow layer
  59115. */
  59116. hasMesh(mesh: AbstractMesh): boolean;
  59117. /**
  59118. * Defines whether the current material of the mesh should be use to render the effect.
  59119. * @param mesh defines the current mesh to render
  59120. */
  59121. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59122. /**
  59123. * Add a mesh to be rendered through its own material and not with emissive only.
  59124. * @param mesh The mesh for which we need to use its material
  59125. */
  59126. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59127. /**
  59128. * Remove a mesh from being rendered through its own material and not with emissive only.
  59129. * @param mesh The mesh for which we need to not use its material
  59130. */
  59131. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59132. /**
  59133. * Free any resources and references associated to a mesh.
  59134. * Internal use
  59135. * @param mesh The mesh to free.
  59136. * @hidden
  59137. */
  59138. _disposeMesh(mesh: Mesh): void;
  59139. /**
  59140. * Gets the class name of the effect layer
  59141. * @returns the string with the class name of the effect layer
  59142. */
  59143. getClassName(): string;
  59144. /**
  59145. * Serializes this glow layer
  59146. * @returns a serialized glow layer object
  59147. */
  59148. serialize(): any;
  59149. /**
  59150. * Creates a Glow Layer from parsed glow layer data
  59151. * @param parsedGlowLayer defines glow layer data
  59152. * @param scene defines the current scene
  59153. * @param rootUrl defines the root URL containing the glow layer information
  59154. * @returns a parsed Glow Layer
  59155. */
  59156. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59157. }
  59158. }
  59159. declare module BABYLON {
  59160. /** @hidden */
  59161. export var glowBlurPostProcessPixelShader: {
  59162. name: string;
  59163. shader: string;
  59164. };
  59165. }
  59166. declare module BABYLON {
  59167. interface AbstractScene {
  59168. /**
  59169. * Return a the first highlight layer of the scene with a given name.
  59170. * @param name The name of the highlight layer to look for.
  59171. * @return The highlight layer if found otherwise null.
  59172. */
  59173. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59174. }
  59175. /**
  59176. * Highlight layer options. This helps customizing the behaviour
  59177. * of the highlight layer.
  59178. */
  59179. export interface IHighlightLayerOptions {
  59180. /**
  59181. * Multiplication factor apply to the canvas size to compute the render target size
  59182. * used to generated the glowing objects (the smaller the faster).
  59183. */
  59184. mainTextureRatio: number;
  59185. /**
  59186. * Enforces a fixed size texture to ensure resize independant blur.
  59187. */
  59188. mainTextureFixedSize?: number;
  59189. /**
  59190. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59191. * of the picture to blur (the smaller the faster).
  59192. */
  59193. blurTextureSizeRatio: number;
  59194. /**
  59195. * How big in texel of the blur texture is the vertical blur.
  59196. */
  59197. blurVerticalSize: number;
  59198. /**
  59199. * How big in texel of the blur texture is the horizontal blur.
  59200. */
  59201. blurHorizontalSize: number;
  59202. /**
  59203. * Alpha blending mode used to apply the blur. Default is combine.
  59204. */
  59205. alphaBlendingMode: number;
  59206. /**
  59207. * The camera attached to the layer.
  59208. */
  59209. camera: Nullable<Camera>;
  59210. /**
  59211. * Should we display highlight as a solid stroke?
  59212. */
  59213. isStroke?: boolean;
  59214. /**
  59215. * The rendering group to draw the layer in.
  59216. */
  59217. renderingGroupId: number;
  59218. }
  59219. /**
  59220. * The highlight layer Helps adding a glow effect around a mesh.
  59221. *
  59222. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59223. * glowy meshes to your scene.
  59224. *
  59225. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59226. */
  59227. export class HighlightLayer extends EffectLayer {
  59228. name: string;
  59229. /**
  59230. * Effect Name of the highlight layer.
  59231. */
  59232. static readonly EffectName: string;
  59233. /**
  59234. * The neutral color used during the preparation of the glow effect.
  59235. * This is black by default as the blend operation is a blend operation.
  59236. */
  59237. static NeutralColor: Color4;
  59238. /**
  59239. * Stencil value used for glowing meshes.
  59240. */
  59241. static GlowingMeshStencilReference: number;
  59242. /**
  59243. * Stencil value used for the other meshes in the scene.
  59244. */
  59245. static NormalMeshStencilReference: number;
  59246. /**
  59247. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59248. */
  59249. innerGlow: boolean;
  59250. /**
  59251. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59252. */
  59253. outerGlow: boolean;
  59254. /**
  59255. * Specifies the horizontal size of the blur.
  59256. */
  59257. set blurHorizontalSize(value: number);
  59258. /**
  59259. * Specifies the vertical size of the blur.
  59260. */
  59261. set blurVerticalSize(value: number);
  59262. /**
  59263. * Gets the horizontal size of the blur.
  59264. */
  59265. get blurHorizontalSize(): number;
  59266. /**
  59267. * Gets the vertical size of the blur.
  59268. */
  59269. get blurVerticalSize(): number;
  59270. /**
  59271. * An event triggered when the highlight layer is being blurred.
  59272. */
  59273. onBeforeBlurObservable: Observable<HighlightLayer>;
  59274. /**
  59275. * An event triggered when the highlight layer has been blurred.
  59276. */
  59277. onAfterBlurObservable: Observable<HighlightLayer>;
  59278. private _instanceGlowingMeshStencilReference;
  59279. private _options;
  59280. private _downSamplePostprocess;
  59281. private _horizontalBlurPostprocess;
  59282. private _verticalBlurPostprocess;
  59283. private _blurTexture;
  59284. private _meshes;
  59285. private _excludedMeshes;
  59286. /**
  59287. * Instantiates a new highlight Layer and references it to the scene..
  59288. * @param name The name of the layer
  59289. * @param scene The scene to use the layer in
  59290. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59291. */
  59292. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59293. /**
  59294. * Get the effect name of the layer.
  59295. * @return The effect name
  59296. */
  59297. getEffectName(): string;
  59298. /**
  59299. * Create the merge effect. This is the shader use to blit the information back
  59300. * to the main canvas at the end of the scene rendering.
  59301. */
  59302. protected _createMergeEffect(): Effect;
  59303. /**
  59304. * Creates the render target textures and post processes used in the highlight layer.
  59305. */
  59306. protected _createTextureAndPostProcesses(): void;
  59307. /**
  59308. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59309. */
  59310. needStencil(): boolean;
  59311. /**
  59312. * Checks for the readiness of the element composing the layer.
  59313. * @param subMesh the mesh to check for
  59314. * @param useInstances specify wether or not to use instances to render the mesh
  59315. * @param emissiveTexture the associated emissive texture used to generate the glow
  59316. * @return true if ready otherwise, false
  59317. */
  59318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59319. /**
  59320. * Implementation specific of rendering the generating effect on the main canvas.
  59321. * @param effect The effect used to render through
  59322. */
  59323. protected _internalRender(effect: Effect): void;
  59324. /**
  59325. * Returns true if the layer contains information to display, otherwise false.
  59326. */
  59327. shouldRender(): boolean;
  59328. /**
  59329. * Returns true if the mesh should render, otherwise false.
  59330. * @param mesh The mesh to render
  59331. * @returns true if it should render otherwise false
  59332. */
  59333. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59334. /**
  59335. * Returns true if the mesh can be rendered, otherwise false.
  59336. * @param mesh The mesh to render
  59337. * @param material The material used on the mesh
  59338. * @returns true if it can be rendered otherwise false
  59339. */
  59340. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59341. /**
  59342. * Adds specific effects defines.
  59343. * @param defines The defines to add specifics to.
  59344. */
  59345. protected _addCustomEffectDefines(defines: string[]): void;
  59346. /**
  59347. * Sets the required values for both the emissive texture and and the main color.
  59348. */
  59349. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59350. /**
  59351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59352. * @param mesh The mesh to exclude from the highlight layer
  59353. */
  59354. addExcludedMesh(mesh: Mesh): void;
  59355. /**
  59356. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59357. * @param mesh The mesh to highlight
  59358. */
  59359. removeExcludedMesh(mesh: Mesh): void;
  59360. /**
  59361. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59362. * @param mesh mesh to test
  59363. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59364. */
  59365. hasMesh(mesh: AbstractMesh): boolean;
  59366. /**
  59367. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59368. * @param mesh The mesh to highlight
  59369. * @param color The color of the highlight
  59370. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59371. */
  59372. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59373. /**
  59374. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59375. * @param mesh The mesh to highlight
  59376. */
  59377. removeMesh(mesh: Mesh): void;
  59378. /**
  59379. * Remove all the meshes currently referenced in the highlight layer
  59380. */
  59381. removeAllMeshes(): void;
  59382. /**
  59383. * Force the stencil to the normal expected value for none glowing parts
  59384. */
  59385. private _defaultStencilReference;
  59386. /**
  59387. * Free any resources and references associated to a mesh.
  59388. * Internal use
  59389. * @param mesh The mesh to free.
  59390. * @hidden
  59391. */
  59392. _disposeMesh(mesh: Mesh): void;
  59393. /**
  59394. * Dispose the highlight layer and free resources.
  59395. */
  59396. dispose(): void;
  59397. /**
  59398. * Gets the class name of the effect layer
  59399. * @returns the string with the class name of the effect layer
  59400. */
  59401. getClassName(): string;
  59402. /**
  59403. * Serializes this Highlight layer
  59404. * @returns a serialized Highlight layer object
  59405. */
  59406. serialize(): any;
  59407. /**
  59408. * Creates a Highlight layer from parsed Highlight layer data
  59409. * @param parsedHightlightLayer defines the Highlight layer data
  59410. * @param scene defines the current scene
  59411. * @param rootUrl defines the root URL containing the Highlight layer information
  59412. * @returns a parsed Highlight layer
  59413. */
  59414. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59415. }
  59416. }
  59417. declare module BABYLON {
  59418. interface AbstractScene {
  59419. /**
  59420. * The list of layers (background and foreground) of the scene
  59421. */
  59422. layers: Array<Layer>;
  59423. }
  59424. /**
  59425. * Defines the layer scene component responsible to manage any layers
  59426. * in a given scene.
  59427. */
  59428. export class LayerSceneComponent implements ISceneComponent {
  59429. /**
  59430. * The component name helpfull to identify the component in the list of scene components.
  59431. */
  59432. readonly name: string;
  59433. /**
  59434. * The scene the component belongs to.
  59435. */
  59436. scene: Scene;
  59437. private _engine;
  59438. /**
  59439. * Creates a new instance of the component for the given scene
  59440. * @param scene Defines the scene to register the component in
  59441. */
  59442. constructor(scene: Scene);
  59443. /**
  59444. * Registers the component in a given scene
  59445. */
  59446. register(): void;
  59447. /**
  59448. * Rebuilds the elements related to this component in case of
  59449. * context lost for instance.
  59450. */
  59451. rebuild(): void;
  59452. /**
  59453. * Disposes the component and the associated ressources.
  59454. */
  59455. dispose(): void;
  59456. private _draw;
  59457. private _drawCameraPredicate;
  59458. private _drawCameraBackground;
  59459. private _drawCameraForeground;
  59460. private _drawRenderTargetPredicate;
  59461. private _drawRenderTargetBackground;
  59462. private _drawRenderTargetForeground;
  59463. /**
  59464. * Adds all the elements from the container to the scene
  59465. * @param container the container holding the elements
  59466. */
  59467. addFromContainer(container: AbstractScene): void;
  59468. /**
  59469. * Removes all the elements in the container from the scene
  59470. * @param container contains the elements to remove
  59471. * @param dispose if the removed element should be disposed (default: false)
  59472. */
  59473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59474. }
  59475. }
  59476. declare module BABYLON {
  59477. /** @hidden */
  59478. export var layerPixelShader: {
  59479. name: string;
  59480. shader: string;
  59481. };
  59482. }
  59483. declare module BABYLON {
  59484. /** @hidden */
  59485. export var layerVertexShader: {
  59486. name: string;
  59487. shader: string;
  59488. };
  59489. }
  59490. declare module BABYLON {
  59491. /**
  59492. * This represents a full screen 2d layer.
  59493. * This can be useful to display a picture in the background of your scene for instance.
  59494. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59495. */
  59496. export class Layer {
  59497. /**
  59498. * Define the name of the layer.
  59499. */
  59500. name: string;
  59501. /**
  59502. * Define the texture the layer should display.
  59503. */
  59504. texture: Nullable<Texture>;
  59505. /**
  59506. * Is the layer in background or foreground.
  59507. */
  59508. isBackground: boolean;
  59509. /**
  59510. * Define the color of the layer (instead of texture).
  59511. */
  59512. color: Color4;
  59513. /**
  59514. * Define the scale of the layer in order to zoom in out of the texture.
  59515. */
  59516. scale: Vector2;
  59517. /**
  59518. * Define an offset for the layer in order to shift the texture.
  59519. */
  59520. offset: Vector2;
  59521. /**
  59522. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59523. */
  59524. alphaBlendingMode: number;
  59525. /**
  59526. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59527. * Alpha test will not mix with the background color in case of transparency.
  59528. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59529. */
  59530. alphaTest: boolean;
  59531. /**
  59532. * Define a mask to restrict the layer to only some of the scene cameras.
  59533. */
  59534. layerMask: number;
  59535. /**
  59536. * Define the list of render target the layer is visible into.
  59537. */
  59538. renderTargetTextures: RenderTargetTexture[];
  59539. /**
  59540. * Define if the layer is only used in renderTarget or if it also
  59541. * renders in the main frame buffer of the canvas.
  59542. */
  59543. renderOnlyInRenderTargetTextures: boolean;
  59544. private _scene;
  59545. private _vertexBuffers;
  59546. private _indexBuffer;
  59547. private _effect;
  59548. private _previousDefines;
  59549. /**
  59550. * An event triggered when the layer is disposed.
  59551. */
  59552. onDisposeObservable: Observable<Layer>;
  59553. private _onDisposeObserver;
  59554. /**
  59555. * Back compatibility with callback before the onDisposeObservable existed.
  59556. * The set callback will be triggered when the layer has been disposed.
  59557. */
  59558. set onDispose(callback: () => void);
  59559. /**
  59560. * An event triggered before rendering the scene
  59561. */
  59562. onBeforeRenderObservable: Observable<Layer>;
  59563. private _onBeforeRenderObserver;
  59564. /**
  59565. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59566. * The set callback will be triggered just before rendering the layer.
  59567. */
  59568. set onBeforeRender(callback: () => void);
  59569. /**
  59570. * An event triggered after rendering the scene
  59571. */
  59572. onAfterRenderObservable: Observable<Layer>;
  59573. private _onAfterRenderObserver;
  59574. /**
  59575. * Back compatibility with callback before the onAfterRenderObservable existed.
  59576. * The set callback will be triggered just after rendering the layer.
  59577. */
  59578. set onAfterRender(callback: () => void);
  59579. /**
  59580. * Instantiates a new layer.
  59581. * This represents a full screen 2d layer.
  59582. * This can be useful to display a picture in the background of your scene for instance.
  59583. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59584. * @param name Define the name of the layer in the scene
  59585. * @param imgUrl Define the url of the texture to display in the layer
  59586. * @param scene Define the scene the layer belongs to
  59587. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59588. * @param color Defines a color for the layer
  59589. */
  59590. constructor(
  59591. /**
  59592. * Define the name of the layer.
  59593. */
  59594. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59595. private _createIndexBuffer;
  59596. /** @hidden */
  59597. _rebuild(): void;
  59598. /**
  59599. * Renders the layer in the scene.
  59600. */
  59601. render(): void;
  59602. /**
  59603. * Disposes and releases the associated ressources.
  59604. */
  59605. dispose(): void;
  59606. }
  59607. }
  59608. declare module BABYLON {
  59609. /** @hidden */
  59610. export var lensFlarePixelShader: {
  59611. name: string;
  59612. shader: string;
  59613. };
  59614. }
  59615. declare module BABYLON {
  59616. /** @hidden */
  59617. export var lensFlareVertexShader: {
  59618. name: string;
  59619. shader: string;
  59620. };
  59621. }
  59622. declare module BABYLON {
  59623. /**
  59624. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59625. * It is usually composed of several `lensFlare`.
  59626. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59627. */
  59628. export class LensFlareSystem {
  59629. /**
  59630. * Define the name of the lens flare system
  59631. */
  59632. name: string;
  59633. /**
  59634. * List of lens flares used in this system.
  59635. */
  59636. lensFlares: LensFlare[];
  59637. /**
  59638. * Define a limit from the border the lens flare can be visible.
  59639. */
  59640. borderLimit: number;
  59641. /**
  59642. * Define a viewport border we do not want to see the lens flare in.
  59643. */
  59644. viewportBorder: number;
  59645. /**
  59646. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59647. */
  59648. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59649. /**
  59650. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59651. */
  59652. layerMask: number;
  59653. /**
  59654. * Define the id of the lens flare system in the scene.
  59655. * (equal to name by default)
  59656. */
  59657. id: string;
  59658. private _scene;
  59659. private _emitter;
  59660. private _vertexBuffers;
  59661. private _indexBuffer;
  59662. private _effect;
  59663. private _positionX;
  59664. private _positionY;
  59665. private _isEnabled;
  59666. /** @hidden */
  59667. static _SceneComponentInitialization: (scene: Scene) => void;
  59668. /**
  59669. * Instantiates a lens flare system.
  59670. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59671. * It is usually composed of several `lensFlare`.
  59672. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59673. * @param name Define the name of the lens flare system in the scene
  59674. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59675. * @param scene Define the scene the lens flare system belongs to
  59676. */
  59677. constructor(
  59678. /**
  59679. * Define the name of the lens flare system
  59680. */
  59681. name: string, emitter: any, scene: Scene);
  59682. /**
  59683. * Define if the lens flare system is enabled.
  59684. */
  59685. get isEnabled(): boolean;
  59686. set isEnabled(value: boolean);
  59687. /**
  59688. * Get the scene the effects belongs to.
  59689. * @returns the scene holding the lens flare system
  59690. */
  59691. getScene(): Scene;
  59692. /**
  59693. * Get the emitter of the lens flare system.
  59694. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59695. * @returns the emitter of the lens flare system
  59696. */
  59697. getEmitter(): any;
  59698. /**
  59699. * Set the emitter of the lens flare system.
  59700. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59701. * @param newEmitter Define the new emitter of the system
  59702. */
  59703. setEmitter(newEmitter: any): void;
  59704. /**
  59705. * Get the lens flare system emitter position.
  59706. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59707. * @returns the position
  59708. */
  59709. getEmitterPosition(): Vector3;
  59710. /**
  59711. * @hidden
  59712. */
  59713. computeEffectivePosition(globalViewport: Viewport): boolean;
  59714. /** @hidden */
  59715. _isVisible(): boolean;
  59716. /**
  59717. * @hidden
  59718. */
  59719. render(): boolean;
  59720. /**
  59721. * Dispose and release the lens flare with its associated resources.
  59722. */
  59723. dispose(): void;
  59724. /**
  59725. * Parse a lens flare system from a JSON repressentation
  59726. * @param parsedLensFlareSystem Define the JSON to parse
  59727. * @param scene Define the scene the parsed system should be instantiated in
  59728. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59729. * @returns the parsed system
  59730. */
  59731. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59732. /**
  59733. * Serialize the current Lens Flare System into a JSON representation.
  59734. * @returns the serialized JSON
  59735. */
  59736. serialize(): any;
  59737. }
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * This represents one of the lens effect in a `lensFlareSystem`.
  59742. * It controls one of the indiviual texture used in the effect.
  59743. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59744. */
  59745. export class LensFlare {
  59746. /**
  59747. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59748. */
  59749. size: number;
  59750. /**
  59751. * 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.
  59752. */
  59753. position: number;
  59754. /**
  59755. * Define the lens color.
  59756. */
  59757. color: Color3;
  59758. /**
  59759. * Define the lens texture.
  59760. */
  59761. texture: Nullable<Texture>;
  59762. /**
  59763. * Define the alpha mode to render this particular lens.
  59764. */
  59765. alphaMode: number;
  59766. private _system;
  59767. /**
  59768. * Creates a new Lens Flare.
  59769. * This represents one of the lens effect in a `lensFlareSystem`.
  59770. * It controls one of the indiviual texture used in the effect.
  59771. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59772. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59773. * @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.
  59774. * @param color Define the lens color
  59775. * @param imgUrl Define the lens texture url
  59776. * @param system Define the `lensFlareSystem` this flare is part of
  59777. * @returns The newly created Lens Flare
  59778. */
  59779. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59780. /**
  59781. * Instantiates a new Lens Flare.
  59782. * This represents one of the lens effect in a `lensFlareSystem`.
  59783. * It controls one of the indiviual texture used in the effect.
  59784. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59785. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59786. * @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.
  59787. * @param color Define the lens color
  59788. * @param imgUrl Define the lens texture url
  59789. * @param system Define the `lensFlareSystem` this flare is part of
  59790. */
  59791. constructor(
  59792. /**
  59793. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59794. */
  59795. size: number,
  59796. /**
  59797. * 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.
  59798. */
  59799. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59800. /**
  59801. * Dispose and release the lens flare with its associated resources.
  59802. */
  59803. dispose(): void;
  59804. }
  59805. }
  59806. declare module BABYLON {
  59807. interface AbstractScene {
  59808. /**
  59809. * The list of lens flare system added to the scene
  59810. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59811. */
  59812. lensFlareSystems: Array<LensFlareSystem>;
  59813. /**
  59814. * Removes the given lens flare system from this scene.
  59815. * @param toRemove The lens flare system to remove
  59816. * @returns The index of the removed lens flare system
  59817. */
  59818. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59819. /**
  59820. * Adds the given lens flare system to this scene
  59821. * @param newLensFlareSystem The lens flare system to add
  59822. */
  59823. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59824. /**
  59825. * Gets a lens flare system using its name
  59826. * @param name defines the name to look for
  59827. * @returns the lens flare system or null if not found
  59828. */
  59829. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59830. /**
  59831. * Gets a lens flare system using its id
  59832. * @param id defines the id to look for
  59833. * @returns the lens flare system or null if not found
  59834. */
  59835. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59836. }
  59837. /**
  59838. * Defines the lens flare scene component responsible to manage any lens flares
  59839. * in a given scene.
  59840. */
  59841. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59842. /**
  59843. * The component name helpfull to identify the component in the list of scene components.
  59844. */
  59845. readonly name: string;
  59846. /**
  59847. * The scene the component belongs to.
  59848. */
  59849. scene: Scene;
  59850. /**
  59851. * Creates a new instance of the component for the given scene
  59852. * @param scene Defines the scene to register the component in
  59853. */
  59854. constructor(scene: Scene);
  59855. /**
  59856. * Registers the component in a given scene
  59857. */
  59858. register(): void;
  59859. /**
  59860. * Rebuilds the elements related to this component in case of
  59861. * context lost for instance.
  59862. */
  59863. rebuild(): void;
  59864. /**
  59865. * Adds all the elements from the container to the scene
  59866. * @param container the container holding the elements
  59867. */
  59868. addFromContainer(container: AbstractScene): void;
  59869. /**
  59870. * Removes all the elements in the container from the scene
  59871. * @param container contains the elements to remove
  59872. * @param dispose if the removed element should be disposed (default: false)
  59873. */
  59874. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59875. /**
  59876. * Serializes the component data to the specified json object
  59877. * @param serializationObject The object to serialize to
  59878. */
  59879. serialize(serializationObject: any): void;
  59880. /**
  59881. * Disposes the component and the associated ressources.
  59882. */
  59883. dispose(): void;
  59884. private _draw;
  59885. }
  59886. }
  59887. declare module BABYLON {
  59888. /** @hidden */
  59889. export var depthPixelShader: {
  59890. name: string;
  59891. shader: string;
  59892. };
  59893. }
  59894. declare module BABYLON {
  59895. /** @hidden */
  59896. export var depthVertexShader: {
  59897. name: string;
  59898. shader: string;
  59899. };
  59900. }
  59901. declare module BABYLON {
  59902. /**
  59903. * This represents a depth renderer in Babylon.
  59904. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59905. */
  59906. export class DepthRenderer {
  59907. private _scene;
  59908. private _depthMap;
  59909. private _effect;
  59910. private readonly _storeNonLinearDepth;
  59911. private readonly _clearColor;
  59912. /** Get if the depth renderer is using packed depth or not */
  59913. readonly isPacked: boolean;
  59914. private _cachedDefines;
  59915. private _camera;
  59916. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59917. enabled: boolean;
  59918. /**
  59919. * Specifiess that the depth renderer will only be used within
  59920. * the camera it is created for.
  59921. * This can help forcing its rendering during the camera processing.
  59922. */
  59923. useOnlyInActiveCamera: boolean;
  59924. /** @hidden */
  59925. static _SceneComponentInitialization: (scene: Scene) => void;
  59926. /**
  59927. * Instantiates a depth renderer
  59928. * @param scene The scene the renderer belongs to
  59929. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59930. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59931. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59932. */
  59933. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59934. /**
  59935. * Creates the depth rendering effect and checks if the effect is ready.
  59936. * @param subMesh The submesh to be used to render the depth map of
  59937. * @param useInstances If multiple world instances should be used
  59938. * @returns if the depth renderer is ready to render the depth map
  59939. */
  59940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59941. /**
  59942. * Gets the texture which the depth map will be written to.
  59943. * @returns The depth map texture
  59944. */
  59945. getDepthMap(): RenderTargetTexture;
  59946. /**
  59947. * Disposes of the depth renderer.
  59948. */
  59949. dispose(): void;
  59950. }
  59951. }
  59952. declare module BABYLON {
  59953. /** @hidden */
  59954. export var minmaxReduxPixelShader: {
  59955. name: string;
  59956. shader: string;
  59957. };
  59958. }
  59959. declare module BABYLON {
  59960. /**
  59961. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59962. * and maximum values from all values of the texture.
  59963. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59964. * The source values are read from the red channel of the texture.
  59965. */
  59966. export class MinMaxReducer {
  59967. /**
  59968. * Observable triggered when the computation has been performed
  59969. */
  59970. onAfterReductionPerformed: Observable<{
  59971. min: number;
  59972. max: number;
  59973. }>;
  59974. protected _camera: Camera;
  59975. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59976. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59977. protected _postProcessManager: PostProcessManager;
  59978. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59979. protected _forceFullscreenViewport: boolean;
  59980. /**
  59981. * Creates a min/max reducer
  59982. * @param camera The camera to use for the post processes
  59983. */
  59984. constructor(camera: Camera);
  59985. /**
  59986. * Gets the texture used to read the values from.
  59987. */
  59988. get sourceTexture(): Nullable<RenderTargetTexture>;
  59989. /**
  59990. * Sets the source texture to read the values from.
  59991. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59992. * because in such textures '1' value must not be taken into account to compute the maximum
  59993. * as this value is used to clear the texture.
  59994. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59995. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59996. * @param depthRedux Indicates if the texture is a depth texture or not
  59997. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59998. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59999. */
  60000. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60001. /**
  60002. * Defines the refresh rate of the computation.
  60003. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60004. */
  60005. get refreshRate(): number;
  60006. set refreshRate(value: number);
  60007. protected _activated: boolean;
  60008. /**
  60009. * Gets the activation status of the reducer
  60010. */
  60011. get activated(): boolean;
  60012. /**
  60013. * Activates the reduction computation.
  60014. * When activated, the observers registered in onAfterReductionPerformed are
  60015. * called after the compuation is performed
  60016. */
  60017. activate(): void;
  60018. /**
  60019. * Deactivates the reduction computation.
  60020. */
  60021. deactivate(): void;
  60022. /**
  60023. * Disposes the min/max reducer
  60024. * @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.
  60025. */
  60026. dispose(disposeAll?: boolean): void;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60032. */
  60033. export class DepthReducer extends MinMaxReducer {
  60034. private _depthRenderer;
  60035. private _depthRendererId;
  60036. /**
  60037. * Gets the depth renderer used for the computation.
  60038. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60039. */
  60040. get depthRenderer(): Nullable<DepthRenderer>;
  60041. /**
  60042. * Creates a depth reducer
  60043. * @param camera The camera used to render the depth texture
  60044. */
  60045. constructor(camera: Camera);
  60046. /**
  60047. * Sets the depth renderer to use to generate the depth map
  60048. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60049. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60050. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60051. */
  60052. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60053. /** @hidden */
  60054. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60055. /**
  60056. * Activates the reduction computation.
  60057. * When activated, the observers registered in onAfterReductionPerformed are
  60058. * called after the compuation is performed
  60059. */
  60060. activate(): void;
  60061. /**
  60062. * Deactivates the reduction computation.
  60063. */
  60064. deactivate(): void;
  60065. /**
  60066. * Disposes the depth reducer
  60067. * @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.
  60068. */
  60069. dispose(disposeAll?: boolean): void;
  60070. }
  60071. }
  60072. declare module BABYLON {
  60073. /**
  60074. * A CSM implementation allowing casting shadows on large scenes.
  60075. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60076. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60077. */
  60078. export class CascadedShadowGenerator extends ShadowGenerator {
  60079. private static readonly frustumCornersNDCSpace;
  60080. /**
  60081. * Name of the CSM class
  60082. */
  60083. static CLASSNAME: string;
  60084. /**
  60085. * Defines the default number of cascades used by the CSM.
  60086. */
  60087. static readonly DEFAULT_CASCADES_COUNT: number;
  60088. /**
  60089. * Defines the minimum number of cascades used by the CSM.
  60090. */
  60091. static readonly MIN_CASCADES_COUNT: number;
  60092. /**
  60093. * Defines the maximum number of cascades used by the CSM.
  60094. */
  60095. static readonly MAX_CASCADES_COUNT: number;
  60096. protected _validateFilter(filter: number): number;
  60097. /**
  60098. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60099. */
  60100. penumbraDarkness: number;
  60101. private _numCascades;
  60102. /**
  60103. * Gets or set the number of cascades used by the CSM.
  60104. */
  60105. get numCascades(): number;
  60106. set numCascades(value: number);
  60107. /**
  60108. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60109. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60110. */
  60111. stabilizeCascades: boolean;
  60112. private _freezeShadowCastersBoundingInfo;
  60113. private _freezeShadowCastersBoundingInfoObservable;
  60114. /**
  60115. * Enables or disables the shadow casters bounding info computation.
  60116. * If your shadow casters don't move, you can disable this feature.
  60117. * If it is enabled, the bounding box computation is done every frame.
  60118. */
  60119. get freezeShadowCastersBoundingInfo(): boolean;
  60120. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60121. private _scbiMin;
  60122. private _scbiMax;
  60123. protected _computeShadowCastersBoundingInfo(): void;
  60124. protected _shadowCastersBoundingInfo: BoundingInfo;
  60125. /**
  60126. * Gets or sets the shadow casters bounding info.
  60127. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60128. * so that the system won't overwrite the bounds you provide
  60129. */
  60130. get shadowCastersBoundingInfo(): BoundingInfo;
  60131. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60132. protected _breaksAreDirty: boolean;
  60133. protected _minDistance: number;
  60134. protected _maxDistance: number;
  60135. /**
  60136. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60137. *
  60138. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60139. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60140. * @param min minimal distance for the breaks (default to 0.)
  60141. * @param max maximal distance for the breaks (default to 1.)
  60142. */
  60143. setMinMaxDistance(min: number, max: number): void;
  60144. /** Gets the minimal distance used in the cascade break computation */
  60145. get minDistance(): number;
  60146. /** Gets the maximal distance used in the cascade break computation */
  60147. get maxDistance(): number;
  60148. /**
  60149. * Gets the class name of that object
  60150. * @returns "CascadedShadowGenerator"
  60151. */
  60152. getClassName(): string;
  60153. private _cascadeMinExtents;
  60154. private _cascadeMaxExtents;
  60155. /**
  60156. * Gets a cascade minimum extents
  60157. * @param cascadeIndex index of the cascade
  60158. * @returns the minimum cascade extents
  60159. */
  60160. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60161. /**
  60162. * Gets a cascade maximum extents
  60163. * @param cascadeIndex index of the cascade
  60164. * @returns the maximum cascade extents
  60165. */
  60166. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60167. private _cascades;
  60168. private _currentLayer;
  60169. private _viewSpaceFrustumsZ;
  60170. private _viewMatrices;
  60171. private _projectionMatrices;
  60172. private _transformMatrices;
  60173. private _transformMatricesAsArray;
  60174. private _frustumLengths;
  60175. private _lightSizeUVCorrection;
  60176. private _depthCorrection;
  60177. private _frustumCornersWorldSpace;
  60178. private _frustumCenter;
  60179. private _shadowCameraPos;
  60180. private _shadowMaxZ;
  60181. /**
  60182. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60183. * It defaults to camera.maxZ
  60184. */
  60185. get shadowMaxZ(): number;
  60186. /**
  60187. * Sets the shadow max z distance.
  60188. */
  60189. set shadowMaxZ(value: number);
  60190. protected _debug: boolean;
  60191. /**
  60192. * Gets or sets the debug flag.
  60193. * When enabled, the cascades are materialized by different colors on the screen.
  60194. */
  60195. get debug(): boolean;
  60196. set debug(dbg: boolean);
  60197. private _depthClamp;
  60198. /**
  60199. * Gets or sets the depth clamping value.
  60200. *
  60201. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60202. * to account for the shadow casters far away.
  60203. *
  60204. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60205. */
  60206. get depthClamp(): boolean;
  60207. set depthClamp(value: boolean);
  60208. private _cascadeBlendPercentage;
  60209. /**
  60210. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60211. * It defaults to 0.1 (10% blending).
  60212. */
  60213. get cascadeBlendPercentage(): number;
  60214. set cascadeBlendPercentage(value: number);
  60215. private _lambda;
  60216. /**
  60217. * Gets or set the lambda parameter.
  60218. * This parameter is used to split the camera frustum and create the cascades.
  60219. * 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.
  60220. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60221. */
  60222. get lambda(): number;
  60223. set lambda(value: number);
  60224. /**
  60225. * Gets the view matrix corresponding to a given cascade
  60226. * @param cascadeNum cascade to retrieve the view matrix from
  60227. * @returns the cascade view matrix
  60228. */
  60229. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60230. /**
  60231. * Gets the projection matrix corresponding to a given cascade
  60232. * @param cascadeNum cascade to retrieve the projection matrix from
  60233. * @returns the cascade projection matrix
  60234. */
  60235. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60236. /**
  60237. * Gets the transformation matrix corresponding to a given cascade
  60238. * @param cascadeNum cascade to retrieve the transformation matrix from
  60239. * @returns the cascade transformation matrix
  60240. */
  60241. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60242. private _depthRenderer;
  60243. /**
  60244. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60245. *
  60246. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60247. *
  60248. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60249. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60250. * @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
  60251. */
  60252. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60253. private _depthReducer;
  60254. private _autoCalcDepthBounds;
  60255. /**
  60256. * Gets or sets the autoCalcDepthBounds property.
  60257. *
  60258. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60259. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60260. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60261. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60262. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60263. */
  60264. get autoCalcDepthBounds(): boolean;
  60265. set autoCalcDepthBounds(value: boolean);
  60266. /**
  60267. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60268. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60269. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60270. * for setting the refresh rate on the renderer yourself!
  60271. */
  60272. get autoCalcDepthBoundsRefreshRate(): number;
  60273. set autoCalcDepthBoundsRefreshRate(value: number);
  60274. /**
  60275. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60276. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60277. * you change the camera near/far planes!
  60278. */
  60279. splitFrustum(): void;
  60280. private _splitFrustum;
  60281. private _computeMatrices;
  60282. private _computeFrustumInWorldSpace;
  60283. private _computeCascadeFrustum;
  60284. /**
  60285. * Support test.
  60286. */
  60287. static get IsSupported(): boolean;
  60288. /** @hidden */
  60289. static _SceneComponentInitialization: (scene: Scene) => void;
  60290. /**
  60291. * Creates a Cascaded Shadow Generator object.
  60292. * A ShadowGenerator is the required tool to use the shadows.
  60293. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60294. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60295. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60296. * @param light The directional light object generating the shadows.
  60297. * @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.
  60298. */
  60299. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60300. protected _initializeGenerator(): void;
  60301. protected _createTargetRenderTexture(): void;
  60302. protected _initializeShadowMap(): void;
  60303. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60304. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60305. /**
  60306. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60307. * @param defines Defines of the material we want to update
  60308. * @param lightIndex Index of the light in the enabled light list of the material
  60309. */
  60310. prepareDefines(defines: any, lightIndex: number): void;
  60311. /**
  60312. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60313. * defined in the generator but impacting the effect).
  60314. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60315. * @param effect The effect we are binfing the information for
  60316. */
  60317. bindShadowLight(lightIndex: string, effect: Effect): void;
  60318. /**
  60319. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60320. * (eq to view projection * shadow projection matrices)
  60321. * @returns The transform matrix used to create the shadow map
  60322. */
  60323. getTransformMatrix(): Matrix;
  60324. /**
  60325. * Disposes the ShadowGenerator.
  60326. * Returns nothing.
  60327. */
  60328. dispose(): void;
  60329. /**
  60330. * Serializes the shadow generator setup to a json object.
  60331. * @returns The serialized JSON object
  60332. */
  60333. serialize(): any;
  60334. /**
  60335. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60336. * @param parsedShadowGenerator The JSON object to parse
  60337. * @param scene The scene to create the shadow map for
  60338. * @returns The parsed shadow generator
  60339. */
  60340. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60341. }
  60342. }
  60343. declare module BABYLON {
  60344. /**
  60345. * Defines the shadow generator component responsible to manage any shadow generators
  60346. * in a given scene.
  60347. */
  60348. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60349. /**
  60350. * The component name helpfull to identify the component in the list of scene components.
  60351. */
  60352. readonly name: string;
  60353. /**
  60354. * The scene the component belongs to.
  60355. */
  60356. scene: Scene;
  60357. /**
  60358. * Creates a new instance of the component for the given scene
  60359. * @param scene Defines the scene to register the component in
  60360. */
  60361. constructor(scene: Scene);
  60362. /**
  60363. * Registers the component in a given scene
  60364. */
  60365. register(): void;
  60366. /**
  60367. * Rebuilds the elements related to this component in case of
  60368. * context lost for instance.
  60369. */
  60370. rebuild(): void;
  60371. /**
  60372. * Serializes the component data to the specified json object
  60373. * @param serializationObject The object to serialize to
  60374. */
  60375. serialize(serializationObject: any): void;
  60376. /**
  60377. * Adds all the elements from the container to the scene
  60378. * @param container the container holding the elements
  60379. */
  60380. addFromContainer(container: AbstractScene): void;
  60381. /**
  60382. * Removes all the elements in the container from the scene
  60383. * @param container contains the elements to remove
  60384. * @param dispose if the removed element should be disposed (default: false)
  60385. */
  60386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60387. /**
  60388. * Rebuilds the elements related to this component in case of
  60389. * context lost for instance.
  60390. */
  60391. dispose(): void;
  60392. private _gatherRenderTargets;
  60393. }
  60394. }
  60395. declare module BABYLON {
  60396. /**
  60397. * A point light is a light defined by an unique point in world space.
  60398. * The light is emitted in every direction from this point.
  60399. * A good example of a point light is a standard light bulb.
  60400. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60401. */
  60402. export class PointLight extends ShadowLight {
  60403. private _shadowAngle;
  60404. /**
  60405. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60406. * This specifies what angle the shadow will use to be created.
  60407. *
  60408. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60409. */
  60410. get shadowAngle(): number;
  60411. /**
  60412. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60413. * This specifies what angle the shadow will use to be created.
  60414. *
  60415. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60416. */
  60417. set shadowAngle(value: number);
  60418. /**
  60419. * Gets the direction if it has been set.
  60420. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60421. */
  60422. get direction(): Vector3;
  60423. /**
  60424. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60425. */
  60426. set direction(value: Vector3);
  60427. /**
  60428. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60429. * A PointLight emits the light in every direction.
  60430. * It can cast shadows.
  60431. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60432. * ```javascript
  60433. * var pointLight = new PointLight("pl", camera.position, scene);
  60434. * ```
  60435. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60436. * @param name The light friendly name
  60437. * @param position The position of the point light in the scene
  60438. * @param scene The scene the lights belongs to
  60439. */
  60440. constructor(name: string, position: Vector3, scene: Scene);
  60441. /**
  60442. * Returns the string "PointLight"
  60443. * @returns the class name
  60444. */
  60445. getClassName(): string;
  60446. /**
  60447. * Returns the integer 0.
  60448. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60449. */
  60450. getTypeID(): number;
  60451. /**
  60452. * Specifies wether or not the shadowmap should be a cube texture.
  60453. * @returns true if the shadowmap needs to be a cube texture.
  60454. */
  60455. needCube(): boolean;
  60456. /**
  60457. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60458. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60459. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60460. */
  60461. getShadowDirection(faceIndex?: number): Vector3;
  60462. /**
  60463. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60464. * - fov = PI / 2
  60465. * - aspect ratio : 1.0
  60466. * - z-near and far equal to the active camera minZ and maxZ.
  60467. * Returns the PointLight.
  60468. */
  60469. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60470. protected _buildUniformLayout(): void;
  60471. /**
  60472. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60473. * @param effect The effect to update
  60474. * @param lightIndex The index of the light in the effect to update
  60475. * @returns The point light
  60476. */
  60477. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60478. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60479. /**
  60480. * Prepares the list of defines specific to the light type.
  60481. * @param defines the list of defines
  60482. * @param lightIndex defines the index of the light for the effect
  60483. */
  60484. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60485. }
  60486. }
  60487. declare module BABYLON {
  60488. /**
  60489. * Header information of HDR texture files.
  60490. */
  60491. export interface HDRInfo {
  60492. /**
  60493. * The height of the texture in pixels.
  60494. */
  60495. height: number;
  60496. /**
  60497. * The width of the texture in pixels.
  60498. */
  60499. width: number;
  60500. /**
  60501. * The index of the beginning of the data in the binary file.
  60502. */
  60503. dataPosition: number;
  60504. }
  60505. /**
  60506. * This groups tools to convert HDR texture to native colors array.
  60507. */
  60508. export class HDRTools {
  60509. private static Ldexp;
  60510. private static Rgbe2float;
  60511. private static readStringLine;
  60512. /**
  60513. * Reads header information from an RGBE texture stored in a native array.
  60514. * More information on this format are available here:
  60515. * https://en.wikipedia.org/wiki/RGBE_image_format
  60516. *
  60517. * @param uint8array The binary file stored in native array.
  60518. * @return The header information.
  60519. */
  60520. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60521. /**
  60522. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60523. * This RGBE texture needs to store the information as a panorama.
  60524. *
  60525. * More information on this format are available here:
  60526. * https://en.wikipedia.org/wiki/RGBE_image_format
  60527. *
  60528. * @param buffer The binary file stored in an array buffer.
  60529. * @param size The expected size of the extracted cubemap.
  60530. * @return The Cube Map information.
  60531. */
  60532. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60533. /**
  60534. * Returns the pixels data extracted from an RGBE texture.
  60535. * This pixels will be stored left to right up to down in the R G B order in one array.
  60536. *
  60537. * More information on this format are available here:
  60538. * https://en.wikipedia.org/wiki/RGBE_image_format
  60539. *
  60540. * @param uint8array The binary file stored in an array buffer.
  60541. * @param hdrInfo The header information of the file.
  60542. * @return The pixels data in RGB right to left up to down order.
  60543. */
  60544. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60545. private static RGBE_ReadPixels_RLE;
  60546. private static RGBE_ReadPixels_NOT_RLE;
  60547. }
  60548. }
  60549. declare module BABYLON {
  60550. /**
  60551. * Effect Render Options
  60552. */
  60553. export interface IEffectRendererOptions {
  60554. /**
  60555. * Defines the vertices positions.
  60556. */
  60557. positions?: number[];
  60558. /**
  60559. * Defines the indices.
  60560. */
  60561. indices?: number[];
  60562. }
  60563. /**
  60564. * Helper class to render one or more effects.
  60565. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60566. */
  60567. export class EffectRenderer {
  60568. private engine;
  60569. private static _DefaultOptions;
  60570. private _vertexBuffers;
  60571. private _indexBuffer;
  60572. private _fullscreenViewport;
  60573. /**
  60574. * Creates an effect renderer
  60575. * @param engine the engine to use for rendering
  60576. * @param options defines the options of the effect renderer
  60577. */
  60578. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60579. /**
  60580. * Sets the current viewport in normalized coordinates 0-1
  60581. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60582. */
  60583. setViewport(viewport?: Viewport): void;
  60584. /**
  60585. * Binds the embedded attributes buffer to the effect.
  60586. * @param effect Defines the effect to bind the attributes for
  60587. */
  60588. bindBuffers(effect: Effect): void;
  60589. /**
  60590. * Sets the current effect wrapper to use during draw.
  60591. * The effect needs to be ready before calling this api.
  60592. * This also sets the default full screen position attribute.
  60593. * @param effectWrapper Defines the effect to draw with
  60594. */
  60595. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60596. /**
  60597. * Restores engine states
  60598. */
  60599. restoreStates(): void;
  60600. /**
  60601. * Draws a full screen quad.
  60602. */
  60603. draw(): void;
  60604. private isRenderTargetTexture;
  60605. /**
  60606. * renders one or more effects to a specified texture
  60607. * @param effectWrapper the effect to renderer
  60608. * @param outputTexture texture to draw to, if null it will render to the screen.
  60609. */
  60610. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60611. /**
  60612. * Disposes of the effect renderer
  60613. */
  60614. dispose(): void;
  60615. }
  60616. /**
  60617. * Options to create an EffectWrapper
  60618. */
  60619. interface EffectWrapperCreationOptions {
  60620. /**
  60621. * Engine to use to create the effect
  60622. */
  60623. engine: ThinEngine;
  60624. /**
  60625. * Fragment shader for the effect
  60626. */
  60627. fragmentShader: string;
  60628. /**
  60629. * Use the shader store instead of direct source code
  60630. */
  60631. useShaderStore?: boolean;
  60632. /**
  60633. * Vertex shader for the effect
  60634. */
  60635. vertexShader?: string;
  60636. /**
  60637. * Attributes to use in the shader
  60638. */
  60639. attributeNames?: Array<string>;
  60640. /**
  60641. * Uniforms to use in the shader
  60642. */
  60643. uniformNames?: Array<string>;
  60644. /**
  60645. * Texture sampler names to use in the shader
  60646. */
  60647. samplerNames?: Array<string>;
  60648. /**
  60649. * Defines to use in the shader
  60650. */
  60651. defines?: Array<string>;
  60652. /**
  60653. * Callback when effect is compiled
  60654. */
  60655. onCompiled?: Nullable<(effect: Effect) => void>;
  60656. /**
  60657. * The friendly name of the effect displayed in Spector.
  60658. */
  60659. name?: string;
  60660. }
  60661. /**
  60662. * Wraps an effect to be used for rendering
  60663. */
  60664. export class EffectWrapper {
  60665. /**
  60666. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60667. */
  60668. onApplyObservable: Observable<{}>;
  60669. /**
  60670. * The underlying effect
  60671. */
  60672. effect: Effect;
  60673. /**
  60674. * Creates an effect to be renderer
  60675. * @param creationOptions options to create the effect
  60676. */
  60677. constructor(creationOptions: EffectWrapperCreationOptions);
  60678. /**
  60679. * Disposes of the effect wrapper
  60680. */
  60681. dispose(): void;
  60682. }
  60683. }
  60684. declare module BABYLON {
  60685. /** @hidden */
  60686. export var hdrFilteringVertexShader: {
  60687. name: string;
  60688. shader: string;
  60689. };
  60690. }
  60691. declare module BABYLON {
  60692. /** @hidden */
  60693. export var hdrFilteringPixelShader: {
  60694. name: string;
  60695. shader: string;
  60696. };
  60697. }
  60698. declare module BABYLON {
  60699. /**
  60700. * Options for texture filtering
  60701. */
  60702. interface IHDRFilteringOptions {
  60703. /**
  60704. * Scales pixel intensity for the input HDR map.
  60705. */
  60706. hdrScale?: number;
  60707. /**
  60708. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60709. */
  60710. quality?: number;
  60711. }
  60712. /**
  60713. * Filters HDR maps to get correct renderings of PBR reflections
  60714. */
  60715. export class HDRFiltering {
  60716. private _engine;
  60717. private _effectRenderer;
  60718. private _effectWrapper;
  60719. private _lodGenerationOffset;
  60720. private _lodGenerationScale;
  60721. /**
  60722. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60723. * you care about baking speed.
  60724. */
  60725. quality: number;
  60726. /**
  60727. * Scales pixel intensity for the input HDR map.
  60728. */
  60729. hdrScale: number;
  60730. /**
  60731. * Instantiates HDR filter for reflection maps
  60732. *
  60733. * @param engine Thin engine
  60734. * @param options Options
  60735. */
  60736. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60737. private _createRenderTarget;
  60738. private _prefilterInternal;
  60739. private _createEffect;
  60740. /**
  60741. * Get a value indicating if the filter is ready to be used
  60742. * @param texture Texture to filter
  60743. * @returns true if the filter is ready
  60744. */
  60745. isReady(texture: BaseTexture): boolean;
  60746. /**
  60747. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60748. * Prefiltering will be invoked at the end of next rendering pass.
  60749. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60750. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60751. * @param texture Texture to filter
  60752. * @param onFinished Callback when filtering is done
  60753. * @return Promise called when prefiltering is done
  60754. */
  60755. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60756. }
  60757. }
  60758. declare module BABYLON {
  60759. /**
  60760. * This represents a texture coming from an HDR input.
  60761. *
  60762. * The only supported format is currently panorama picture stored in RGBE format.
  60763. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60764. */
  60765. export class HDRCubeTexture extends BaseTexture {
  60766. private static _facesMapping;
  60767. private _generateHarmonics;
  60768. private _noMipmap;
  60769. private _prefilterOnLoad;
  60770. private _textureMatrix;
  60771. private _size;
  60772. private _onLoad;
  60773. private _onError;
  60774. /**
  60775. * The texture URL.
  60776. */
  60777. url: string;
  60778. protected _isBlocking: boolean;
  60779. /**
  60780. * Sets wether or not the texture is blocking during loading.
  60781. */
  60782. set isBlocking(value: boolean);
  60783. /**
  60784. * Gets wether or not the texture is blocking during loading.
  60785. */
  60786. get isBlocking(): boolean;
  60787. protected _rotationY: number;
  60788. /**
  60789. * Sets texture matrix rotation angle around Y axis in radians.
  60790. */
  60791. set rotationY(value: number);
  60792. /**
  60793. * Gets texture matrix rotation angle around Y axis radians.
  60794. */
  60795. get rotationY(): number;
  60796. /**
  60797. * Gets or sets the center of the bounding box associated with the cube texture
  60798. * It must define where the camera used to render the texture was set
  60799. */
  60800. boundingBoxPosition: Vector3;
  60801. private _boundingBoxSize;
  60802. /**
  60803. * Gets or sets the size of the bounding box associated with the cube texture
  60804. * When defined, the cubemap will switch to local mode
  60805. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60806. * @example https://www.babylonjs-playground.com/#RNASML
  60807. */
  60808. set boundingBoxSize(value: Vector3);
  60809. get boundingBoxSize(): Vector3;
  60810. /**
  60811. * Instantiates an HDRTexture from the following parameters.
  60812. *
  60813. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60814. * @param sceneOrEngine The scene or engine the texture will be used in
  60815. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60816. * @param noMipmap Forces to not generate the mipmap if true
  60817. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60818. * @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)
  60819. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60820. */
  60821. 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>);
  60822. /**
  60823. * Get the current class name of the texture useful for serialization or dynamic coding.
  60824. * @returns "HDRCubeTexture"
  60825. */
  60826. getClassName(): string;
  60827. /**
  60828. * Occurs when the file is raw .hdr file.
  60829. */
  60830. private loadTexture;
  60831. clone(): HDRCubeTexture;
  60832. delayLoad(): void;
  60833. /**
  60834. * Get the texture reflection matrix used to rotate/transform the reflection.
  60835. * @returns the reflection matrix
  60836. */
  60837. getReflectionTextureMatrix(): Matrix;
  60838. /**
  60839. * Set the texture reflection matrix used to rotate/transform the reflection.
  60840. * @param value Define the reflection matrix to set
  60841. */
  60842. setReflectionTextureMatrix(value: Matrix): void;
  60843. /**
  60844. * Parses a JSON representation of an HDR Texture in order to create the texture
  60845. * @param parsedTexture Define the JSON representation
  60846. * @param scene Define the scene the texture should be created in
  60847. * @param rootUrl Define the root url in case we need to load relative dependencies
  60848. * @returns the newly created texture after parsing
  60849. */
  60850. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60851. serialize(): any;
  60852. }
  60853. }
  60854. declare module BABYLON {
  60855. /**
  60856. * Class used to control physics engine
  60857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60858. */
  60859. export class PhysicsEngine implements IPhysicsEngine {
  60860. private _physicsPlugin;
  60861. /**
  60862. * Global value used to control the smallest number supported by the simulation
  60863. */
  60864. static Epsilon: number;
  60865. private _impostors;
  60866. private _joints;
  60867. private _subTimeStep;
  60868. /**
  60869. * Gets the gravity vector used by the simulation
  60870. */
  60871. gravity: Vector3;
  60872. /**
  60873. * Factory used to create the default physics plugin.
  60874. * @returns The default physics plugin
  60875. */
  60876. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60877. /**
  60878. * Creates a new Physics Engine
  60879. * @param gravity defines the gravity vector used by the simulation
  60880. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60881. */
  60882. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60883. /**
  60884. * Sets the gravity vector used by the simulation
  60885. * @param gravity defines the gravity vector to use
  60886. */
  60887. setGravity(gravity: Vector3): void;
  60888. /**
  60889. * Set the time step of the physics engine.
  60890. * Default is 1/60.
  60891. * To slow it down, enter 1/600 for example.
  60892. * To speed it up, 1/30
  60893. * @param newTimeStep defines the new timestep to apply to this world.
  60894. */
  60895. setTimeStep(newTimeStep?: number): void;
  60896. /**
  60897. * Get the time step of the physics engine.
  60898. * @returns the current time step
  60899. */
  60900. getTimeStep(): number;
  60901. /**
  60902. * Set the sub time step of the physics engine.
  60903. * Default is 0 meaning there is no sub steps
  60904. * To increase physics resolution precision, set a small value (like 1 ms)
  60905. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60906. */
  60907. setSubTimeStep(subTimeStep?: number): void;
  60908. /**
  60909. * Get the sub time step of the physics engine.
  60910. * @returns the current sub time step
  60911. */
  60912. getSubTimeStep(): number;
  60913. /**
  60914. * Release all resources
  60915. */
  60916. dispose(): void;
  60917. /**
  60918. * Gets the name of the current physics plugin
  60919. * @returns the name of the plugin
  60920. */
  60921. getPhysicsPluginName(): string;
  60922. /**
  60923. * Adding a new impostor for the impostor tracking.
  60924. * This will be done by the impostor itself.
  60925. * @param impostor the impostor to add
  60926. */
  60927. addImpostor(impostor: PhysicsImpostor): void;
  60928. /**
  60929. * Remove an impostor from the engine.
  60930. * This impostor and its mesh will not longer be updated by the physics engine.
  60931. * @param impostor the impostor to remove
  60932. */
  60933. removeImpostor(impostor: PhysicsImpostor): void;
  60934. /**
  60935. * Add a joint to the physics engine
  60936. * @param mainImpostor defines the main impostor to which the joint is added.
  60937. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60938. * @param joint defines the joint that will connect both impostors.
  60939. */
  60940. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60941. /**
  60942. * Removes a joint from the simulation
  60943. * @param mainImpostor defines the impostor used with the joint
  60944. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60945. * @param joint defines the joint to remove
  60946. */
  60947. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60948. /**
  60949. * Called by the scene. No need to call it.
  60950. * @param delta defines the timespam between frames
  60951. */
  60952. _step(delta: number): void;
  60953. /**
  60954. * Gets the current plugin used to run the simulation
  60955. * @returns current plugin
  60956. */
  60957. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60958. /**
  60959. * Gets the list of physic impostors
  60960. * @returns an array of PhysicsImpostor
  60961. */
  60962. getImpostors(): Array<PhysicsImpostor>;
  60963. /**
  60964. * Gets the impostor for a physics enabled object
  60965. * @param object defines the object impersonated by the impostor
  60966. * @returns the PhysicsImpostor or null if not found
  60967. */
  60968. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60969. /**
  60970. * Gets the impostor for a physics body object
  60971. * @param body defines physics body used by the impostor
  60972. * @returns the PhysicsImpostor or null if not found
  60973. */
  60974. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60975. /**
  60976. * Does a raycast in the physics world
  60977. * @param from when should the ray start?
  60978. * @param to when should the ray end?
  60979. * @returns PhysicsRaycastResult
  60980. */
  60981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60982. }
  60983. }
  60984. declare module BABYLON {
  60985. /** @hidden */
  60986. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60987. private _useDeltaForWorldStep;
  60988. world: any;
  60989. name: string;
  60990. private _physicsMaterials;
  60991. private _fixedTimeStep;
  60992. private _cannonRaycastResult;
  60993. private _raycastResult;
  60994. private _physicsBodysToRemoveAfterStep;
  60995. private _firstFrame;
  60996. BJSCANNON: any;
  60997. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60998. setGravity(gravity: Vector3): void;
  60999. setTimeStep(timeStep: number): void;
  61000. getTimeStep(): number;
  61001. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61002. private _removeMarkedPhysicsBodiesFromWorld;
  61003. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61004. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61005. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61006. private _processChildMeshes;
  61007. removePhysicsBody(impostor: PhysicsImpostor): void;
  61008. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61009. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61010. private _addMaterial;
  61011. private _checkWithEpsilon;
  61012. private _createShape;
  61013. private _createHeightmap;
  61014. private _minus90X;
  61015. private _plus90X;
  61016. private _tmpPosition;
  61017. private _tmpDeltaPosition;
  61018. private _tmpUnityRotation;
  61019. private _updatePhysicsBodyTransformation;
  61020. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61021. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61022. isSupported(): boolean;
  61023. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61024. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61025. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61026. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61027. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61028. getBodyMass(impostor: PhysicsImpostor): number;
  61029. getBodyFriction(impostor: PhysicsImpostor): number;
  61030. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61031. getBodyRestitution(impostor: PhysicsImpostor): number;
  61032. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61033. sleepBody(impostor: PhysicsImpostor): void;
  61034. wakeUpBody(impostor: PhysicsImpostor): void;
  61035. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61036. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61037. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61038. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61039. getRadius(impostor: PhysicsImpostor): number;
  61040. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61041. dispose(): void;
  61042. private _extendNamespace;
  61043. /**
  61044. * Does a raycast in the physics world
  61045. * @param from when should the ray start?
  61046. * @param to when should the ray end?
  61047. * @returns PhysicsRaycastResult
  61048. */
  61049. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61050. }
  61051. }
  61052. declare module BABYLON {
  61053. /** @hidden */
  61054. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61055. private _useDeltaForWorldStep;
  61056. world: any;
  61057. name: string;
  61058. BJSOIMO: any;
  61059. private _raycastResult;
  61060. private _fixedTimeStep;
  61061. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61062. setGravity(gravity: Vector3): void;
  61063. setTimeStep(timeStep: number): void;
  61064. getTimeStep(): number;
  61065. private _tmpImpostorsArray;
  61066. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61067. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61068. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61069. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61070. private _tmpPositionVector;
  61071. removePhysicsBody(impostor: PhysicsImpostor): void;
  61072. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61073. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61074. isSupported(): boolean;
  61075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61077. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61078. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61079. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61080. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61081. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61082. getBodyMass(impostor: PhysicsImpostor): number;
  61083. getBodyFriction(impostor: PhysicsImpostor): number;
  61084. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61085. getBodyRestitution(impostor: PhysicsImpostor): number;
  61086. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61087. sleepBody(impostor: PhysicsImpostor): void;
  61088. wakeUpBody(impostor: PhysicsImpostor): void;
  61089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61090. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61091. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61092. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61093. getRadius(impostor: PhysicsImpostor): number;
  61094. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61095. dispose(): void;
  61096. /**
  61097. * Does a raycast in the physics world
  61098. * @param from when should the ray start?
  61099. * @param to when should the ray end?
  61100. * @returns PhysicsRaycastResult
  61101. */
  61102. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61103. }
  61104. }
  61105. declare module BABYLON {
  61106. /**
  61107. * AmmoJS Physics plugin
  61108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61109. * @see https://github.com/kripken/ammo.js/
  61110. */
  61111. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61112. private _useDeltaForWorldStep;
  61113. /**
  61114. * Reference to the Ammo library
  61115. */
  61116. bjsAMMO: any;
  61117. /**
  61118. * Created ammoJS world which physics bodies are added to
  61119. */
  61120. world: any;
  61121. /**
  61122. * Name of the plugin
  61123. */
  61124. name: string;
  61125. private _timeStep;
  61126. private _fixedTimeStep;
  61127. private _maxSteps;
  61128. private _tmpQuaternion;
  61129. private _tmpAmmoTransform;
  61130. private _tmpAmmoQuaternion;
  61131. private _tmpAmmoConcreteContactResultCallback;
  61132. private _collisionConfiguration;
  61133. private _dispatcher;
  61134. private _overlappingPairCache;
  61135. private _solver;
  61136. private _softBodySolver;
  61137. private _tmpAmmoVectorA;
  61138. private _tmpAmmoVectorB;
  61139. private _tmpAmmoVectorC;
  61140. private _tmpAmmoVectorD;
  61141. private _tmpContactCallbackResult;
  61142. private _tmpAmmoVectorRCA;
  61143. private _tmpAmmoVectorRCB;
  61144. private _raycastResult;
  61145. private static readonly DISABLE_COLLISION_FLAG;
  61146. private static readonly KINEMATIC_FLAG;
  61147. private static readonly DISABLE_DEACTIVATION_FLAG;
  61148. /**
  61149. * Initializes the ammoJS plugin
  61150. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61151. * @param ammoInjection can be used to inject your own ammo reference
  61152. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61153. */
  61154. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61155. /**
  61156. * Sets the gravity of the physics world (m/(s^2))
  61157. * @param gravity Gravity to set
  61158. */
  61159. setGravity(gravity: Vector3): void;
  61160. /**
  61161. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61162. * @param timeStep timestep to use in seconds
  61163. */
  61164. setTimeStep(timeStep: number): void;
  61165. /**
  61166. * 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)
  61167. * @param fixedTimeStep fixedTimeStep to use in seconds
  61168. */
  61169. setFixedTimeStep(fixedTimeStep: number): void;
  61170. /**
  61171. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61172. * @param maxSteps the maximum number of steps by the physics engine per frame
  61173. */
  61174. setMaxSteps(maxSteps: number): void;
  61175. /**
  61176. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61177. * @returns the current timestep in seconds
  61178. */
  61179. getTimeStep(): number;
  61180. /**
  61181. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61182. */
  61183. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61184. private _isImpostorInContact;
  61185. private _isImpostorPairInContact;
  61186. private _stepSimulation;
  61187. /**
  61188. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61189. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61190. * After the step the babylon meshes are set to the position of the physics imposters
  61191. * @param delta amount of time to step forward
  61192. * @param impostors array of imposters to update before/after the step
  61193. */
  61194. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61195. /**
  61196. * Update babylon mesh to match physics world object
  61197. * @param impostor imposter to match
  61198. */
  61199. private _afterSoftStep;
  61200. /**
  61201. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61202. * @param impostor imposter to match
  61203. */
  61204. private _ropeStep;
  61205. /**
  61206. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61207. * @param impostor imposter to match
  61208. */
  61209. private _softbodyOrClothStep;
  61210. private _tmpMatrix;
  61211. /**
  61212. * Applies an impulse on the imposter
  61213. * @param impostor imposter to apply impulse to
  61214. * @param force amount of force to be applied to the imposter
  61215. * @param contactPoint the location to apply the impulse on the imposter
  61216. */
  61217. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61218. /**
  61219. * Applies a force on the imposter
  61220. * @param impostor imposter to apply force
  61221. * @param force amount of force to be applied to the imposter
  61222. * @param contactPoint the location to apply the force on the imposter
  61223. */
  61224. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61225. /**
  61226. * Creates a physics body using the plugin
  61227. * @param impostor the imposter to create the physics body on
  61228. */
  61229. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61230. /**
  61231. * Removes the physics body from the imposter and disposes of the body's memory
  61232. * @param impostor imposter to remove the physics body from
  61233. */
  61234. removePhysicsBody(impostor: PhysicsImpostor): void;
  61235. /**
  61236. * Generates a joint
  61237. * @param impostorJoint the imposter joint to create the joint with
  61238. */
  61239. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61240. /**
  61241. * Removes a joint
  61242. * @param impostorJoint the imposter joint to remove the joint from
  61243. */
  61244. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61245. private _addMeshVerts;
  61246. /**
  61247. * Initialise the soft body vertices to match its object's (mesh) vertices
  61248. * Softbody vertices (nodes) are in world space and to match this
  61249. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61250. * @param impostor to create the softbody for
  61251. */
  61252. private _softVertexData;
  61253. /**
  61254. * Create an impostor's soft body
  61255. * @param impostor to create the softbody for
  61256. */
  61257. private _createSoftbody;
  61258. /**
  61259. * Create cloth for an impostor
  61260. * @param impostor to create the softbody for
  61261. */
  61262. private _createCloth;
  61263. /**
  61264. * Create rope for an impostor
  61265. * @param impostor to create the softbody for
  61266. */
  61267. private _createRope;
  61268. /**
  61269. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61270. * @param impostor to create the custom physics shape for
  61271. */
  61272. private _createCustom;
  61273. private _addHullVerts;
  61274. private _createShape;
  61275. /**
  61276. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61277. * @param impostor imposter containing the physics body and babylon object
  61278. */
  61279. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61280. /**
  61281. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61282. * @param impostor imposter containing the physics body and babylon object
  61283. * @param newPosition new position
  61284. * @param newRotation new rotation
  61285. */
  61286. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61287. /**
  61288. * If this plugin is supported
  61289. * @returns true if its supported
  61290. */
  61291. isSupported(): boolean;
  61292. /**
  61293. * Sets the linear velocity of the physics body
  61294. * @param impostor imposter to set the velocity on
  61295. * @param velocity velocity to set
  61296. */
  61297. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61298. /**
  61299. * Sets the angular velocity of the physics body
  61300. * @param impostor imposter to set the velocity on
  61301. * @param velocity velocity to set
  61302. */
  61303. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61304. /**
  61305. * gets the linear velocity
  61306. * @param impostor imposter to get linear velocity from
  61307. * @returns linear velocity
  61308. */
  61309. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61310. /**
  61311. * gets the angular velocity
  61312. * @param impostor imposter to get angular velocity from
  61313. * @returns angular velocity
  61314. */
  61315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61316. /**
  61317. * Sets the mass of physics body
  61318. * @param impostor imposter to set the mass on
  61319. * @param mass mass to set
  61320. */
  61321. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61322. /**
  61323. * Gets the mass of the physics body
  61324. * @param impostor imposter to get the mass from
  61325. * @returns mass
  61326. */
  61327. getBodyMass(impostor: PhysicsImpostor): number;
  61328. /**
  61329. * Gets friction of the impostor
  61330. * @param impostor impostor to get friction from
  61331. * @returns friction value
  61332. */
  61333. getBodyFriction(impostor: PhysicsImpostor): number;
  61334. /**
  61335. * Sets friction of the impostor
  61336. * @param impostor impostor to set friction on
  61337. * @param friction friction value
  61338. */
  61339. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61340. /**
  61341. * Gets restitution of the impostor
  61342. * @param impostor impostor to get restitution from
  61343. * @returns restitution value
  61344. */
  61345. getBodyRestitution(impostor: PhysicsImpostor): number;
  61346. /**
  61347. * Sets resitution of the impostor
  61348. * @param impostor impostor to set resitution on
  61349. * @param restitution resitution value
  61350. */
  61351. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61352. /**
  61353. * Gets pressure inside the impostor
  61354. * @param impostor impostor to get pressure from
  61355. * @returns pressure value
  61356. */
  61357. getBodyPressure(impostor: PhysicsImpostor): number;
  61358. /**
  61359. * Sets pressure inside a soft body impostor
  61360. * Cloth and rope must remain 0 pressure
  61361. * @param impostor impostor to set pressure on
  61362. * @param pressure pressure value
  61363. */
  61364. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61365. /**
  61366. * Gets stiffness of the impostor
  61367. * @param impostor impostor to get stiffness from
  61368. * @returns pressure value
  61369. */
  61370. getBodyStiffness(impostor: PhysicsImpostor): number;
  61371. /**
  61372. * Sets stiffness of the impostor
  61373. * @param impostor impostor to set stiffness on
  61374. * @param stiffness stiffness value from 0 to 1
  61375. */
  61376. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61377. /**
  61378. * Gets velocityIterations of the impostor
  61379. * @param impostor impostor to get velocity iterations from
  61380. * @returns velocityIterations value
  61381. */
  61382. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61383. /**
  61384. * Sets velocityIterations of the impostor
  61385. * @param impostor impostor to set velocity iterations on
  61386. * @param velocityIterations velocityIterations value
  61387. */
  61388. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61389. /**
  61390. * Gets positionIterations of the impostor
  61391. * @param impostor impostor to get position iterations from
  61392. * @returns positionIterations value
  61393. */
  61394. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61395. /**
  61396. * Sets positionIterations of the impostor
  61397. * @param impostor impostor to set position on
  61398. * @param positionIterations positionIterations value
  61399. */
  61400. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61401. /**
  61402. * Append an anchor to a cloth object
  61403. * @param impostor is the cloth impostor to add anchor to
  61404. * @param otherImpostor is the rigid impostor to anchor to
  61405. * @param width ratio across width from 0 to 1
  61406. * @param height ratio up height from 0 to 1
  61407. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61408. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61409. */
  61410. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61411. /**
  61412. * Append an hook to a rope object
  61413. * @param impostor is the rope impostor to add hook to
  61414. * @param otherImpostor is the rigid impostor to hook to
  61415. * @param length ratio along the rope from 0 to 1
  61416. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61418. */
  61419. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61420. /**
  61421. * Sleeps the physics body and stops it from being active
  61422. * @param impostor impostor to sleep
  61423. */
  61424. sleepBody(impostor: PhysicsImpostor): void;
  61425. /**
  61426. * Activates the physics body
  61427. * @param impostor impostor to activate
  61428. */
  61429. wakeUpBody(impostor: PhysicsImpostor): void;
  61430. /**
  61431. * Updates the distance parameters of the joint
  61432. * @param joint joint to update
  61433. * @param maxDistance maximum distance of the joint
  61434. * @param minDistance minimum distance of the joint
  61435. */
  61436. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61437. /**
  61438. * Sets a motor on the joint
  61439. * @param joint joint to set motor on
  61440. * @param speed speed of the motor
  61441. * @param maxForce maximum force of the motor
  61442. * @param motorIndex index of the motor
  61443. */
  61444. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61445. /**
  61446. * Sets the motors limit
  61447. * @param joint joint to set limit on
  61448. * @param upperLimit upper limit
  61449. * @param lowerLimit lower limit
  61450. */
  61451. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61452. /**
  61453. * Syncs the position and rotation of a mesh with the impostor
  61454. * @param mesh mesh to sync
  61455. * @param impostor impostor to update the mesh with
  61456. */
  61457. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61458. /**
  61459. * Gets the radius of the impostor
  61460. * @param impostor impostor to get radius from
  61461. * @returns the radius
  61462. */
  61463. getRadius(impostor: PhysicsImpostor): number;
  61464. /**
  61465. * Gets the box size of the impostor
  61466. * @param impostor impostor to get box size from
  61467. * @param result the resulting box size
  61468. */
  61469. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61470. /**
  61471. * Disposes of the impostor
  61472. */
  61473. dispose(): void;
  61474. /**
  61475. * Does a raycast in the physics world
  61476. * @param from when should the ray start?
  61477. * @param to when should the ray end?
  61478. * @returns PhysicsRaycastResult
  61479. */
  61480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. interface AbstractScene {
  61485. /**
  61486. * The list of reflection probes added to the scene
  61487. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61488. */
  61489. reflectionProbes: Array<ReflectionProbe>;
  61490. /**
  61491. * Removes the given reflection probe from this scene.
  61492. * @param toRemove The reflection probe to remove
  61493. * @returns The index of the removed reflection probe
  61494. */
  61495. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61496. /**
  61497. * Adds the given reflection probe to this scene.
  61498. * @param newReflectionProbe The reflection probe to add
  61499. */
  61500. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61501. }
  61502. /**
  61503. * Class used to generate realtime reflection / refraction cube textures
  61504. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61505. */
  61506. export class ReflectionProbe {
  61507. /** defines the name of the probe */
  61508. name: string;
  61509. private _scene;
  61510. private _renderTargetTexture;
  61511. private _projectionMatrix;
  61512. private _viewMatrix;
  61513. private _target;
  61514. private _add;
  61515. private _attachedMesh;
  61516. private _invertYAxis;
  61517. /** Gets or sets probe position (center of the cube map) */
  61518. position: Vector3;
  61519. /**
  61520. * Creates a new reflection probe
  61521. * @param name defines the name of the probe
  61522. * @param size defines the texture resolution (for each face)
  61523. * @param scene defines the hosting scene
  61524. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61525. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61526. */
  61527. constructor(
  61528. /** defines the name of the probe */
  61529. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61530. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61531. get samples(): number;
  61532. set samples(value: number);
  61533. /** Gets or sets the refresh rate to use (on every frame by default) */
  61534. get refreshRate(): number;
  61535. set refreshRate(value: number);
  61536. /**
  61537. * Gets the hosting scene
  61538. * @returns a Scene
  61539. */
  61540. getScene(): Scene;
  61541. /** Gets the internal CubeTexture used to render to */
  61542. get cubeTexture(): RenderTargetTexture;
  61543. /** Gets the list of meshes to render */
  61544. get renderList(): Nullable<AbstractMesh[]>;
  61545. /**
  61546. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61547. * @param mesh defines the mesh to attach to
  61548. */
  61549. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61550. /**
  61551. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61552. * @param renderingGroupId The rendering group id corresponding to its index
  61553. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61554. */
  61555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61556. /**
  61557. * Clean all associated resources
  61558. */
  61559. dispose(): void;
  61560. /**
  61561. * Converts the reflection probe information to a readable string for debug purpose.
  61562. * @param fullDetails Supports for multiple levels of logging within scene loading
  61563. * @returns the human readable reflection probe info
  61564. */
  61565. toString(fullDetails?: boolean): string;
  61566. /**
  61567. * Get the class name of the relfection probe.
  61568. * @returns "ReflectionProbe"
  61569. */
  61570. getClassName(): string;
  61571. /**
  61572. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61573. * @returns The JSON representation of the texture
  61574. */
  61575. serialize(): any;
  61576. /**
  61577. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61578. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61579. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61580. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61581. * @returns The parsed reflection probe if successful
  61582. */
  61583. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61584. }
  61585. }
  61586. declare module BABYLON {
  61587. /** @hidden */
  61588. export var _BabylonLoaderRegistered: boolean;
  61589. /**
  61590. * Helps setting up some configuration for the babylon file loader.
  61591. */
  61592. export class BabylonFileLoaderConfiguration {
  61593. /**
  61594. * The loader does not allow injecting custom physix engine into the plugins.
  61595. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61596. * So you could set this variable to your engine import to make it work.
  61597. */
  61598. static LoaderInjectedPhysicsEngine: any;
  61599. }
  61600. }
  61601. declare module BABYLON {
  61602. /**
  61603. * The Physically based simple base material of BJS.
  61604. *
  61605. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61606. * It is used as the base class for both the specGloss and metalRough conventions.
  61607. */
  61608. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61609. /**
  61610. * Number of Simultaneous lights allowed on the material.
  61611. */
  61612. maxSimultaneousLights: number;
  61613. /**
  61614. * If sets to true, disables all the lights affecting the material.
  61615. */
  61616. disableLighting: boolean;
  61617. /**
  61618. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61619. */
  61620. environmentTexture: BaseTexture;
  61621. /**
  61622. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61623. */
  61624. invertNormalMapX: boolean;
  61625. /**
  61626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61627. */
  61628. invertNormalMapY: boolean;
  61629. /**
  61630. * Normal map used in the model.
  61631. */
  61632. normalTexture: BaseTexture;
  61633. /**
  61634. * Emissivie color used to self-illuminate the model.
  61635. */
  61636. emissiveColor: Color3;
  61637. /**
  61638. * Emissivie texture used to self-illuminate the model.
  61639. */
  61640. emissiveTexture: BaseTexture;
  61641. /**
  61642. * Occlusion Channel Strenght.
  61643. */
  61644. occlusionStrength: number;
  61645. /**
  61646. * Occlusion Texture of the material (adding extra occlusion effects).
  61647. */
  61648. occlusionTexture: BaseTexture;
  61649. /**
  61650. * Defines the alpha limits in alpha test mode.
  61651. */
  61652. alphaCutOff: number;
  61653. /**
  61654. * Gets the current double sided mode.
  61655. */
  61656. get doubleSided(): boolean;
  61657. /**
  61658. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61659. */
  61660. set doubleSided(value: boolean);
  61661. /**
  61662. * Stores the pre-calculated light information of a mesh in a texture.
  61663. */
  61664. lightmapTexture: BaseTexture;
  61665. /**
  61666. * If true, the light map contains occlusion information instead of lighting info.
  61667. */
  61668. useLightmapAsShadowmap: boolean;
  61669. /**
  61670. * Instantiates a new PBRMaterial instance.
  61671. *
  61672. * @param name The material name
  61673. * @param scene The scene the material will be use in.
  61674. */
  61675. constructor(name: string, scene: Scene);
  61676. getClassName(): string;
  61677. }
  61678. }
  61679. declare module BABYLON {
  61680. /**
  61681. * The PBR material of BJS following the metal roughness convention.
  61682. *
  61683. * This fits to the PBR convention in the GLTF definition:
  61684. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61685. */
  61686. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61687. /**
  61688. * The base color has two different interpretations depending on the value of metalness.
  61689. * When the material is a metal, the base color is the specific measured reflectance value
  61690. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61691. * of the material.
  61692. */
  61693. baseColor: Color3;
  61694. /**
  61695. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61696. * well as opacity information in the alpha channel.
  61697. */
  61698. baseTexture: BaseTexture;
  61699. /**
  61700. * Specifies the metallic scalar value of the material.
  61701. * Can also be used to scale the metalness values of the metallic texture.
  61702. */
  61703. metallic: number;
  61704. /**
  61705. * Specifies the roughness scalar value of the material.
  61706. * Can also be used to scale the roughness values of the metallic texture.
  61707. */
  61708. roughness: number;
  61709. /**
  61710. * Texture containing both the metallic value in the B channel and the
  61711. * roughness value in the G channel to keep better precision.
  61712. */
  61713. metallicRoughnessTexture: BaseTexture;
  61714. /**
  61715. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61716. *
  61717. * @param name The material name
  61718. * @param scene The scene the material will be use in.
  61719. */
  61720. constructor(name: string, scene: Scene);
  61721. /**
  61722. * Return the currrent class name of the material.
  61723. */
  61724. getClassName(): string;
  61725. /**
  61726. * Makes a duplicate of the current material.
  61727. * @param name - name to use for the new material.
  61728. */
  61729. clone(name: string): PBRMetallicRoughnessMaterial;
  61730. /**
  61731. * Serialize the material to a parsable JSON object.
  61732. */
  61733. serialize(): any;
  61734. /**
  61735. * Parses a JSON object correponding to the serialize function.
  61736. */
  61737. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61738. }
  61739. }
  61740. declare module BABYLON {
  61741. /**
  61742. * The PBR material of BJS following the specular glossiness convention.
  61743. *
  61744. * This fits to the PBR convention in the GLTF definition:
  61745. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61746. */
  61747. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61748. /**
  61749. * Specifies the diffuse color of the material.
  61750. */
  61751. diffuseColor: Color3;
  61752. /**
  61753. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61754. * channel.
  61755. */
  61756. diffuseTexture: BaseTexture;
  61757. /**
  61758. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61759. */
  61760. specularColor: Color3;
  61761. /**
  61762. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61763. */
  61764. glossiness: number;
  61765. /**
  61766. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61767. */
  61768. specularGlossinessTexture: BaseTexture;
  61769. /**
  61770. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61771. *
  61772. * @param name The material name
  61773. * @param scene The scene the material will be use in.
  61774. */
  61775. constructor(name: string, scene: Scene);
  61776. /**
  61777. * Return the currrent class name of the material.
  61778. */
  61779. getClassName(): string;
  61780. /**
  61781. * Makes a duplicate of the current material.
  61782. * @param name - name to use for the new material.
  61783. */
  61784. clone(name: string): PBRSpecularGlossinessMaterial;
  61785. /**
  61786. * Serialize the material to a parsable JSON object.
  61787. */
  61788. serialize(): any;
  61789. /**
  61790. * Parses a JSON object correponding to the serialize function.
  61791. */
  61792. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61793. }
  61794. }
  61795. declare module BABYLON {
  61796. /**
  61797. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61798. * It can help converting any input color in a desired output one. This can then be used to create effects
  61799. * from sepia, black and white to sixties or futuristic rendering...
  61800. *
  61801. * The only supported format is currently 3dl.
  61802. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61803. */
  61804. export class ColorGradingTexture extends BaseTexture {
  61805. /**
  61806. * The texture URL.
  61807. */
  61808. url: string;
  61809. /**
  61810. * Empty line regex stored for GC.
  61811. */
  61812. private static _noneEmptyLineRegex;
  61813. private _textureMatrix;
  61814. private _onLoad;
  61815. /**
  61816. * Instantiates a ColorGradingTexture from the following parameters.
  61817. *
  61818. * @param url The location of the color gradind data (currently only supporting 3dl)
  61819. * @param sceneOrEngine The scene or engine the texture will be used in
  61820. * @param onLoad defines a callback triggered when the texture has been loaded
  61821. */
  61822. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61823. /**
  61824. * Fires the onload event from the constructor if requested.
  61825. */
  61826. private _triggerOnLoad;
  61827. /**
  61828. * Returns the texture matrix used in most of the material.
  61829. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61830. */
  61831. getTextureMatrix(): Matrix;
  61832. /**
  61833. * Occurs when the file being loaded is a .3dl LUT file.
  61834. */
  61835. private load3dlTexture;
  61836. /**
  61837. * Starts the loading process of the texture.
  61838. */
  61839. private loadTexture;
  61840. /**
  61841. * Clones the color gradind texture.
  61842. */
  61843. clone(): ColorGradingTexture;
  61844. /**
  61845. * Called during delayed load for textures.
  61846. */
  61847. delayLoad(): void;
  61848. /**
  61849. * Parses a color grading texture serialized by Babylon.
  61850. * @param parsedTexture The texture information being parsedTexture
  61851. * @param scene The scene to load the texture in
  61852. * @param rootUrl The root url of the data assets to load
  61853. * @return A color gradind texture
  61854. */
  61855. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61856. /**
  61857. * Serializes the LUT texture to json format.
  61858. */
  61859. serialize(): any;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /**
  61864. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61865. */
  61866. export class EquiRectangularCubeTexture extends BaseTexture {
  61867. /** The six faces of the cube. */
  61868. private static _FacesMapping;
  61869. private _noMipmap;
  61870. private _onLoad;
  61871. private _onError;
  61872. /** The size of the cubemap. */
  61873. private _size;
  61874. /** The buffer of the image. */
  61875. private _buffer;
  61876. /** The width of the input image. */
  61877. private _width;
  61878. /** The height of the input image. */
  61879. private _height;
  61880. /** The URL to the image. */
  61881. url: string;
  61882. /**
  61883. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61884. * @param url The location of the image
  61885. * @param scene The scene the texture will be used in
  61886. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61887. * @param noMipmap Forces to not generate the mipmap if true
  61888. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61889. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61890. * @param onLoad — defines a callback called when texture is loaded
  61891. * @param onError — defines a callback called if there is an error
  61892. */
  61893. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61894. /**
  61895. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61896. */
  61897. private loadImage;
  61898. /**
  61899. * Convert the image buffer into a cubemap and create a CubeTexture.
  61900. */
  61901. private loadTexture;
  61902. /**
  61903. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61904. * @param buffer The ArrayBuffer that should be converted.
  61905. * @returns The buffer as Float32Array.
  61906. */
  61907. private getFloat32ArrayFromArrayBuffer;
  61908. /**
  61909. * Get the current class name of the texture useful for serialization or dynamic coding.
  61910. * @returns "EquiRectangularCubeTexture"
  61911. */
  61912. getClassName(): string;
  61913. /**
  61914. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61915. * @returns A clone of the current EquiRectangularCubeTexture.
  61916. */
  61917. clone(): EquiRectangularCubeTexture;
  61918. }
  61919. }
  61920. declare module BABYLON {
  61921. /**
  61922. * Defines the options related to the creation of an HtmlElementTexture
  61923. */
  61924. export interface IHtmlElementTextureOptions {
  61925. /**
  61926. * Defines wether mip maps should be created or not.
  61927. */
  61928. generateMipMaps?: boolean;
  61929. /**
  61930. * Defines the sampling mode of the texture.
  61931. */
  61932. samplingMode?: number;
  61933. /**
  61934. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61935. */
  61936. engine: Nullable<ThinEngine>;
  61937. /**
  61938. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61939. */
  61940. scene: Nullable<Scene>;
  61941. }
  61942. /**
  61943. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61944. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61945. * is automatically managed.
  61946. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61947. * in your application.
  61948. *
  61949. * As the update is not automatic, you need to call them manually.
  61950. */
  61951. export class HtmlElementTexture extends BaseTexture {
  61952. /**
  61953. * The texture URL.
  61954. */
  61955. element: HTMLVideoElement | HTMLCanvasElement;
  61956. private static readonly DefaultOptions;
  61957. private _textureMatrix;
  61958. private _isVideo;
  61959. private _generateMipMaps;
  61960. private _samplingMode;
  61961. /**
  61962. * Instantiates a HtmlElementTexture from the following parameters.
  61963. *
  61964. * @param name Defines the name of the texture
  61965. * @param element Defines the video or canvas the texture is filled with
  61966. * @param options Defines the other none mandatory texture creation options
  61967. */
  61968. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61969. private _createInternalTexture;
  61970. /**
  61971. * Returns the texture matrix used in most of the material.
  61972. */
  61973. getTextureMatrix(): Matrix;
  61974. /**
  61975. * Updates the content of the texture.
  61976. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61977. */
  61978. update(invertY?: Nullable<boolean>): void;
  61979. }
  61980. }
  61981. declare module BABYLON {
  61982. /**
  61983. * Based on jsTGALoader - Javascript loader for TGA file
  61984. * By Vincent Thibault
  61985. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61986. */
  61987. export class TGATools {
  61988. private static _TYPE_INDEXED;
  61989. private static _TYPE_RGB;
  61990. private static _TYPE_GREY;
  61991. private static _TYPE_RLE_INDEXED;
  61992. private static _TYPE_RLE_RGB;
  61993. private static _TYPE_RLE_GREY;
  61994. private static _ORIGIN_MASK;
  61995. private static _ORIGIN_SHIFT;
  61996. private static _ORIGIN_BL;
  61997. private static _ORIGIN_BR;
  61998. private static _ORIGIN_UL;
  61999. private static _ORIGIN_UR;
  62000. /**
  62001. * Gets the header of a TGA file
  62002. * @param data defines the TGA data
  62003. * @returns the header
  62004. */
  62005. static GetTGAHeader(data: Uint8Array): any;
  62006. /**
  62007. * Uploads TGA content to a Babylon Texture
  62008. * @hidden
  62009. */
  62010. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62011. /** @hidden */
  62012. 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;
  62013. /** @hidden */
  62014. 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;
  62015. /** @hidden */
  62016. 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;
  62017. /** @hidden */
  62018. 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;
  62019. /** @hidden */
  62020. 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;
  62021. /** @hidden */
  62022. 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;
  62023. }
  62024. }
  62025. declare module BABYLON {
  62026. /**
  62027. * Implementation of the TGA Texture Loader.
  62028. * @hidden
  62029. */
  62030. export class _TGATextureLoader implements IInternalTextureLoader {
  62031. /**
  62032. * Defines wether the loader supports cascade loading the different faces.
  62033. */
  62034. readonly supportCascades: boolean;
  62035. /**
  62036. * This returns if the loader support the current file information.
  62037. * @param extension defines the file extension of the file being loaded
  62038. * @returns true if the loader can load the specified file
  62039. */
  62040. canLoad(extension: string): boolean;
  62041. /**
  62042. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62043. * @param data contains the texture data
  62044. * @param texture defines the BabylonJS internal texture
  62045. * @param createPolynomials will be true if polynomials have been requested
  62046. * @param onLoad defines the callback to trigger once the texture is ready
  62047. * @param onError defines the callback to trigger in case of error
  62048. */
  62049. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62050. /**
  62051. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62052. * @param data contains the texture data
  62053. * @param texture defines the BabylonJS internal texture
  62054. * @param callback defines the method to call once ready to upload
  62055. */
  62056. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62057. }
  62058. }
  62059. declare module BABYLON {
  62060. /**
  62061. * Info about the .basis files
  62062. */
  62063. class BasisFileInfo {
  62064. /**
  62065. * If the file has alpha
  62066. */
  62067. hasAlpha: boolean;
  62068. /**
  62069. * Info about each image of the basis file
  62070. */
  62071. images: Array<{
  62072. levels: Array<{
  62073. width: number;
  62074. height: number;
  62075. transcodedPixels: ArrayBufferView;
  62076. }>;
  62077. }>;
  62078. }
  62079. /**
  62080. * Result of transcoding a basis file
  62081. */
  62082. class TranscodeResult {
  62083. /**
  62084. * Info about the .basis file
  62085. */
  62086. fileInfo: BasisFileInfo;
  62087. /**
  62088. * Format to use when loading the file
  62089. */
  62090. format: number;
  62091. }
  62092. /**
  62093. * Configuration options for the Basis transcoder
  62094. */
  62095. export class BasisTranscodeConfiguration {
  62096. /**
  62097. * Supported compression formats used to determine the supported output format of the transcoder
  62098. */
  62099. supportedCompressionFormats?: {
  62100. /**
  62101. * etc1 compression format
  62102. */
  62103. etc1?: boolean;
  62104. /**
  62105. * s3tc compression format
  62106. */
  62107. s3tc?: boolean;
  62108. /**
  62109. * pvrtc compression format
  62110. */
  62111. pvrtc?: boolean;
  62112. /**
  62113. * etc2 compression format
  62114. */
  62115. etc2?: boolean;
  62116. };
  62117. /**
  62118. * If mipmap levels should be loaded for transcoded images (Default: true)
  62119. */
  62120. loadMipmapLevels?: boolean;
  62121. /**
  62122. * Index of a single image to load (Default: all images)
  62123. */
  62124. loadSingleImage?: number;
  62125. }
  62126. /**
  62127. * Used to load .Basis files
  62128. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62129. */
  62130. export class BasisTools {
  62131. private static _IgnoreSupportedFormats;
  62132. /**
  62133. * URL to use when loading the basis transcoder
  62134. */
  62135. static JSModuleURL: string;
  62136. /**
  62137. * URL to use when loading the wasm module for the transcoder
  62138. */
  62139. static WasmModuleURL: string;
  62140. /**
  62141. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62142. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62143. * @returns internal format corresponding to the Basis format
  62144. */
  62145. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62146. private static _WorkerPromise;
  62147. private static _Worker;
  62148. private static _actionId;
  62149. private static _CreateWorkerAsync;
  62150. /**
  62151. * Transcodes a loaded image file to compressed pixel data
  62152. * @param data image data to transcode
  62153. * @param config configuration options for the transcoding
  62154. * @returns a promise resulting in the transcoded image
  62155. */
  62156. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62157. /**
  62158. * Loads a texture from the transcode result
  62159. * @param texture texture load to
  62160. * @param transcodeResult the result of transcoding the basis file to load from
  62161. */
  62162. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62163. }
  62164. }
  62165. declare module BABYLON {
  62166. /**
  62167. * Loader for .basis file format
  62168. */
  62169. export class _BasisTextureLoader implements IInternalTextureLoader {
  62170. /**
  62171. * Defines whether the loader supports cascade loading the different faces.
  62172. */
  62173. readonly supportCascades: boolean;
  62174. /**
  62175. * This returns if the loader support the current file information.
  62176. * @param extension defines the file extension of the file being loaded
  62177. * @returns true if the loader can load the specified file
  62178. */
  62179. canLoad(extension: string): boolean;
  62180. /**
  62181. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62182. * @param data contains the texture data
  62183. * @param texture defines the BabylonJS internal texture
  62184. * @param createPolynomials will be true if polynomials have been requested
  62185. * @param onLoad defines the callback to trigger once the texture is ready
  62186. * @param onError defines the callback to trigger in case of error
  62187. */
  62188. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62189. /**
  62190. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62191. * @param data contains the texture data
  62192. * @param texture defines the BabylonJS internal texture
  62193. * @param callback defines the method to call once ready to upload
  62194. */
  62195. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62196. }
  62197. }
  62198. declare module BABYLON {
  62199. /**
  62200. * Defines the basic options interface of a TexturePacker Frame
  62201. */
  62202. export interface ITexturePackerFrame {
  62203. /**
  62204. * The frame ID
  62205. */
  62206. id: number;
  62207. /**
  62208. * The frames Scale
  62209. */
  62210. scale: Vector2;
  62211. /**
  62212. * The Frames offset
  62213. */
  62214. offset: Vector2;
  62215. }
  62216. /**
  62217. * This is a support class for frame Data on texture packer sets.
  62218. */
  62219. export class TexturePackerFrame implements ITexturePackerFrame {
  62220. /**
  62221. * The frame ID
  62222. */
  62223. id: number;
  62224. /**
  62225. * The frames Scale
  62226. */
  62227. scale: Vector2;
  62228. /**
  62229. * The Frames offset
  62230. */
  62231. offset: Vector2;
  62232. /**
  62233. * Initializes a texture package frame.
  62234. * @param id The numerical frame identifier
  62235. * @param scale Scalar Vector2 for UV frame
  62236. * @param offset Vector2 for the frame position in UV units.
  62237. * @returns TexturePackerFrame
  62238. */
  62239. constructor(id: number, scale: Vector2, offset: Vector2);
  62240. }
  62241. }
  62242. declare module BABYLON {
  62243. /**
  62244. * Defines the basic options interface of a TexturePacker
  62245. */
  62246. export interface ITexturePackerOptions {
  62247. /**
  62248. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62249. */
  62250. map?: string[];
  62251. /**
  62252. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62253. */
  62254. uvsIn?: string;
  62255. /**
  62256. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62257. */
  62258. uvsOut?: string;
  62259. /**
  62260. * number representing the layout style. Defaults to LAYOUT_STRIP
  62261. */
  62262. layout?: number;
  62263. /**
  62264. * number of columns if using custom column count layout(2). This defaults to 4.
  62265. */
  62266. colnum?: number;
  62267. /**
  62268. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62269. */
  62270. updateInputMeshes?: boolean;
  62271. /**
  62272. * boolean flag to dispose all the source textures. Defaults to true.
  62273. */
  62274. disposeSources?: boolean;
  62275. /**
  62276. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62277. */
  62278. fillBlanks?: boolean;
  62279. /**
  62280. * string value representing the context fill style color. Defaults to 'black'.
  62281. */
  62282. customFillColor?: string;
  62283. /**
  62284. * Width and Height Value of each Frame in the TexturePacker Sets
  62285. */
  62286. frameSize?: number;
  62287. /**
  62288. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62289. */
  62290. paddingRatio?: number;
  62291. /**
  62292. * Number that declares the fill method for the padding gutter.
  62293. */
  62294. paddingMode?: number;
  62295. /**
  62296. * If in SUBUV_COLOR padding mode what color to use.
  62297. */
  62298. paddingColor?: Color3 | Color4;
  62299. }
  62300. /**
  62301. * Defines the basic interface of a TexturePacker JSON File
  62302. */
  62303. export interface ITexturePackerJSON {
  62304. /**
  62305. * The frame ID
  62306. */
  62307. name: string;
  62308. /**
  62309. * The base64 channel data
  62310. */
  62311. sets: any;
  62312. /**
  62313. * The options of the Packer
  62314. */
  62315. options: ITexturePackerOptions;
  62316. /**
  62317. * The frame data of the Packer
  62318. */
  62319. frames: Array<number>;
  62320. }
  62321. /**
  62322. * This is a support class that generates a series of packed texture sets.
  62323. * @see https://doc.babylonjs.com/babylon101/materials
  62324. */
  62325. export class TexturePacker {
  62326. /** Packer Layout Constant 0 */
  62327. static readonly LAYOUT_STRIP: number;
  62328. /** Packer Layout Constant 1 */
  62329. static readonly LAYOUT_POWER2: number;
  62330. /** Packer Layout Constant 2 */
  62331. static readonly LAYOUT_COLNUM: number;
  62332. /** Packer Layout Constant 0 */
  62333. static readonly SUBUV_WRAP: number;
  62334. /** Packer Layout Constant 1 */
  62335. static readonly SUBUV_EXTEND: number;
  62336. /** Packer Layout Constant 2 */
  62337. static readonly SUBUV_COLOR: number;
  62338. /** The Name of the Texture Package */
  62339. name: string;
  62340. /** The scene scope of the TexturePacker */
  62341. scene: Scene;
  62342. /** The Meshes to target */
  62343. meshes: AbstractMesh[];
  62344. /** Arguments passed with the Constructor */
  62345. options: ITexturePackerOptions;
  62346. /** The promise that is started upon initialization */
  62347. promise: Nullable<Promise<TexturePacker | string>>;
  62348. /** The Container object for the channel sets that are generated */
  62349. sets: object;
  62350. /** The Container array for the frames that are generated */
  62351. frames: TexturePackerFrame[];
  62352. /** The expected number of textures the system is parsing. */
  62353. private _expecting;
  62354. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62355. private _paddingValue;
  62356. /**
  62357. * Initializes a texture package series from an array of meshes or a single mesh.
  62358. * @param name The name of the package
  62359. * @param meshes The target meshes to compose the package from
  62360. * @param options The arguments that texture packer should follow while building.
  62361. * @param scene The scene which the textures are scoped to.
  62362. * @returns TexturePacker
  62363. */
  62364. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62365. /**
  62366. * Starts the package process
  62367. * @param resolve The promises resolution function
  62368. * @returns TexturePacker
  62369. */
  62370. private _createFrames;
  62371. /**
  62372. * Calculates the Size of the Channel Sets
  62373. * @returns Vector2
  62374. */
  62375. private _calculateSize;
  62376. /**
  62377. * Calculates the UV data for the frames.
  62378. * @param baseSize the base frameSize
  62379. * @param padding the base frame padding
  62380. * @param dtSize size of the Dynamic Texture for that channel
  62381. * @param dtUnits is 1/dtSize
  62382. * @param update flag to update the input meshes
  62383. */
  62384. private _calculateMeshUVFrames;
  62385. /**
  62386. * Calculates the frames Offset.
  62387. * @param index of the frame
  62388. * @returns Vector2
  62389. */
  62390. private _getFrameOffset;
  62391. /**
  62392. * Updates a Mesh to the frame data
  62393. * @param mesh that is the target
  62394. * @param frameID or the frame index
  62395. */
  62396. private _updateMeshUV;
  62397. /**
  62398. * Updates a Meshes materials to use the texture packer channels
  62399. * @param m is the mesh to target
  62400. * @param force all channels on the packer to be set.
  62401. */
  62402. private _updateTextureReferences;
  62403. /**
  62404. * Public method to set a Mesh to a frame
  62405. * @param m that is the target
  62406. * @param frameID or the frame index
  62407. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62408. */
  62409. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62410. /**
  62411. * Starts the async promise to compile the texture packer.
  62412. * @returns Promise<void>
  62413. */
  62414. processAsync(): Promise<void>;
  62415. /**
  62416. * Disposes all textures associated with this packer
  62417. */
  62418. dispose(): void;
  62419. /**
  62420. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62421. * @param imageType is the image type to use.
  62422. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62423. */
  62424. download(imageType?: string, quality?: number): void;
  62425. /**
  62426. * Public method to load a texturePacker JSON file.
  62427. * @param data of the JSON file in string format.
  62428. */
  62429. updateFromJSON(data: string): void;
  62430. }
  62431. }
  62432. declare module BABYLON {
  62433. /**
  62434. * 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.
  62435. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62436. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62437. */
  62438. export class CustomProceduralTexture extends ProceduralTexture {
  62439. private _animate;
  62440. private _time;
  62441. private _config;
  62442. private _texturePath;
  62443. /**
  62444. * Instantiates a new Custom Procedural Texture.
  62445. * 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.
  62446. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62447. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62448. * @param name Define the name of the texture
  62449. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62450. * @param size Define the size of the texture to create
  62451. * @param scene Define the scene the texture belongs to
  62452. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62453. * @param generateMipMaps Define if the texture should creates mip maps or not
  62454. */
  62455. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62456. private _loadJson;
  62457. /**
  62458. * Is the texture ready to be used ? (rendered at least once)
  62459. * @returns true if ready, otherwise, false.
  62460. */
  62461. isReady(): boolean;
  62462. /**
  62463. * Render the texture to its associated render target.
  62464. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62465. */
  62466. render(useCameraPostProcess?: boolean): void;
  62467. /**
  62468. * Update the list of dependant textures samplers in the shader.
  62469. */
  62470. updateTextures(): void;
  62471. /**
  62472. * Update the uniform values of the procedural texture in the shader.
  62473. */
  62474. updateShaderUniforms(): void;
  62475. /**
  62476. * Define if the texture animates or not.
  62477. */
  62478. get animate(): boolean;
  62479. set animate(value: boolean);
  62480. }
  62481. }
  62482. declare module BABYLON {
  62483. /** @hidden */
  62484. export var noisePixelShader: {
  62485. name: string;
  62486. shader: string;
  62487. };
  62488. }
  62489. declare module BABYLON {
  62490. /**
  62491. * Class used to generate noise procedural textures
  62492. */
  62493. export class NoiseProceduralTexture extends ProceduralTexture {
  62494. /** Gets or sets the start time (default is 0) */
  62495. time: number;
  62496. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62497. brightness: number;
  62498. /** Defines the number of octaves to process */
  62499. octaves: number;
  62500. /** Defines the level of persistence (0.8 by default) */
  62501. persistence: number;
  62502. /** Gets or sets animation speed factor (default is 1) */
  62503. animationSpeedFactor: number;
  62504. /**
  62505. * Creates a new NoiseProceduralTexture
  62506. * @param name defines the name fo the texture
  62507. * @param size defines the size of the texture (default is 256)
  62508. * @param scene defines the hosting scene
  62509. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62510. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62511. */
  62512. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62513. private _updateShaderUniforms;
  62514. protected _getDefines(): string;
  62515. /** Generate the current state of the procedural texture */
  62516. render(useCameraPostProcess?: boolean): void;
  62517. /**
  62518. * Serializes this noise procedural texture
  62519. * @returns a serialized noise procedural texture object
  62520. */
  62521. serialize(): any;
  62522. /**
  62523. * Clone the texture.
  62524. * @returns the cloned texture
  62525. */
  62526. clone(): NoiseProceduralTexture;
  62527. /**
  62528. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62529. * @param parsedTexture defines parsed texture data
  62530. * @param scene defines the current scene
  62531. * @param rootUrl defines the root URL containing noise procedural texture information
  62532. * @returns a parsed NoiseProceduralTexture
  62533. */
  62534. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62535. }
  62536. }
  62537. declare module BABYLON {
  62538. /**
  62539. * Raw cube texture where the raw buffers are passed in
  62540. */
  62541. export class RawCubeTexture extends CubeTexture {
  62542. /**
  62543. * Creates a cube texture where the raw buffers are passed in.
  62544. * @param scene defines the scene the texture is attached to
  62545. * @param data defines the array of data to use to create each face
  62546. * @param size defines the size of the textures
  62547. * @param format defines the format of the data
  62548. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62549. * @param generateMipMaps defines if the engine should generate the mip levels
  62550. * @param invertY defines if data must be stored with Y axis inverted
  62551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62552. * @param compression defines the compression used (null by default)
  62553. */
  62554. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62555. /**
  62556. * Updates the raw cube texture.
  62557. * @param data defines the data to store
  62558. * @param format defines the data format
  62559. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62560. * @param invertY defines if data must be stored with Y axis inverted
  62561. * @param compression defines the compression used (null by default)
  62562. * @param level defines which level of the texture to update
  62563. */
  62564. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62565. /**
  62566. * Updates a raw cube texture with RGBD encoded data.
  62567. * @param data defines the array of data [mipmap][face] to use to create each face
  62568. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62571. * @returns a promsie that resolves when the operation is complete
  62572. */
  62573. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62574. /**
  62575. * Clones the raw cube texture.
  62576. * @return a new cube texture
  62577. */
  62578. clone(): CubeTexture;
  62579. /** @hidden */
  62580. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62581. }
  62582. }
  62583. declare module BABYLON {
  62584. /**
  62585. * Class used to store 2D array textures containing user data
  62586. */
  62587. export class RawTexture2DArray extends Texture {
  62588. /** Gets or sets the texture format to use */
  62589. format: number;
  62590. /**
  62591. * Create a new RawTexture2DArray
  62592. * @param data defines the data of the texture
  62593. * @param width defines the width of the texture
  62594. * @param height defines the height of the texture
  62595. * @param depth defines the number of layers of the texture
  62596. * @param format defines the texture format to use
  62597. * @param scene defines the hosting scene
  62598. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62599. * @param invertY defines if texture must be stored with Y axis inverted
  62600. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62601. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62602. */
  62603. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62604. /** Gets or sets the texture format to use */
  62605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62606. /**
  62607. * Update the texture with new data
  62608. * @param data defines the data to store in the texture
  62609. */
  62610. update(data: ArrayBufferView): void;
  62611. }
  62612. }
  62613. declare module BABYLON {
  62614. /**
  62615. * Class used to store 3D textures containing user data
  62616. */
  62617. export class RawTexture3D extends Texture {
  62618. /** Gets or sets the texture format to use */
  62619. format: number;
  62620. /**
  62621. * Create a new RawTexture3D
  62622. * @param data defines the data of the texture
  62623. * @param width defines the width of the texture
  62624. * @param height defines the height of the texture
  62625. * @param depth defines the depth of the texture
  62626. * @param format defines the texture format to use
  62627. * @param scene defines the hosting scene
  62628. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62629. * @param invertY defines if texture must be stored with Y axis inverted
  62630. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62631. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62632. */
  62633. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62634. /** Gets or sets the texture format to use */
  62635. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62636. /**
  62637. * Update the texture with new data
  62638. * @param data defines the data to store in the texture
  62639. */
  62640. update(data: ArrayBufferView): void;
  62641. }
  62642. }
  62643. declare module BABYLON {
  62644. /**
  62645. * Creates a refraction texture used by refraction channel of the standard material.
  62646. * It is like a mirror but to see through a material.
  62647. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62648. */
  62649. export class RefractionTexture extends RenderTargetTexture {
  62650. /**
  62651. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62652. * 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.
  62653. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62654. */
  62655. refractionPlane: Plane;
  62656. /**
  62657. * Define how deep under the surface we should see.
  62658. */
  62659. depth: number;
  62660. /**
  62661. * Creates a refraction texture used by refraction channel of the standard material.
  62662. * It is like a mirror but to see through a material.
  62663. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62664. * @param name Define the texture name
  62665. * @param size Define the size of the underlying texture
  62666. * @param scene Define the scene the refraction belongs to
  62667. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62668. */
  62669. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62670. /**
  62671. * Clone the refraction texture.
  62672. * @returns the cloned texture
  62673. */
  62674. clone(): RefractionTexture;
  62675. /**
  62676. * Serialize the texture to a JSON representation you could use in Parse later on
  62677. * @returns the serialized JSON representation
  62678. */
  62679. serialize(): any;
  62680. }
  62681. }
  62682. declare module BABYLON {
  62683. /**
  62684. * Block used to add support for vertex skinning (bones)
  62685. */
  62686. export class BonesBlock extends NodeMaterialBlock {
  62687. /**
  62688. * Creates a new BonesBlock
  62689. * @param name defines the block name
  62690. */
  62691. constructor(name: string);
  62692. /**
  62693. * Initialize the block and prepare the context for build
  62694. * @param state defines the state that will be used for the build
  62695. */
  62696. initialize(state: NodeMaterialBuildState): void;
  62697. /**
  62698. * Gets the current class name
  62699. * @returns the class name
  62700. */
  62701. getClassName(): string;
  62702. /**
  62703. * Gets the matrix indices input component
  62704. */
  62705. get matricesIndices(): NodeMaterialConnectionPoint;
  62706. /**
  62707. * Gets the matrix weights input component
  62708. */
  62709. get matricesWeights(): NodeMaterialConnectionPoint;
  62710. /**
  62711. * Gets the extra matrix indices input component
  62712. */
  62713. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62714. /**
  62715. * Gets the extra matrix weights input component
  62716. */
  62717. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62718. /**
  62719. * Gets the world input component
  62720. */
  62721. get world(): NodeMaterialConnectionPoint;
  62722. /**
  62723. * Gets the output component
  62724. */
  62725. get output(): NodeMaterialConnectionPoint;
  62726. autoConfigure(material: NodeMaterial): void;
  62727. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62728. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62730. protected _buildBlock(state: NodeMaterialBuildState): this;
  62731. }
  62732. }
  62733. declare module BABYLON {
  62734. /**
  62735. * Block used to add support for instances
  62736. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62737. */
  62738. export class InstancesBlock extends NodeMaterialBlock {
  62739. /**
  62740. * Creates a new InstancesBlock
  62741. * @param name defines the block name
  62742. */
  62743. constructor(name: string);
  62744. /**
  62745. * Gets the current class name
  62746. * @returns the class name
  62747. */
  62748. getClassName(): string;
  62749. /**
  62750. * Gets the first world row input component
  62751. */
  62752. get world0(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the second world row input component
  62755. */
  62756. get world1(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the third world row input component
  62759. */
  62760. get world2(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the forth world row input component
  62763. */
  62764. get world3(): NodeMaterialConnectionPoint;
  62765. /**
  62766. * Gets the world input component
  62767. */
  62768. get world(): NodeMaterialConnectionPoint;
  62769. /**
  62770. * Gets the output component
  62771. */
  62772. get output(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the isntanceID component
  62775. */
  62776. get instanceID(): NodeMaterialConnectionPoint;
  62777. autoConfigure(material: NodeMaterial): void;
  62778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62779. protected _buildBlock(state: NodeMaterialBuildState): this;
  62780. }
  62781. }
  62782. declare module BABYLON {
  62783. /**
  62784. * Block used to add morph targets support to vertex shader
  62785. */
  62786. export class MorphTargetsBlock extends NodeMaterialBlock {
  62787. private _repeatableContentAnchor;
  62788. /**
  62789. * Create a new MorphTargetsBlock
  62790. * @param name defines the block name
  62791. */
  62792. constructor(name: string);
  62793. /**
  62794. * Gets the current class name
  62795. * @returns the class name
  62796. */
  62797. getClassName(): string;
  62798. /**
  62799. * Gets the position input component
  62800. */
  62801. get position(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the normal input component
  62804. */
  62805. get normal(): NodeMaterialConnectionPoint;
  62806. /**
  62807. * Gets the tangent input component
  62808. */
  62809. get tangent(): NodeMaterialConnectionPoint;
  62810. /**
  62811. * Gets the tangent input component
  62812. */
  62813. get uv(): NodeMaterialConnectionPoint;
  62814. /**
  62815. * Gets the position output component
  62816. */
  62817. get positionOutput(): NodeMaterialConnectionPoint;
  62818. /**
  62819. * Gets the normal output component
  62820. */
  62821. get normalOutput(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the tangent output component
  62824. */
  62825. get tangentOutput(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the tangent output component
  62828. */
  62829. get uvOutput(): NodeMaterialConnectionPoint;
  62830. initialize(state: NodeMaterialBuildState): void;
  62831. autoConfigure(material: NodeMaterial): void;
  62832. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62834. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62835. protected _buildBlock(state: NodeMaterialBuildState): this;
  62836. }
  62837. }
  62838. declare module BABYLON {
  62839. /**
  62840. * Block used to get data information from a light
  62841. */
  62842. export class LightInformationBlock extends NodeMaterialBlock {
  62843. private _lightDataUniformName;
  62844. private _lightColorUniformName;
  62845. private _lightTypeDefineName;
  62846. /**
  62847. * Gets or sets the light associated with this block
  62848. */
  62849. light: Nullable<Light>;
  62850. /**
  62851. * Creates a new LightInformationBlock
  62852. * @param name defines the block name
  62853. */
  62854. constructor(name: string);
  62855. /**
  62856. * Gets the current class name
  62857. * @returns the class name
  62858. */
  62859. getClassName(): string;
  62860. /**
  62861. * Gets the world position input component
  62862. */
  62863. get worldPosition(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the direction output component
  62866. */
  62867. get direction(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the direction output component
  62870. */
  62871. get color(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the direction output component
  62874. */
  62875. get intensity(): NodeMaterialConnectionPoint;
  62876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62878. protected _buildBlock(state: NodeMaterialBuildState): this;
  62879. serialize(): any;
  62880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62881. }
  62882. }
  62883. declare module BABYLON {
  62884. /**
  62885. * Block used to add image processing support to fragment shader
  62886. */
  62887. export class ImageProcessingBlock extends NodeMaterialBlock {
  62888. /**
  62889. * Create a new ImageProcessingBlock
  62890. * @param name defines the block name
  62891. */
  62892. constructor(name: string);
  62893. /**
  62894. * Gets the current class name
  62895. * @returns the class name
  62896. */
  62897. getClassName(): string;
  62898. /**
  62899. * Gets the color input component
  62900. */
  62901. get color(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Initialize the block and prepare the context for build
  62908. * @param state defines the state that will be used for the build
  62909. */
  62910. initialize(state: NodeMaterialBuildState): void;
  62911. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62913. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62914. protected _buildBlock(state: NodeMaterialBuildState): this;
  62915. }
  62916. }
  62917. declare module BABYLON {
  62918. /**
  62919. * Block used to pertub normals based on a normal map
  62920. */
  62921. export class PerturbNormalBlock extends NodeMaterialBlock {
  62922. private _tangentSpaceParameterName;
  62923. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62924. invertX: boolean;
  62925. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62926. invertY: boolean;
  62927. /**
  62928. * Create a new PerturbNormalBlock
  62929. * @param name defines the block name
  62930. */
  62931. constructor(name: string);
  62932. /**
  62933. * Gets the current class name
  62934. * @returns the class name
  62935. */
  62936. getClassName(): string;
  62937. /**
  62938. * Gets the world position input component
  62939. */
  62940. get worldPosition(): NodeMaterialConnectionPoint;
  62941. /**
  62942. * Gets the world normal input component
  62943. */
  62944. get worldNormal(): NodeMaterialConnectionPoint;
  62945. /**
  62946. * Gets the world tangent input component
  62947. */
  62948. get worldTangent(): NodeMaterialConnectionPoint;
  62949. /**
  62950. * Gets the uv input component
  62951. */
  62952. get uv(): NodeMaterialConnectionPoint;
  62953. /**
  62954. * Gets the normal map color input component
  62955. */
  62956. get normalMapColor(): NodeMaterialConnectionPoint;
  62957. /**
  62958. * Gets the strength input component
  62959. */
  62960. get strength(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the output component
  62963. */
  62964. get output(): NodeMaterialConnectionPoint;
  62965. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62967. autoConfigure(material: NodeMaterial): void;
  62968. protected _buildBlock(state: NodeMaterialBuildState): this;
  62969. protected _dumpPropertiesCode(): string;
  62970. serialize(): any;
  62971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Block used to discard a pixel if a value is smaller than a cutoff
  62977. */
  62978. export class DiscardBlock extends NodeMaterialBlock {
  62979. /**
  62980. * Create a new DiscardBlock
  62981. * @param name defines the block name
  62982. */
  62983. constructor(name: string);
  62984. /**
  62985. * Gets the current class name
  62986. * @returns the class name
  62987. */
  62988. getClassName(): string;
  62989. /**
  62990. * Gets the color input component
  62991. */
  62992. get value(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the cutoff input component
  62995. */
  62996. get cutoff(): NodeMaterialConnectionPoint;
  62997. protected _buildBlock(state: NodeMaterialBuildState): this;
  62998. }
  62999. }
  63000. declare module BABYLON {
  63001. /**
  63002. * Block used to test if the fragment shader is front facing
  63003. */
  63004. export class FrontFacingBlock extends NodeMaterialBlock {
  63005. /**
  63006. * Creates a new FrontFacingBlock
  63007. * @param name defines the block name
  63008. */
  63009. constructor(name: string);
  63010. /**
  63011. * Gets the current class name
  63012. * @returns the class name
  63013. */
  63014. getClassName(): string;
  63015. /**
  63016. * Gets the output component
  63017. */
  63018. get output(): NodeMaterialConnectionPoint;
  63019. protected _buildBlock(state: NodeMaterialBuildState): this;
  63020. }
  63021. }
  63022. declare module BABYLON {
  63023. /**
  63024. * Block used to get the derivative value on x and y of a given input
  63025. */
  63026. export class DerivativeBlock extends NodeMaterialBlock {
  63027. /**
  63028. * Create a new DerivativeBlock
  63029. * @param name defines the block name
  63030. */
  63031. constructor(name: string);
  63032. /**
  63033. * Gets the current class name
  63034. * @returns the class name
  63035. */
  63036. getClassName(): string;
  63037. /**
  63038. * Gets the input component
  63039. */
  63040. get input(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the derivative output on x
  63043. */
  63044. get dx(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the derivative output on y
  63047. */
  63048. get dy(): NodeMaterialConnectionPoint;
  63049. protected _buildBlock(state: NodeMaterialBuildState): this;
  63050. }
  63051. }
  63052. declare module BABYLON {
  63053. /**
  63054. * Block used to make gl_FragCoord available
  63055. */
  63056. export class FragCoordBlock extends NodeMaterialBlock {
  63057. /**
  63058. * Creates a new FragCoordBlock
  63059. * @param name defines the block name
  63060. */
  63061. constructor(name: string);
  63062. /**
  63063. * Gets the current class name
  63064. * @returns the class name
  63065. */
  63066. getClassName(): string;
  63067. /**
  63068. * Gets the xy component
  63069. */
  63070. get xy(): NodeMaterialConnectionPoint;
  63071. /**
  63072. * Gets the xyz component
  63073. */
  63074. get xyz(): NodeMaterialConnectionPoint;
  63075. /**
  63076. * Gets the xyzw component
  63077. */
  63078. get xyzw(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the x component
  63081. */
  63082. get x(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the y component
  63085. */
  63086. get y(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the z component
  63089. */
  63090. get z(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the w component
  63093. */
  63094. get output(): NodeMaterialConnectionPoint;
  63095. protected writeOutputs(state: NodeMaterialBuildState): string;
  63096. protected _buildBlock(state: NodeMaterialBuildState): this;
  63097. }
  63098. }
  63099. declare module BABYLON {
  63100. /**
  63101. * Block used to get the screen sizes
  63102. */
  63103. export class ScreenSizeBlock extends NodeMaterialBlock {
  63104. private _varName;
  63105. private _scene;
  63106. /**
  63107. * Creates a new ScreenSizeBlock
  63108. * @param name defines the block name
  63109. */
  63110. constructor(name: string);
  63111. /**
  63112. * Gets the current class name
  63113. * @returns the class name
  63114. */
  63115. getClassName(): string;
  63116. /**
  63117. * Gets the xy component
  63118. */
  63119. get xy(): NodeMaterialConnectionPoint;
  63120. /**
  63121. * Gets the x component
  63122. */
  63123. get x(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the y component
  63126. */
  63127. get y(): NodeMaterialConnectionPoint;
  63128. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63129. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63130. protected _buildBlock(state: NodeMaterialBuildState): this;
  63131. }
  63132. }
  63133. declare module BABYLON {
  63134. /**
  63135. * Block used to add support for scene fog
  63136. */
  63137. export class FogBlock extends NodeMaterialBlock {
  63138. private _fogDistanceName;
  63139. private _fogParameters;
  63140. /**
  63141. * Create a new FogBlock
  63142. * @param name defines the block name
  63143. */
  63144. constructor(name: string);
  63145. /**
  63146. * Gets the current class name
  63147. * @returns the class name
  63148. */
  63149. getClassName(): string;
  63150. /**
  63151. * Gets the world position input component
  63152. */
  63153. get worldPosition(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the view input component
  63156. */
  63157. get view(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the color input component
  63160. */
  63161. get input(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the fog color input component
  63164. */
  63165. get fogColor(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the output component
  63168. */
  63169. get output(): NodeMaterialConnectionPoint;
  63170. autoConfigure(material: NodeMaterial): void;
  63171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63173. protected _buildBlock(state: NodeMaterialBuildState): this;
  63174. }
  63175. }
  63176. declare module BABYLON {
  63177. /**
  63178. * Block used to add light in the fragment shader
  63179. */
  63180. export class LightBlock extends NodeMaterialBlock {
  63181. private _lightId;
  63182. /**
  63183. * Gets or sets the light associated with this block
  63184. */
  63185. light: Nullable<Light>;
  63186. /**
  63187. * Create a new LightBlock
  63188. * @param name defines the block name
  63189. */
  63190. constructor(name: string);
  63191. /**
  63192. * Gets the current class name
  63193. * @returns the class name
  63194. */
  63195. getClassName(): string;
  63196. /**
  63197. * Gets the world position input component
  63198. */
  63199. get worldPosition(): NodeMaterialConnectionPoint;
  63200. /**
  63201. * Gets the world normal input component
  63202. */
  63203. get worldNormal(): NodeMaterialConnectionPoint;
  63204. /**
  63205. * Gets the camera (or eye) position component
  63206. */
  63207. get cameraPosition(): NodeMaterialConnectionPoint;
  63208. /**
  63209. * Gets the glossiness component
  63210. */
  63211. get glossiness(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the glossinness power component
  63214. */
  63215. get glossPower(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the diffuse color component
  63218. */
  63219. get diffuseColor(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the specular color component
  63222. */
  63223. get specularColor(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the diffuse output component
  63226. */
  63227. get diffuseOutput(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the specular output component
  63230. */
  63231. get specularOutput(): NodeMaterialConnectionPoint;
  63232. /**
  63233. * Gets the shadow output component
  63234. */
  63235. get shadow(): NodeMaterialConnectionPoint;
  63236. autoConfigure(material: NodeMaterial): void;
  63237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63238. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63240. private _injectVertexCode;
  63241. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63242. serialize(): any;
  63243. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63244. }
  63245. }
  63246. declare module BABYLON {
  63247. /**
  63248. * Block used to read a reflection texture from a sampler
  63249. */
  63250. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63251. /**
  63252. * Create a new ReflectionTextureBlock
  63253. * @param name defines the block name
  63254. */
  63255. constructor(name: string);
  63256. /**
  63257. * Gets the current class name
  63258. * @returns the class name
  63259. */
  63260. getClassName(): string;
  63261. /**
  63262. * Gets the world position input component
  63263. */
  63264. get position(): NodeMaterialConnectionPoint;
  63265. /**
  63266. * Gets the world position input component
  63267. */
  63268. get worldPosition(): NodeMaterialConnectionPoint;
  63269. /**
  63270. * Gets the world normal input component
  63271. */
  63272. get worldNormal(): NodeMaterialConnectionPoint;
  63273. /**
  63274. * Gets the world input component
  63275. */
  63276. get world(): NodeMaterialConnectionPoint;
  63277. /**
  63278. * Gets the camera (or eye) position component
  63279. */
  63280. get cameraPosition(): NodeMaterialConnectionPoint;
  63281. /**
  63282. * Gets the view input component
  63283. */
  63284. get view(): NodeMaterialConnectionPoint;
  63285. /**
  63286. * Gets the rgb output component
  63287. */
  63288. get rgb(): NodeMaterialConnectionPoint;
  63289. /**
  63290. * Gets the rgba output component
  63291. */
  63292. get rgba(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the r output component
  63295. */
  63296. get r(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the g output component
  63299. */
  63300. get g(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the b output component
  63303. */
  63304. get b(): NodeMaterialConnectionPoint;
  63305. /**
  63306. * Gets the a output component
  63307. */
  63308. get a(): NodeMaterialConnectionPoint;
  63309. autoConfigure(material: NodeMaterial): void;
  63310. protected _buildBlock(state: NodeMaterialBuildState): this;
  63311. }
  63312. }
  63313. declare module BABYLON {
  63314. /**
  63315. * Block used to add 2 vectors
  63316. */
  63317. export class AddBlock extends NodeMaterialBlock {
  63318. /**
  63319. * Creates a new AddBlock
  63320. * @param name defines the block name
  63321. */
  63322. constructor(name: string);
  63323. /**
  63324. * Gets the current class name
  63325. * @returns the class name
  63326. */
  63327. getClassName(): string;
  63328. /**
  63329. * Gets the left operand input component
  63330. */
  63331. get left(): NodeMaterialConnectionPoint;
  63332. /**
  63333. * Gets the right operand input component
  63334. */
  63335. get right(): NodeMaterialConnectionPoint;
  63336. /**
  63337. * Gets the output component
  63338. */
  63339. get output(): NodeMaterialConnectionPoint;
  63340. protected _buildBlock(state: NodeMaterialBuildState): this;
  63341. }
  63342. }
  63343. declare module BABYLON {
  63344. /**
  63345. * Block used to scale a vector by a float
  63346. */
  63347. export class ScaleBlock extends NodeMaterialBlock {
  63348. /**
  63349. * Creates a new ScaleBlock
  63350. * @param name defines the block name
  63351. */
  63352. constructor(name: string);
  63353. /**
  63354. * Gets the current class name
  63355. * @returns the class name
  63356. */
  63357. getClassName(): string;
  63358. /**
  63359. * Gets the input component
  63360. */
  63361. get input(): NodeMaterialConnectionPoint;
  63362. /**
  63363. * Gets the factor input component
  63364. */
  63365. get factor(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the output component
  63368. */
  63369. get output(): NodeMaterialConnectionPoint;
  63370. protected _buildBlock(state: NodeMaterialBuildState): this;
  63371. }
  63372. }
  63373. declare module BABYLON {
  63374. /**
  63375. * Block used to clamp a float
  63376. */
  63377. export class ClampBlock extends NodeMaterialBlock {
  63378. /** Gets or sets the minimum range */
  63379. minimum: number;
  63380. /** Gets or sets the maximum range */
  63381. maximum: number;
  63382. /**
  63383. * Creates a new ClampBlock
  63384. * @param name defines the block name
  63385. */
  63386. constructor(name: string);
  63387. /**
  63388. * Gets the current class name
  63389. * @returns the class name
  63390. */
  63391. getClassName(): string;
  63392. /**
  63393. * Gets the value input component
  63394. */
  63395. get value(): NodeMaterialConnectionPoint;
  63396. /**
  63397. * Gets the output component
  63398. */
  63399. get output(): NodeMaterialConnectionPoint;
  63400. protected _buildBlock(state: NodeMaterialBuildState): this;
  63401. protected _dumpPropertiesCode(): string;
  63402. serialize(): any;
  63403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63404. }
  63405. }
  63406. declare module BABYLON {
  63407. /**
  63408. * Block used to apply a cross product between 2 vectors
  63409. */
  63410. export class CrossBlock extends NodeMaterialBlock {
  63411. /**
  63412. * Creates a new CrossBlock
  63413. * @param name defines the block name
  63414. */
  63415. constructor(name: string);
  63416. /**
  63417. * Gets the current class name
  63418. * @returns the class name
  63419. */
  63420. getClassName(): string;
  63421. /**
  63422. * Gets the left operand input component
  63423. */
  63424. get left(): NodeMaterialConnectionPoint;
  63425. /**
  63426. * Gets the right operand input component
  63427. */
  63428. get right(): NodeMaterialConnectionPoint;
  63429. /**
  63430. * Gets the output component
  63431. */
  63432. get output(): NodeMaterialConnectionPoint;
  63433. protected _buildBlock(state: NodeMaterialBuildState): this;
  63434. }
  63435. }
  63436. declare module BABYLON {
  63437. /**
  63438. * Block used to apply a dot product between 2 vectors
  63439. */
  63440. export class DotBlock extends NodeMaterialBlock {
  63441. /**
  63442. * Creates a new DotBlock
  63443. * @param name defines the block name
  63444. */
  63445. constructor(name: string);
  63446. /**
  63447. * Gets the current class name
  63448. * @returns the class name
  63449. */
  63450. getClassName(): string;
  63451. /**
  63452. * Gets the left operand input component
  63453. */
  63454. get left(): NodeMaterialConnectionPoint;
  63455. /**
  63456. * Gets the right operand input component
  63457. */
  63458. get right(): NodeMaterialConnectionPoint;
  63459. /**
  63460. * Gets the output component
  63461. */
  63462. get output(): NodeMaterialConnectionPoint;
  63463. protected _buildBlock(state: NodeMaterialBuildState): this;
  63464. }
  63465. }
  63466. declare module BABYLON {
  63467. /**
  63468. * Block used to normalize a vector
  63469. */
  63470. export class NormalizeBlock extends NodeMaterialBlock {
  63471. /**
  63472. * Creates a new NormalizeBlock
  63473. * @param name defines the block name
  63474. */
  63475. constructor(name: string);
  63476. /**
  63477. * Gets the current class name
  63478. * @returns the class name
  63479. */
  63480. getClassName(): string;
  63481. /**
  63482. * Gets the input component
  63483. */
  63484. get input(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the output component
  63487. */
  63488. get output(): NodeMaterialConnectionPoint;
  63489. protected _buildBlock(state: NodeMaterialBuildState): this;
  63490. }
  63491. }
  63492. declare module BABYLON {
  63493. /**
  63494. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63495. */
  63496. export class ColorMergerBlock extends NodeMaterialBlock {
  63497. /**
  63498. * Create a new ColorMergerBlock
  63499. * @param name defines the block name
  63500. */
  63501. constructor(name: string);
  63502. /**
  63503. * Gets the current class name
  63504. * @returns the class name
  63505. */
  63506. getClassName(): string;
  63507. /**
  63508. * Gets the rgb component (input)
  63509. */
  63510. get rgbIn(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the r component (input)
  63513. */
  63514. get r(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the g component (input)
  63517. */
  63518. get g(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the b component (input)
  63521. */
  63522. get b(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the a component (input)
  63525. */
  63526. get a(): NodeMaterialConnectionPoint;
  63527. /**
  63528. * Gets the rgba component (output)
  63529. */
  63530. get rgba(): NodeMaterialConnectionPoint;
  63531. /**
  63532. * Gets the rgb component (output)
  63533. */
  63534. get rgbOut(): NodeMaterialConnectionPoint;
  63535. /**
  63536. * Gets the rgb component (output)
  63537. * @deprecated Please use rgbOut instead.
  63538. */
  63539. get rgb(): NodeMaterialConnectionPoint;
  63540. protected _buildBlock(state: NodeMaterialBuildState): this;
  63541. }
  63542. }
  63543. declare module BABYLON {
  63544. /**
  63545. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63546. */
  63547. export class VectorSplitterBlock extends NodeMaterialBlock {
  63548. /**
  63549. * Create a new VectorSplitterBlock
  63550. * @param name defines the block name
  63551. */
  63552. constructor(name: string);
  63553. /**
  63554. * Gets the current class name
  63555. * @returns the class name
  63556. */
  63557. getClassName(): string;
  63558. /**
  63559. * Gets the xyzw component (input)
  63560. */
  63561. get xyzw(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the xyz component (input)
  63564. */
  63565. get xyzIn(): NodeMaterialConnectionPoint;
  63566. /**
  63567. * Gets the xy component (input)
  63568. */
  63569. get xyIn(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the xyz component (output)
  63572. */
  63573. get xyzOut(): NodeMaterialConnectionPoint;
  63574. /**
  63575. * Gets the xy component (output)
  63576. */
  63577. get xyOut(): NodeMaterialConnectionPoint;
  63578. /**
  63579. * Gets the x component (output)
  63580. */
  63581. get x(): NodeMaterialConnectionPoint;
  63582. /**
  63583. * Gets the y component (output)
  63584. */
  63585. get y(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the z component (output)
  63588. */
  63589. get z(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the w component (output)
  63592. */
  63593. get w(): NodeMaterialConnectionPoint;
  63594. protected _inputRename(name: string): string;
  63595. protected _outputRename(name: string): string;
  63596. protected _buildBlock(state: NodeMaterialBuildState): this;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Block used to lerp between 2 values
  63602. */
  63603. export class LerpBlock extends NodeMaterialBlock {
  63604. /**
  63605. * Creates a new LerpBlock
  63606. * @param name defines the block name
  63607. */
  63608. constructor(name: string);
  63609. /**
  63610. * Gets the current class name
  63611. * @returns the class name
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * Gets the left operand input component
  63616. */
  63617. get left(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the right operand input component
  63620. */
  63621. get right(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the gradient operand input component
  63624. */
  63625. get gradient(): NodeMaterialConnectionPoint;
  63626. /**
  63627. * Gets the output component
  63628. */
  63629. get output(): NodeMaterialConnectionPoint;
  63630. protected _buildBlock(state: NodeMaterialBuildState): this;
  63631. }
  63632. }
  63633. declare module BABYLON {
  63634. /**
  63635. * Block used to divide 2 vectors
  63636. */
  63637. export class DivideBlock extends NodeMaterialBlock {
  63638. /**
  63639. * Creates a new DivideBlock
  63640. * @param name defines the block name
  63641. */
  63642. constructor(name: string);
  63643. /**
  63644. * Gets the current class name
  63645. * @returns the class name
  63646. */
  63647. getClassName(): string;
  63648. /**
  63649. * Gets the left operand input component
  63650. */
  63651. get left(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the right operand input component
  63654. */
  63655. get right(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the output component
  63658. */
  63659. get output(): NodeMaterialConnectionPoint;
  63660. protected _buildBlock(state: NodeMaterialBuildState): this;
  63661. }
  63662. }
  63663. declare module BABYLON {
  63664. /**
  63665. * Block used to subtract 2 vectors
  63666. */
  63667. export class SubtractBlock extends NodeMaterialBlock {
  63668. /**
  63669. * Creates a new SubtractBlock
  63670. * @param name defines the block name
  63671. */
  63672. constructor(name: string);
  63673. /**
  63674. * Gets the current class name
  63675. * @returns the class name
  63676. */
  63677. getClassName(): string;
  63678. /**
  63679. * Gets the left operand input component
  63680. */
  63681. get left(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the right operand input component
  63684. */
  63685. get right(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Gets the output component
  63688. */
  63689. get output(): NodeMaterialConnectionPoint;
  63690. protected _buildBlock(state: NodeMaterialBuildState): this;
  63691. }
  63692. }
  63693. declare module BABYLON {
  63694. /**
  63695. * Block used to step a value
  63696. */
  63697. export class StepBlock extends NodeMaterialBlock {
  63698. /**
  63699. * Creates a new StepBlock
  63700. * @param name defines the block name
  63701. */
  63702. constructor(name: string);
  63703. /**
  63704. * Gets the current class name
  63705. * @returns the class name
  63706. */
  63707. getClassName(): string;
  63708. /**
  63709. * Gets the value operand input component
  63710. */
  63711. get value(): NodeMaterialConnectionPoint;
  63712. /**
  63713. * Gets the edge operand input component
  63714. */
  63715. get edge(): NodeMaterialConnectionPoint;
  63716. /**
  63717. * Gets the output component
  63718. */
  63719. get output(): NodeMaterialConnectionPoint;
  63720. protected _buildBlock(state: NodeMaterialBuildState): this;
  63721. }
  63722. }
  63723. declare module BABYLON {
  63724. /**
  63725. * Block used to get the opposite (1 - x) of a value
  63726. */
  63727. export class OneMinusBlock extends NodeMaterialBlock {
  63728. /**
  63729. * Creates a new OneMinusBlock
  63730. * @param name defines the block name
  63731. */
  63732. constructor(name: string);
  63733. /**
  63734. * Gets the current class name
  63735. * @returns the class name
  63736. */
  63737. getClassName(): string;
  63738. /**
  63739. * Gets the input component
  63740. */
  63741. get input(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the output component
  63744. */
  63745. get output(): NodeMaterialConnectionPoint;
  63746. protected _buildBlock(state: NodeMaterialBuildState): this;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. /**
  63751. * Block used to get the view direction
  63752. */
  63753. export class ViewDirectionBlock extends NodeMaterialBlock {
  63754. /**
  63755. * Creates a new ViewDirectionBlock
  63756. * @param name defines the block name
  63757. */
  63758. constructor(name: string);
  63759. /**
  63760. * Gets the current class name
  63761. * @returns the class name
  63762. */
  63763. getClassName(): string;
  63764. /**
  63765. * Gets the world position component
  63766. */
  63767. get worldPosition(): NodeMaterialConnectionPoint;
  63768. /**
  63769. * Gets the camera position component
  63770. */
  63771. get cameraPosition(): NodeMaterialConnectionPoint;
  63772. /**
  63773. * Gets the output component
  63774. */
  63775. get output(): NodeMaterialConnectionPoint;
  63776. autoConfigure(material: NodeMaterial): void;
  63777. protected _buildBlock(state: NodeMaterialBuildState): this;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * Block used to compute fresnel value
  63783. */
  63784. export class FresnelBlock extends NodeMaterialBlock {
  63785. /**
  63786. * Create a new FresnelBlock
  63787. * @param name defines the block name
  63788. */
  63789. constructor(name: string);
  63790. /**
  63791. * Gets the current class name
  63792. * @returns the class name
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Gets the world normal input component
  63797. */
  63798. get worldNormal(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the view direction input component
  63801. */
  63802. get viewDirection(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the bias input component
  63805. */
  63806. get bias(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the camera (or eye) position component
  63809. */
  63810. get power(): NodeMaterialConnectionPoint;
  63811. /**
  63812. * Gets the fresnel output component
  63813. */
  63814. get fresnel(): NodeMaterialConnectionPoint;
  63815. autoConfigure(material: NodeMaterial): void;
  63816. protected _buildBlock(state: NodeMaterialBuildState): this;
  63817. }
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * Block used to get the max of 2 values
  63822. */
  63823. export class MaxBlock extends NodeMaterialBlock {
  63824. /**
  63825. * Creates a new MaxBlock
  63826. * @param name defines the block name
  63827. */
  63828. constructor(name: string);
  63829. /**
  63830. * Gets the current class name
  63831. * @returns the class name
  63832. */
  63833. getClassName(): string;
  63834. /**
  63835. * Gets the left operand input component
  63836. */
  63837. get left(): NodeMaterialConnectionPoint;
  63838. /**
  63839. * Gets the right operand input component
  63840. */
  63841. get right(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the output component
  63844. */
  63845. get output(): NodeMaterialConnectionPoint;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to get the min of 2 values
  63852. */
  63853. export class MinBlock extends NodeMaterialBlock {
  63854. /**
  63855. * Creates a new MinBlock
  63856. * @param name defines the block name
  63857. */
  63858. constructor(name: string);
  63859. /**
  63860. * Gets the current class name
  63861. * @returns the class name
  63862. */
  63863. getClassName(): string;
  63864. /**
  63865. * Gets the left operand input component
  63866. */
  63867. get left(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the right operand input component
  63870. */
  63871. get right(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the output component
  63874. */
  63875. get output(): NodeMaterialConnectionPoint;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to get the distance between 2 values
  63882. */
  63883. export class DistanceBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Creates a new DistanceBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * Gets the current class name
  63891. * @returns the class name
  63892. */
  63893. getClassName(): string;
  63894. /**
  63895. * Gets the left operand input component
  63896. */
  63897. get left(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the right operand input component
  63900. */
  63901. get right(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the output component
  63904. */
  63905. get output(): NodeMaterialConnectionPoint;
  63906. protected _buildBlock(state: NodeMaterialBuildState): this;
  63907. }
  63908. }
  63909. declare module BABYLON {
  63910. /**
  63911. * Block used to get the length of a vector
  63912. */
  63913. export class LengthBlock extends NodeMaterialBlock {
  63914. /**
  63915. * Creates a new LengthBlock
  63916. * @param name defines the block name
  63917. */
  63918. constructor(name: string);
  63919. /**
  63920. * Gets the current class name
  63921. * @returns the class name
  63922. */
  63923. getClassName(): string;
  63924. /**
  63925. * Gets the value input component
  63926. */
  63927. get value(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the output component
  63930. */
  63931. get output(): NodeMaterialConnectionPoint;
  63932. protected _buildBlock(state: NodeMaterialBuildState): this;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Block used to get negative version of a value (i.e. x * -1)
  63938. */
  63939. export class NegateBlock extends NodeMaterialBlock {
  63940. /**
  63941. * Creates a new NegateBlock
  63942. * @param name defines the block name
  63943. */
  63944. constructor(name: string);
  63945. /**
  63946. * Gets the current class name
  63947. * @returns the class name
  63948. */
  63949. getClassName(): string;
  63950. /**
  63951. * Gets the value input component
  63952. */
  63953. get value(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the output component
  63956. */
  63957. get output(): NodeMaterialConnectionPoint;
  63958. protected _buildBlock(state: NodeMaterialBuildState): this;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Block used to get the value of the first parameter raised to the power of the second
  63964. */
  63965. export class PowBlock extends NodeMaterialBlock {
  63966. /**
  63967. * Creates a new PowBlock
  63968. * @param name defines the block name
  63969. */
  63970. constructor(name: string);
  63971. /**
  63972. * Gets the current class name
  63973. * @returns the class name
  63974. */
  63975. getClassName(): string;
  63976. /**
  63977. * Gets the value operand input component
  63978. */
  63979. get value(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the power operand input component
  63982. */
  63983. get power(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the output component
  63986. */
  63987. get output(): NodeMaterialConnectionPoint;
  63988. protected _buildBlock(state: NodeMaterialBuildState): this;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Block used to get a random number
  63994. */
  63995. export class RandomNumberBlock extends NodeMaterialBlock {
  63996. /**
  63997. * Creates a new RandomNumberBlock
  63998. * @param name defines the block name
  63999. */
  64000. constructor(name: string);
  64001. /**
  64002. * Gets the current class name
  64003. * @returns the class name
  64004. */
  64005. getClassName(): string;
  64006. /**
  64007. * Gets the seed input component
  64008. */
  64009. get seed(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the output component
  64012. */
  64013. get output(): NodeMaterialConnectionPoint;
  64014. protected _buildBlock(state: NodeMaterialBuildState): this;
  64015. }
  64016. }
  64017. declare module BABYLON {
  64018. /**
  64019. * Block used to compute arc tangent of 2 values
  64020. */
  64021. export class ArcTan2Block extends NodeMaterialBlock {
  64022. /**
  64023. * Creates a new ArcTan2Block
  64024. * @param name defines the block name
  64025. */
  64026. constructor(name: string);
  64027. /**
  64028. * Gets the current class name
  64029. * @returns the class name
  64030. */
  64031. getClassName(): string;
  64032. /**
  64033. * Gets the x operand input component
  64034. */
  64035. get x(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the y operand input component
  64038. */
  64039. get y(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the output component
  64042. */
  64043. get output(): NodeMaterialConnectionPoint;
  64044. protected _buildBlock(state: NodeMaterialBuildState): this;
  64045. }
  64046. }
  64047. declare module BABYLON {
  64048. /**
  64049. * Block used to smooth step a value
  64050. */
  64051. export class SmoothStepBlock extends NodeMaterialBlock {
  64052. /**
  64053. * Creates a new SmoothStepBlock
  64054. * @param name defines the block name
  64055. */
  64056. constructor(name: string);
  64057. /**
  64058. * Gets the current class name
  64059. * @returns the class name
  64060. */
  64061. getClassName(): string;
  64062. /**
  64063. * Gets the value operand input component
  64064. */
  64065. get value(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the first edge operand input component
  64068. */
  64069. get edge0(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the second edge operand input component
  64072. */
  64073. get edge1(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the output component
  64076. */
  64077. get output(): NodeMaterialConnectionPoint;
  64078. protected _buildBlock(state: NodeMaterialBuildState): this;
  64079. }
  64080. }
  64081. declare module BABYLON {
  64082. /**
  64083. * Block used to get the reciprocal (1 / x) of a value
  64084. */
  64085. export class ReciprocalBlock extends NodeMaterialBlock {
  64086. /**
  64087. * Creates a new ReciprocalBlock
  64088. * @param name defines the block name
  64089. */
  64090. constructor(name: string);
  64091. /**
  64092. * Gets the current class name
  64093. * @returns the class name
  64094. */
  64095. getClassName(): string;
  64096. /**
  64097. * Gets the input component
  64098. */
  64099. get input(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the output component
  64102. */
  64103. get output(): NodeMaterialConnectionPoint;
  64104. protected _buildBlock(state: NodeMaterialBuildState): this;
  64105. }
  64106. }
  64107. declare module BABYLON {
  64108. /**
  64109. * Block used to replace a color by another one
  64110. */
  64111. export class ReplaceColorBlock extends NodeMaterialBlock {
  64112. /**
  64113. * Creates a new ReplaceColorBlock
  64114. * @param name defines the block name
  64115. */
  64116. constructor(name: string);
  64117. /**
  64118. * Gets the current class name
  64119. * @returns the class name
  64120. */
  64121. getClassName(): string;
  64122. /**
  64123. * Gets the value input component
  64124. */
  64125. get value(): NodeMaterialConnectionPoint;
  64126. /**
  64127. * Gets the reference input component
  64128. */
  64129. get reference(): NodeMaterialConnectionPoint;
  64130. /**
  64131. * Gets the distance input component
  64132. */
  64133. get distance(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the replacement input component
  64136. */
  64137. get replacement(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the output component
  64140. */
  64141. get output(): NodeMaterialConnectionPoint;
  64142. protected _buildBlock(state: NodeMaterialBuildState): this;
  64143. }
  64144. }
  64145. declare module BABYLON {
  64146. /**
  64147. * Block used to posterize a value
  64148. * @see https://en.wikipedia.org/wiki/Posterization
  64149. */
  64150. export class PosterizeBlock extends NodeMaterialBlock {
  64151. /**
  64152. * Creates a new PosterizeBlock
  64153. * @param name defines the block name
  64154. */
  64155. constructor(name: string);
  64156. /**
  64157. * Gets the current class name
  64158. * @returns the class name
  64159. */
  64160. getClassName(): string;
  64161. /**
  64162. * Gets the value input component
  64163. */
  64164. get value(): NodeMaterialConnectionPoint;
  64165. /**
  64166. * Gets the steps input component
  64167. */
  64168. get steps(): NodeMaterialConnectionPoint;
  64169. /**
  64170. * Gets the output component
  64171. */
  64172. get output(): NodeMaterialConnectionPoint;
  64173. protected _buildBlock(state: NodeMaterialBuildState): this;
  64174. }
  64175. }
  64176. declare module BABYLON {
  64177. /**
  64178. * Operations supported by the Wave block
  64179. */
  64180. export enum WaveBlockKind {
  64181. /** SawTooth */
  64182. SawTooth = 0,
  64183. /** Square */
  64184. Square = 1,
  64185. /** Triangle */
  64186. Triangle = 2
  64187. }
  64188. /**
  64189. * Block used to apply wave operation to floats
  64190. */
  64191. export class WaveBlock extends NodeMaterialBlock {
  64192. /**
  64193. * Gets or sets the kibnd of wave to be applied by the block
  64194. */
  64195. kind: WaveBlockKind;
  64196. /**
  64197. * Creates a new WaveBlock
  64198. * @param name defines the block name
  64199. */
  64200. constructor(name: string);
  64201. /**
  64202. * Gets the current class name
  64203. * @returns the class name
  64204. */
  64205. getClassName(): string;
  64206. /**
  64207. * Gets the input component
  64208. */
  64209. get input(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the output component
  64212. */
  64213. get output(): NodeMaterialConnectionPoint;
  64214. protected _buildBlock(state: NodeMaterialBuildState): this;
  64215. serialize(): any;
  64216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * Class used to store a color step for the GradientBlock
  64222. */
  64223. export class GradientBlockColorStep {
  64224. private _step;
  64225. /**
  64226. * Gets value indicating which step this color is associated with (between 0 and 1)
  64227. */
  64228. get step(): number;
  64229. /**
  64230. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64231. */
  64232. set step(val: number);
  64233. private _color;
  64234. /**
  64235. * Gets the color associated with this step
  64236. */
  64237. get color(): Color3;
  64238. /**
  64239. * Sets the color associated with this step
  64240. */
  64241. set color(val: Color3);
  64242. /**
  64243. * Creates a new GradientBlockColorStep
  64244. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64245. * @param color defines the color associated with this step
  64246. */
  64247. constructor(step: number, color: Color3);
  64248. }
  64249. /**
  64250. * Block used to return a color from a gradient based on an input value between 0 and 1
  64251. */
  64252. export class GradientBlock extends NodeMaterialBlock {
  64253. /**
  64254. * Gets or sets the list of color steps
  64255. */
  64256. colorSteps: GradientBlockColorStep[];
  64257. /** Gets an observable raised when the value is changed */
  64258. onValueChangedObservable: Observable<GradientBlock>;
  64259. /** calls observable when the value is changed*/
  64260. colorStepsUpdated(): void;
  64261. /**
  64262. * Creates a new GradientBlock
  64263. * @param name defines the block name
  64264. */
  64265. constructor(name: string);
  64266. /**
  64267. * Gets the current class name
  64268. * @returns the class name
  64269. */
  64270. getClassName(): string;
  64271. /**
  64272. * Gets the gradient input component
  64273. */
  64274. get gradient(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the output component
  64277. */
  64278. get output(): NodeMaterialConnectionPoint;
  64279. private _writeColorConstant;
  64280. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64281. serialize(): any;
  64282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64283. protected _dumpPropertiesCode(): string;
  64284. }
  64285. }
  64286. declare module BABYLON {
  64287. /**
  64288. * Block used to normalize lerp between 2 values
  64289. */
  64290. export class NLerpBlock extends NodeMaterialBlock {
  64291. /**
  64292. * Creates a new NLerpBlock
  64293. * @param name defines the block name
  64294. */
  64295. constructor(name: string);
  64296. /**
  64297. * Gets the current class name
  64298. * @returns the class name
  64299. */
  64300. getClassName(): string;
  64301. /**
  64302. * Gets the left operand input component
  64303. */
  64304. get left(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the right operand input component
  64307. */
  64308. get right(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the gradient operand input component
  64311. */
  64312. get gradient(): NodeMaterialConnectionPoint;
  64313. /**
  64314. * Gets the output component
  64315. */
  64316. get output(): NodeMaterialConnectionPoint;
  64317. protected _buildBlock(state: NodeMaterialBuildState): this;
  64318. }
  64319. }
  64320. declare module BABYLON {
  64321. /**
  64322. * block used to Generate a Worley Noise 3D Noise Pattern
  64323. */
  64324. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64325. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64326. manhattanDistance: boolean;
  64327. /**
  64328. * Creates a new WorleyNoise3DBlock
  64329. * @param name defines the block name
  64330. */
  64331. constructor(name: string);
  64332. /**
  64333. * Gets the current class name
  64334. * @returns the class name
  64335. */
  64336. getClassName(): string;
  64337. /**
  64338. * Gets the seed input component
  64339. */
  64340. get seed(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the jitter input component
  64343. */
  64344. get jitter(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the output component
  64347. */
  64348. get output(): NodeMaterialConnectionPoint;
  64349. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64350. /**
  64351. * Exposes the properties to the UI?
  64352. */
  64353. protected _dumpPropertiesCode(): string;
  64354. /**
  64355. * Exposes the properties to the Seralize?
  64356. */
  64357. serialize(): any;
  64358. /**
  64359. * Exposes the properties to the deseralize?
  64360. */
  64361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. /**
  64366. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64367. */
  64368. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64369. /**
  64370. * Creates a new SimplexPerlin3DBlock
  64371. * @param name defines the block name
  64372. */
  64373. constructor(name: string);
  64374. /**
  64375. * Gets the current class name
  64376. * @returns the class name
  64377. */
  64378. getClassName(): string;
  64379. /**
  64380. * Gets the seed operand input component
  64381. */
  64382. get seed(): NodeMaterialConnectionPoint;
  64383. /**
  64384. * Gets the output component
  64385. */
  64386. get output(): NodeMaterialConnectionPoint;
  64387. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64388. }
  64389. }
  64390. declare module BABYLON {
  64391. /**
  64392. * Block used to blend normals
  64393. */
  64394. export class NormalBlendBlock extends NodeMaterialBlock {
  64395. /**
  64396. * Creates a new NormalBlendBlock
  64397. * @param name defines the block name
  64398. */
  64399. constructor(name: string);
  64400. /**
  64401. * Gets the current class name
  64402. * @returns the class name
  64403. */
  64404. getClassName(): string;
  64405. /**
  64406. * Gets the first input component
  64407. */
  64408. get normalMap0(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the second input component
  64411. */
  64412. get normalMap1(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the output component
  64415. */
  64416. get output(): NodeMaterialConnectionPoint;
  64417. protected _buildBlock(state: NodeMaterialBuildState): this;
  64418. }
  64419. }
  64420. declare module BABYLON {
  64421. /**
  64422. * Block used to rotate a 2d vector by a given angle
  64423. */
  64424. export class Rotate2dBlock extends NodeMaterialBlock {
  64425. /**
  64426. * Creates a new Rotate2dBlock
  64427. * @param name defines the block name
  64428. */
  64429. constructor(name: string);
  64430. /**
  64431. * Gets the current class name
  64432. * @returns the class name
  64433. */
  64434. getClassName(): string;
  64435. /**
  64436. * Gets the input vector
  64437. */
  64438. get input(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the input angle
  64441. */
  64442. get angle(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the output component
  64445. */
  64446. get output(): NodeMaterialConnectionPoint;
  64447. autoConfigure(material: NodeMaterial): void;
  64448. protected _buildBlock(state: NodeMaterialBuildState): this;
  64449. }
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * Block used to get the reflected vector from a direction and a normal
  64454. */
  64455. export class ReflectBlock extends NodeMaterialBlock {
  64456. /**
  64457. * Creates a new ReflectBlock
  64458. * @param name defines the block name
  64459. */
  64460. constructor(name: string);
  64461. /**
  64462. * Gets the current class name
  64463. * @returns the class name
  64464. */
  64465. getClassName(): string;
  64466. /**
  64467. * Gets the incident component
  64468. */
  64469. get incident(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the normal component
  64472. */
  64473. get normal(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the output component
  64476. */
  64477. get output(): NodeMaterialConnectionPoint;
  64478. protected _buildBlock(state: NodeMaterialBuildState): this;
  64479. }
  64480. }
  64481. declare module BABYLON {
  64482. /**
  64483. * Block used to get the refracted vector from a direction and a normal
  64484. */
  64485. export class RefractBlock extends NodeMaterialBlock {
  64486. /**
  64487. * Creates a new RefractBlock
  64488. * @param name defines the block name
  64489. */
  64490. constructor(name: string);
  64491. /**
  64492. * Gets the current class name
  64493. * @returns the class name
  64494. */
  64495. getClassName(): string;
  64496. /**
  64497. * Gets the incident component
  64498. */
  64499. get incident(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the normal component
  64502. */
  64503. get normal(): NodeMaterialConnectionPoint;
  64504. /**
  64505. * Gets the index of refraction component
  64506. */
  64507. get ior(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the output component
  64510. */
  64511. get output(): NodeMaterialConnectionPoint;
  64512. protected _buildBlock(state: NodeMaterialBuildState): this;
  64513. }
  64514. }
  64515. declare module BABYLON {
  64516. /**
  64517. * Block used to desaturate a color
  64518. */
  64519. export class DesaturateBlock extends NodeMaterialBlock {
  64520. /**
  64521. * Creates a new DesaturateBlock
  64522. * @param name defines the block name
  64523. */
  64524. constructor(name: string);
  64525. /**
  64526. * Gets the current class name
  64527. * @returns the class name
  64528. */
  64529. getClassName(): string;
  64530. /**
  64531. * Gets the color operand input component
  64532. */
  64533. get color(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the level operand input component
  64536. */
  64537. get level(): NodeMaterialConnectionPoint;
  64538. /**
  64539. * Gets the output component
  64540. */
  64541. get output(): NodeMaterialConnectionPoint;
  64542. protected _buildBlock(state: NodeMaterialBuildState): this;
  64543. }
  64544. }
  64545. declare module BABYLON {
  64546. /**
  64547. * Block used to implement the ambient occlusion module of the PBR material
  64548. */
  64549. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64550. /**
  64551. * Create a new AmbientOcclusionBlock
  64552. * @param name defines the block name
  64553. */
  64554. constructor(name: string);
  64555. /**
  64556. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64557. */
  64558. useAmbientInGrayScale: boolean;
  64559. /**
  64560. * Initialize the block and prepare the context for build
  64561. * @param state defines the state that will be used for the build
  64562. */
  64563. initialize(state: NodeMaterialBuildState): void;
  64564. /**
  64565. * Gets the current class name
  64566. * @returns the class name
  64567. */
  64568. getClassName(): string;
  64569. /**
  64570. * Gets the texture input component
  64571. */
  64572. get texture(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the texture intensity component
  64575. */
  64576. get intensity(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the direct light intensity input component
  64579. */
  64580. get directLightIntensity(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the ambient occlusion object output component
  64583. */
  64584. get ambientOcc(): NodeMaterialConnectionPoint;
  64585. /**
  64586. * Gets the main code of the block (fragment side)
  64587. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64588. * @returns the shader code
  64589. */
  64590. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64592. protected _buildBlock(state: NodeMaterialBuildState): this;
  64593. protected _dumpPropertiesCode(): string;
  64594. serialize(): any;
  64595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * Block used to implement the reflection module of the PBR material
  64601. */
  64602. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64603. /** @hidden */
  64604. _defineLODReflectionAlpha: string;
  64605. /** @hidden */
  64606. _defineLinearSpecularReflection: string;
  64607. private _vEnvironmentIrradianceName;
  64608. /** @hidden */
  64609. _vReflectionMicrosurfaceInfosName: string;
  64610. /** @hidden */
  64611. _vReflectionInfosName: string;
  64612. /** @hidden */
  64613. _vReflectionFilteringInfoName: string;
  64614. private _scene;
  64615. /**
  64616. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64617. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64618. * It's less burden on the user side in the editor part.
  64619. */
  64620. /** @hidden */
  64621. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64622. /** @hidden */
  64623. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64624. /** @hidden */
  64625. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64626. /**
  64627. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64628. * diffuse part of the IBL.
  64629. */
  64630. useSphericalHarmonics: boolean;
  64631. /**
  64632. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64633. */
  64634. forceIrradianceInFragment: boolean;
  64635. /**
  64636. * Create a new ReflectionBlock
  64637. * @param name defines the block name
  64638. */
  64639. constructor(name: string);
  64640. /**
  64641. * Gets the current class name
  64642. * @returns the class name
  64643. */
  64644. getClassName(): string;
  64645. /**
  64646. * Gets the position input component
  64647. */
  64648. get position(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the world position input component
  64651. */
  64652. get worldPosition(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the world normal input component
  64655. */
  64656. get worldNormal(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the world input component
  64659. */
  64660. get world(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the camera (or eye) position component
  64663. */
  64664. get cameraPosition(): NodeMaterialConnectionPoint;
  64665. /**
  64666. * Gets the view input component
  64667. */
  64668. get view(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the color input component
  64671. */
  64672. get color(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the reflection object output component
  64675. */
  64676. get reflection(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64679. */
  64680. get hasTexture(): boolean;
  64681. /**
  64682. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64683. */
  64684. get reflectionColor(): string;
  64685. protected _getTexture(): Nullable<BaseTexture>;
  64686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64688. /**
  64689. * Gets the code to inject in the vertex shader
  64690. * @param state current state of the node material building
  64691. * @returns the shader code
  64692. */
  64693. handleVertexSide(state: NodeMaterialBuildState): string;
  64694. /**
  64695. * Gets the main code of the block (fragment side)
  64696. * @param state current state of the node material building
  64697. * @param normalVarName name of the existing variable corresponding to the normal
  64698. * @returns the shader code
  64699. */
  64700. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64701. protected _buildBlock(state: NodeMaterialBuildState): this;
  64702. protected _dumpPropertiesCode(): string;
  64703. serialize(): any;
  64704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64705. }
  64706. }
  64707. declare module BABYLON {
  64708. /**
  64709. * Block used to implement the sheen module of the PBR material
  64710. */
  64711. export class SheenBlock extends NodeMaterialBlock {
  64712. /**
  64713. * Create a new SheenBlock
  64714. * @param name defines the block name
  64715. */
  64716. constructor(name: string);
  64717. /**
  64718. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64719. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64720. * making it easier to setup and tweak the effect
  64721. */
  64722. albedoScaling: boolean;
  64723. /**
  64724. * Defines if the sheen is linked to the sheen color.
  64725. */
  64726. linkSheenWithAlbedo: boolean;
  64727. /**
  64728. * Initialize the block and prepare the context for build
  64729. * @param state defines the state that will be used for the build
  64730. */
  64731. initialize(state: NodeMaterialBuildState): void;
  64732. /**
  64733. * Gets the current class name
  64734. * @returns the class name
  64735. */
  64736. getClassName(): string;
  64737. /**
  64738. * Gets the intensity input component
  64739. */
  64740. get intensity(): NodeMaterialConnectionPoint;
  64741. /**
  64742. * Gets the color input component
  64743. */
  64744. get color(): NodeMaterialConnectionPoint;
  64745. /**
  64746. * Gets the roughness input component
  64747. */
  64748. get roughness(): NodeMaterialConnectionPoint;
  64749. /**
  64750. * Gets the sheen object output component
  64751. */
  64752. get sheen(): NodeMaterialConnectionPoint;
  64753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64754. /**
  64755. * Gets the main code of the block (fragment side)
  64756. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64757. * @returns the shader code
  64758. */
  64759. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64760. protected _buildBlock(state: NodeMaterialBuildState): this;
  64761. protected _dumpPropertiesCode(): string;
  64762. serialize(): any;
  64763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64764. }
  64765. }
  64766. declare module BABYLON {
  64767. /**
  64768. * Block used to implement the reflectivity module of the PBR material
  64769. */
  64770. export class ReflectivityBlock extends NodeMaterialBlock {
  64771. private _metallicReflectanceColor;
  64772. private _metallicF0Factor;
  64773. /** @hidden */
  64774. _vMetallicReflectanceFactorsName: string;
  64775. /**
  64776. * The property below is set by the main PBR block prior to calling methods of this class.
  64777. */
  64778. /** @hidden */
  64779. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64780. /**
  64781. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64782. */
  64783. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64784. /**
  64785. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64786. */
  64787. useMetallnessFromMetallicTextureBlue: boolean;
  64788. /**
  64789. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64790. */
  64791. useRoughnessFromMetallicTextureAlpha: boolean;
  64792. /**
  64793. * Specifies if the metallic texture contains the roughness information in its green channel.
  64794. */
  64795. useRoughnessFromMetallicTextureGreen: boolean;
  64796. /**
  64797. * Create a new ReflectivityBlock
  64798. * @param name defines the block name
  64799. */
  64800. constructor(name: string);
  64801. /**
  64802. * Initialize the block and prepare the context for build
  64803. * @param state defines the state that will be used for the build
  64804. */
  64805. initialize(state: NodeMaterialBuildState): void;
  64806. /**
  64807. * Gets the current class name
  64808. * @returns the class name
  64809. */
  64810. getClassName(): string;
  64811. /**
  64812. * Gets the metallic input component
  64813. */
  64814. get metallic(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the roughness input component
  64817. */
  64818. get roughness(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the texture input component
  64821. */
  64822. get texture(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the reflectivity object output component
  64825. */
  64826. get reflectivity(): NodeMaterialConnectionPoint;
  64827. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64828. /**
  64829. * Gets the main code of the block (fragment side)
  64830. * @param state current state of the node material building
  64831. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64832. * @returns the shader code
  64833. */
  64834. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64836. protected _buildBlock(state: NodeMaterialBuildState): this;
  64837. protected _dumpPropertiesCode(): string;
  64838. serialize(): any;
  64839. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64840. }
  64841. }
  64842. declare module BABYLON {
  64843. /**
  64844. * Block used to implement the anisotropy module of the PBR material
  64845. */
  64846. export class AnisotropyBlock extends NodeMaterialBlock {
  64847. /**
  64848. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64849. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64850. * It's less burden on the user side in the editor part.
  64851. */
  64852. /** @hidden */
  64853. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64854. /** @hidden */
  64855. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64856. /**
  64857. * Create a new AnisotropyBlock
  64858. * @param name defines the block name
  64859. */
  64860. constructor(name: string);
  64861. /**
  64862. * Initialize the block and prepare the context for build
  64863. * @param state defines the state that will be used for the build
  64864. */
  64865. initialize(state: NodeMaterialBuildState): void;
  64866. /**
  64867. * Gets the current class name
  64868. * @returns the class name
  64869. */
  64870. getClassName(): string;
  64871. /**
  64872. * Gets the intensity input component
  64873. */
  64874. get intensity(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the direction input component
  64877. */
  64878. get direction(): NodeMaterialConnectionPoint;
  64879. /**
  64880. * Gets the texture input component
  64881. */
  64882. get texture(): NodeMaterialConnectionPoint;
  64883. /**
  64884. * Gets the uv input component
  64885. */
  64886. get uv(): NodeMaterialConnectionPoint;
  64887. /**
  64888. * Gets the worldTangent input component
  64889. */
  64890. get worldTangent(): NodeMaterialConnectionPoint;
  64891. /**
  64892. * Gets the anisotropy object output component
  64893. */
  64894. get anisotropy(): NodeMaterialConnectionPoint;
  64895. private _generateTBNSpace;
  64896. /**
  64897. * Gets the main code of the block (fragment side)
  64898. * @param state current state of the node material building
  64899. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64900. * @returns the shader code
  64901. */
  64902. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64904. protected _buildBlock(state: NodeMaterialBuildState): this;
  64905. }
  64906. }
  64907. declare module BABYLON {
  64908. /**
  64909. * Block used to implement the clear coat module of the PBR material
  64910. */
  64911. export class ClearCoatBlock extends NodeMaterialBlock {
  64912. private _scene;
  64913. /**
  64914. * Create a new ClearCoatBlock
  64915. * @param name defines the block name
  64916. */
  64917. constructor(name: string);
  64918. /**
  64919. * Initialize the block and prepare the context for build
  64920. * @param state defines the state that will be used for the build
  64921. */
  64922. initialize(state: NodeMaterialBuildState): void;
  64923. /**
  64924. * Gets the current class name
  64925. * @returns the class name
  64926. */
  64927. getClassName(): string;
  64928. /**
  64929. * Gets the intensity input component
  64930. */
  64931. get intensity(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the roughness input component
  64934. */
  64935. get roughness(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the ior input component
  64938. */
  64939. get ior(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the texture input component
  64942. */
  64943. get texture(): NodeMaterialConnectionPoint;
  64944. /**
  64945. * Gets the bump texture input component
  64946. */
  64947. get bumpTexture(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the uv input component
  64950. */
  64951. get uv(): NodeMaterialConnectionPoint;
  64952. /**
  64953. * Gets the tint color input component
  64954. */
  64955. get tintColor(): NodeMaterialConnectionPoint;
  64956. /**
  64957. * Gets the tint "at distance" input component
  64958. */
  64959. get tintAtDistance(): NodeMaterialConnectionPoint;
  64960. /**
  64961. * Gets the tint thickness input component
  64962. */
  64963. get tintThickness(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the world tangent input component
  64966. */
  64967. get worldTangent(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the clear coat object output component
  64970. */
  64971. get clearcoat(): NodeMaterialConnectionPoint;
  64972. autoConfigure(material: NodeMaterial): void;
  64973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64975. private _generateTBNSpace;
  64976. /**
  64977. * Gets the main code of the block (fragment side)
  64978. * @param state current state of the node material building
  64979. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64980. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64981. * @param worldPosVarName name of the variable holding the world position
  64982. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64983. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64984. * @param worldNormalVarName name of the variable holding the world normal
  64985. * @returns the shader code
  64986. */
  64987. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64988. protected _buildBlock(state: NodeMaterialBuildState): this;
  64989. }
  64990. }
  64991. declare module BABYLON {
  64992. /**
  64993. * Block used to implement the sub surface module of the PBR material
  64994. */
  64995. export class SubSurfaceBlock extends NodeMaterialBlock {
  64996. /**
  64997. * Create a new SubSurfaceBlock
  64998. * @param name defines the block name
  64999. */
  65000. constructor(name: string);
  65001. /**
  65002. * Stores the intensity of the different subsurface effects in the thickness texture.
  65003. * * the green channel is the translucency intensity.
  65004. * * the blue channel is the scattering intensity.
  65005. * * the alpha channel is the refraction intensity.
  65006. */
  65007. useMaskFromThicknessTexture: boolean;
  65008. /**
  65009. * Initialize the block and prepare the context for build
  65010. * @param state defines the state that will be used for the build
  65011. */
  65012. initialize(state: NodeMaterialBuildState): void;
  65013. /**
  65014. * Gets the current class name
  65015. * @returns the class name
  65016. */
  65017. getClassName(): string;
  65018. /**
  65019. * Gets the min thickness input component
  65020. */
  65021. get minThickness(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the max thickness input component
  65024. */
  65025. get maxThickness(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the thickness texture component
  65028. */
  65029. get thicknessTexture(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the tint color input component
  65032. */
  65033. get tintColor(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the translucency intensity input component
  65036. */
  65037. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the translucency diffusion distance input component
  65040. */
  65041. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the refraction object parameters
  65044. */
  65045. get refraction(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the sub surface object output component
  65048. */
  65049. get subsurface(): NodeMaterialConnectionPoint;
  65050. autoConfigure(material: NodeMaterial): void;
  65051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65052. /**
  65053. * Gets the main code of the block (fragment side)
  65054. * @param state current state of the node material building
  65055. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65056. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65057. * @param worldPosVarName name of the variable holding the world position
  65058. * @returns the shader code
  65059. */
  65060. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65061. protected _buildBlock(state: NodeMaterialBuildState): this;
  65062. }
  65063. }
  65064. declare module BABYLON {
  65065. /**
  65066. * Block used to implement the PBR metallic/roughness model
  65067. */
  65068. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65069. /**
  65070. * Gets or sets the light associated with this block
  65071. */
  65072. light: Nullable<Light>;
  65073. private _lightId;
  65074. private _scene;
  65075. private _environmentBRDFTexture;
  65076. private _environmentBrdfSamplerName;
  65077. private _vNormalWName;
  65078. private _invertNormalName;
  65079. /**
  65080. * Create a new ReflectionBlock
  65081. * @param name defines the block name
  65082. */
  65083. constructor(name: string);
  65084. /**
  65085. * Intensity of the direct lights e.g. the four lights available in your scene.
  65086. * This impacts both the direct diffuse and specular highlights.
  65087. */
  65088. directIntensity: number;
  65089. /**
  65090. * Intensity of the environment e.g. how much the environment will light the object
  65091. * either through harmonics for rough material or through the refelction for shiny ones.
  65092. */
  65093. environmentIntensity: number;
  65094. /**
  65095. * This is a special control allowing the reduction of the specular highlights coming from the
  65096. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65097. */
  65098. specularIntensity: number;
  65099. /**
  65100. * Defines the falloff type used in this material.
  65101. * It by default is Physical.
  65102. */
  65103. lightFalloff: number;
  65104. /**
  65105. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65106. */
  65107. useAlphaFromAlbedoTexture: boolean;
  65108. /**
  65109. * Specifies that alpha test should be used
  65110. */
  65111. useAlphaTest: boolean;
  65112. /**
  65113. * Defines the alpha limits in alpha test mode.
  65114. */
  65115. alphaTestCutoff: number;
  65116. /**
  65117. * Specifies that alpha blending should be used
  65118. */
  65119. useAlphaBlending: boolean;
  65120. /**
  65121. * Defines if the alpha value should be determined via the rgb values.
  65122. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65123. */
  65124. opacityRGB: boolean;
  65125. /**
  65126. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65127. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65128. */
  65129. useRadianceOverAlpha: boolean;
  65130. /**
  65131. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65132. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65133. */
  65134. useSpecularOverAlpha: boolean;
  65135. /**
  65136. * Enables specular anti aliasing in the PBR shader.
  65137. * It will both interacts on the Geometry for analytical and IBL lighting.
  65138. * It also prefilter the roughness map based on the bump values.
  65139. */
  65140. enableSpecularAntiAliasing: boolean;
  65141. /**
  65142. * Enables realtime filtering on the texture.
  65143. */
  65144. realTimeFiltering: boolean;
  65145. /**
  65146. * Quality switch for realtime filtering
  65147. */
  65148. realTimeFilteringQuality: number;
  65149. /**
  65150. * Defines if the material uses energy conservation.
  65151. */
  65152. useEnergyConservation: boolean;
  65153. /**
  65154. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65155. * too much the area relying on ambient texture to define their ambient occlusion.
  65156. */
  65157. useRadianceOcclusion: boolean;
  65158. /**
  65159. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65160. * makes the reflect vector face the model (under horizon).
  65161. */
  65162. useHorizonOcclusion: boolean;
  65163. /**
  65164. * If set to true, no lighting calculations will be applied.
  65165. */
  65166. unlit: boolean;
  65167. /**
  65168. * Force normal to face away from face.
  65169. */
  65170. forceNormalForward: boolean;
  65171. /**
  65172. * Defines the material debug mode.
  65173. * It helps seeing only some components of the material while troubleshooting.
  65174. */
  65175. debugMode: number;
  65176. /**
  65177. * Specify from where on screen the debug mode should start.
  65178. * The value goes from -1 (full screen) to 1 (not visible)
  65179. * It helps with side by side comparison against the final render
  65180. * This defaults to 0
  65181. */
  65182. debugLimit: number;
  65183. /**
  65184. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65185. * You can use the factor to better multiply the final value.
  65186. */
  65187. debugFactor: number;
  65188. /**
  65189. * Initialize the block and prepare the context for build
  65190. * @param state defines the state that will be used for the build
  65191. */
  65192. initialize(state: NodeMaterialBuildState): void;
  65193. /**
  65194. * Gets the current class name
  65195. * @returns the class name
  65196. */
  65197. getClassName(): string;
  65198. /**
  65199. * Gets the world position input component
  65200. */
  65201. get worldPosition(): NodeMaterialConnectionPoint;
  65202. /**
  65203. * Gets the world normal input component
  65204. */
  65205. get worldNormal(): NodeMaterialConnectionPoint;
  65206. /**
  65207. * Gets the perturbed normal input component
  65208. */
  65209. get perturbedNormal(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the camera position input component
  65212. */
  65213. get cameraPosition(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the base color input component
  65216. */
  65217. get baseColor(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the opacity texture input component
  65220. */
  65221. get opacityTexture(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the ambient color input component
  65224. */
  65225. get ambientColor(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the reflectivity object parameters
  65228. */
  65229. get reflectivity(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the ambient occlusion object parameters
  65232. */
  65233. get ambientOcc(): NodeMaterialConnectionPoint;
  65234. /**
  65235. * Gets the reflection object parameters
  65236. */
  65237. get reflection(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the sheen object parameters
  65240. */
  65241. get sheen(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the clear coat object parameters
  65244. */
  65245. get clearcoat(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the sub surface object parameters
  65248. */
  65249. get subsurface(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the anisotropy object parameters
  65252. */
  65253. get anisotropy(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the ambient output component
  65256. */
  65257. get ambient(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the diffuse output component
  65260. */
  65261. get diffuse(): NodeMaterialConnectionPoint;
  65262. /**
  65263. * Gets the specular output component
  65264. */
  65265. get specular(): NodeMaterialConnectionPoint;
  65266. /**
  65267. * Gets the sheen output component
  65268. */
  65269. get sheenDir(): NodeMaterialConnectionPoint;
  65270. /**
  65271. * Gets the clear coat output component
  65272. */
  65273. get clearcoatDir(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the indirect diffuse output component
  65276. */
  65277. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the indirect specular output component
  65280. */
  65281. get specularIndirect(): NodeMaterialConnectionPoint;
  65282. /**
  65283. * Gets the indirect sheen output component
  65284. */
  65285. get sheenIndirect(): NodeMaterialConnectionPoint;
  65286. /**
  65287. * Gets the indirect clear coat output component
  65288. */
  65289. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65290. /**
  65291. * Gets the refraction output component
  65292. */
  65293. get refraction(): NodeMaterialConnectionPoint;
  65294. /**
  65295. * Gets the global lighting output component
  65296. */
  65297. get lighting(): NodeMaterialConnectionPoint;
  65298. /**
  65299. * Gets the shadow output component
  65300. */
  65301. get shadow(): NodeMaterialConnectionPoint;
  65302. /**
  65303. * Gets the alpha output component
  65304. */
  65305. get alpha(): NodeMaterialConnectionPoint;
  65306. autoConfigure(material: NodeMaterial): void;
  65307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65308. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65310. private _injectVertexCode;
  65311. /**
  65312. * Gets the code corresponding to the albedo/opacity module
  65313. * @returns the shader code
  65314. */
  65315. getAlbedoOpacityCode(): string;
  65316. protected _buildBlock(state: NodeMaterialBuildState): this;
  65317. protected _dumpPropertiesCode(): string;
  65318. serialize(): any;
  65319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65320. }
  65321. }
  65322. declare module BABYLON {
  65323. /**
  65324. * Block used to compute value of one parameter modulo another
  65325. */
  65326. export class ModBlock extends NodeMaterialBlock {
  65327. /**
  65328. * Creates a new ModBlock
  65329. * @param name defines the block name
  65330. */
  65331. constructor(name: string);
  65332. /**
  65333. * Gets the current class name
  65334. * @returns the class name
  65335. */
  65336. getClassName(): string;
  65337. /**
  65338. * Gets the left operand input component
  65339. */
  65340. get left(): NodeMaterialConnectionPoint;
  65341. /**
  65342. * Gets the right operand input component
  65343. */
  65344. get right(): NodeMaterialConnectionPoint;
  65345. /**
  65346. * Gets the output component
  65347. */
  65348. get output(): NodeMaterialConnectionPoint;
  65349. protected _buildBlock(state: NodeMaterialBuildState): this;
  65350. }
  65351. }
  65352. declare module BABYLON {
  65353. /**
  65354. * Configuration for Draco compression
  65355. */
  65356. export interface IDracoCompressionConfiguration {
  65357. /**
  65358. * Configuration for the decoder.
  65359. */
  65360. decoder: {
  65361. /**
  65362. * The url to the WebAssembly module.
  65363. */
  65364. wasmUrl?: string;
  65365. /**
  65366. * The url to the WebAssembly binary.
  65367. */
  65368. wasmBinaryUrl?: string;
  65369. /**
  65370. * The url to the fallback JavaScript module.
  65371. */
  65372. fallbackUrl?: string;
  65373. };
  65374. }
  65375. /**
  65376. * Draco compression (https://google.github.io/draco/)
  65377. *
  65378. * This class wraps the Draco module.
  65379. *
  65380. * **Encoder**
  65381. *
  65382. * The encoder is not currently implemented.
  65383. *
  65384. * **Decoder**
  65385. *
  65386. * 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.
  65387. *
  65388. * To update the configuration, use the following code:
  65389. * ```javascript
  65390. * DracoCompression.Configuration = {
  65391. * decoder: {
  65392. * wasmUrl: "<url to the WebAssembly library>",
  65393. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65394. * fallbackUrl: "<url to the fallback JavaScript library>",
  65395. * }
  65396. * };
  65397. * ```
  65398. *
  65399. * 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.
  65400. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65401. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65402. *
  65403. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65404. * ```javascript
  65405. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65406. * ```
  65407. *
  65408. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65409. */
  65410. export class DracoCompression implements IDisposable {
  65411. private _workerPoolPromise?;
  65412. private _decoderModulePromise?;
  65413. /**
  65414. * The configuration. Defaults to the following urls:
  65415. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65416. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65417. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65418. */
  65419. static Configuration: IDracoCompressionConfiguration;
  65420. /**
  65421. * Returns true if the decoder configuration is available.
  65422. */
  65423. static get DecoderAvailable(): boolean;
  65424. /**
  65425. * Default number of workers to create when creating the draco compression object.
  65426. */
  65427. static DefaultNumWorkers: number;
  65428. private static GetDefaultNumWorkers;
  65429. private static _Default;
  65430. /**
  65431. * Default instance for the draco compression object.
  65432. */
  65433. static get Default(): DracoCompression;
  65434. /**
  65435. * Constructor
  65436. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65437. */
  65438. constructor(numWorkers?: number);
  65439. /**
  65440. * Stop all async operations and release resources.
  65441. */
  65442. dispose(): void;
  65443. /**
  65444. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65445. * @returns a promise that resolves when ready
  65446. */
  65447. whenReadyAsync(): Promise<void>;
  65448. /**
  65449. * Decode Draco compressed mesh data to vertex data.
  65450. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65451. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65452. * @returns A promise that resolves with the decoded vertex data
  65453. */
  65454. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65455. [kind: string]: number;
  65456. }): Promise<VertexData>;
  65457. }
  65458. }
  65459. declare module BABYLON {
  65460. /**
  65461. * Class for building Constructive Solid Geometry
  65462. */
  65463. export class CSG {
  65464. private polygons;
  65465. /**
  65466. * The world matrix
  65467. */
  65468. matrix: Matrix;
  65469. /**
  65470. * Stores the position
  65471. */
  65472. position: Vector3;
  65473. /**
  65474. * Stores the rotation
  65475. */
  65476. rotation: Vector3;
  65477. /**
  65478. * Stores the rotation quaternion
  65479. */
  65480. rotationQuaternion: Nullable<Quaternion>;
  65481. /**
  65482. * Stores the scaling vector
  65483. */
  65484. scaling: Vector3;
  65485. /**
  65486. * Convert the Mesh to CSG
  65487. * @param mesh The Mesh to convert to CSG
  65488. * @returns A new CSG from the Mesh
  65489. */
  65490. static FromMesh(mesh: Mesh): CSG;
  65491. /**
  65492. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65493. * @param polygons Polygons used to construct a CSG solid
  65494. */
  65495. private static FromPolygons;
  65496. /**
  65497. * Clones, or makes a deep copy, of the CSG
  65498. * @returns A new CSG
  65499. */
  65500. clone(): CSG;
  65501. /**
  65502. * Unions this CSG with another CSG
  65503. * @param csg The CSG to union against this CSG
  65504. * @returns The unioned CSG
  65505. */
  65506. union(csg: CSG): CSG;
  65507. /**
  65508. * Unions this CSG with another CSG in place
  65509. * @param csg The CSG to union against this CSG
  65510. */
  65511. unionInPlace(csg: CSG): void;
  65512. /**
  65513. * Subtracts this CSG with another CSG
  65514. * @param csg The CSG to subtract against this CSG
  65515. * @returns A new CSG
  65516. */
  65517. subtract(csg: CSG): CSG;
  65518. /**
  65519. * Subtracts this CSG with another CSG in place
  65520. * @param csg The CSG to subtact against this CSG
  65521. */
  65522. subtractInPlace(csg: CSG): void;
  65523. /**
  65524. * Intersect this CSG with another CSG
  65525. * @param csg The CSG to intersect against this CSG
  65526. * @returns A new CSG
  65527. */
  65528. intersect(csg: CSG): CSG;
  65529. /**
  65530. * Intersects this CSG with another CSG in place
  65531. * @param csg The CSG to intersect against this CSG
  65532. */
  65533. intersectInPlace(csg: CSG): void;
  65534. /**
  65535. * Return a new CSG solid with solid and empty space switched. This solid is
  65536. * not modified.
  65537. * @returns A new CSG solid with solid and empty space switched
  65538. */
  65539. inverse(): CSG;
  65540. /**
  65541. * Inverses the CSG in place
  65542. */
  65543. inverseInPlace(): void;
  65544. /**
  65545. * This is used to keep meshes transformations so they can be restored
  65546. * when we build back a Babylon Mesh
  65547. * NB : All CSG operations are performed in world coordinates
  65548. * @param csg The CSG to copy the transform attributes from
  65549. * @returns This CSG
  65550. */
  65551. copyTransformAttributes(csg: CSG): CSG;
  65552. /**
  65553. * Build Raw mesh from CSG
  65554. * Coordinates here are in world space
  65555. * @param name The name of the mesh geometry
  65556. * @param scene The Scene
  65557. * @param keepSubMeshes Specifies if the submeshes should be kept
  65558. * @returns A new Mesh
  65559. */
  65560. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65561. /**
  65562. * Build Mesh from CSG taking material and transforms into account
  65563. * @param name The name of the Mesh
  65564. * @param material The material of the Mesh
  65565. * @param scene The Scene
  65566. * @param keepSubMeshes Specifies if submeshes should be kept
  65567. * @returns The new Mesh
  65568. */
  65569. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65570. }
  65571. }
  65572. declare module BABYLON {
  65573. /**
  65574. * Class used to create a trail following a mesh
  65575. */
  65576. export class TrailMesh extends Mesh {
  65577. private _generator;
  65578. private _autoStart;
  65579. private _running;
  65580. private _diameter;
  65581. private _length;
  65582. private _sectionPolygonPointsCount;
  65583. private _sectionVectors;
  65584. private _sectionNormalVectors;
  65585. private _beforeRenderObserver;
  65586. /**
  65587. * @constructor
  65588. * @param name The value used by scene.getMeshByName() to do a lookup.
  65589. * @param generator The mesh or transform node to generate a trail.
  65590. * @param scene The scene to add this mesh to.
  65591. * @param diameter Diameter of trailing mesh. Default is 1.
  65592. * @param length Length of trailing mesh. Default is 60.
  65593. * @param autoStart Automatically start trailing mesh. Default true.
  65594. */
  65595. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65596. /**
  65597. * "TrailMesh"
  65598. * @returns "TrailMesh"
  65599. */
  65600. getClassName(): string;
  65601. private _createMesh;
  65602. /**
  65603. * Start trailing mesh.
  65604. */
  65605. start(): void;
  65606. /**
  65607. * Stop trailing mesh.
  65608. */
  65609. stop(): void;
  65610. /**
  65611. * Update trailing mesh geometry.
  65612. */
  65613. update(): void;
  65614. /**
  65615. * Returns a new TrailMesh object.
  65616. * @param name is a string, the name given to the new mesh
  65617. * @param newGenerator use new generator object for cloned trail mesh
  65618. * @returns a new mesh
  65619. */
  65620. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65621. /**
  65622. * Serializes this trail mesh
  65623. * @param serializationObject object to write serialization to
  65624. */
  65625. serialize(serializationObject: any): void;
  65626. /**
  65627. * Parses a serialized trail mesh
  65628. * @param parsedMesh the serialized mesh
  65629. * @param scene the scene to create the trail mesh in
  65630. * @returns the created trail mesh
  65631. */
  65632. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65633. }
  65634. }
  65635. declare module BABYLON {
  65636. /**
  65637. * Class containing static functions to help procedurally build meshes
  65638. */
  65639. export class TiledBoxBuilder {
  65640. /**
  65641. * Creates a box mesh
  65642. * 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)
  65643. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65645. * * 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
  65646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65647. * @param name defines the name of the mesh
  65648. * @param options defines the options used to create the mesh
  65649. * @param scene defines the hosting scene
  65650. * @returns the box mesh
  65651. */
  65652. static CreateTiledBox(name: string, options: {
  65653. pattern?: number;
  65654. width?: number;
  65655. height?: number;
  65656. depth?: number;
  65657. tileSize?: number;
  65658. tileWidth?: number;
  65659. tileHeight?: number;
  65660. alignHorizontal?: number;
  65661. alignVertical?: number;
  65662. faceUV?: Vector4[];
  65663. faceColors?: Color4[];
  65664. sideOrientation?: number;
  65665. updatable?: boolean;
  65666. }, scene?: Nullable<Scene>): Mesh;
  65667. }
  65668. }
  65669. declare module BABYLON {
  65670. /**
  65671. * Class containing static functions to help procedurally build meshes
  65672. */
  65673. export class TorusKnotBuilder {
  65674. /**
  65675. * Creates a torus knot mesh
  65676. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65677. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65678. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65679. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65681. * * 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
  65682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65683. * @param name defines the name of the mesh
  65684. * @param options defines the options used to create the mesh
  65685. * @param scene defines the hosting scene
  65686. * @returns the torus knot mesh
  65687. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65688. */
  65689. static CreateTorusKnot(name: string, options: {
  65690. radius?: number;
  65691. tube?: number;
  65692. radialSegments?: number;
  65693. tubularSegments?: number;
  65694. p?: number;
  65695. q?: number;
  65696. updatable?: boolean;
  65697. sideOrientation?: number;
  65698. frontUVs?: Vector4;
  65699. backUVs?: Vector4;
  65700. }, scene: any): Mesh;
  65701. }
  65702. }
  65703. declare module BABYLON {
  65704. /**
  65705. * Polygon
  65706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65707. */
  65708. export class Polygon {
  65709. /**
  65710. * Creates a rectangle
  65711. * @param xmin bottom X coord
  65712. * @param ymin bottom Y coord
  65713. * @param xmax top X coord
  65714. * @param ymax top Y coord
  65715. * @returns points that make the resulting rectation
  65716. */
  65717. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65718. /**
  65719. * Creates a circle
  65720. * @param radius radius of circle
  65721. * @param cx scale in x
  65722. * @param cy scale in y
  65723. * @param numberOfSides number of sides that make up the circle
  65724. * @returns points that make the resulting circle
  65725. */
  65726. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65727. /**
  65728. * Creates a polygon from input string
  65729. * @param input Input polygon data
  65730. * @returns the parsed points
  65731. */
  65732. static Parse(input: string): Vector2[];
  65733. /**
  65734. * Starts building a polygon from x and y coordinates
  65735. * @param x x coordinate
  65736. * @param y y coordinate
  65737. * @returns the started path2
  65738. */
  65739. static StartingAt(x: number, y: number): Path2;
  65740. }
  65741. /**
  65742. * Builds a polygon
  65743. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65744. */
  65745. export class PolygonMeshBuilder {
  65746. private _points;
  65747. private _outlinepoints;
  65748. private _holes;
  65749. private _name;
  65750. private _scene;
  65751. private _epoints;
  65752. private _eholes;
  65753. private _addToepoint;
  65754. /**
  65755. * Babylon reference to the earcut plugin.
  65756. */
  65757. bjsEarcut: any;
  65758. /**
  65759. * Creates a PolygonMeshBuilder
  65760. * @param name name of the builder
  65761. * @param contours Path of the polygon
  65762. * @param scene scene to add to when creating the mesh
  65763. * @param earcutInjection can be used to inject your own earcut reference
  65764. */
  65765. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65766. /**
  65767. * Adds a whole within the polygon
  65768. * @param hole Array of points defining the hole
  65769. * @returns this
  65770. */
  65771. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65772. /**
  65773. * Creates the polygon
  65774. * @param updatable If the mesh should be updatable
  65775. * @param depth The depth of the mesh created
  65776. * @returns the created mesh
  65777. */
  65778. build(updatable?: boolean, depth?: number): Mesh;
  65779. /**
  65780. * Creates the polygon
  65781. * @param depth The depth of the mesh created
  65782. * @returns the created VertexData
  65783. */
  65784. buildVertexData(depth?: number): VertexData;
  65785. /**
  65786. * Adds a side to the polygon
  65787. * @param positions points that make the polygon
  65788. * @param normals normals of the polygon
  65789. * @param uvs uvs of the polygon
  65790. * @param indices indices of the polygon
  65791. * @param bounds bounds of the polygon
  65792. * @param points points of the polygon
  65793. * @param depth depth of the polygon
  65794. * @param flip flip of the polygon
  65795. */
  65796. private addSide;
  65797. }
  65798. }
  65799. declare module BABYLON {
  65800. /**
  65801. * Class containing static functions to help procedurally build meshes
  65802. */
  65803. export class PolygonBuilder {
  65804. /**
  65805. * Creates a polygon mesh
  65806. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65807. * * 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
  65808. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65810. * * 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)
  65811. * * Remember you can only change the shape positions, not their number when updating a polygon
  65812. * @param name defines the name of the mesh
  65813. * @param options defines the options used to create the mesh
  65814. * @param scene defines the hosting scene
  65815. * @param earcutInjection can be used to inject your own earcut reference
  65816. * @returns the polygon mesh
  65817. */
  65818. static CreatePolygon(name: string, options: {
  65819. shape: Vector3[];
  65820. holes?: Vector3[][];
  65821. depth?: number;
  65822. faceUV?: Vector4[];
  65823. faceColors?: Color4[];
  65824. updatable?: boolean;
  65825. sideOrientation?: number;
  65826. frontUVs?: Vector4;
  65827. backUVs?: Vector4;
  65828. wrap?: boolean;
  65829. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65830. /**
  65831. * Creates an extruded polygon mesh, with depth in the Y direction.
  65832. * * 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)
  65833. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65834. * @param name defines the name of the mesh
  65835. * @param options defines the options used to create the mesh
  65836. * @param scene defines the hosting scene
  65837. * @param earcutInjection can be used to inject your own earcut reference
  65838. * @returns the polygon mesh
  65839. */
  65840. static ExtrudePolygon(name: string, options: {
  65841. shape: Vector3[];
  65842. holes?: Vector3[][];
  65843. depth?: number;
  65844. faceUV?: Vector4[];
  65845. faceColors?: Color4[];
  65846. updatable?: boolean;
  65847. sideOrientation?: number;
  65848. frontUVs?: Vector4;
  65849. backUVs?: Vector4;
  65850. wrap?: boolean;
  65851. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65852. }
  65853. }
  65854. declare module BABYLON {
  65855. /**
  65856. * Class containing static functions to help procedurally build meshes
  65857. */
  65858. export class LatheBuilder {
  65859. /**
  65860. * Creates lathe mesh.
  65861. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65862. * * 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
  65863. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65864. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65865. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65866. * * 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
  65867. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65868. * * 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
  65869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65870. * * 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
  65871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65873. * @param name defines the name of the mesh
  65874. * @param options defines the options used to create the mesh
  65875. * @param scene defines the hosting scene
  65876. * @returns the lathe mesh
  65877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65878. */
  65879. static CreateLathe(name: string, options: {
  65880. shape: Vector3[];
  65881. radius?: number;
  65882. tessellation?: number;
  65883. clip?: number;
  65884. arc?: number;
  65885. closed?: boolean;
  65886. updatable?: boolean;
  65887. sideOrientation?: number;
  65888. frontUVs?: Vector4;
  65889. backUVs?: Vector4;
  65890. cap?: number;
  65891. invertUV?: boolean;
  65892. }, scene?: Nullable<Scene>): Mesh;
  65893. }
  65894. }
  65895. declare module BABYLON {
  65896. /**
  65897. * Class containing static functions to help procedurally build meshes
  65898. */
  65899. export class TiledPlaneBuilder {
  65900. /**
  65901. * Creates a tiled plane mesh
  65902. * * The parameter `pattern` will, depending on value, do nothing or
  65903. * * * flip (reflect about central vertical) alternate tiles across and up
  65904. * * * flip every tile on alternate rows
  65905. * * * rotate (180 degs) alternate tiles across and up
  65906. * * * rotate every tile on alternate rows
  65907. * * * flip and rotate alternate tiles across and up
  65908. * * * flip and rotate every tile on alternate rows
  65909. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65910. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65911. * * 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
  65912. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65913. * * 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)
  65914. * * 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)
  65915. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65916. * @param name defines the name of the mesh
  65917. * @param options defines the options used to create the mesh
  65918. * @param scene defines the hosting scene
  65919. * @returns the box mesh
  65920. */
  65921. static CreateTiledPlane(name: string, options: {
  65922. pattern?: number;
  65923. tileSize?: number;
  65924. tileWidth?: number;
  65925. tileHeight?: number;
  65926. size?: number;
  65927. width?: number;
  65928. height?: number;
  65929. alignHorizontal?: number;
  65930. alignVertical?: number;
  65931. sideOrientation?: number;
  65932. frontUVs?: Vector4;
  65933. backUVs?: Vector4;
  65934. updatable?: boolean;
  65935. }, scene?: Nullable<Scene>): Mesh;
  65936. }
  65937. }
  65938. declare module BABYLON {
  65939. /**
  65940. * Class containing static functions to help procedurally build meshes
  65941. */
  65942. export class TubeBuilder {
  65943. /**
  65944. * Creates a tube mesh.
  65945. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65946. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65947. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65948. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65949. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65950. * * 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)
  65951. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65952. * * 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
  65953. * * 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
  65954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65955. * * 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
  65956. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65958. * @param name defines the name of the mesh
  65959. * @param options defines the options used to create the mesh
  65960. * @param scene defines the hosting scene
  65961. * @returns the tube mesh
  65962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65963. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65964. */
  65965. static CreateTube(name: string, options: {
  65966. path: Vector3[];
  65967. radius?: number;
  65968. tessellation?: number;
  65969. radiusFunction?: {
  65970. (i: number, distance: number): number;
  65971. };
  65972. cap?: number;
  65973. arc?: number;
  65974. updatable?: boolean;
  65975. sideOrientation?: number;
  65976. frontUVs?: Vector4;
  65977. backUVs?: Vector4;
  65978. instance?: Mesh;
  65979. invertUV?: boolean;
  65980. }, scene?: Nullable<Scene>): Mesh;
  65981. }
  65982. }
  65983. declare module BABYLON {
  65984. /**
  65985. * Class containing static functions to help procedurally build meshes
  65986. */
  65987. export class IcoSphereBuilder {
  65988. /**
  65989. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65990. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65991. * * 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`)
  65992. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65993. * * 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
  65994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65995. * * 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
  65996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65997. * @param name defines the name of the mesh
  65998. * @param options defines the options used to create the mesh
  65999. * @param scene defines the hosting scene
  66000. * @returns the icosahedron mesh
  66001. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66002. */
  66003. static CreateIcoSphere(name: string, options: {
  66004. radius?: number;
  66005. radiusX?: number;
  66006. radiusY?: number;
  66007. radiusZ?: number;
  66008. flat?: boolean;
  66009. subdivisions?: number;
  66010. sideOrientation?: number;
  66011. frontUVs?: Vector4;
  66012. backUVs?: Vector4;
  66013. updatable?: boolean;
  66014. }, scene?: Nullable<Scene>): Mesh;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Class containing static functions to help procedurally build meshes
  66020. */
  66021. export class DecalBuilder {
  66022. /**
  66023. * Creates a decal mesh.
  66024. * 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
  66025. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66026. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66027. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66028. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66029. * @param name defines the name of the mesh
  66030. * @param sourceMesh defines the mesh where the decal must be applied
  66031. * @param options defines the options used to create the mesh
  66032. * @param scene defines the hosting scene
  66033. * @returns the decal mesh
  66034. * @see https://doc.babylonjs.com/how_to/decals
  66035. */
  66036. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66037. position?: Vector3;
  66038. normal?: Vector3;
  66039. size?: Vector3;
  66040. angle?: number;
  66041. }): Mesh;
  66042. }
  66043. }
  66044. declare module BABYLON {
  66045. /**
  66046. * Class containing static functions to help procedurally build meshes
  66047. */
  66048. export class MeshBuilder {
  66049. /**
  66050. * Creates a box mesh
  66051. * * The parameter `size` sets the size (float) of each box side (default 1)
  66052. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66053. * * 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)
  66054. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66056. * * 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
  66057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66058. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66059. * @param name defines the name of the mesh
  66060. * @param options defines the options used to create the mesh
  66061. * @param scene defines the hosting scene
  66062. * @returns the box mesh
  66063. */
  66064. static CreateBox(name: string, options: {
  66065. size?: number;
  66066. width?: number;
  66067. height?: number;
  66068. depth?: number;
  66069. faceUV?: Vector4[];
  66070. faceColors?: Color4[];
  66071. sideOrientation?: number;
  66072. frontUVs?: Vector4;
  66073. backUVs?: Vector4;
  66074. wrap?: boolean;
  66075. topBaseAt?: number;
  66076. bottomBaseAt?: number;
  66077. updatable?: boolean;
  66078. }, scene?: Nullable<Scene>): Mesh;
  66079. /**
  66080. * Creates a tiled box mesh
  66081. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66083. * @param name defines the name of the mesh
  66084. * @param options defines the options used to create the mesh
  66085. * @param scene defines the hosting scene
  66086. * @returns the tiled box mesh
  66087. */
  66088. static CreateTiledBox(name: string, options: {
  66089. pattern?: number;
  66090. size?: number;
  66091. width?: number;
  66092. height?: number;
  66093. depth: number;
  66094. tileSize?: number;
  66095. tileWidth?: number;
  66096. tileHeight?: number;
  66097. faceUV?: Vector4[];
  66098. faceColors?: Color4[];
  66099. alignHorizontal?: number;
  66100. alignVertical?: number;
  66101. sideOrientation?: number;
  66102. updatable?: boolean;
  66103. }, scene?: Nullable<Scene>): Mesh;
  66104. /**
  66105. * Creates a sphere mesh
  66106. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66107. * * 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`)
  66108. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66109. * * 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
  66110. * * 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)
  66111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66112. * * 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
  66113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66114. * @param name defines the name of the mesh
  66115. * @param options defines the options used to create the mesh
  66116. * @param scene defines the hosting scene
  66117. * @returns the sphere mesh
  66118. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66119. */
  66120. static CreateSphere(name: string, options: {
  66121. segments?: number;
  66122. diameter?: number;
  66123. diameterX?: number;
  66124. diameterY?: number;
  66125. diameterZ?: number;
  66126. arc?: number;
  66127. slice?: number;
  66128. sideOrientation?: number;
  66129. frontUVs?: Vector4;
  66130. backUVs?: Vector4;
  66131. updatable?: boolean;
  66132. }, scene?: Nullable<Scene>): Mesh;
  66133. /**
  66134. * Creates a plane polygonal mesh. By default, this is a disc
  66135. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66136. * * 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
  66137. * * 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
  66138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66139. * * 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
  66140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66141. * @param name defines the name of the mesh
  66142. * @param options defines the options used to create the mesh
  66143. * @param scene defines the hosting scene
  66144. * @returns the plane polygonal mesh
  66145. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66146. */
  66147. static CreateDisc(name: string, options: {
  66148. radius?: number;
  66149. tessellation?: number;
  66150. arc?: number;
  66151. updatable?: boolean;
  66152. sideOrientation?: number;
  66153. frontUVs?: Vector4;
  66154. backUVs?: Vector4;
  66155. }, scene?: Nullable<Scene>): Mesh;
  66156. /**
  66157. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66158. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66159. * * 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`)
  66160. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66161. * * 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
  66162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66163. * * 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
  66164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66165. * @param name defines the name of the mesh
  66166. * @param options defines the options used to create the mesh
  66167. * @param scene defines the hosting scene
  66168. * @returns the icosahedron mesh
  66169. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66170. */
  66171. static CreateIcoSphere(name: string, options: {
  66172. radius?: number;
  66173. radiusX?: number;
  66174. radiusY?: number;
  66175. radiusZ?: number;
  66176. flat?: boolean;
  66177. subdivisions?: number;
  66178. sideOrientation?: number;
  66179. frontUVs?: Vector4;
  66180. backUVs?: Vector4;
  66181. updatable?: boolean;
  66182. }, scene?: Nullable<Scene>): Mesh;
  66183. /**
  66184. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66185. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66186. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66187. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66188. * * 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
  66189. * * 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
  66190. * * 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
  66191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66192. * * 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
  66193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66194. * * 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
  66195. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66196. * * 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
  66197. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66199. * @param name defines the name of the mesh
  66200. * @param options defines the options used to create the mesh
  66201. * @param scene defines the hosting scene
  66202. * @returns the ribbon mesh
  66203. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66205. */
  66206. static CreateRibbon(name: string, options: {
  66207. pathArray: Vector3[][];
  66208. closeArray?: boolean;
  66209. closePath?: boolean;
  66210. offset?: number;
  66211. updatable?: boolean;
  66212. sideOrientation?: number;
  66213. frontUVs?: Vector4;
  66214. backUVs?: Vector4;
  66215. instance?: Mesh;
  66216. invertUV?: boolean;
  66217. uvs?: Vector2[];
  66218. colors?: Color4[];
  66219. }, scene?: Nullable<Scene>): Mesh;
  66220. /**
  66221. * Creates a cylinder or a cone mesh
  66222. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66223. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66224. * * 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.
  66225. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66226. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66227. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66228. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66229. * * 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).
  66230. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66231. * * 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).
  66232. * * 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
  66233. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66234. * * 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
  66235. * * 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.
  66236. * * If `enclose` is false, a ring surface is one element.
  66237. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66238. * * 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
  66239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66240. * * 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
  66241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66242. * @param name defines the name of the mesh
  66243. * @param options defines the options used to create the mesh
  66244. * @param scene defines the hosting scene
  66245. * @returns the cylinder mesh
  66246. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66247. */
  66248. static CreateCylinder(name: string, options: {
  66249. height?: number;
  66250. diameterTop?: number;
  66251. diameterBottom?: number;
  66252. diameter?: number;
  66253. tessellation?: number;
  66254. subdivisions?: number;
  66255. arc?: number;
  66256. faceColors?: Color4[];
  66257. faceUV?: Vector4[];
  66258. updatable?: boolean;
  66259. hasRings?: boolean;
  66260. enclose?: boolean;
  66261. cap?: number;
  66262. sideOrientation?: number;
  66263. frontUVs?: Vector4;
  66264. backUVs?: Vector4;
  66265. }, scene?: Nullable<Scene>): Mesh;
  66266. /**
  66267. * Creates a torus mesh
  66268. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66269. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66270. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66272. * * 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
  66273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66274. * @param name defines the name of the mesh
  66275. * @param options defines the options used to create the mesh
  66276. * @param scene defines the hosting scene
  66277. * @returns the torus mesh
  66278. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66279. */
  66280. static CreateTorus(name: string, options: {
  66281. diameter?: number;
  66282. thickness?: number;
  66283. tessellation?: number;
  66284. updatable?: boolean;
  66285. sideOrientation?: number;
  66286. frontUVs?: Vector4;
  66287. backUVs?: Vector4;
  66288. }, scene?: Nullable<Scene>): Mesh;
  66289. /**
  66290. * Creates a torus knot mesh
  66291. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66292. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66293. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66294. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66296. * * 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
  66297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66298. * @param name defines the name of the mesh
  66299. * @param options defines the options used to create the mesh
  66300. * @param scene defines the hosting scene
  66301. * @returns the torus knot mesh
  66302. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66303. */
  66304. static CreateTorusKnot(name: string, options: {
  66305. radius?: number;
  66306. tube?: number;
  66307. radialSegments?: number;
  66308. tubularSegments?: number;
  66309. p?: number;
  66310. q?: number;
  66311. updatable?: boolean;
  66312. sideOrientation?: number;
  66313. frontUVs?: Vector4;
  66314. backUVs?: Vector4;
  66315. }, scene?: Nullable<Scene>): Mesh;
  66316. /**
  66317. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66318. * * 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
  66319. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66320. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66321. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66322. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66323. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66324. * * 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
  66325. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66328. * @param name defines the name of the new line system
  66329. * @param options defines the options used to create the line system
  66330. * @param scene defines the hosting scene
  66331. * @returns a new line system mesh
  66332. */
  66333. static CreateLineSystem(name: string, options: {
  66334. lines: Vector3[][];
  66335. updatable?: boolean;
  66336. instance?: Nullable<LinesMesh>;
  66337. colors?: Nullable<Color4[][]>;
  66338. useVertexAlpha?: boolean;
  66339. }, scene: Nullable<Scene>): LinesMesh;
  66340. /**
  66341. * Creates a line mesh
  66342. * 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
  66343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66344. * * The parameter `points` is an array successive Vector3
  66345. * * 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
  66346. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66348. * * When updating an instance, remember that only point positions can change, not the number of points
  66349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66351. * @param name defines the name of the new line system
  66352. * @param options defines the options used to create the line system
  66353. * @param scene defines the hosting scene
  66354. * @returns a new line mesh
  66355. */
  66356. static CreateLines(name: string, options: {
  66357. points: Vector3[];
  66358. updatable?: boolean;
  66359. instance?: Nullable<LinesMesh>;
  66360. colors?: Color4[];
  66361. useVertexAlpha?: boolean;
  66362. }, scene?: Nullable<Scene>): LinesMesh;
  66363. /**
  66364. * Creates a dashed line mesh
  66365. * * 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
  66366. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66367. * * The parameter `points` is an array successive Vector3
  66368. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66369. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66370. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66371. * * 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
  66372. * * When updating an instance, remember that only point positions can change, not the number of points
  66373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66374. * @param name defines the name of the mesh
  66375. * @param options defines the options used to create the mesh
  66376. * @param scene defines the hosting scene
  66377. * @returns the dashed line mesh
  66378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66379. */
  66380. static CreateDashedLines(name: string, options: {
  66381. points: Vector3[];
  66382. dashSize?: number;
  66383. gapSize?: number;
  66384. dashNb?: number;
  66385. updatable?: boolean;
  66386. instance?: LinesMesh;
  66387. }, scene?: Nullable<Scene>): LinesMesh;
  66388. /**
  66389. * 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.
  66390. * * 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.
  66391. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66392. * * 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.
  66393. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66394. * * 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
  66395. * * 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
  66396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66398. * * 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
  66399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66401. * @param name defines the name of the mesh
  66402. * @param options defines the options used to create the mesh
  66403. * @param scene defines the hosting scene
  66404. * @returns the extruded shape mesh
  66405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66407. */
  66408. static ExtrudeShape(name: string, options: {
  66409. shape: Vector3[];
  66410. path: Vector3[];
  66411. scale?: number;
  66412. rotation?: number;
  66413. cap?: number;
  66414. updatable?: boolean;
  66415. sideOrientation?: number;
  66416. frontUVs?: Vector4;
  66417. backUVs?: Vector4;
  66418. instance?: Mesh;
  66419. invertUV?: boolean;
  66420. }, scene?: Nullable<Scene>): Mesh;
  66421. /**
  66422. * Creates an custom extruded shape mesh.
  66423. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66424. * * 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.
  66425. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66426. * * 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
  66427. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66428. * * 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
  66429. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66430. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66431. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66432. * * 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
  66433. * * 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
  66434. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66436. * * 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
  66437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66439. * @param name defines the name of the mesh
  66440. * @param options defines the options used to create the mesh
  66441. * @param scene defines the hosting scene
  66442. * @returns the custom extruded shape mesh
  66443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66446. */
  66447. static ExtrudeShapeCustom(name: string, options: {
  66448. shape: Vector3[];
  66449. path: Vector3[];
  66450. scaleFunction?: any;
  66451. rotationFunction?: any;
  66452. ribbonCloseArray?: boolean;
  66453. ribbonClosePath?: boolean;
  66454. cap?: number;
  66455. updatable?: boolean;
  66456. sideOrientation?: number;
  66457. frontUVs?: Vector4;
  66458. backUVs?: Vector4;
  66459. instance?: Mesh;
  66460. invertUV?: boolean;
  66461. }, scene?: Nullable<Scene>): Mesh;
  66462. /**
  66463. * Creates lathe mesh.
  66464. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66465. * * 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
  66466. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66467. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66468. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66469. * * 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
  66470. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66471. * * 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
  66472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66473. * * 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
  66474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66476. * @param name defines the name of the mesh
  66477. * @param options defines the options used to create the mesh
  66478. * @param scene defines the hosting scene
  66479. * @returns the lathe mesh
  66480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66481. */
  66482. static CreateLathe(name: string, options: {
  66483. shape: Vector3[];
  66484. radius?: number;
  66485. tessellation?: number;
  66486. clip?: number;
  66487. arc?: number;
  66488. closed?: boolean;
  66489. updatable?: boolean;
  66490. sideOrientation?: number;
  66491. frontUVs?: Vector4;
  66492. backUVs?: Vector4;
  66493. cap?: number;
  66494. invertUV?: boolean;
  66495. }, scene?: Nullable<Scene>): Mesh;
  66496. /**
  66497. * Creates a tiled plane mesh
  66498. * * You can set a limited pattern arrangement with the tiles
  66499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66500. * * 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
  66501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66502. * @param name defines the name of the mesh
  66503. * @param options defines the options used to create the mesh
  66504. * @param scene defines the hosting scene
  66505. * @returns the plane mesh
  66506. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66507. */
  66508. static CreateTiledPlane(name: string, options: {
  66509. pattern?: number;
  66510. tileSize?: number;
  66511. tileWidth?: number;
  66512. tileHeight?: number;
  66513. size?: number;
  66514. width?: number;
  66515. height?: number;
  66516. alignHorizontal?: number;
  66517. alignVertical?: number;
  66518. sideOrientation?: number;
  66519. frontUVs?: Vector4;
  66520. backUVs?: Vector4;
  66521. updatable?: boolean;
  66522. }, scene?: Nullable<Scene>): Mesh;
  66523. /**
  66524. * Creates a plane mesh
  66525. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66526. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66527. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66529. * * 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
  66530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66531. * @param name defines the name of the mesh
  66532. * @param options defines the options used to create the mesh
  66533. * @param scene defines the hosting scene
  66534. * @returns the plane mesh
  66535. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66536. */
  66537. static CreatePlane(name: string, options: {
  66538. size?: number;
  66539. width?: number;
  66540. height?: number;
  66541. sideOrientation?: number;
  66542. frontUVs?: Vector4;
  66543. backUVs?: Vector4;
  66544. updatable?: boolean;
  66545. sourcePlane?: Plane;
  66546. }, scene?: Nullable<Scene>): Mesh;
  66547. /**
  66548. * Creates a ground mesh
  66549. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66550. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66552. * @param name defines the name of the mesh
  66553. * @param options defines the options used to create the mesh
  66554. * @param scene defines the hosting scene
  66555. * @returns the ground mesh
  66556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66557. */
  66558. static CreateGround(name: string, options: {
  66559. width?: number;
  66560. height?: number;
  66561. subdivisions?: number;
  66562. subdivisionsX?: number;
  66563. subdivisionsY?: number;
  66564. updatable?: boolean;
  66565. }, scene?: Nullable<Scene>): Mesh;
  66566. /**
  66567. * Creates a tiled ground mesh
  66568. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66569. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66570. * * 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
  66571. * * 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
  66572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66573. * @param name defines the name of the mesh
  66574. * @param options defines the options used to create the mesh
  66575. * @param scene defines the hosting scene
  66576. * @returns the tiled ground mesh
  66577. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66578. */
  66579. static CreateTiledGround(name: string, options: {
  66580. xmin: number;
  66581. zmin: number;
  66582. xmax: number;
  66583. zmax: number;
  66584. subdivisions?: {
  66585. w: number;
  66586. h: number;
  66587. };
  66588. precision?: {
  66589. w: number;
  66590. h: number;
  66591. };
  66592. updatable?: boolean;
  66593. }, scene?: Nullable<Scene>): Mesh;
  66594. /**
  66595. * Creates a ground mesh from a height map
  66596. * * The parameter `url` sets the URL of the height map image resource.
  66597. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66598. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66599. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66600. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66601. * * 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.
  66602. * * 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).
  66603. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66605. * @param name defines the name of the mesh
  66606. * @param url defines the url to the height map
  66607. * @param options defines the options used to create the mesh
  66608. * @param scene defines the hosting scene
  66609. * @returns the ground mesh
  66610. * @see https://doc.babylonjs.com/babylon101/height_map
  66611. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66612. */
  66613. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66614. width?: number;
  66615. height?: number;
  66616. subdivisions?: number;
  66617. minHeight?: number;
  66618. maxHeight?: number;
  66619. colorFilter?: Color3;
  66620. alphaFilter?: number;
  66621. updatable?: boolean;
  66622. onReady?: (mesh: GroundMesh) => void;
  66623. }, scene?: Nullable<Scene>): GroundMesh;
  66624. /**
  66625. * Creates a polygon mesh
  66626. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66627. * * 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
  66628. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66630. * * 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)
  66631. * * Remember you can only change the shape positions, not their number when updating a polygon
  66632. * @param name defines the name of the mesh
  66633. * @param options defines the options used to create the mesh
  66634. * @param scene defines the hosting scene
  66635. * @param earcutInjection can be used to inject your own earcut reference
  66636. * @returns the polygon mesh
  66637. */
  66638. static CreatePolygon(name: string, options: {
  66639. shape: Vector3[];
  66640. holes?: Vector3[][];
  66641. depth?: number;
  66642. faceUV?: Vector4[];
  66643. faceColors?: Color4[];
  66644. updatable?: boolean;
  66645. sideOrientation?: number;
  66646. frontUVs?: Vector4;
  66647. backUVs?: Vector4;
  66648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66649. /**
  66650. * Creates an extruded polygon mesh, with depth in the Y direction.
  66651. * * 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)
  66652. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66653. * @param name defines the name of the mesh
  66654. * @param options defines the options used to create the mesh
  66655. * @param scene defines the hosting scene
  66656. * @param earcutInjection can be used to inject your own earcut reference
  66657. * @returns the polygon mesh
  66658. */
  66659. static ExtrudePolygon(name: string, options: {
  66660. shape: Vector3[];
  66661. holes?: Vector3[][];
  66662. depth?: number;
  66663. faceUV?: Vector4[];
  66664. faceColors?: Color4[];
  66665. updatable?: boolean;
  66666. sideOrientation?: number;
  66667. frontUVs?: Vector4;
  66668. backUVs?: Vector4;
  66669. wrap?: boolean;
  66670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66671. /**
  66672. * Creates a tube mesh.
  66673. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66674. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66675. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66676. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66677. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66678. * * 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)
  66679. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66680. * * 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
  66681. * * 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
  66682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66683. * * 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
  66684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66686. * @param name defines the name of the mesh
  66687. * @param options defines the options used to create the mesh
  66688. * @param scene defines the hosting scene
  66689. * @returns the tube mesh
  66690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66691. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66692. */
  66693. static CreateTube(name: string, options: {
  66694. path: Vector3[];
  66695. radius?: number;
  66696. tessellation?: number;
  66697. radiusFunction?: {
  66698. (i: number, distance: number): number;
  66699. };
  66700. cap?: number;
  66701. arc?: number;
  66702. updatable?: boolean;
  66703. sideOrientation?: number;
  66704. frontUVs?: Vector4;
  66705. backUVs?: Vector4;
  66706. instance?: Mesh;
  66707. invertUV?: boolean;
  66708. }, scene?: Nullable<Scene>): Mesh;
  66709. /**
  66710. * Creates a polyhedron mesh
  66711. * * 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
  66712. * * The parameter `size` (positive float, default 1) sets the polygon size
  66713. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66714. * * 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`
  66715. * * 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
  66716. * * 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)`)
  66717. * * 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
  66718. * * 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
  66719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66720. * * 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
  66721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66722. * @param name defines the name of the mesh
  66723. * @param options defines the options used to create the mesh
  66724. * @param scene defines the hosting scene
  66725. * @returns the polyhedron mesh
  66726. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66727. */
  66728. static CreatePolyhedron(name: string, options: {
  66729. type?: number;
  66730. size?: number;
  66731. sizeX?: number;
  66732. sizeY?: number;
  66733. sizeZ?: number;
  66734. custom?: any;
  66735. faceUV?: Vector4[];
  66736. faceColors?: Color4[];
  66737. flat?: boolean;
  66738. updatable?: boolean;
  66739. sideOrientation?: number;
  66740. frontUVs?: Vector4;
  66741. backUVs?: Vector4;
  66742. }, scene?: Nullable<Scene>): Mesh;
  66743. /**
  66744. * Creates a decal mesh.
  66745. * 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
  66746. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66747. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66748. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66749. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66750. * @param name defines the name of the mesh
  66751. * @param sourceMesh defines the mesh where the decal must be applied
  66752. * @param options defines the options used to create the mesh
  66753. * @param scene defines the hosting scene
  66754. * @returns the decal mesh
  66755. * @see https://doc.babylonjs.com/how_to/decals
  66756. */
  66757. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66758. position?: Vector3;
  66759. normal?: Vector3;
  66760. size?: Vector3;
  66761. angle?: number;
  66762. }): Mesh;
  66763. /**
  66764. * Creates a Capsule Mesh
  66765. * @param name defines the name of the mesh.
  66766. * @param options the constructors options used to shape the mesh.
  66767. * @param scene defines the scene the mesh is scoped to.
  66768. * @returns the capsule mesh
  66769. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66770. */
  66771. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66772. }
  66773. }
  66774. declare module BABYLON {
  66775. /**
  66776. * A simplifier interface for future simplification implementations
  66777. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66778. */
  66779. export interface ISimplifier {
  66780. /**
  66781. * Simplification of a given mesh according to the given settings.
  66782. * Since this requires computation, it is assumed that the function runs async.
  66783. * @param settings The settings of the simplification, including quality and distance
  66784. * @param successCallback A callback that will be called after the mesh was simplified.
  66785. * @param errorCallback in case of an error, this callback will be called. optional.
  66786. */
  66787. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66788. }
  66789. /**
  66790. * Expected simplification settings.
  66791. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66792. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66793. */
  66794. export interface ISimplificationSettings {
  66795. /**
  66796. * Gets or sets the expected quality
  66797. */
  66798. quality: number;
  66799. /**
  66800. * Gets or sets the distance when this optimized version should be used
  66801. */
  66802. distance: number;
  66803. /**
  66804. * Gets an already optimized mesh
  66805. */
  66806. optimizeMesh?: boolean;
  66807. }
  66808. /**
  66809. * Class used to specify simplification options
  66810. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66811. */
  66812. export class SimplificationSettings implements ISimplificationSettings {
  66813. /** expected quality */
  66814. quality: number;
  66815. /** distance when this optimized version should be used */
  66816. distance: number;
  66817. /** already optimized mesh */
  66818. optimizeMesh?: boolean | undefined;
  66819. /**
  66820. * Creates a SimplificationSettings
  66821. * @param quality expected quality
  66822. * @param distance distance when this optimized version should be used
  66823. * @param optimizeMesh already optimized mesh
  66824. */
  66825. constructor(
  66826. /** expected quality */
  66827. quality: number,
  66828. /** distance when this optimized version should be used */
  66829. distance: number,
  66830. /** already optimized mesh */
  66831. optimizeMesh?: boolean | undefined);
  66832. }
  66833. /**
  66834. * Interface used to define a simplification task
  66835. */
  66836. export interface ISimplificationTask {
  66837. /**
  66838. * Array of settings
  66839. */
  66840. settings: Array<ISimplificationSettings>;
  66841. /**
  66842. * Simplification type
  66843. */
  66844. simplificationType: SimplificationType;
  66845. /**
  66846. * Mesh to simplify
  66847. */
  66848. mesh: Mesh;
  66849. /**
  66850. * Callback called on success
  66851. */
  66852. successCallback?: () => void;
  66853. /**
  66854. * Defines if parallel processing can be used
  66855. */
  66856. parallelProcessing: boolean;
  66857. }
  66858. /**
  66859. * Queue used to order the simplification tasks
  66860. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66861. */
  66862. export class SimplificationQueue {
  66863. private _simplificationArray;
  66864. /**
  66865. * Gets a boolean indicating that the process is still running
  66866. */
  66867. running: boolean;
  66868. /**
  66869. * Creates a new queue
  66870. */
  66871. constructor();
  66872. /**
  66873. * Adds a new simplification task
  66874. * @param task defines a task to add
  66875. */
  66876. addTask(task: ISimplificationTask): void;
  66877. /**
  66878. * Execute next task
  66879. */
  66880. executeNext(): void;
  66881. /**
  66882. * Execute a simplification task
  66883. * @param task defines the task to run
  66884. */
  66885. runSimplification(task: ISimplificationTask): void;
  66886. private getSimplifier;
  66887. }
  66888. /**
  66889. * The implemented types of simplification
  66890. * At the moment only Quadratic Error Decimation is implemented
  66891. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66892. */
  66893. export enum SimplificationType {
  66894. /** Quadratic error decimation */
  66895. QUADRATIC = 0
  66896. }
  66897. /**
  66898. * An implementation of the Quadratic Error simplification algorithm.
  66899. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66900. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66901. * @author RaananW
  66902. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66903. */
  66904. export class QuadraticErrorSimplification implements ISimplifier {
  66905. private _mesh;
  66906. private triangles;
  66907. private vertices;
  66908. private references;
  66909. private _reconstructedMesh;
  66910. /** Gets or sets the number pf sync interations */
  66911. syncIterations: number;
  66912. /** Gets or sets the aggressiveness of the simplifier */
  66913. aggressiveness: number;
  66914. /** Gets or sets the number of allowed iterations for decimation */
  66915. decimationIterations: number;
  66916. /** Gets or sets the espilon to use for bounding box computation */
  66917. boundingBoxEpsilon: number;
  66918. /**
  66919. * Creates a new QuadraticErrorSimplification
  66920. * @param _mesh defines the target mesh
  66921. */
  66922. constructor(_mesh: Mesh);
  66923. /**
  66924. * Simplification of a given mesh according to the given settings.
  66925. * Since this requires computation, it is assumed that the function runs async.
  66926. * @param settings The settings of the simplification, including quality and distance
  66927. * @param successCallback A callback that will be called after the mesh was simplified.
  66928. */
  66929. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66930. private runDecimation;
  66931. private initWithMesh;
  66932. private init;
  66933. private reconstructMesh;
  66934. private initDecimatedMesh;
  66935. private isFlipped;
  66936. private updateTriangles;
  66937. private identifyBorder;
  66938. private updateMesh;
  66939. private vertexError;
  66940. private calculateError;
  66941. }
  66942. }
  66943. declare module BABYLON {
  66944. interface Scene {
  66945. /** @hidden (Backing field) */
  66946. _simplificationQueue: SimplificationQueue;
  66947. /**
  66948. * Gets or sets the simplification queue attached to the scene
  66949. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66950. */
  66951. simplificationQueue: SimplificationQueue;
  66952. }
  66953. interface Mesh {
  66954. /**
  66955. * Simplify the mesh according to the given array of settings.
  66956. * Function will return immediately and will simplify async
  66957. * @param settings a collection of simplification settings
  66958. * @param parallelProcessing should all levels calculate parallel or one after the other
  66959. * @param simplificationType the type of simplification to run
  66960. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66961. * @returns the current mesh
  66962. */
  66963. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66964. }
  66965. /**
  66966. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66967. * created in a scene
  66968. */
  66969. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66970. /**
  66971. * The component name helpfull to identify the component in the list of scene components.
  66972. */
  66973. readonly name: string;
  66974. /**
  66975. * The scene the component belongs to.
  66976. */
  66977. scene: Scene;
  66978. /**
  66979. * Creates a new instance of the component for the given scene
  66980. * @param scene Defines the scene to register the component in
  66981. */
  66982. constructor(scene: Scene);
  66983. /**
  66984. * Registers the component in a given scene
  66985. */
  66986. register(): void;
  66987. /**
  66988. * Rebuilds the elements related to this component in case of
  66989. * context lost for instance.
  66990. */
  66991. rebuild(): void;
  66992. /**
  66993. * Disposes the component and the associated ressources
  66994. */
  66995. dispose(): void;
  66996. private _beforeCameraUpdate;
  66997. }
  66998. }
  66999. declare module BABYLON {
  67000. interface Mesh {
  67001. /**
  67002. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67003. */
  67004. thinInstanceEnablePicking: boolean;
  67005. /**
  67006. * Creates a new thin instance
  67007. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67008. * @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
  67009. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67010. */
  67011. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67012. /**
  67013. * Adds the transformation (matrix) of the current mesh as a thin instance
  67014. * @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
  67015. * @returns the thin instance index number
  67016. */
  67017. thinInstanceAddSelf(refresh: boolean): number;
  67018. /**
  67019. * Registers a custom attribute to be used with thin instances
  67020. * @param kind name of the attribute
  67021. * @param stride size in floats of the attribute
  67022. */
  67023. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67024. /**
  67025. * Sets the matrix of a thin instance
  67026. * @param index index of the thin instance
  67027. * @param matrix matrix to set
  67028. * @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
  67029. */
  67030. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67031. /**
  67032. * Sets the value of a custom attribute for a thin instance
  67033. * @param kind name of the attribute
  67034. * @param index index of the thin instance
  67035. * @param value value to set
  67036. * @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
  67037. */
  67038. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67039. /**
  67040. * 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.
  67041. */
  67042. thinInstanceCount: number;
  67043. /**
  67044. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67045. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67046. * @param buffer buffer to set
  67047. * @param stride size in floats of each value of the buffer
  67048. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67049. */
  67050. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67051. /**
  67052. * Gets the list of world matrices
  67053. * @return an array containing all the world matrices from the thin instances
  67054. */
  67055. thinInstanceGetWorldMatrices(): Matrix[];
  67056. /**
  67057. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67058. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67059. */
  67060. thinInstanceBufferUpdated(kind: string): void;
  67061. /**
  67062. * Applies a partial update to a buffer directly on the GPU
  67063. * 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
  67064. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67065. * @param data the data to set in the GPU buffer
  67066. * @param offset the offset in the GPU buffer where to update the data
  67067. */
  67068. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67069. /**
  67070. * Refreshes the bounding info, taking into account all the thin instances defined
  67071. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67072. */
  67073. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67074. /** @hidden */
  67075. _thinInstanceInitializeUserStorage(): void;
  67076. /** @hidden */
  67077. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67078. /** @hidden */
  67079. _userThinInstanceBuffersStorage: {
  67080. data: {
  67081. [key: string]: Float32Array;
  67082. };
  67083. sizes: {
  67084. [key: string]: number;
  67085. };
  67086. vertexBuffers: {
  67087. [key: string]: Nullable<VertexBuffer>;
  67088. };
  67089. strides: {
  67090. [key: string]: number;
  67091. };
  67092. };
  67093. }
  67094. }
  67095. declare module BABYLON {
  67096. /**
  67097. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67098. */
  67099. export interface INavigationEnginePlugin {
  67100. /**
  67101. * plugin name
  67102. */
  67103. name: string;
  67104. /**
  67105. * Creates a navigation mesh
  67106. * @param meshes array of all the geometry used to compute the navigatio mesh
  67107. * @param parameters bunch of parameters used to filter geometry
  67108. */
  67109. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67110. /**
  67111. * Create a navigation mesh debug mesh
  67112. * @param scene is where the mesh will be added
  67113. * @returns debug display mesh
  67114. */
  67115. createDebugNavMesh(scene: Scene): Mesh;
  67116. /**
  67117. * Get a navigation mesh constrained position, closest to the parameter position
  67118. * @param position world position
  67119. * @returns the closest point to position constrained by the navigation mesh
  67120. */
  67121. getClosestPoint(position: Vector3): Vector3;
  67122. /**
  67123. * Get a navigation mesh constrained position, closest to the parameter position
  67124. * @param position world position
  67125. * @param result output the closest point to position constrained by the navigation mesh
  67126. */
  67127. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67128. /**
  67129. * Get a navigation mesh constrained position, within a particular radius
  67130. * @param position world position
  67131. * @param maxRadius the maximum distance to the constrained world position
  67132. * @returns the closest point to position constrained by the navigation mesh
  67133. */
  67134. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67135. /**
  67136. * Get a navigation mesh constrained position, within a particular radius
  67137. * @param position world position
  67138. * @param maxRadius the maximum distance to the constrained world position
  67139. * @param result output the closest point to position constrained by the navigation mesh
  67140. */
  67141. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67142. /**
  67143. * Compute the final position from a segment made of destination-position
  67144. * @param position world position
  67145. * @param destination world position
  67146. * @returns the resulting point along the navmesh
  67147. */
  67148. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67149. /**
  67150. * Compute the final position from a segment made of destination-position
  67151. * @param position world position
  67152. * @param destination world position
  67153. * @param result output the resulting point along the navmesh
  67154. */
  67155. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67156. /**
  67157. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67158. * @param start world position
  67159. * @param end world position
  67160. * @returns array containing world position composing the path
  67161. */
  67162. computePath(start: Vector3, end: Vector3): Vector3[];
  67163. /**
  67164. * If this plugin is supported
  67165. * @returns true if plugin is supported
  67166. */
  67167. isSupported(): boolean;
  67168. /**
  67169. * Create a new Crowd so you can add agents
  67170. * @param maxAgents the maximum agent count in the crowd
  67171. * @param maxAgentRadius the maximum radius an agent can have
  67172. * @param scene to attach the crowd to
  67173. * @returns the crowd you can add agents to
  67174. */
  67175. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67176. /**
  67177. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67178. * The queries will try to find a solution within those bounds
  67179. * default is (1,1,1)
  67180. * @param extent x,y,z value that define the extent around the queries point of reference
  67181. */
  67182. setDefaultQueryExtent(extent: Vector3): void;
  67183. /**
  67184. * Get the Bounding box extent specified by setDefaultQueryExtent
  67185. * @returns the box extent values
  67186. */
  67187. getDefaultQueryExtent(): Vector3;
  67188. /**
  67189. * build the navmesh from a previously saved state using getNavmeshData
  67190. * @param data the Uint8Array returned by getNavmeshData
  67191. */
  67192. buildFromNavmeshData(data: Uint8Array): void;
  67193. /**
  67194. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67195. * @returns data the Uint8Array that can be saved and reused
  67196. */
  67197. getNavmeshData(): Uint8Array;
  67198. /**
  67199. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67200. * @param result output the box extent values
  67201. */
  67202. getDefaultQueryExtentToRef(result: Vector3): void;
  67203. /**
  67204. * Release all resources
  67205. */
  67206. dispose(): void;
  67207. }
  67208. /**
  67209. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67210. */
  67211. export interface ICrowd {
  67212. /**
  67213. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67214. * You can attach anything to that node. The node position is updated in the scene update tick.
  67215. * @param pos world position that will be constrained by the navigation mesh
  67216. * @param parameters agent parameters
  67217. * @param transform hooked to the agent that will be update by the scene
  67218. * @returns agent index
  67219. */
  67220. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67221. /**
  67222. * Returns the agent position in world space
  67223. * @param index agent index returned by addAgent
  67224. * @returns world space position
  67225. */
  67226. getAgentPosition(index: number): Vector3;
  67227. /**
  67228. * Gets the agent position result in world space
  67229. * @param index agent index returned by addAgent
  67230. * @param result output world space position
  67231. */
  67232. getAgentPositionToRef(index: number, result: Vector3): void;
  67233. /**
  67234. * Gets the agent velocity in world space
  67235. * @param index agent index returned by addAgent
  67236. * @returns world space velocity
  67237. */
  67238. getAgentVelocity(index: number): Vector3;
  67239. /**
  67240. * Gets the agent velocity result in world space
  67241. * @param index agent index returned by addAgent
  67242. * @param result output world space velocity
  67243. */
  67244. getAgentVelocityToRef(index: number, result: Vector3): void;
  67245. /**
  67246. * remove a particular agent previously created
  67247. * @param index agent index returned by addAgent
  67248. */
  67249. removeAgent(index: number): void;
  67250. /**
  67251. * get the list of all agents attached to this crowd
  67252. * @returns list of agent indices
  67253. */
  67254. getAgents(): number[];
  67255. /**
  67256. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67257. * @param deltaTime in seconds
  67258. */
  67259. update(deltaTime: number): void;
  67260. /**
  67261. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67262. * @param index agent index returned by addAgent
  67263. * @param destination targeted world position
  67264. */
  67265. agentGoto(index: number, destination: Vector3): void;
  67266. /**
  67267. * Teleport the agent to a new position
  67268. * @param index agent index returned by addAgent
  67269. * @param destination targeted world position
  67270. */
  67271. agentTeleport(index: number, destination: Vector3): void;
  67272. /**
  67273. * Update agent parameters
  67274. * @param index agent index returned by addAgent
  67275. * @param parameters agent parameters
  67276. */
  67277. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67278. /**
  67279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67280. * The queries will try to find a solution within those bounds
  67281. * default is (1,1,1)
  67282. * @param extent x,y,z value that define the extent around the queries point of reference
  67283. */
  67284. setDefaultQueryExtent(extent: Vector3): void;
  67285. /**
  67286. * Get the Bounding box extent specified by setDefaultQueryExtent
  67287. * @returns the box extent values
  67288. */
  67289. getDefaultQueryExtent(): Vector3;
  67290. /**
  67291. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67292. * @param result output the box extent values
  67293. */
  67294. getDefaultQueryExtentToRef(result: Vector3): void;
  67295. /**
  67296. * Release all resources
  67297. */
  67298. dispose(): void;
  67299. }
  67300. /**
  67301. * Configures an agent
  67302. */
  67303. export interface IAgentParameters {
  67304. /**
  67305. * Agent radius. [Limit: >= 0]
  67306. */
  67307. radius: number;
  67308. /**
  67309. * Agent height. [Limit: > 0]
  67310. */
  67311. height: number;
  67312. /**
  67313. * Maximum allowed acceleration. [Limit: >= 0]
  67314. */
  67315. maxAcceleration: number;
  67316. /**
  67317. * Maximum allowed speed. [Limit: >= 0]
  67318. */
  67319. maxSpeed: number;
  67320. /**
  67321. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67322. */
  67323. collisionQueryRange: number;
  67324. /**
  67325. * The path visibility optimization range. [Limit: > 0]
  67326. */
  67327. pathOptimizationRange: number;
  67328. /**
  67329. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67330. */
  67331. separationWeight: number;
  67332. }
  67333. /**
  67334. * Configures the navigation mesh creation
  67335. */
  67336. export interface INavMeshParameters {
  67337. /**
  67338. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67339. */
  67340. cs: number;
  67341. /**
  67342. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67343. */
  67344. ch: number;
  67345. /**
  67346. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67347. */
  67348. walkableSlopeAngle: number;
  67349. /**
  67350. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67351. * be considered walkable. [Limit: >= 3] [Units: vx]
  67352. */
  67353. walkableHeight: number;
  67354. /**
  67355. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67356. */
  67357. walkableClimb: number;
  67358. /**
  67359. * The distance to erode/shrink the walkable area of the heightfield away from
  67360. * obstructions. [Limit: >=0] [Units: vx]
  67361. */
  67362. walkableRadius: number;
  67363. /**
  67364. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67365. */
  67366. maxEdgeLen: number;
  67367. /**
  67368. * The maximum distance a simplfied contour's border edges should deviate
  67369. * the original raw contour. [Limit: >=0] [Units: vx]
  67370. */
  67371. maxSimplificationError: number;
  67372. /**
  67373. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67374. */
  67375. minRegionArea: number;
  67376. /**
  67377. * Any regions with a span count smaller than this value will, if possible,
  67378. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67379. */
  67380. mergeRegionArea: number;
  67381. /**
  67382. * The maximum number of vertices allowed for polygons generated during the
  67383. * contour to polygon conversion process. [Limit: >= 3]
  67384. */
  67385. maxVertsPerPoly: number;
  67386. /**
  67387. * Sets the sampling distance to use when generating the detail mesh.
  67388. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67389. */
  67390. detailSampleDist: number;
  67391. /**
  67392. * The maximum distance the detail mesh surface should deviate from heightfield
  67393. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67394. */
  67395. detailSampleMaxError: number;
  67396. }
  67397. }
  67398. declare module BABYLON {
  67399. /**
  67400. * RecastJS navigation plugin
  67401. */
  67402. export class RecastJSPlugin implements INavigationEnginePlugin {
  67403. /**
  67404. * Reference to the Recast library
  67405. */
  67406. bjsRECAST: any;
  67407. /**
  67408. * plugin name
  67409. */
  67410. name: string;
  67411. /**
  67412. * the first navmesh created. We might extend this to support multiple navmeshes
  67413. */
  67414. navMesh: any;
  67415. /**
  67416. * Initializes the recastJS plugin
  67417. * @param recastInjection can be used to inject your own recast reference
  67418. */
  67419. constructor(recastInjection?: any);
  67420. /**
  67421. * Creates a navigation mesh
  67422. * @param meshes array of all the geometry used to compute the navigatio mesh
  67423. * @param parameters bunch of parameters used to filter geometry
  67424. */
  67425. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67426. /**
  67427. * Create a navigation mesh debug mesh
  67428. * @param scene is where the mesh will be added
  67429. * @returns debug display mesh
  67430. */
  67431. createDebugNavMesh(scene: Scene): Mesh;
  67432. /**
  67433. * Get a navigation mesh constrained position, closest to the parameter position
  67434. * @param position world position
  67435. * @returns the closest point to position constrained by the navigation mesh
  67436. */
  67437. getClosestPoint(position: Vector3): Vector3;
  67438. /**
  67439. * Get a navigation mesh constrained position, closest to the parameter position
  67440. * @param position world position
  67441. * @param result output the closest point to position constrained by the navigation mesh
  67442. */
  67443. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67444. /**
  67445. * Get a navigation mesh constrained position, within a particular radius
  67446. * @param position world position
  67447. * @param maxRadius the maximum distance to the constrained world position
  67448. * @returns the closest point to position constrained by the navigation mesh
  67449. */
  67450. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67451. /**
  67452. * Get a navigation mesh constrained position, within a particular radius
  67453. * @param position world position
  67454. * @param maxRadius the maximum distance to the constrained world position
  67455. * @param result output the closest point to position constrained by the navigation mesh
  67456. */
  67457. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67458. /**
  67459. * Compute the final position from a segment made of destination-position
  67460. * @param position world position
  67461. * @param destination world position
  67462. * @returns the resulting point along the navmesh
  67463. */
  67464. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67465. /**
  67466. * Compute the final position from a segment made of destination-position
  67467. * @param position world position
  67468. * @param destination world position
  67469. * @param result output the resulting point along the navmesh
  67470. */
  67471. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67472. /**
  67473. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67474. * @param start world position
  67475. * @param end world position
  67476. * @returns array containing world position composing the path
  67477. */
  67478. computePath(start: Vector3, end: Vector3): Vector3[];
  67479. /**
  67480. * Create a new Crowd so you can add agents
  67481. * @param maxAgents the maximum agent count in the crowd
  67482. * @param maxAgentRadius the maximum radius an agent can have
  67483. * @param scene to attach the crowd to
  67484. * @returns the crowd you can add agents to
  67485. */
  67486. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67487. /**
  67488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67489. * The queries will try to find a solution within those bounds
  67490. * default is (1,1,1)
  67491. * @param extent x,y,z value that define the extent around the queries point of reference
  67492. */
  67493. setDefaultQueryExtent(extent: Vector3): void;
  67494. /**
  67495. * Get the Bounding box extent specified by setDefaultQueryExtent
  67496. * @returns the box extent values
  67497. */
  67498. getDefaultQueryExtent(): Vector3;
  67499. /**
  67500. * build the navmesh from a previously saved state using getNavmeshData
  67501. * @param data the Uint8Array returned by getNavmeshData
  67502. */
  67503. buildFromNavmeshData(data: Uint8Array): void;
  67504. /**
  67505. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67506. * @returns data the Uint8Array that can be saved and reused
  67507. */
  67508. getNavmeshData(): Uint8Array;
  67509. /**
  67510. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67511. * @param result output the box extent values
  67512. */
  67513. getDefaultQueryExtentToRef(result: Vector3): void;
  67514. /**
  67515. * Disposes
  67516. */
  67517. dispose(): void;
  67518. /**
  67519. * If this plugin is supported
  67520. * @returns true if plugin is supported
  67521. */
  67522. isSupported(): boolean;
  67523. }
  67524. /**
  67525. * Recast detour crowd implementation
  67526. */
  67527. export class RecastJSCrowd implements ICrowd {
  67528. /**
  67529. * Recast/detour plugin
  67530. */
  67531. bjsRECASTPlugin: RecastJSPlugin;
  67532. /**
  67533. * Link to the detour crowd
  67534. */
  67535. recastCrowd: any;
  67536. /**
  67537. * One transform per agent
  67538. */
  67539. transforms: TransformNode[];
  67540. /**
  67541. * All agents created
  67542. */
  67543. agents: number[];
  67544. /**
  67545. * Link to the scene is kept to unregister the crowd from the scene
  67546. */
  67547. private _scene;
  67548. /**
  67549. * Observer for crowd updates
  67550. */
  67551. private _onBeforeAnimationsObserver;
  67552. /**
  67553. * Constructor
  67554. * @param plugin recastJS plugin
  67555. * @param maxAgents the maximum agent count in the crowd
  67556. * @param maxAgentRadius the maximum radius an agent can have
  67557. * @param scene to attach the crowd to
  67558. * @returns the crowd you can add agents to
  67559. */
  67560. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67561. /**
  67562. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67563. * You can attach anything to that node. The node position is updated in the scene update tick.
  67564. * @param pos world position that will be constrained by the navigation mesh
  67565. * @param parameters agent parameters
  67566. * @param transform hooked to the agent that will be update by the scene
  67567. * @returns agent index
  67568. */
  67569. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67570. /**
  67571. * Returns the agent position in world space
  67572. * @param index agent index returned by addAgent
  67573. * @returns world space position
  67574. */
  67575. getAgentPosition(index: number): Vector3;
  67576. /**
  67577. * Returns the agent position result in world space
  67578. * @param index agent index returned by addAgent
  67579. * @param result output world space position
  67580. */
  67581. getAgentPositionToRef(index: number, result: Vector3): void;
  67582. /**
  67583. * Returns the agent velocity in world space
  67584. * @param index agent index returned by addAgent
  67585. * @returns world space velocity
  67586. */
  67587. getAgentVelocity(index: number): Vector3;
  67588. /**
  67589. * Returns the agent velocity result in world space
  67590. * @param index agent index returned by addAgent
  67591. * @param result output world space velocity
  67592. */
  67593. getAgentVelocityToRef(index: number, result: Vector3): void;
  67594. /**
  67595. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67596. * @param index agent index returned by addAgent
  67597. * @param destination targeted world position
  67598. */
  67599. agentGoto(index: number, destination: Vector3): void;
  67600. /**
  67601. * Teleport the agent to a new position
  67602. * @param index agent index returned by addAgent
  67603. * @param destination targeted world position
  67604. */
  67605. agentTeleport(index: number, destination: Vector3): void;
  67606. /**
  67607. * Update agent parameters
  67608. * @param index agent index returned by addAgent
  67609. * @param parameters agent parameters
  67610. */
  67611. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67612. /**
  67613. * remove a particular agent previously created
  67614. * @param index agent index returned by addAgent
  67615. */
  67616. removeAgent(index: number): void;
  67617. /**
  67618. * get the list of all agents attached to this crowd
  67619. * @returns list of agent indices
  67620. */
  67621. getAgents(): number[];
  67622. /**
  67623. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67624. * @param deltaTime in seconds
  67625. */
  67626. update(deltaTime: number): void;
  67627. /**
  67628. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67629. * The queries will try to find a solution within those bounds
  67630. * default is (1,1,1)
  67631. * @param extent x,y,z value that define the extent around the queries point of reference
  67632. */
  67633. setDefaultQueryExtent(extent: Vector3): void;
  67634. /**
  67635. * Get the Bounding box extent specified by setDefaultQueryExtent
  67636. * @returns the box extent values
  67637. */
  67638. getDefaultQueryExtent(): Vector3;
  67639. /**
  67640. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67641. * @param result output the box extent values
  67642. */
  67643. getDefaultQueryExtentToRef(result: Vector3): void;
  67644. /**
  67645. * Release all resources
  67646. */
  67647. dispose(): void;
  67648. }
  67649. }
  67650. declare module BABYLON {
  67651. /**
  67652. * Class used to enable access to IndexedDB
  67653. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67654. */
  67655. export class Database implements IOfflineProvider {
  67656. private _callbackManifestChecked;
  67657. private _currentSceneUrl;
  67658. private _db;
  67659. private _enableSceneOffline;
  67660. private _enableTexturesOffline;
  67661. private _manifestVersionFound;
  67662. private _mustUpdateRessources;
  67663. private _hasReachedQuota;
  67664. private _isSupported;
  67665. private _idbFactory;
  67666. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67667. private static IsUASupportingBlobStorage;
  67668. /**
  67669. * Gets a boolean indicating if Database storate is enabled (off by default)
  67670. */
  67671. static IDBStorageEnabled: boolean;
  67672. /**
  67673. * Gets a boolean indicating if scene must be saved in the database
  67674. */
  67675. get enableSceneOffline(): boolean;
  67676. /**
  67677. * Gets a boolean indicating if textures must be saved in the database
  67678. */
  67679. get enableTexturesOffline(): boolean;
  67680. /**
  67681. * Creates a new Database
  67682. * @param urlToScene defines the url to load the scene
  67683. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67684. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67685. */
  67686. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67687. private static _ParseURL;
  67688. private static _ReturnFullUrlLocation;
  67689. private _checkManifestFile;
  67690. /**
  67691. * Open the database and make it available
  67692. * @param successCallback defines the callback to call on success
  67693. * @param errorCallback defines the callback to call on error
  67694. */
  67695. open(successCallback: () => void, errorCallback: () => void): void;
  67696. /**
  67697. * Loads an image from the database
  67698. * @param url defines the url to load from
  67699. * @param image defines the target DOM image
  67700. */
  67701. loadImage(url: string, image: HTMLImageElement): void;
  67702. private _loadImageFromDBAsync;
  67703. private _saveImageIntoDBAsync;
  67704. private _checkVersionFromDB;
  67705. private _loadVersionFromDBAsync;
  67706. private _saveVersionIntoDBAsync;
  67707. /**
  67708. * Loads a file from database
  67709. * @param url defines the URL to load from
  67710. * @param sceneLoaded defines a callback to call on success
  67711. * @param progressCallBack defines a callback to call when progress changed
  67712. * @param errorCallback defines a callback to call on error
  67713. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67714. */
  67715. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67716. private _loadFileAsync;
  67717. private _saveFileAsync;
  67718. /**
  67719. * Validates if xhr data is correct
  67720. * @param xhr defines the request to validate
  67721. * @param dataType defines the expected data type
  67722. * @returns true if data is correct
  67723. */
  67724. private static _ValidateXHRData;
  67725. }
  67726. }
  67727. declare module BABYLON {
  67728. /** @hidden */
  67729. export var gpuUpdateParticlesPixelShader: {
  67730. name: string;
  67731. shader: string;
  67732. };
  67733. }
  67734. declare module BABYLON {
  67735. /** @hidden */
  67736. export var gpuUpdateParticlesVertexShader: {
  67737. name: string;
  67738. shader: string;
  67739. };
  67740. }
  67741. declare module BABYLON {
  67742. /** @hidden */
  67743. export var clipPlaneFragmentDeclaration2: {
  67744. name: string;
  67745. shader: string;
  67746. };
  67747. }
  67748. declare module BABYLON {
  67749. /** @hidden */
  67750. export var gpuRenderParticlesPixelShader: {
  67751. name: string;
  67752. shader: string;
  67753. };
  67754. }
  67755. declare module BABYLON {
  67756. /** @hidden */
  67757. export var clipPlaneVertexDeclaration2: {
  67758. name: string;
  67759. shader: string;
  67760. };
  67761. }
  67762. declare module BABYLON {
  67763. /** @hidden */
  67764. export var gpuRenderParticlesVertexShader: {
  67765. name: string;
  67766. shader: string;
  67767. };
  67768. }
  67769. declare module BABYLON {
  67770. /**
  67771. * This represents a GPU particle system in Babylon
  67772. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67773. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67774. */
  67775. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67776. /**
  67777. * The layer mask we are rendering the particles through.
  67778. */
  67779. layerMask: number;
  67780. private _capacity;
  67781. private _activeCount;
  67782. private _currentActiveCount;
  67783. private _accumulatedCount;
  67784. private _renderEffect;
  67785. private _updateEffect;
  67786. private _buffer0;
  67787. private _buffer1;
  67788. private _spriteBuffer;
  67789. private _updateVAO;
  67790. private _renderVAO;
  67791. private _targetIndex;
  67792. private _sourceBuffer;
  67793. private _targetBuffer;
  67794. private _currentRenderId;
  67795. private _started;
  67796. private _stopped;
  67797. private _timeDelta;
  67798. private _randomTexture;
  67799. private _randomTexture2;
  67800. private _attributesStrideSize;
  67801. private _updateEffectOptions;
  67802. private _randomTextureSize;
  67803. private _actualFrame;
  67804. private _customEffect;
  67805. private readonly _rawTextureWidth;
  67806. /**
  67807. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67808. */
  67809. static get IsSupported(): boolean;
  67810. /**
  67811. * An event triggered when the system is disposed.
  67812. */
  67813. onDisposeObservable: Observable<IParticleSystem>;
  67814. /**
  67815. * Gets the maximum number of particles active at the same time.
  67816. * @returns The max number of active particles.
  67817. */
  67818. getCapacity(): number;
  67819. /**
  67820. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67821. * to override the particles.
  67822. */
  67823. forceDepthWrite: boolean;
  67824. /**
  67825. * Gets or set the number of active particles
  67826. */
  67827. get activeParticleCount(): number;
  67828. set activeParticleCount(value: number);
  67829. private _preWarmDone;
  67830. /**
  67831. * Specifies if the particles are updated in emitter local space or world space.
  67832. */
  67833. isLocal: boolean;
  67834. /** Gets or sets a matrix to use to compute projection */
  67835. defaultProjectionMatrix: Matrix;
  67836. /**
  67837. * Is this system ready to be used/rendered
  67838. * @return true if the system is ready
  67839. */
  67840. isReady(): boolean;
  67841. /**
  67842. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67843. * @returns True if it has been started, otherwise false.
  67844. */
  67845. isStarted(): boolean;
  67846. /**
  67847. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67848. * @returns True if it has been stopped, otherwise false.
  67849. */
  67850. isStopped(): boolean;
  67851. /**
  67852. * Gets a boolean indicating that the system is stopping
  67853. * @returns true if the system is currently stopping
  67854. */
  67855. isStopping(): boolean;
  67856. /**
  67857. * Gets the number of particles active at the same time.
  67858. * @returns The number of active particles.
  67859. */
  67860. getActiveCount(): number;
  67861. /**
  67862. * Starts the particle system and begins to emit
  67863. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67864. */
  67865. start(delay?: number): void;
  67866. /**
  67867. * Stops the particle system.
  67868. */
  67869. stop(): void;
  67870. /**
  67871. * Remove all active particles
  67872. */
  67873. reset(): void;
  67874. /**
  67875. * Returns the string "GPUParticleSystem"
  67876. * @returns a string containing the class name
  67877. */
  67878. getClassName(): string;
  67879. /**
  67880. * Gets the custom effect used to render the particles
  67881. * @param blendMode Blend mode for which the effect should be retrieved
  67882. * @returns The effect
  67883. */
  67884. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67885. /**
  67886. * Sets the custom effect used to render the particles
  67887. * @param effect The effect to set
  67888. * @param blendMode Blend mode for which the effect should be set
  67889. */
  67890. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67891. /** @hidden */
  67892. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67893. /**
  67894. * Observable that will be called just before the particles are drawn
  67895. */
  67896. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67897. /**
  67898. * Gets the name of the particle vertex shader
  67899. */
  67900. get vertexShaderName(): string;
  67901. private _colorGradientsTexture;
  67902. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67903. /**
  67904. * Adds a new color gradient
  67905. * @param gradient defines the gradient to use (between 0 and 1)
  67906. * @param color1 defines the color to affect to the specified gradient
  67907. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67908. * @returns the current particle system
  67909. */
  67910. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67911. private _refreshColorGradient;
  67912. /** Force the system to rebuild all gradients that need to be resync */
  67913. forceRefreshGradients(): void;
  67914. /**
  67915. * Remove a specific color gradient
  67916. * @param gradient defines the gradient to remove
  67917. * @returns the current particle system
  67918. */
  67919. removeColorGradient(gradient: number): GPUParticleSystem;
  67920. private _angularSpeedGradientsTexture;
  67921. private _sizeGradientsTexture;
  67922. private _velocityGradientsTexture;
  67923. private _limitVelocityGradientsTexture;
  67924. private _dragGradientsTexture;
  67925. private _addFactorGradient;
  67926. /**
  67927. * Adds a new size gradient
  67928. * @param gradient defines the gradient to use (between 0 and 1)
  67929. * @param factor defines the size factor to affect to the specified gradient
  67930. * @returns the current particle system
  67931. */
  67932. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67933. /**
  67934. * Remove a specific size gradient
  67935. * @param gradient defines the gradient to remove
  67936. * @returns the current particle system
  67937. */
  67938. removeSizeGradient(gradient: number): GPUParticleSystem;
  67939. private _refreshFactorGradient;
  67940. /**
  67941. * Adds a new angular speed gradient
  67942. * @param gradient defines the gradient to use (between 0 and 1)
  67943. * @param factor defines the angular speed to affect to the specified gradient
  67944. * @returns the current particle system
  67945. */
  67946. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67947. /**
  67948. * Remove a specific angular speed gradient
  67949. * @param gradient defines the gradient to remove
  67950. * @returns the current particle system
  67951. */
  67952. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67953. /**
  67954. * Adds a new velocity gradient
  67955. * @param gradient defines the gradient to use (between 0 and 1)
  67956. * @param factor defines the velocity to affect to the specified gradient
  67957. * @returns the current particle system
  67958. */
  67959. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67960. /**
  67961. * Remove a specific velocity gradient
  67962. * @param gradient defines the gradient to remove
  67963. * @returns the current particle system
  67964. */
  67965. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67966. /**
  67967. * Adds a new limit velocity gradient
  67968. * @param gradient defines the gradient to use (between 0 and 1)
  67969. * @param factor defines the limit velocity value to affect to the specified gradient
  67970. * @returns the current particle system
  67971. */
  67972. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67973. /**
  67974. * Remove a specific limit velocity gradient
  67975. * @param gradient defines the gradient to remove
  67976. * @returns the current particle system
  67977. */
  67978. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67979. /**
  67980. * Adds a new drag gradient
  67981. * @param gradient defines the gradient to use (between 0 and 1)
  67982. * @param factor defines the drag value to affect to the specified gradient
  67983. * @returns the current particle system
  67984. */
  67985. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67986. /**
  67987. * Remove a specific drag gradient
  67988. * @param gradient defines the gradient to remove
  67989. * @returns the current particle system
  67990. */
  67991. removeDragGradient(gradient: number): GPUParticleSystem;
  67992. /**
  67993. * Not supported by GPUParticleSystem
  67994. * @param gradient defines the gradient to use (between 0 and 1)
  67995. * @param factor defines the emit rate value to affect to the specified gradient
  67996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67997. * @returns the current particle system
  67998. */
  67999. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68000. /**
  68001. * Not supported by GPUParticleSystem
  68002. * @param gradient defines the gradient to remove
  68003. * @returns the current particle system
  68004. */
  68005. removeEmitRateGradient(gradient: number): IParticleSystem;
  68006. /**
  68007. * Not supported by GPUParticleSystem
  68008. * @param gradient defines the gradient to use (between 0 and 1)
  68009. * @param factor defines the start size value to affect to the specified gradient
  68010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68011. * @returns the current particle system
  68012. */
  68013. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68014. /**
  68015. * Not supported by GPUParticleSystem
  68016. * @param gradient defines the gradient to remove
  68017. * @returns the current particle system
  68018. */
  68019. removeStartSizeGradient(gradient: number): IParticleSystem;
  68020. /**
  68021. * Not supported by GPUParticleSystem
  68022. * @param gradient defines the gradient to use (between 0 and 1)
  68023. * @param min defines the color remap minimal range
  68024. * @param max defines the color remap maximal range
  68025. * @returns the current particle system
  68026. */
  68027. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68028. /**
  68029. * Not supported by GPUParticleSystem
  68030. * @param gradient defines the gradient to remove
  68031. * @returns the current particle system
  68032. */
  68033. removeColorRemapGradient(): IParticleSystem;
  68034. /**
  68035. * Not supported by GPUParticleSystem
  68036. * @param gradient defines the gradient to use (between 0 and 1)
  68037. * @param min defines the alpha remap minimal range
  68038. * @param max defines the alpha remap maximal range
  68039. * @returns the current particle system
  68040. */
  68041. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68042. /**
  68043. * Not supported by GPUParticleSystem
  68044. * @param gradient defines the gradient to remove
  68045. * @returns the current particle system
  68046. */
  68047. removeAlphaRemapGradient(): IParticleSystem;
  68048. /**
  68049. * Not supported by GPUParticleSystem
  68050. * @param gradient defines the gradient to use (between 0 and 1)
  68051. * @param color defines the color to affect to the specified gradient
  68052. * @returns the current particle system
  68053. */
  68054. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68055. /**
  68056. * Not supported by GPUParticleSystem
  68057. * @param gradient defines the gradient to remove
  68058. * @returns the current particle system
  68059. */
  68060. removeRampGradient(): IParticleSystem;
  68061. /**
  68062. * Not supported by GPUParticleSystem
  68063. * @returns the list of ramp gradients
  68064. */
  68065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68066. /**
  68067. * Not supported by GPUParticleSystem
  68068. * Gets or sets a boolean indicating that ramp gradients must be used
  68069. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68070. */
  68071. get useRampGradients(): boolean;
  68072. set useRampGradients(value: boolean);
  68073. /**
  68074. * Not supported by GPUParticleSystem
  68075. * @param gradient defines the gradient to use (between 0 and 1)
  68076. * @param factor defines the life time factor to affect to the specified gradient
  68077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68078. * @returns the current particle system
  68079. */
  68080. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68081. /**
  68082. * Not supported by GPUParticleSystem
  68083. * @param gradient defines the gradient to remove
  68084. * @returns the current particle system
  68085. */
  68086. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68087. /**
  68088. * Instantiates a GPU particle system.
  68089. * 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.
  68090. * @param name The name of the particle system
  68091. * @param options The options used to create the system
  68092. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68093. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68094. * @param customEffect a custom effect used to change the way particles are rendered by default
  68095. */
  68096. constructor(name: string, options: Partial<{
  68097. capacity: number;
  68098. randomTextureSize: number;
  68099. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68100. protected _reset(): void;
  68101. private _createUpdateVAO;
  68102. private _createRenderVAO;
  68103. private _initialize;
  68104. /** @hidden */
  68105. _recreateUpdateEffect(): void;
  68106. private _getEffect;
  68107. /**
  68108. * Fill the defines array according to the current settings of the particle system
  68109. * @param defines Array to be updated
  68110. * @param blendMode blend mode to take into account when updating the array
  68111. */
  68112. fillDefines(defines: Array<string>, blendMode?: number): void;
  68113. /**
  68114. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68115. * @param uniforms Uniforms array to fill
  68116. * @param attributes Attributes array to fill
  68117. * @param samplers Samplers array to fill
  68118. */
  68119. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68120. /** @hidden */
  68121. _recreateRenderEffect(): Effect;
  68122. /**
  68123. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68124. * @param preWarm defines if we are in the pre-warmimg phase
  68125. */
  68126. animate(preWarm?: boolean): void;
  68127. private _createFactorGradientTexture;
  68128. private _createSizeGradientTexture;
  68129. private _createAngularSpeedGradientTexture;
  68130. private _createVelocityGradientTexture;
  68131. private _createLimitVelocityGradientTexture;
  68132. private _createDragGradientTexture;
  68133. private _createColorGradientTexture;
  68134. /**
  68135. * Renders the particle system in its current state
  68136. * @param preWarm defines if the system should only update the particles but not render them
  68137. * @returns the current number of particles
  68138. */
  68139. render(preWarm?: boolean): number;
  68140. /**
  68141. * Rebuilds the particle system
  68142. */
  68143. rebuild(): void;
  68144. private _releaseBuffers;
  68145. private _releaseVAOs;
  68146. /**
  68147. * Disposes the particle system and free the associated resources
  68148. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68149. */
  68150. dispose(disposeTexture?: boolean): void;
  68151. /**
  68152. * Clones the particle system.
  68153. * @param name The name of the cloned object
  68154. * @param newEmitter The new emitter to use
  68155. * @returns the cloned particle system
  68156. */
  68157. clone(name: string, newEmitter: any): GPUParticleSystem;
  68158. /**
  68159. * Serializes the particle system to a JSON object
  68160. * @param serializeTexture defines if the texture must be serialized as well
  68161. * @returns the JSON object
  68162. */
  68163. serialize(serializeTexture?: boolean): any;
  68164. /**
  68165. * Parses a JSON object to create a GPU particle system.
  68166. * @param parsedParticleSystem The JSON object to parse
  68167. * @param sceneOrEngine The scene or the engine to create the particle system in
  68168. * @param rootUrl The root url to use to load external dependencies like texture
  68169. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68170. * @returns the parsed GPU particle system
  68171. */
  68172. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68173. }
  68174. }
  68175. declare module BABYLON {
  68176. /**
  68177. * Represents a set of particle systems working together to create a specific effect
  68178. */
  68179. export class ParticleSystemSet implements IDisposable {
  68180. /**
  68181. * Gets or sets base Assets URL
  68182. */
  68183. static BaseAssetsUrl: string;
  68184. private _emitterCreationOptions;
  68185. private _emitterNode;
  68186. /**
  68187. * Gets the particle system list
  68188. */
  68189. systems: IParticleSystem[];
  68190. /**
  68191. * Gets the emitter node used with this set
  68192. */
  68193. get emitterNode(): Nullable<TransformNode>;
  68194. /**
  68195. * Creates a new emitter mesh as a sphere
  68196. * @param options defines the options used to create the sphere
  68197. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68198. * @param scene defines the hosting scene
  68199. */
  68200. setEmitterAsSphere(options: {
  68201. diameter: number;
  68202. segments: number;
  68203. color: Color3;
  68204. }, renderingGroupId: number, scene: Scene): void;
  68205. /**
  68206. * Starts all particle systems of the set
  68207. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68208. */
  68209. start(emitter?: AbstractMesh): void;
  68210. /**
  68211. * Release all associated resources
  68212. */
  68213. dispose(): void;
  68214. /**
  68215. * Serialize the set into a JSON compatible object
  68216. * @param serializeTexture defines if the texture must be serialized as well
  68217. * @returns a JSON compatible representation of the set
  68218. */
  68219. serialize(serializeTexture?: boolean): any;
  68220. /**
  68221. * Parse a new ParticleSystemSet from a serialized source
  68222. * @param data defines a JSON compatible representation of the set
  68223. * @param scene defines the hosting scene
  68224. * @param gpu defines if we want GPU particles or CPU particles
  68225. * @returns a new ParticleSystemSet
  68226. */
  68227. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * This class is made for on one-liner static method to help creating particle system set.
  68233. */
  68234. export class ParticleHelper {
  68235. /**
  68236. * Gets or sets base Assets URL
  68237. */
  68238. static BaseAssetsUrl: string;
  68239. /** Define the Url to load snippets */
  68240. static SnippetUrl: string;
  68241. /**
  68242. * Create a default particle system that you can tweak
  68243. * @param emitter defines the emitter to use
  68244. * @param capacity defines the system capacity (default is 500 particles)
  68245. * @param scene defines the hosting scene
  68246. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68247. * @returns the new Particle system
  68248. */
  68249. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68250. /**
  68251. * This is the main static method (one-liner) of this helper to create different particle systems
  68252. * @param type This string represents the type to the particle system to create
  68253. * @param scene The scene where the particle system should live
  68254. * @param gpu If the system will use gpu
  68255. * @returns the ParticleSystemSet created
  68256. */
  68257. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68258. /**
  68259. * Static function used to export a particle system to a ParticleSystemSet variable.
  68260. * Please note that the emitter shape is not exported
  68261. * @param systems defines the particle systems to export
  68262. * @returns the created particle system set
  68263. */
  68264. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68265. /**
  68266. * Creates a particle system from a snippet saved in a remote file
  68267. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68268. * @param url defines the url to load from
  68269. * @param scene defines the hosting scene
  68270. * @param gpu If the system will use gpu
  68271. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68272. * @returns a promise that will resolve to the new particle system
  68273. */
  68274. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68275. /**
  68276. * Creates a particle system from a snippet saved by the particle system editor
  68277. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68278. * @param scene defines the hosting scene
  68279. * @param gpu If the system will use gpu
  68280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68281. * @returns a promise that will resolve to the new particle system
  68282. */
  68283. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68284. }
  68285. }
  68286. declare module BABYLON {
  68287. interface Engine {
  68288. /**
  68289. * Create an effect to use with particle systems.
  68290. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68291. * the particle system for which you want to create a custom effect in the last parameter
  68292. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68293. * @param uniformsNames defines a list of attribute names
  68294. * @param samplers defines an array of string used to represent textures
  68295. * @param defines defines the string containing the defines to use to compile the shaders
  68296. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68297. * @param onCompiled defines a function to call when the effect creation is successful
  68298. * @param onError defines a function to call when the effect creation has failed
  68299. * @param particleSystem the particle system you want to create the effect for
  68300. * @returns the new Effect
  68301. */
  68302. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68303. }
  68304. interface Mesh {
  68305. /**
  68306. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68307. * @returns an array of IParticleSystem
  68308. */
  68309. getEmittedParticleSystems(): IParticleSystem[];
  68310. /**
  68311. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68312. * @returns an array of IParticleSystem
  68313. */
  68314. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68315. }
  68316. }
  68317. declare module BABYLON {
  68318. /** Defines the 4 color options */
  68319. export enum PointColor {
  68320. /** color value */
  68321. Color = 2,
  68322. /** uv value */
  68323. UV = 1,
  68324. /** random value */
  68325. Random = 0,
  68326. /** stated value */
  68327. Stated = 3
  68328. }
  68329. /**
  68330. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68331. * 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.
  68332. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68333. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68334. *
  68335. * Full documentation here : TO BE ENTERED
  68336. */
  68337. export class PointsCloudSystem implements IDisposable {
  68338. /**
  68339. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68340. * Example : var p = SPS.particles[i];
  68341. */
  68342. particles: CloudPoint[];
  68343. /**
  68344. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68345. */
  68346. nbParticles: number;
  68347. /**
  68348. * This a counter for your own usage. It's not set by any SPS functions.
  68349. */
  68350. counter: number;
  68351. /**
  68352. * The PCS name. This name is also given to the underlying mesh.
  68353. */
  68354. name: string;
  68355. /**
  68356. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68357. */
  68358. mesh: Mesh;
  68359. /**
  68360. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68361. * Please read :
  68362. */
  68363. vars: any;
  68364. /**
  68365. * @hidden
  68366. */
  68367. _size: number;
  68368. private _scene;
  68369. private _promises;
  68370. private _positions;
  68371. private _indices;
  68372. private _normals;
  68373. private _colors;
  68374. private _uvs;
  68375. private _indices32;
  68376. private _positions32;
  68377. private _colors32;
  68378. private _uvs32;
  68379. private _updatable;
  68380. private _isVisibilityBoxLocked;
  68381. private _alwaysVisible;
  68382. private _groups;
  68383. private _groupCounter;
  68384. private _computeParticleColor;
  68385. private _computeParticleTexture;
  68386. private _computeParticleRotation;
  68387. private _computeBoundingBox;
  68388. private _isReady;
  68389. /**
  68390. * Creates a PCS (Points Cloud System) object
  68391. * @param name (String) is the PCS name, this will be the underlying mesh name
  68392. * @param pointSize (number) is the size for each point
  68393. * @param scene (Scene) is the scene in which the PCS is added
  68394. * @param options defines the options of the PCS e.g.
  68395. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68396. */
  68397. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68398. updatable?: boolean;
  68399. });
  68400. /**
  68401. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68402. * If no points were added to the PCS, the returned mesh is just a single point.
  68403. * @returns a promise for the created mesh
  68404. */
  68405. buildMeshAsync(): Promise<Mesh>;
  68406. /**
  68407. * @hidden
  68408. */
  68409. private _buildMesh;
  68410. private _addParticle;
  68411. private _randomUnitVector;
  68412. private _getColorIndicesForCoord;
  68413. private _setPointsColorOrUV;
  68414. private _colorFromTexture;
  68415. private _calculateDensity;
  68416. /**
  68417. * Adds points to the PCS in random positions within a unit sphere
  68418. * @param nb (positive integer) the number of particles to be created from this model
  68419. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68420. * @returns the number of groups in the system
  68421. */
  68422. addPoints(nb: number, pointFunction?: any): number;
  68423. /**
  68424. * Adds points to the PCS from the surface of the model shape
  68425. * @param mesh is any Mesh object that will be used as a surface model for the points
  68426. * @param nb (positive integer) the number of particles to be created from this model
  68427. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68428. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68429. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68430. * @returns the number of groups in the system
  68431. */
  68432. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68433. /**
  68434. * Adds points to the PCS inside the model shape
  68435. * @param mesh is any Mesh object that will be used as a surface model for the points
  68436. * @param nb (positive integer) the number of particles to be created from this model
  68437. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68438. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68439. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68440. * @returns the number of groups in the system
  68441. */
  68442. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68443. /**
  68444. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68445. * This method calls `updateParticle()` for each particle of the SPS.
  68446. * For an animated SPS, it is usually called within the render loop.
  68447. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68448. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68449. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68450. * @returns the PCS.
  68451. */
  68452. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68453. /**
  68454. * Disposes the PCS.
  68455. */
  68456. dispose(): void;
  68457. /**
  68458. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68459. * doc :
  68460. * @returns the PCS.
  68461. */
  68462. refreshVisibleSize(): PointsCloudSystem;
  68463. /**
  68464. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68465. * @param size the size (float) of the visibility box
  68466. * note : this doesn't lock the PCS mesh bounding box.
  68467. * doc :
  68468. */
  68469. setVisibilityBox(size: number): void;
  68470. /**
  68471. * Gets whether the PCS is always visible or not
  68472. * doc :
  68473. */
  68474. get isAlwaysVisible(): boolean;
  68475. /**
  68476. * Sets the PCS as always visible or not
  68477. * doc :
  68478. */
  68479. set isAlwaysVisible(val: boolean);
  68480. /**
  68481. * Tells to `setParticles()` to compute the particle rotations or not
  68482. * Default value : false. The PCS is faster when it's set to false
  68483. * Note : particle rotations are only applied to parent particles
  68484. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68485. */
  68486. set computeParticleRotation(val: boolean);
  68487. /**
  68488. * Tells to `setParticles()` to compute the particle colors or not.
  68489. * Default value : true. The PCS is faster when it's set to false.
  68490. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68491. */
  68492. set computeParticleColor(val: boolean);
  68493. set computeParticleTexture(val: boolean);
  68494. /**
  68495. * Gets if `setParticles()` computes the particle colors or not.
  68496. * Default value : false. The PCS is faster when it's set to false.
  68497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68498. */
  68499. get computeParticleColor(): boolean;
  68500. /**
  68501. * Gets if `setParticles()` computes the particle textures or not.
  68502. * Default value : false. The PCS is faster when it's set to false.
  68503. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68504. */
  68505. get computeParticleTexture(): boolean;
  68506. /**
  68507. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68508. */
  68509. set computeBoundingBox(val: boolean);
  68510. /**
  68511. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68512. */
  68513. get computeBoundingBox(): boolean;
  68514. /**
  68515. * This function does nothing. It may be overwritten to set all the particle first values.
  68516. * The PCS doesn't call this function, you may have to call it by your own.
  68517. * doc :
  68518. */
  68519. initParticles(): void;
  68520. /**
  68521. * This function does nothing. It may be overwritten to recycle a particle
  68522. * The PCS doesn't call this function, you can to call it
  68523. * doc :
  68524. * @param particle The particle to recycle
  68525. * @returns the recycled particle
  68526. */
  68527. recycleParticle(particle: CloudPoint): CloudPoint;
  68528. /**
  68529. * Updates a particle : this function should be overwritten by the user.
  68530. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68531. * doc :
  68532. * @example : just set a particle position or velocity and recycle conditions
  68533. * @param particle The particle to update
  68534. * @returns the updated particle
  68535. */
  68536. updateParticle(particle: CloudPoint): CloudPoint;
  68537. /**
  68538. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68539. * This does nothing and may be overwritten by the user.
  68540. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68541. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68542. * @param update the boolean update value actually passed to setParticles()
  68543. */
  68544. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68545. /**
  68546. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68547. * This will be passed three parameters.
  68548. * This does nothing and may be overwritten by the user.
  68549. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68550. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68551. * @param update the boolean update value actually passed to setParticles()
  68552. */
  68553. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68554. }
  68555. }
  68556. declare module BABYLON {
  68557. /**
  68558. * Represents one particle of a points cloud system.
  68559. */
  68560. export class CloudPoint {
  68561. /**
  68562. * particle global index
  68563. */
  68564. idx: number;
  68565. /**
  68566. * The color of the particle
  68567. */
  68568. color: Nullable<Color4>;
  68569. /**
  68570. * The world space position of the particle.
  68571. */
  68572. position: Vector3;
  68573. /**
  68574. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68575. */
  68576. rotation: Vector3;
  68577. /**
  68578. * The world space rotation quaternion of the particle.
  68579. */
  68580. rotationQuaternion: Nullable<Quaternion>;
  68581. /**
  68582. * The uv of the particle.
  68583. */
  68584. uv: Nullable<Vector2>;
  68585. /**
  68586. * The current speed of the particle.
  68587. */
  68588. velocity: Vector3;
  68589. /**
  68590. * The pivot point in the particle local space.
  68591. */
  68592. pivot: Vector3;
  68593. /**
  68594. * Must the particle be translated from its pivot point in its local space ?
  68595. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68596. * Default : false
  68597. */
  68598. translateFromPivot: boolean;
  68599. /**
  68600. * Index of this particle in the global "positions" array (Internal use)
  68601. * @hidden
  68602. */
  68603. _pos: number;
  68604. /**
  68605. * @hidden Index of this particle in the global "indices" array (Internal use)
  68606. */
  68607. _ind: number;
  68608. /**
  68609. * Group this particle belongs to
  68610. */
  68611. _group: PointsGroup;
  68612. /**
  68613. * Group id of this particle
  68614. */
  68615. groupId: number;
  68616. /**
  68617. * Index of the particle in its group id (Internal use)
  68618. */
  68619. idxInGroup: number;
  68620. /**
  68621. * @hidden Particle BoundingInfo object (Internal use)
  68622. */
  68623. _boundingInfo: BoundingInfo;
  68624. /**
  68625. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68626. */
  68627. _pcs: PointsCloudSystem;
  68628. /**
  68629. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68630. */
  68631. _stillInvisible: boolean;
  68632. /**
  68633. * @hidden Last computed particle rotation matrix
  68634. */
  68635. _rotationMatrix: number[];
  68636. /**
  68637. * Parent particle Id, if any.
  68638. * Default null.
  68639. */
  68640. parentId: Nullable<number>;
  68641. /**
  68642. * @hidden Internal global position in the PCS.
  68643. */
  68644. _globalPosition: Vector3;
  68645. /**
  68646. * Creates a Point Cloud object.
  68647. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68648. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68649. * @param group (PointsGroup) is the group the particle belongs to
  68650. * @param groupId (integer) is the group identifier in the PCS.
  68651. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68652. * @param pcs defines the PCS it is associated to
  68653. */
  68654. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68655. /**
  68656. * get point size
  68657. */
  68658. get size(): Vector3;
  68659. /**
  68660. * Set point size
  68661. */
  68662. set size(scale: Vector3);
  68663. /**
  68664. * Legacy support, changed quaternion to rotationQuaternion
  68665. */
  68666. get quaternion(): Nullable<Quaternion>;
  68667. /**
  68668. * Legacy support, changed quaternion to rotationQuaternion
  68669. */
  68670. set quaternion(q: Nullable<Quaternion>);
  68671. /**
  68672. * Returns a boolean. True if the particle intersects a mesh, else false
  68673. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68674. * @param target is the object (point or mesh) what the intersection is computed against
  68675. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68676. * @returns true if it intersects
  68677. */
  68678. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68679. /**
  68680. * get the rotation matrix of the particle
  68681. * @hidden
  68682. */
  68683. getRotationMatrix(m: Matrix): void;
  68684. }
  68685. /**
  68686. * Represents a group of points in a points cloud system
  68687. * * PCS internal tool, don't use it manually.
  68688. */
  68689. export class PointsGroup {
  68690. /**
  68691. * The group id
  68692. * @hidden
  68693. */
  68694. groupID: number;
  68695. /**
  68696. * image data for group (internal use)
  68697. * @hidden
  68698. */
  68699. _groupImageData: Nullable<ArrayBufferView>;
  68700. /**
  68701. * Image Width (internal use)
  68702. * @hidden
  68703. */
  68704. _groupImgWidth: number;
  68705. /**
  68706. * Image Height (internal use)
  68707. * @hidden
  68708. */
  68709. _groupImgHeight: number;
  68710. /**
  68711. * Custom position function (internal use)
  68712. * @hidden
  68713. */
  68714. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68715. /**
  68716. * density per facet for surface points
  68717. * @hidden
  68718. */
  68719. _groupDensity: number[];
  68720. /**
  68721. * Only when points are colored by texture carries pointer to texture list array
  68722. * @hidden
  68723. */
  68724. _textureNb: number;
  68725. /**
  68726. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68727. * PCS internal tool, don't use it manually.
  68728. * @hidden
  68729. */
  68730. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68731. }
  68732. }
  68733. declare module BABYLON {
  68734. interface Scene {
  68735. /** @hidden (Backing field) */
  68736. _physicsEngine: Nullable<IPhysicsEngine>;
  68737. /** @hidden */
  68738. _physicsTimeAccumulator: number;
  68739. /**
  68740. * Gets the current physics engine
  68741. * @returns a IPhysicsEngine or null if none attached
  68742. */
  68743. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68744. /**
  68745. * Enables physics to the current scene
  68746. * @param gravity defines the scene's gravity for the physics engine
  68747. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68748. * @return a boolean indicating if the physics engine was initialized
  68749. */
  68750. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68751. /**
  68752. * Disables and disposes the physics engine associated with the scene
  68753. */
  68754. disablePhysicsEngine(): void;
  68755. /**
  68756. * Gets a boolean indicating if there is an active physics engine
  68757. * @returns a boolean indicating if there is an active physics engine
  68758. */
  68759. isPhysicsEnabled(): boolean;
  68760. /**
  68761. * Deletes a physics compound impostor
  68762. * @param compound defines the compound to delete
  68763. */
  68764. deleteCompoundImpostor(compound: any): void;
  68765. /**
  68766. * An event triggered when physic simulation is about to be run
  68767. */
  68768. onBeforePhysicsObservable: Observable<Scene>;
  68769. /**
  68770. * An event triggered when physic simulation has been done
  68771. */
  68772. onAfterPhysicsObservable: Observable<Scene>;
  68773. }
  68774. interface AbstractMesh {
  68775. /** @hidden */
  68776. _physicsImpostor: Nullable<PhysicsImpostor>;
  68777. /**
  68778. * Gets or sets impostor used for physic simulation
  68779. * @see https://doc.babylonjs.com/features/physics_engine
  68780. */
  68781. physicsImpostor: Nullable<PhysicsImpostor>;
  68782. /**
  68783. * Gets the current physics impostor
  68784. * @see https://doc.babylonjs.com/features/physics_engine
  68785. * @returns a physics impostor or null
  68786. */
  68787. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68788. /** Apply a physic impulse to the mesh
  68789. * @param force defines the force to apply
  68790. * @param contactPoint defines where to apply the force
  68791. * @returns the current mesh
  68792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68793. */
  68794. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68795. /**
  68796. * Creates a physic joint between two meshes
  68797. * @param otherMesh defines the other mesh to use
  68798. * @param pivot1 defines the pivot to use on this mesh
  68799. * @param pivot2 defines the pivot to use on the other mesh
  68800. * @param options defines additional options (can be plugin dependent)
  68801. * @returns the current mesh
  68802. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68803. */
  68804. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68805. /** @hidden */
  68806. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68807. }
  68808. /**
  68809. * Defines the physics engine scene component responsible to manage a physics engine
  68810. */
  68811. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68812. /**
  68813. * The component name helpful to identify the component in the list of scene components.
  68814. */
  68815. readonly name: string;
  68816. /**
  68817. * The scene the component belongs to.
  68818. */
  68819. scene: Scene;
  68820. /**
  68821. * Creates a new instance of the component for the given scene
  68822. * @param scene Defines the scene to register the component in
  68823. */
  68824. constructor(scene: Scene);
  68825. /**
  68826. * Registers the component in a given scene
  68827. */
  68828. register(): void;
  68829. /**
  68830. * Rebuilds the elements related to this component in case of
  68831. * context lost for instance.
  68832. */
  68833. rebuild(): void;
  68834. /**
  68835. * Disposes the component and the associated ressources
  68836. */
  68837. dispose(): void;
  68838. }
  68839. }
  68840. declare module BABYLON {
  68841. /**
  68842. * A helper for physics simulations
  68843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68844. */
  68845. export class PhysicsHelper {
  68846. private _scene;
  68847. private _physicsEngine;
  68848. /**
  68849. * Initializes the Physics helper
  68850. * @param scene Babylon.js scene
  68851. */
  68852. constructor(scene: Scene);
  68853. /**
  68854. * Applies a radial explosion impulse
  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 radial explosion event, or null
  68860. */
  68861. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68862. /**
  68863. * Applies a radial explosion force
  68864. * @param origin the origin of the explosion
  68865. * @param radiusOrEventOptions the radius or the options of radial explosion
  68866. * @param strength the explosion strength
  68867. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68868. * @returns A physics radial explosion event, or null
  68869. */
  68870. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68871. /**
  68872. * Creates a gravitational field
  68873. * @param origin the origin of the explosion
  68874. * @param radiusOrEventOptions the radius or the options of radial explosion
  68875. * @param strength the explosion strength
  68876. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68877. * @returns A physics gravitational field event, or null
  68878. */
  68879. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68880. /**
  68881. * Creates a physics updraft event
  68882. * @param origin the origin of the updraft
  68883. * @param radiusOrEventOptions the radius or the options of the updraft
  68884. * @param strength the strength of the updraft
  68885. * @param height the height of the updraft
  68886. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68887. * @returns A physics updraft event, or null
  68888. */
  68889. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68890. /**
  68891. * Creates a physics vortex event
  68892. * @param origin the of the vortex
  68893. * @param radiusOrEventOptions the radius or the options of the vortex
  68894. * @param strength the strength of the vortex
  68895. * @param height the height of the vortex
  68896. * @returns a Physics vortex event, or null
  68897. * A physics vortex event or null
  68898. */
  68899. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68900. }
  68901. /**
  68902. * Represents a physics radial explosion event
  68903. */
  68904. class PhysicsRadialExplosionEvent {
  68905. private _scene;
  68906. private _options;
  68907. private _sphere;
  68908. private _dataFetched;
  68909. /**
  68910. * Initializes a radial explosioin event
  68911. * @param _scene BabylonJS scene
  68912. * @param _options The options for the vortex event
  68913. */
  68914. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68915. /**
  68916. * Returns the data related to the radial explosion event (sphere).
  68917. * @returns The radial explosion event data
  68918. */
  68919. getData(): PhysicsRadialExplosionEventData;
  68920. /**
  68921. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68922. * @param impostor A physics imposter
  68923. * @param origin the origin of the explosion
  68924. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68925. */
  68926. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68927. /**
  68928. * Triggers affecterd impostors callbacks
  68929. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68930. */
  68931. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68932. /**
  68933. * Disposes the sphere.
  68934. * @param force Specifies if the sphere should be disposed by force
  68935. */
  68936. dispose(force?: boolean): void;
  68937. /*** Helpers ***/
  68938. private _prepareSphere;
  68939. private _intersectsWithSphere;
  68940. }
  68941. /**
  68942. * Represents a gravitational field event
  68943. */
  68944. class PhysicsGravitationalFieldEvent {
  68945. private _physicsHelper;
  68946. private _scene;
  68947. private _origin;
  68948. private _options;
  68949. private _tickCallback;
  68950. private _sphere;
  68951. private _dataFetched;
  68952. /**
  68953. * Initializes the physics gravitational field event
  68954. * @param _physicsHelper A physics helper
  68955. * @param _scene BabylonJS scene
  68956. * @param _origin The origin position of the gravitational field event
  68957. * @param _options The options for the vortex event
  68958. */
  68959. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68960. /**
  68961. * Returns the data related to the gravitational field event (sphere).
  68962. * @returns A gravitational field event
  68963. */
  68964. getData(): PhysicsGravitationalFieldEventData;
  68965. /**
  68966. * Enables the gravitational field.
  68967. */
  68968. enable(): void;
  68969. /**
  68970. * Disables the gravitational field.
  68971. */
  68972. disable(): void;
  68973. /**
  68974. * Disposes the sphere.
  68975. * @param force The force to dispose from the gravitational field event
  68976. */
  68977. dispose(force?: boolean): void;
  68978. private _tick;
  68979. }
  68980. /**
  68981. * Represents a physics updraft event
  68982. */
  68983. class PhysicsUpdraftEvent {
  68984. private _scene;
  68985. private _origin;
  68986. private _options;
  68987. private _physicsEngine;
  68988. private _originTop;
  68989. private _originDirection;
  68990. private _tickCallback;
  68991. private _cylinder;
  68992. private _cylinderPosition;
  68993. private _dataFetched;
  68994. /**
  68995. * Initializes the physics updraft event
  68996. * @param _scene BabylonJS scene
  68997. * @param _origin The origin position of the updraft
  68998. * @param _options The options for the updraft event
  68999. */
  69000. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69001. /**
  69002. * Returns the data related to the updraft event (cylinder).
  69003. * @returns A physics updraft event
  69004. */
  69005. getData(): PhysicsUpdraftEventData;
  69006. /**
  69007. * Enables the updraft.
  69008. */
  69009. enable(): void;
  69010. /**
  69011. * Disables the updraft.
  69012. */
  69013. disable(): void;
  69014. /**
  69015. * Disposes the cylinder.
  69016. * @param force Specifies if the updraft should be disposed by force
  69017. */
  69018. dispose(force?: boolean): void;
  69019. private getImpostorHitData;
  69020. private _tick;
  69021. /*** Helpers ***/
  69022. private _prepareCylinder;
  69023. private _intersectsWithCylinder;
  69024. }
  69025. /**
  69026. * Represents a physics vortex event
  69027. */
  69028. class PhysicsVortexEvent {
  69029. private _scene;
  69030. private _origin;
  69031. private _options;
  69032. private _physicsEngine;
  69033. private _originTop;
  69034. private _tickCallback;
  69035. private _cylinder;
  69036. private _cylinderPosition;
  69037. private _dataFetched;
  69038. /**
  69039. * Initializes the physics vortex event
  69040. * @param _scene The BabylonJS scene
  69041. * @param _origin The origin position of the vortex
  69042. * @param _options The options for the vortex event
  69043. */
  69044. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69045. /**
  69046. * Returns the data related to the vortex event (cylinder).
  69047. * @returns The physics vortex event data
  69048. */
  69049. getData(): PhysicsVortexEventData;
  69050. /**
  69051. * Enables the vortex.
  69052. */
  69053. enable(): void;
  69054. /**
  69055. * Disables the cortex.
  69056. */
  69057. disable(): void;
  69058. /**
  69059. * Disposes the sphere.
  69060. * @param force
  69061. */
  69062. dispose(force?: boolean): void;
  69063. private getImpostorHitData;
  69064. private _tick;
  69065. /*** Helpers ***/
  69066. private _prepareCylinder;
  69067. private _intersectsWithCylinder;
  69068. }
  69069. /**
  69070. * Options fot the radial explosion event
  69071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69072. */
  69073. export class PhysicsRadialExplosionEventOptions {
  69074. /**
  69075. * The radius of the sphere for the radial explosion.
  69076. */
  69077. radius: number;
  69078. /**
  69079. * The strenth of the explosion.
  69080. */
  69081. strength: number;
  69082. /**
  69083. * The strenght of the force in correspondence to the distance of the affected object
  69084. */
  69085. falloff: PhysicsRadialImpulseFalloff;
  69086. /**
  69087. * Sphere options for the radial explosion.
  69088. */
  69089. sphere: {
  69090. segments: number;
  69091. diameter: number;
  69092. };
  69093. /**
  69094. * Sphere options for the radial explosion.
  69095. */
  69096. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69097. }
  69098. /**
  69099. * Options fot the updraft event
  69100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69101. */
  69102. export class PhysicsUpdraftEventOptions {
  69103. /**
  69104. * The radius of the cylinder for the vortex
  69105. */
  69106. radius: number;
  69107. /**
  69108. * The strenth of the updraft.
  69109. */
  69110. strength: number;
  69111. /**
  69112. * The height of the cylinder for the updraft.
  69113. */
  69114. height: number;
  69115. /**
  69116. * The mode for the the updraft.
  69117. */
  69118. updraftMode: PhysicsUpdraftMode;
  69119. }
  69120. /**
  69121. * Options fot the vortex event
  69122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69123. */
  69124. export class PhysicsVortexEventOptions {
  69125. /**
  69126. * The radius of the cylinder for the vortex
  69127. */
  69128. radius: number;
  69129. /**
  69130. * The strenth of the vortex.
  69131. */
  69132. strength: number;
  69133. /**
  69134. * The height of the cylinder for the vortex.
  69135. */
  69136. height: number;
  69137. /**
  69138. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69139. */
  69140. centripetalForceThreshold: number;
  69141. /**
  69142. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69143. */
  69144. centripetalForceMultiplier: number;
  69145. /**
  69146. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69147. */
  69148. centrifugalForceMultiplier: number;
  69149. /**
  69150. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69151. */
  69152. updraftForceMultiplier: number;
  69153. }
  69154. /**
  69155. * The strenght of the force in correspondence to the distance of the affected object
  69156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69157. */
  69158. export enum PhysicsRadialImpulseFalloff {
  69159. /** Defines that impulse is constant in strength across it's whole radius */
  69160. Constant = 0,
  69161. /** Defines that impulse gets weaker if it's further from the origin */
  69162. Linear = 1
  69163. }
  69164. /**
  69165. * The strength of the force in correspondence to the distance of the affected object
  69166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69167. */
  69168. export enum PhysicsUpdraftMode {
  69169. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69170. Center = 0,
  69171. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69172. Perpendicular = 1
  69173. }
  69174. /**
  69175. * Interface for a physics hit data
  69176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69177. */
  69178. export interface PhysicsHitData {
  69179. /**
  69180. * The force applied at the contact point
  69181. */
  69182. force: Vector3;
  69183. /**
  69184. * The contact point
  69185. */
  69186. contactPoint: Vector3;
  69187. /**
  69188. * The distance from the origin to the contact point
  69189. */
  69190. distanceFromOrigin: number;
  69191. }
  69192. /**
  69193. * Interface for radial explosion event data
  69194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69195. */
  69196. export interface PhysicsRadialExplosionEventData {
  69197. /**
  69198. * A sphere used for the radial explosion event
  69199. */
  69200. sphere: Mesh;
  69201. }
  69202. /**
  69203. * Interface for gravitational field event data
  69204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69205. */
  69206. export interface PhysicsGravitationalFieldEventData {
  69207. /**
  69208. * A sphere mesh used for the gravitational field event
  69209. */
  69210. sphere: Mesh;
  69211. }
  69212. /**
  69213. * Interface for updraft event data
  69214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69215. */
  69216. export interface PhysicsUpdraftEventData {
  69217. /**
  69218. * A cylinder used for the updraft event
  69219. */
  69220. cylinder: Mesh;
  69221. }
  69222. /**
  69223. * Interface for vortex event data
  69224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69225. */
  69226. export interface PhysicsVortexEventData {
  69227. /**
  69228. * A cylinder used for the vortex event
  69229. */
  69230. cylinder: Mesh;
  69231. }
  69232. /**
  69233. * Interface for an affected physics impostor
  69234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69235. */
  69236. export interface PhysicsAffectedImpostorWithData {
  69237. /**
  69238. * The impostor affected by the effect
  69239. */
  69240. impostor: PhysicsImpostor;
  69241. /**
  69242. * The data about the hit/horce from the explosion
  69243. */
  69244. hitData: PhysicsHitData;
  69245. }
  69246. }
  69247. declare module BABYLON {
  69248. /** @hidden */
  69249. export var blackAndWhitePixelShader: {
  69250. name: string;
  69251. shader: string;
  69252. };
  69253. }
  69254. declare module BABYLON {
  69255. /**
  69256. * Post process used to render in black and white
  69257. */
  69258. export class BlackAndWhitePostProcess extends PostProcess {
  69259. /**
  69260. * Linear about to convert he result to black and white (default: 1)
  69261. */
  69262. degree: number;
  69263. /**
  69264. * Gets a string identifying the name of the class
  69265. * @returns "BlackAndWhitePostProcess" string
  69266. */
  69267. getClassName(): string;
  69268. /**
  69269. * Creates a black and white post process
  69270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69271. * @param name The name of the effect.
  69272. * @param options The required width/height ratio to downsize to before computing the render pass.
  69273. * @param camera The camera to apply the render pass to.
  69274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69275. * @param engine The engine which the post process will be applied. (default: current engine)
  69276. * @param reusable If the post process can be reused on the same frame. (default: false)
  69277. */
  69278. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69279. /** @hidden */
  69280. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69281. }
  69282. }
  69283. declare module BABYLON {
  69284. /**
  69285. * This represents a set of one or more post processes in Babylon.
  69286. * A post process can be used to apply a shader to a texture after it is rendered.
  69287. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69288. */
  69289. export class PostProcessRenderEffect {
  69290. private _postProcesses;
  69291. private _getPostProcesses;
  69292. private _singleInstance;
  69293. private _cameras;
  69294. private _indicesForCamera;
  69295. /**
  69296. * Name of the effect
  69297. * @hidden
  69298. */
  69299. _name: string;
  69300. /**
  69301. * Instantiates a post process render effect.
  69302. * A post process can be used to apply a shader to a texture after it is rendered.
  69303. * @param engine The engine the effect is tied to
  69304. * @param name The name of the effect
  69305. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69306. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69307. */
  69308. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69309. /**
  69310. * Checks if all the post processes in the effect are supported.
  69311. */
  69312. get isSupported(): boolean;
  69313. /**
  69314. * Updates the current state of the effect
  69315. * @hidden
  69316. */
  69317. _update(): void;
  69318. /**
  69319. * Attaches the effect on cameras
  69320. * @param cameras The camera to attach to.
  69321. * @hidden
  69322. */
  69323. _attachCameras(cameras: Camera): void;
  69324. /**
  69325. * Attaches the effect on cameras
  69326. * @param cameras The camera to attach to.
  69327. * @hidden
  69328. */
  69329. _attachCameras(cameras: Camera[]): void;
  69330. /**
  69331. * Detaches the effect on cameras
  69332. * @param cameras The camera to detatch from.
  69333. * @hidden
  69334. */
  69335. _detachCameras(cameras: Camera): void;
  69336. /**
  69337. * Detatches the effect on cameras
  69338. * @param cameras The camera to detatch from.
  69339. * @hidden
  69340. */
  69341. _detachCameras(cameras: Camera[]): void;
  69342. /**
  69343. * Enables the effect on given cameras
  69344. * @param cameras The camera to enable.
  69345. * @hidden
  69346. */
  69347. _enable(cameras: Camera): void;
  69348. /**
  69349. * Enables the effect on given cameras
  69350. * @param cameras The camera to enable.
  69351. * @hidden
  69352. */
  69353. _enable(cameras: Nullable<Camera[]>): void;
  69354. /**
  69355. * Disables the effect on the given cameras
  69356. * @param cameras The camera to disable.
  69357. * @hidden
  69358. */
  69359. _disable(cameras: Camera): void;
  69360. /**
  69361. * Disables the effect on the given cameras
  69362. * @param cameras The camera to disable.
  69363. * @hidden
  69364. */
  69365. _disable(cameras: Nullable<Camera[]>): void;
  69366. /**
  69367. * Gets a list of the post processes contained in the effect.
  69368. * @param camera The camera to get the post processes on.
  69369. * @returns The list of the post processes in the effect.
  69370. */
  69371. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69372. }
  69373. }
  69374. declare module BABYLON {
  69375. /** @hidden */
  69376. export var extractHighlightsPixelShader: {
  69377. name: string;
  69378. shader: string;
  69379. };
  69380. }
  69381. declare module BABYLON {
  69382. /**
  69383. * 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.
  69384. */
  69385. export class ExtractHighlightsPostProcess extends PostProcess {
  69386. /**
  69387. * The luminance threshold, pixels below this value will be set to black.
  69388. */
  69389. threshold: number;
  69390. /** @hidden */
  69391. _exposure: number;
  69392. /**
  69393. * Post process which has the input texture to be used when performing highlight extraction
  69394. * @hidden
  69395. */
  69396. _inputPostProcess: Nullable<PostProcess>;
  69397. /**
  69398. * Gets a string identifying the name of the class
  69399. * @returns "ExtractHighlightsPostProcess" string
  69400. */
  69401. getClassName(): string;
  69402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69403. }
  69404. }
  69405. declare module BABYLON {
  69406. /** @hidden */
  69407. export var bloomMergePixelShader: {
  69408. name: string;
  69409. shader: string;
  69410. };
  69411. }
  69412. declare module BABYLON {
  69413. /**
  69414. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69415. */
  69416. export class BloomMergePostProcess extends PostProcess {
  69417. /** Weight of the bloom to be added to the original input. */
  69418. weight: number;
  69419. /**
  69420. * Gets a string identifying the name of the class
  69421. * @returns "BloomMergePostProcess" string
  69422. */
  69423. getClassName(): string;
  69424. /**
  69425. * Creates a new instance of @see BloomMergePostProcess
  69426. * @param name The name of the effect.
  69427. * @param originalFromInput Post process which's input will be used for the merge.
  69428. * @param blurred Blurred highlights post process which's output will be used.
  69429. * @param weight Weight of the bloom to be added to the original input.
  69430. * @param options The required width/height ratio to downsize to before computing the render pass.
  69431. * @param camera The camera to apply the render pass to.
  69432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69433. * @param engine The engine which the post process will be applied. (default: current engine)
  69434. * @param reusable If the post process can be reused on the same frame. (default: false)
  69435. * @param textureType Type of textures used when performing the post process. (default: 0)
  69436. * @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)
  69437. */
  69438. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69439. /** Weight of the bloom to be added to the original input. */
  69440. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69441. }
  69442. }
  69443. declare module BABYLON {
  69444. /**
  69445. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69446. */
  69447. export class BloomEffect extends PostProcessRenderEffect {
  69448. private bloomScale;
  69449. /**
  69450. * @hidden Internal
  69451. */
  69452. _effects: Array<PostProcess>;
  69453. /**
  69454. * @hidden Internal
  69455. */
  69456. _downscale: ExtractHighlightsPostProcess;
  69457. private _blurX;
  69458. private _blurY;
  69459. private _merge;
  69460. /**
  69461. * The luminance threshold to find bright areas of the image to bloom.
  69462. */
  69463. get threshold(): number;
  69464. set threshold(value: number);
  69465. /**
  69466. * The strength of the bloom.
  69467. */
  69468. get weight(): number;
  69469. set weight(value: number);
  69470. /**
  69471. * Specifies the size of the bloom blur kernel, relative to the final output size
  69472. */
  69473. get kernel(): number;
  69474. set kernel(value: number);
  69475. /**
  69476. * Creates a new instance of @see BloomEffect
  69477. * @param scene The scene the effect belongs to.
  69478. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69479. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69480. * @param bloomWeight The the strength of bloom.
  69481. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69482. * @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)
  69483. */
  69484. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69485. /**
  69486. * Disposes each of the internal effects for a given camera.
  69487. * @param camera The camera to dispose the effect on.
  69488. */
  69489. disposeEffects(camera: Camera): void;
  69490. /**
  69491. * @hidden Internal
  69492. */
  69493. _updateEffects(): void;
  69494. /**
  69495. * Internal
  69496. * @returns if all the contained post processes are ready.
  69497. * @hidden
  69498. */
  69499. _isReady(): boolean;
  69500. }
  69501. }
  69502. declare module BABYLON {
  69503. /** @hidden */
  69504. export var chromaticAberrationPixelShader: {
  69505. name: string;
  69506. shader: string;
  69507. };
  69508. }
  69509. declare module BABYLON {
  69510. /**
  69511. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69512. */
  69513. export class ChromaticAberrationPostProcess extends PostProcess {
  69514. /**
  69515. * The amount of seperation of rgb channels (default: 30)
  69516. */
  69517. aberrationAmount: number;
  69518. /**
  69519. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69520. */
  69521. radialIntensity: number;
  69522. /**
  69523. * 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))
  69524. */
  69525. direction: Vector2;
  69526. /**
  69527. * 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))
  69528. */
  69529. centerPosition: Vector2;
  69530. /** The width of the screen to apply the effect on */
  69531. screenWidth: number;
  69532. /** The height of the screen to apply the effect on */
  69533. screenHeight: number;
  69534. /**
  69535. * Gets a string identifying the name of the class
  69536. * @returns "ChromaticAberrationPostProcess" string
  69537. */
  69538. getClassName(): string;
  69539. /**
  69540. * Creates a new instance ChromaticAberrationPostProcess
  69541. * @param name The name of the effect.
  69542. * @param screenWidth The width of the screen to apply the effect on.
  69543. * @param screenHeight The height of the screen to apply the effect on.
  69544. * @param options The required width/height ratio to downsize to before computing the render pass.
  69545. * @param camera The camera to apply the render pass to.
  69546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69547. * @param engine The engine which the post process will be applied. (default: current engine)
  69548. * @param reusable If the post process can be reused on the same frame. (default: false)
  69549. * @param textureType Type of textures used when performing the post process. (default: 0)
  69550. * @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)
  69551. */
  69552. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69553. /** @hidden */
  69554. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69555. }
  69556. }
  69557. declare module BABYLON {
  69558. /** @hidden */
  69559. export var circleOfConfusionPixelShader: {
  69560. name: string;
  69561. shader: string;
  69562. };
  69563. }
  69564. declare module BABYLON {
  69565. /**
  69566. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69567. */
  69568. export class CircleOfConfusionPostProcess extends PostProcess {
  69569. /**
  69570. * 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.
  69571. */
  69572. lensSize: number;
  69573. /**
  69574. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69575. */
  69576. fStop: number;
  69577. /**
  69578. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69579. */
  69580. focusDistance: number;
  69581. /**
  69582. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69583. */
  69584. focalLength: number;
  69585. /**
  69586. * Gets a string identifying the name of the class
  69587. * @returns "CircleOfConfusionPostProcess" string
  69588. */
  69589. getClassName(): string;
  69590. private _depthTexture;
  69591. /**
  69592. * Creates a new instance CircleOfConfusionPostProcess
  69593. * @param name The name of the effect.
  69594. * @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.
  69595. * @param options The required width/height ratio to downsize to before computing the render pass.
  69596. * @param camera The camera to apply the render pass to.
  69597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69598. * @param engine The engine which the post process will be applied. (default: current engine)
  69599. * @param reusable If the post process can be reused on the same frame. (default: false)
  69600. * @param textureType Type of textures used when performing the post process. (default: 0)
  69601. * @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)
  69602. */
  69603. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69604. /**
  69605. * 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.
  69606. */
  69607. set depthTexture(value: RenderTargetTexture);
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /** @hidden */
  69612. export var colorCorrectionPixelShader: {
  69613. name: string;
  69614. shader: string;
  69615. };
  69616. }
  69617. declare module BABYLON {
  69618. /**
  69619. *
  69620. * This post-process allows the modification of rendered colors by using
  69621. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69622. *
  69623. * The object needs to be provided an url to a texture containing the color
  69624. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69625. * Use an image editing software to tweak the LUT to match your needs.
  69626. *
  69627. * For an example of a color LUT, see here:
  69628. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69629. * For explanations on color grading, see here:
  69630. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69631. *
  69632. */
  69633. export class ColorCorrectionPostProcess extends PostProcess {
  69634. private _colorTableTexture;
  69635. /**
  69636. * Gets the color table url used to create the LUT texture
  69637. */
  69638. colorTableUrl: string;
  69639. /**
  69640. * Gets a string identifying the name of the class
  69641. * @returns "ColorCorrectionPostProcess" string
  69642. */
  69643. getClassName(): string;
  69644. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69645. /** @hidden */
  69646. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69647. }
  69648. }
  69649. declare module BABYLON {
  69650. /** @hidden */
  69651. export var convolutionPixelShader: {
  69652. name: string;
  69653. shader: string;
  69654. };
  69655. }
  69656. declare module BABYLON {
  69657. /**
  69658. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69659. * input texture to perform effects such as edge detection or sharpening
  69660. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69661. */
  69662. export class ConvolutionPostProcess extends PostProcess {
  69663. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69664. kernel: number[];
  69665. /**
  69666. * Gets a string identifying the name of the class
  69667. * @returns "ConvolutionPostProcess" string
  69668. */
  69669. getClassName(): string;
  69670. /**
  69671. * Creates a new instance ConvolutionPostProcess
  69672. * @param name The name of the effect.
  69673. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69674. * @param options The required width/height ratio to downsize to before computing the render pass.
  69675. * @param camera The camera to apply the render pass to.
  69676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69677. * @param engine The engine which the post process will be applied. (default: current engine)
  69678. * @param reusable If the post process can be reused on the same frame. (default: false)
  69679. * @param textureType Type of textures used when performing the post process. (default: 0)
  69680. */
  69681. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69682. /** @hidden */
  69683. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69684. /**
  69685. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69686. */
  69687. static EdgeDetect0Kernel: number[];
  69688. /**
  69689. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69690. */
  69691. static EdgeDetect1Kernel: number[];
  69692. /**
  69693. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69694. */
  69695. static EdgeDetect2Kernel: number[];
  69696. /**
  69697. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69698. */
  69699. static SharpenKernel: number[];
  69700. /**
  69701. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69702. */
  69703. static EmbossKernel: number[];
  69704. /**
  69705. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69706. */
  69707. static GaussianKernel: number[];
  69708. }
  69709. }
  69710. declare module BABYLON {
  69711. /**
  69712. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69713. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69714. * based on samples that have a large difference in distance than the center pixel.
  69715. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69716. */
  69717. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69718. /**
  69719. * The direction the blur should be applied
  69720. */
  69721. direction: Vector2;
  69722. /**
  69723. * Gets a string identifying the name of the class
  69724. * @returns "DepthOfFieldBlurPostProcess" string
  69725. */
  69726. getClassName(): string;
  69727. /**
  69728. * Creates a new instance CircleOfConfusionPostProcess
  69729. * @param name The name of the effect.
  69730. * @param scene The scene the effect belongs to.
  69731. * @param direction The direction the blur should be applied.
  69732. * @param kernel The size of the kernel used to blur.
  69733. * @param options The required width/height ratio to downsize to before computing the render pass.
  69734. * @param camera The camera to apply the render pass to.
  69735. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69736. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69738. * @param engine The engine which the post process will be applied. (default: current engine)
  69739. * @param reusable If the post process can be reused on the same frame. (default: false)
  69740. * @param textureType Type of textures used when performing the post process. (default: 0)
  69741. * @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)
  69742. */
  69743. 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);
  69744. }
  69745. }
  69746. declare module BABYLON {
  69747. /** @hidden */
  69748. export var depthOfFieldMergePixelShader: {
  69749. name: string;
  69750. shader: string;
  69751. };
  69752. }
  69753. declare module BABYLON {
  69754. /**
  69755. * Options to be set when merging outputs from the default pipeline.
  69756. */
  69757. export class DepthOfFieldMergePostProcessOptions {
  69758. /**
  69759. * The original image to merge on top of
  69760. */
  69761. originalFromInput: PostProcess;
  69762. /**
  69763. * Parameters to perform the merge of the depth of field effect
  69764. */
  69765. depthOfField?: {
  69766. circleOfConfusion: PostProcess;
  69767. blurSteps: Array<PostProcess>;
  69768. };
  69769. /**
  69770. * Parameters to perform the merge of bloom effect
  69771. */
  69772. bloom?: {
  69773. blurred: PostProcess;
  69774. weight: number;
  69775. };
  69776. }
  69777. /**
  69778. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69779. */
  69780. export class DepthOfFieldMergePostProcess extends PostProcess {
  69781. private blurSteps;
  69782. /**
  69783. * Gets a string identifying the name of the class
  69784. * @returns "DepthOfFieldMergePostProcess" string
  69785. */
  69786. getClassName(): string;
  69787. /**
  69788. * Creates a new instance of DepthOfFieldMergePostProcess
  69789. * @param name The name of the effect.
  69790. * @param originalFromInput Post process which's input will be used for the merge.
  69791. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69792. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69793. * @param options The required width/height ratio to downsize to before computing the render pass.
  69794. * @param camera The camera to apply the render pass to.
  69795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69796. * @param engine The engine which the post process will be applied. (default: current engine)
  69797. * @param reusable If the post process can be reused on the same frame. (default: false)
  69798. * @param textureType Type of textures used when performing the post process. (default: 0)
  69799. * @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)
  69800. */
  69801. 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);
  69802. /**
  69803. * Updates the effect with the current post process compile time values and recompiles the shader.
  69804. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69805. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69806. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69807. * @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
  69808. * @param onCompiled Called when the shader has been compiled.
  69809. * @param onError Called if there is an error when compiling a shader.
  69810. */
  69811. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69812. }
  69813. }
  69814. declare module BABYLON {
  69815. /**
  69816. * Specifies the level of max blur that should be applied when using the depth of field effect
  69817. */
  69818. export enum DepthOfFieldEffectBlurLevel {
  69819. /**
  69820. * Subtle blur
  69821. */
  69822. Low = 0,
  69823. /**
  69824. * Medium blur
  69825. */
  69826. Medium = 1,
  69827. /**
  69828. * Large blur
  69829. */
  69830. High = 2
  69831. }
  69832. /**
  69833. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69834. */
  69835. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69836. private _circleOfConfusion;
  69837. /**
  69838. * @hidden Internal, blurs from high to low
  69839. */
  69840. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69841. private _depthOfFieldBlurY;
  69842. private _dofMerge;
  69843. /**
  69844. * @hidden Internal post processes in depth of field effect
  69845. */
  69846. _effects: Array<PostProcess>;
  69847. /**
  69848. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69849. */
  69850. set focalLength(value: number);
  69851. get focalLength(): number;
  69852. /**
  69853. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69854. */
  69855. set fStop(value: number);
  69856. get fStop(): number;
  69857. /**
  69858. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69859. */
  69860. set focusDistance(value: number);
  69861. get focusDistance(): number;
  69862. /**
  69863. * 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.
  69864. */
  69865. set lensSize(value: number);
  69866. get lensSize(): number;
  69867. /**
  69868. * Creates a new instance DepthOfFieldEffect
  69869. * @param scene The scene the effect belongs to.
  69870. * @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.
  69871. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69872. * @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)
  69873. */
  69874. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69875. /**
  69876. * Get the current class name of the current effet
  69877. * @returns "DepthOfFieldEffect"
  69878. */
  69879. getClassName(): string;
  69880. /**
  69881. * 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.
  69882. */
  69883. set depthTexture(value: RenderTargetTexture);
  69884. /**
  69885. * Disposes each of the internal effects for a given camera.
  69886. * @param camera The camera to dispose the effect on.
  69887. */
  69888. disposeEffects(camera: Camera): void;
  69889. /**
  69890. * @hidden Internal
  69891. */
  69892. _updateEffects(): void;
  69893. /**
  69894. * Internal
  69895. * @returns if all the contained post processes are ready.
  69896. * @hidden
  69897. */
  69898. _isReady(): boolean;
  69899. }
  69900. }
  69901. declare module BABYLON {
  69902. /** @hidden */
  69903. export var displayPassPixelShader: {
  69904. name: string;
  69905. shader: string;
  69906. };
  69907. }
  69908. declare module BABYLON {
  69909. /**
  69910. * DisplayPassPostProcess which produces an output the same as it's input
  69911. */
  69912. export class DisplayPassPostProcess extends PostProcess {
  69913. /**
  69914. * Gets a string identifying the name of the class
  69915. * @returns "DisplayPassPostProcess" string
  69916. */
  69917. getClassName(): string;
  69918. /**
  69919. * Creates the DisplayPassPostProcess
  69920. * @param name The name of the effect.
  69921. * @param options The required width/height ratio to downsize to before computing the render pass.
  69922. * @param camera The camera to apply the render pass to.
  69923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69924. * @param engine The engine which the post process will be applied. (default: current engine)
  69925. * @param reusable If the post process can be reused on the same frame. (default: false)
  69926. */
  69927. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69928. /** @hidden */
  69929. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69930. }
  69931. }
  69932. declare module BABYLON {
  69933. /** @hidden */
  69934. export var filterPixelShader: {
  69935. name: string;
  69936. shader: string;
  69937. };
  69938. }
  69939. declare module BABYLON {
  69940. /**
  69941. * Applies a kernel filter to the image
  69942. */
  69943. export class FilterPostProcess extends PostProcess {
  69944. /** The matrix to be applied to the image */
  69945. kernelMatrix: Matrix;
  69946. /**
  69947. * Gets a string identifying the name of the class
  69948. * @returns "FilterPostProcess" string
  69949. */
  69950. getClassName(): string;
  69951. /**
  69952. *
  69953. * @param name The name of the effect.
  69954. * @param kernelMatrix The matrix to be applied to the image
  69955. * @param options The required width/height ratio to downsize to before computing the render pass.
  69956. * @param camera The camera to apply the render pass to.
  69957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69958. * @param engine The engine which the post process will be applied. (default: current engine)
  69959. * @param reusable If the post process can be reused on the same frame. (default: false)
  69960. */
  69961. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69962. /** @hidden */
  69963. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69964. }
  69965. }
  69966. declare module BABYLON {
  69967. /** @hidden */
  69968. export var fxaaPixelShader: {
  69969. name: string;
  69970. shader: string;
  69971. };
  69972. }
  69973. declare module BABYLON {
  69974. /** @hidden */
  69975. export var fxaaVertexShader: {
  69976. name: string;
  69977. shader: string;
  69978. };
  69979. }
  69980. declare module BABYLON {
  69981. /**
  69982. * Fxaa post process
  69983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69984. */
  69985. export class FxaaPostProcess extends PostProcess {
  69986. /**
  69987. * Gets a string identifying the name of the class
  69988. * @returns "FxaaPostProcess" string
  69989. */
  69990. getClassName(): string;
  69991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69992. private _getDefines;
  69993. /** @hidden */
  69994. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69995. }
  69996. }
  69997. declare module BABYLON {
  69998. /** @hidden */
  69999. export var grainPixelShader: {
  70000. name: string;
  70001. shader: string;
  70002. };
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * The GrainPostProcess adds noise to the image at mid luminance levels
  70007. */
  70008. export class GrainPostProcess extends PostProcess {
  70009. /**
  70010. * The intensity of the grain added (default: 30)
  70011. */
  70012. intensity: number;
  70013. /**
  70014. * If the grain should be randomized on every frame
  70015. */
  70016. animated: boolean;
  70017. /**
  70018. * Gets a string identifying the name of the class
  70019. * @returns "GrainPostProcess" string
  70020. */
  70021. getClassName(): string;
  70022. /**
  70023. * Creates a new instance of @see GrainPostProcess
  70024. * @param name The name of the effect.
  70025. * @param options The required width/height ratio to downsize to before computing the render pass.
  70026. * @param camera The camera to apply the render pass to.
  70027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70028. * @param engine The engine which the post process will be applied. (default: current engine)
  70029. * @param reusable If the post process can be reused on the same frame. (default: false)
  70030. * @param textureType Type of textures used when performing the post process. (default: 0)
  70031. * @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)
  70032. */
  70033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70034. /** @hidden */
  70035. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70036. }
  70037. }
  70038. declare module BABYLON {
  70039. /** @hidden */
  70040. export var highlightsPixelShader: {
  70041. name: string;
  70042. shader: string;
  70043. };
  70044. }
  70045. declare module BABYLON {
  70046. /**
  70047. * Extracts highlights from the image
  70048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70049. */
  70050. export class HighlightsPostProcess extends PostProcess {
  70051. /**
  70052. * Gets a string identifying the name of the class
  70053. * @returns "HighlightsPostProcess" string
  70054. */
  70055. getClassName(): string;
  70056. /**
  70057. * Extracts highlights from the image
  70058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70059. * @param name The name of the effect.
  70060. * @param options The required width/height ratio to downsize to before computing the render pass.
  70061. * @param camera The camera to apply the render pass to.
  70062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70063. * @param engine The engine which the post process will be applied. (default: current engine)
  70064. * @param reusable If the post process can be reused on the same frame. (default: false)
  70065. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70066. */
  70067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /** @hidden */
  70072. export var mrtFragmentDeclaration: {
  70073. name: string;
  70074. shader: string;
  70075. };
  70076. }
  70077. declare module BABYLON {
  70078. /** @hidden */
  70079. export var geometryPixelShader: {
  70080. name: string;
  70081. shader: string;
  70082. };
  70083. }
  70084. declare module BABYLON {
  70085. /** @hidden */
  70086. export var geometryVertexShader: {
  70087. name: string;
  70088. shader: string;
  70089. };
  70090. }
  70091. declare module BABYLON {
  70092. /** @hidden */
  70093. interface ISavedTransformationMatrix {
  70094. world: Matrix;
  70095. viewProjection: Matrix;
  70096. }
  70097. /**
  70098. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70099. */
  70100. export class GeometryBufferRenderer {
  70101. /**
  70102. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70103. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70104. */
  70105. static readonly POSITION_TEXTURE_TYPE: number;
  70106. /**
  70107. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70108. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70109. */
  70110. static readonly VELOCITY_TEXTURE_TYPE: number;
  70111. /**
  70112. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70113. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70114. */
  70115. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70116. /**
  70117. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70118. * in order to compute objects velocities when enableVelocity is set to "true"
  70119. * @hidden
  70120. */
  70121. _previousTransformationMatrices: {
  70122. [index: number]: ISavedTransformationMatrix;
  70123. };
  70124. /**
  70125. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70126. * in order to compute objects velocities when enableVelocity is set to "true"
  70127. * @hidden
  70128. */
  70129. _previousBonesTransformationMatrices: {
  70130. [index: number]: Float32Array;
  70131. };
  70132. /**
  70133. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70134. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70135. */
  70136. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70137. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70138. renderTransparentMeshes: boolean;
  70139. private _scene;
  70140. private _resizeObserver;
  70141. private _multiRenderTarget;
  70142. private _ratio;
  70143. private _enablePosition;
  70144. private _enableVelocity;
  70145. private _enableReflectivity;
  70146. private _positionIndex;
  70147. private _velocityIndex;
  70148. private _reflectivityIndex;
  70149. protected _effect: Effect;
  70150. protected _cachedDefines: string;
  70151. /**
  70152. * Set the render list (meshes to be rendered) used in the G buffer.
  70153. */
  70154. set renderList(meshes: Mesh[]);
  70155. /**
  70156. * Gets wether or not G buffer are supported by the running hardware.
  70157. * This requires draw buffer supports
  70158. */
  70159. get isSupported(): boolean;
  70160. /**
  70161. * Returns the index of the given texture type in the G-Buffer textures array
  70162. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70163. * @returns the index of the given texture type in the G-Buffer textures array
  70164. */
  70165. getTextureIndex(textureType: number): number;
  70166. /**
  70167. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70168. */
  70169. get enablePosition(): boolean;
  70170. /**
  70171. * Sets whether or not objects positions are enabled for the G buffer.
  70172. */
  70173. set enablePosition(enable: boolean);
  70174. /**
  70175. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70176. */
  70177. get enableVelocity(): boolean;
  70178. /**
  70179. * Sets wether or not objects velocities are enabled for the G buffer.
  70180. */
  70181. set enableVelocity(enable: boolean);
  70182. /**
  70183. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70184. */
  70185. get enableReflectivity(): boolean;
  70186. /**
  70187. * Sets wether or not objects roughness are enabled for the G buffer.
  70188. */
  70189. set enableReflectivity(enable: boolean);
  70190. /**
  70191. * Gets the scene associated with the buffer.
  70192. */
  70193. get scene(): Scene;
  70194. /**
  70195. * Gets the ratio used by the buffer during its creation.
  70196. * How big is the buffer related to the main canvas.
  70197. */
  70198. get ratio(): number;
  70199. /** @hidden */
  70200. static _SceneComponentInitialization: (scene: Scene) => void;
  70201. /**
  70202. * Creates a new G Buffer for the scene
  70203. * @param scene The scene the buffer belongs to
  70204. * @param ratio How big is the buffer related to the main canvas.
  70205. */
  70206. constructor(scene: Scene, ratio?: number);
  70207. /**
  70208. * Checks wether everything is ready to render a submesh to the G buffer.
  70209. * @param subMesh the submesh to check readiness for
  70210. * @param useInstances is the mesh drawn using instance or not
  70211. * @returns true if ready otherwise false
  70212. */
  70213. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70214. /**
  70215. * Gets the current underlying G Buffer.
  70216. * @returns the buffer
  70217. */
  70218. getGBuffer(): MultiRenderTarget;
  70219. /**
  70220. * Gets the number of samples used to render the buffer (anti aliasing).
  70221. */
  70222. get samples(): number;
  70223. /**
  70224. * Sets the number of samples used to render the buffer (anti aliasing).
  70225. */
  70226. set samples(value: number);
  70227. /**
  70228. * Disposes the renderer and frees up associated resources.
  70229. */
  70230. dispose(): void;
  70231. protected _createRenderTargets(): void;
  70232. private _copyBonesTransformationMatrices;
  70233. }
  70234. }
  70235. declare module BABYLON {
  70236. /**
  70237. * Contains all parameters needed for the prepass to perform
  70238. * motion blur
  70239. */
  70240. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70241. /**
  70242. * Is motion blur enabled
  70243. */
  70244. enabled: boolean;
  70245. /**
  70246. * Name of the configuration
  70247. */
  70248. name: string;
  70249. /**
  70250. * Textures that should be present in the MRT for this effect to work
  70251. */
  70252. readonly texturesRequired: number[];
  70253. }
  70254. }
  70255. declare module BABYLON {
  70256. interface Scene {
  70257. /** @hidden (Backing field) */
  70258. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70259. /**
  70260. * Gets or Sets the current geometry buffer associated to the scene.
  70261. */
  70262. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70263. /**
  70264. * Enables a GeometryBufferRender and associates it with the scene
  70265. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70266. * @returns the GeometryBufferRenderer
  70267. */
  70268. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70269. /**
  70270. * Disables the GeometryBufferRender associated with the scene
  70271. */
  70272. disableGeometryBufferRenderer(): void;
  70273. }
  70274. /**
  70275. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70276. * in several rendering techniques.
  70277. */
  70278. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70279. /**
  70280. * The component name helpful to identify the component in the list of scene components.
  70281. */
  70282. readonly name: string;
  70283. /**
  70284. * The scene the component belongs to.
  70285. */
  70286. scene: Scene;
  70287. /**
  70288. * Creates a new instance of the component for the given scene
  70289. * @param scene Defines the scene to register the component in
  70290. */
  70291. constructor(scene: Scene);
  70292. /**
  70293. * Registers the component in a given scene
  70294. */
  70295. register(): void;
  70296. /**
  70297. * Rebuilds the elements related to this component in case of
  70298. * context lost for instance.
  70299. */
  70300. rebuild(): void;
  70301. /**
  70302. * Disposes the component and the associated ressources
  70303. */
  70304. dispose(): void;
  70305. private _gatherRenderTargets;
  70306. }
  70307. }
  70308. declare module BABYLON {
  70309. /** @hidden */
  70310. export var motionBlurPixelShader: {
  70311. name: string;
  70312. shader: string;
  70313. };
  70314. }
  70315. declare module BABYLON {
  70316. /**
  70317. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70318. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70319. * As an example, all you have to do is to create the post-process:
  70320. * var mb = new BABYLON.MotionBlurPostProcess(
  70321. * 'mb', // The name of the effect.
  70322. * scene, // The scene containing the objects to blur according to their velocity.
  70323. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70324. * camera // The camera to apply the render pass to.
  70325. * );
  70326. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70327. */
  70328. export class MotionBlurPostProcess extends PostProcess {
  70329. /**
  70330. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70331. */
  70332. motionStrength: number;
  70333. /**
  70334. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70335. */
  70336. get motionBlurSamples(): number;
  70337. /**
  70338. * Sets the number of iterations to be used for motion blur quality
  70339. */
  70340. set motionBlurSamples(samples: number);
  70341. private _motionBlurSamples;
  70342. private _forceGeometryBuffer;
  70343. private _geometryBufferRenderer;
  70344. private _prePassRenderer;
  70345. /**
  70346. * Gets a string identifying the name of the class
  70347. * @returns "MotionBlurPostProcess" string
  70348. */
  70349. getClassName(): string;
  70350. /**
  70351. * Creates a new instance MotionBlurPostProcess
  70352. * @param name The name of the effect.
  70353. * @param scene The scene containing the objects to blur according to their velocity.
  70354. * @param options The required width/height ratio to downsize to before computing the render pass.
  70355. * @param camera The camera to apply the render pass to.
  70356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70357. * @param engine The engine which the post process will be applied. (default: current engine)
  70358. * @param reusable If the post process can be reused on the same frame. (default: false)
  70359. * @param textureType Type of textures used when performing the post process. (default: 0)
  70360. * @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)
  70361. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70362. */
  70363. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70364. /**
  70365. * Excludes the given skinned mesh from computing bones velocities.
  70366. * 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.
  70367. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70368. */
  70369. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70370. /**
  70371. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70372. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70373. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70374. */
  70375. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70376. /**
  70377. * Disposes the post process.
  70378. * @param camera The camera to dispose the post process on.
  70379. */
  70380. dispose(camera?: Camera): void;
  70381. /** @hidden */
  70382. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70383. }
  70384. }
  70385. declare module BABYLON {
  70386. /** @hidden */
  70387. export var refractionPixelShader: {
  70388. name: string;
  70389. shader: string;
  70390. };
  70391. }
  70392. declare module BABYLON {
  70393. /**
  70394. * Post process which applies a refractin texture
  70395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70396. */
  70397. export class RefractionPostProcess extends PostProcess {
  70398. private _refTexture;
  70399. private _ownRefractionTexture;
  70400. /** the base color of the refraction (used to taint the rendering) */
  70401. color: Color3;
  70402. /** simulated refraction depth */
  70403. depth: number;
  70404. /** the coefficient of the base color (0 to remove base color tainting) */
  70405. colorLevel: number;
  70406. /** Gets the url used to load the refraction texture */
  70407. refractionTextureUrl: string;
  70408. /**
  70409. * Gets or sets the refraction texture
  70410. * Please note that you are responsible for disposing the texture if you set it manually
  70411. */
  70412. get refractionTexture(): Texture;
  70413. set refractionTexture(value: Texture);
  70414. /**
  70415. * Gets a string identifying the name of the class
  70416. * @returns "RefractionPostProcess" string
  70417. */
  70418. getClassName(): string;
  70419. /**
  70420. * Initializes the RefractionPostProcess
  70421. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70422. * @param name The name of the effect.
  70423. * @param refractionTextureUrl Url of the refraction texture to use
  70424. * @param color the base color of the refraction (used to taint the rendering)
  70425. * @param depth simulated refraction depth
  70426. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70427. * @param camera The camera to apply the render pass to.
  70428. * @param options The required width/height ratio to downsize to before computing the render pass.
  70429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70430. * @param engine The engine which the post process will be applied. (default: current engine)
  70431. * @param reusable If the post process can be reused on the same frame. (default: false)
  70432. */
  70433. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70434. /**
  70435. * Disposes of the post process
  70436. * @param camera Camera to dispose post process on
  70437. */
  70438. dispose(camera: Camera): void;
  70439. /** @hidden */
  70440. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70441. }
  70442. }
  70443. declare module BABYLON {
  70444. /** @hidden */
  70445. export var sharpenPixelShader: {
  70446. name: string;
  70447. shader: string;
  70448. };
  70449. }
  70450. declare module BABYLON {
  70451. /**
  70452. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70453. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70454. */
  70455. export class SharpenPostProcess extends PostProcess {
  70456. /**
  70457. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70458. */
  70459. colorAmount: number;
  70460. /**
  70461. * How much sharpness should be applied (default: 0.3)
  70462. */
  70463. edgeAmount: number;
  70464. /**
  70465. * Gets a string identifying the name of the class
  70466. * @returns "SharpenPostProcess" string
  70467. */
  70468. getClassName(): string;
  70469. /**
  70470. * Creates a new instance ConvolutionPostProcess
  70471. * @param name The name of the effect.
  70472. * @param options The required width/height ratio to downsize to before computing the render pass.
  70473. * @param camera The camera to apply the render pass to.
  70474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70475. * @param engine The engine which the post process will be applied. (default: current engine)
  70476. * @param reusable If the post process can be reused on the same frame. (default: false)
  70477. * @param textureType Type of textures used when performing the post process. (default: 0)
  70478. * @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)
  70479. */
  70480. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70481. /** @hidden */
  70482. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70483. }
  70484. }
  70485. declare module BABYLON {
  70486. /**
  70487. * PostProcessRenderPipeline
  70488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70489. */
  70490. export class PostProcessRenderPipeline {
  70491. private engine;
  70492. private _renderEffects;
  70493. private _renderEffectsForIsolatedPass;
  70494. /**
  70495. * List of inspectable custom properties (used by the Inspector)
  70496. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70497. */
  70498. inspectableCustomProperties: IInspectable[];
  70499. /**
  70500. * @hidden
  70501. */
  70502. protected _cameras: Camera[];
  70503. /** @hidden */
  70504. _name: string;
  70505. /**
  70506. * Gets pipeline name
  70507. */
  70508. get name(): string;
  70509. /** Gets the list of attached cameras */
  70510. get cameras(): Camera[];
  70511. /**
  70512. * Initializes a PostProcessRenderPipeline
  70513. * @param engine engine to add the pipeline to
  70514. * @param name name of the pipeline
  70515. */
  70516. constructor(engine: Engine, name: string);
  70517. /**
  70518. * Gets the class name
  70519. * @returns "PostProcessRenderPipeline"
  70520. */
  70521. getClassName(): string;
  70522. /**
  70523. * If all the render effects in the pipeline are supported
  70524. */
  70525. get isSupported(): boolean;
  70526. /**
  70527. * Adds an effect to the pipeline
  70528. * @param renderEffect the effect to add
  70529. */
  70530. addEffect(renderEffect: PostProcessRenderEffect): void;
  70531. /** @hidden */
  70532. _rebuild(): void;
  70533. /** @hidden */
  70534. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70535. /** @hidden */
  70536. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70537. /** @hidden */
  70538. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70539. /** @hidden */
  70540. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70541. /** @hidden */
  70542. _attachCameras(cameras: Camera, unique: boolean): void;
  70543. /** @hidden */
  70544. _attachCameras(cameras: Camera[], unique: boolean): void;
  70545. /** @hidden */
  70546. _detachCameras(cameras: Camera): void;
  70547. /** @hidden */
  70548. _detachCameras(cameras: Nullable<Camera[]>): void;
  70549. /** @hidden */
  70550. _update(): void;
  70551. /** @hidden */
  70552. _reset(): void;
  70553. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70554. /**
  70555. * Sets the required values to the prepass renderer.
  70556. * @param prePassRenderer defines the prepass renderer to setup.
  70557. * @returns true if the pre pass is needed.
  70558. */
  70559. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70560. /**
  70561. * Disposes of the pipeline
  70562. */
  70563. dispose(): void;
  70564. }
  70565. }
  70566. declare module BABYLON {
  70567. /**
  70568. * PostProcessRenderPipelineManager class
  70569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70570. */
  70571. export class PostProcessRenderPipelineManager {
  70572. private _renderPipelines;
  70573. /**
  70574. * Initializes a PostProcessRenderPipelineManager
  70575. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70576. */
  70577. constructor();
  70578. /**
  70579. * Gets the list of supported render pipelines
  70580. */
  70581. get supportedPipelines(): PostProcessRenderPipeline[];
  70582. /**
  70583. * Adds a pipeline to the manager
  70584. * @param renderPipeline The pipeline to add
  70585. */
  70586. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70587. /**
  70588. * Attaches a camera to the pipeline
  70589. * @param renderPipelineName The name of the pipeline to attach to
  70590. * @param cameras the camera to attach
  70591. * @param unique if the camera can be attached multiple times to the pipeline
  70592. */
  70593. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70594. /**
  70595. * Detaches a camera from the pipeline
  70596. * @param renderPipelineName The name of the pipeline to detach from
  70597. * @param cameras the camera to detach
  70598. */
  70599. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70600. /**
  70601. * Enables an effect by name on a pipeline
  70602. * @param renderPipelineName the name of the pipeline to enable the effect in
  70603. * @param renderEffectName the name of the effect to enable
  70604. * @param cameras the cameras that the effect should be enabled on
  70605. */
  70606. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70607. /**
  70608. * Disables an effect by name on a pipeline
  70609. * @param renderPipelineName the name of the pipeline to disable the effect in
  70610. * @param renderEffectName the name of the effect to disable
  70611. * @param cameras the cameras that the effect should be disabled on
  70612. */
  70613. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70614. /**
  70615. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70616. */
  70617. update(): void;
  70618. /** @hidden */
  70619. _rebuild(): void;
  70620. /**
  70621. * Disposes of the manager and pipelines
  70622. */
  70623. dispose(): void;
  70624. }
  70625. }
  70626. declare module BABYLON {
  70627. interface Scene {
  70628. /** @hidden (Backing field) */
  70629. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70630. /**
  70631. * Gets the postprocess render pipeline manager
  70632. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70633. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70634. */
  70635. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70636. }
  70637. /**
  70638. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70639. */
  70640. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70641. /**
  70642. * The component name helpfull to identify the component in the list of scene components.
  70643. */
  70644. readonly name: string;
  70645. /**
  70646. * The scene the component belongs to.
  70647. */
  70648. scene: Scene;
  70649. /**
  70650. * Creates a new instance of the component for the given scene
  70651. * @param scene Defines the scene to register the component in
  70652. */
  70653. constructor(scene: Scene);
  70654. /**
  70655. * Registers the component in a given scene
  70656. */
  70657. register(): void;
  70658. /**
  70659. * Rebuilds the elements related to this component in case of
  70660. * context lost for instance.
  70661. */
  70662. rebuild(): void;
  70663. /**
  70664. * Disposes the component and the associated ressources
  70665. */
  70666. dispose(): void;
  70667. private _gatherRenderTargets;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /**
  70672. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70673. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70674. */
  70675. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70676. private _scene;
  70677. private _camerasToBeAttached;
  70678. /**
  70679. * ID of the sharpen post process,
  70680. */
  70681. private readonly SharpenPostProcessId;
  70682. /**
  70683. * @ignore
  70684. * ID of the image processing post process;
  70685. */
  70686. readonly ImageProcessingPostProcessId: string;
  70687. /**
  70688. * @ignore
  70689. * ID of the Fast Approximate Anti-Aliasing post process;
  70690. */
  70691. readonly FxaaPostProcessId: string;
  70692. /**
  70693. * ID of the chromatic aberration post process,
  70694. */
  70695. private readonly ChromaticAberrationPostProcessId;
  70696. /**
  70697. * ID of the grain post process
  70698. */
  70699. private readonly GrainPostProcessId;
  70700. /**
  70701. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70702. */
  70703. sharpen: SharpenPostProcess;
  70704. private _sharpenEffect;
  70705. private bloom;
  70706. /**
  70707. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70708. */
  70709. depthOfField: DepthOfFieldEffect;
  70710. /**
  70711. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70712. */
  70713. fxaa: FxaaPostProcess;
  70714. /**
  70715. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70716. */
  70717. imageProcessing: ImageProcessingPostProcess;
  70718. /**
  70719. * Chromatic aberration post process which will shift rgb colors in the image
  70720. */
  70721. chromaticAberration: ChromaticAberrationPostProcess;
  70722. private _chromaticAberrationEffect;
  70723. /**
  70724. * Grain post process which add noise to the image
  70725. */
  70726. grain: GrainPostProcess;
  70727. private _grainEffect;
  70728. /**
  70729. * Glow post process which adds a glow to emissive areas of the image
  70730. */
  70731. private _glowLayer;
  70732. /**
  70733. * Animations which can be used to tweak settings over a period of time
  70734. */
  70735. animations: Animation[];
  70736. private _imageProcessingConfigurationObserver;
  70737. private _sharpenEnabled;
  70738. private _bloomEnabled;
  70739. private _depthOfFieldEnabled;
  70740. private _depthOfFieldBlurLevel;
  70741. private _fxaaEnabled;
  70742. private _imageProcessingEnabled;
  70743. private _defaultPipelineTextureType;
  70744. private _bloomScale;
  70745. private _chromaticAberrationEnabled;
  70746. private _grainEnabled;
  70747. private _buildAllowed;
  70748. /**
  70749. * Gets active scene
  70750. */
  70751. get scene(): Scene;
  70752. /**
  70753. * Enable or disable the sharpen process from the pipeline
  70754. */
  70755. set sharpenEnabled(enabled: boolean);
  70756. get sharpenEnabled(): boolean;
  70757. private _resizeObserver;
  70758. private _hardwareScaleLevel;
  70759. private _bloomKernel;
  70760. /**
  70761. * Specifies the size of the bloom blur kernel, relative to the final output size
  70762. */
  70763. get bloomKernel(): number;
  70764. set bloomKernel(value: number);
  70765. /**
  70766. * Specifies the weight of the bloom in the final rendering
  70767. */
  70768. private _bloomWeight;
  70769. /**
  70770. * Specifies the luma threshold for the area that will be blurred by the bloom
  70771. */
  70772. private _bloomThreshold;
  70773. private _hdr;
  70774. /**
  70775. * The strength of the bloom.
  70776. */
  70777. set bloomWeight(value: number);
  70778. get bloomWeight(): number;
  70779. /**
  70780. * The strength of the bloom.
  70781. */
  70782. set bloomThreshold(value: number);
  70783. get bloomThreshold(): number;
  70784. /**
  70785. * The scale of the bloom, lower value will provide better performance.
  70786. */
  70787. set bloomScale(value: number);
  70788. get bloomScale(): number;
  70789. /**
  70790. * Enable or disable the bloom from the pipeline
  70791. */
  70792. set bloomEnabled(enabled: boolean);
  70793. get bloomEnabled(): boolean;
  70794. private _rebuildBloom;
  70795. /**
  70796. * If the depth of field is enabled.
  70797. */
  70798. get depthOfFieldEnabled(): boolean;
  70799. set depthOfFieldEnabled(enabled: boolean);
  70800. /**
  70801. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70802. */
  70803. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70804. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70805. /**
  70806. * If the anti aliasing is enabled.
  70807. */
  70808. set fxaaEnabled(enabled: boolean);
  70809. get fxaaEnabled(): boolean;
  70810. private _samples;
  70811. /**
  70812. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70813. */
  70814. set samples(sampleCount: number);
  70815. get samples(): number;
  70816. /**
  70817. * If image processing is enabled.
  70818. */
  70819. set imageProcessingEnabled(enabled: boolean);
  70820. get imageProcessingEnabled(): boolean;
  70821. /**
  70822. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70823. */
  70824. set glowLayerEnabled(enabled: boolean);
  70825. get glowLayerEnabled(): boolean;
  70826. /**
  70827. * Gets the glow layer (or null if not defined)
  70828. */
  70829. get glowLayer(): Nullable<GlowLayer>;
  70830. /**
  70831. * Enable or disable the chromaticAberration process from the pipeline
  70832. */
  70833. set chromaticAberrationEnabled(enabled: boolean);
  70834. get chromaticAberrationEnabled(): boolean;
  70835. /**
  70836. * Enable or disable the grain process from the pipeline
  70837. */
  70838. set grainEnabled(enabled: boolean);
  70839. get grainEnabled(): boolean;
  70840. /**
  70841. * @constructor
  70842. * @param name - The rendering pipeline name (default: "")
  70843. * @param hdr - If high dynamic range textures should be used (default: true)
  70844. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70845. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70846. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70847. */
  70848. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70849. /**
  70850. * Get the class name
  70851. * @returns "DefaultRenderingPipeline"
  70852. */
  70853. getClassName(): string;
  70854. /**
  70855. * Force the compilation of the entire pipeline.
  70856. */
  70857. prepare(): void;
  70858. private _hasCleared;
  70859. private _prevPostProcess;
  70860. private _prevPrevPostProcess;
  70861. private _setAutoClearAndTextureSharing;
  70862. private _depthOfFieldSceneObserver;
  70863. private _buildPipeline;
  70864. private _disposePostProcesses;
  70865. /**
  70866. * Adds a camera to the pipeline
  70867. * @param camera the camera to be added
  70868. */
  70869. addCamera(camera: Camera): void;
  70870. /**
  70871. * Removes a camera from the pipeline
  70872. * @param camera the camera to remove
  70873. */
  70874. removeCamera(camera: Camera): void;
  70875. /**
  70876. * Dispose of the pipeline and stop all post processes
  70877. */
  70878. dispose(): void;
  70879. /**
  70880. * Serialize the rendering pipeline (Used when exporting)
  70881. * @returns the serialized object
  70882. */
  70883. serialize(): any;
  70884. /**
  70885. * Parse the serialized pipeline
  70886. * @param source Source pipeline.
  70887. * @param scene The scene to load the pipeline to.
  70888. * @param rootUrl The URL of the serialized pipeline.
  70889. * @returns An instantiated pipeline from the serialized object.
  70890. */
  70891. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70892. }
  70893. }
  70894. declare module BABYLON {
  70895. /** @hidden */
  70896. export var lensHighlightsPixelShader: {
  70897. name: string;
  70898. shader: string;
  70899. };
  70900. }
  70901. declare module BABYLON {
  70902. /** @hidden */
  70903. export var depthOfFieldPixelShader: {
  70904. name: string;
  70905. shader: string;
  70906. };
  70907. }
  70908. declare module BABYLON {
  70909. /**
  70910. * BABYLON.JS Chromatic Aberration GLSL Shader
  70911. * Author: Olivier Guyot
  70912. * Separates very slightly R, G and B colors on the edges of the screen
  70913. * Inspired by Francois Tarlier & Martins Upitis
  70914. */
  70915. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70916. /**
  70917. * @ignore
  70918. * The chromatic aberration PostProcess id in the pipeline
  70919. */
  70920. LensChromaticAberrationEffect: string;
  70921. /**
  70922. * @ignore
  70923. * The highlights enhancing PostProcess id in the pipeline
  70924. */
  70925. HighlightsEnhancingEffect: string;
  70926. /**
  70927. * @ignore
  70928. * The depth-of-field PostProcess id in the pipeline
  70929. */
  70930. LensDepthOfFieldEffect: string;
  70931. private _scene;
  70932. private _depthTexture;
  70933. private _grainTexture;
  70934. private _chromaticAberrationPostProcess;
  70935. private _highlightsPostProcess;
  70936. private _depthOfFieldPostProcess;
  70937. private _edgeBlur;
  70938. private _grainAmount;
  70939. private _chromaticAberration;
  70940. private _distortion;
  70941. private _highlightsGain;
  70942. private _highlightsThreshold;
  70943. private _dofDistance;
  70944. private _dofAperture;
  70945. private _dofDarken;
  70946. private _dofPentagon;
  70947. private _blurNoise;
  70948. /**
  70949. * @constructor
  70950. *
  70951. * Effect parameters are as follow:
  70952. * {
  70953. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70954. * edge_blur: number; // from 0 to x (1 for realism)
  70955. * distortion: number; // from 0 to x (1 for realism)
  70956. * grain_amount: number; // from 0 to 1
  70957. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70958. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70959. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70960. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70961. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70962. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70963. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70964. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70965. * }
  70966. * Note: if an effect parameter is unset, effect is disabled
  70967. *
  70968. * @param name The rendering pipeline name
  70969. * @param parameters - An object containing all parameters (see above)
  70970. * @param scene The scene linked to this pipeline
  70971. * @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)
  70972. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70973. */
  70974. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70975. /**
  70976. * Get the class name
  70977. * @returns "LensRenderingPipeline"
  70978. */
  70979. getClassName(): string;
  70980. /**
  70981. * Gets associated scene
  70982. */
  70983. get scene(): Scene;
  70984. /**
  70985. * Gets or sets the edge blur
  70986. */
  70987. get edgeBlur(): number;
  70988. set edgeBlur(value: number);
  70989. /**
  70990. * Gets or sets the grain amount
  70991. */
  70992. get grainAmount(): number;
  70993. set grainAmount(value: number);
  70994. /**
  70995. * Gets or sets the chromatic aberration amount
  70996. */
  70997. get chromaticAberration(): number;
  70998. set chromaticAberration(value: number);
  70999. /**
  71000. * Gets or sets the depth of field aperture
  71001. */
  71002. get dofAperture(): number;
  71003. set dofAperture(value: number);
  71004. /**
  71005. * Gets or sets the edge distortion
  71006. */
  71007. get edgeDistortion(): number;
  71008. set edgeDistortion(value: number);
  71009. /**
  71010. * Gets or sets the depth of field distortion
  71011. */
  71012. get dofDistortion(): number;
  71013. set dofDistortion(value: number);
  71014. /**
  71015. * Gets or sets the darken out of focus amount
  71016. */
  71017. get darkenOutOfFocus(): number;
  71018. set darkenOutOfFocus(value: number);
  71019. /**
  71020. * Gets or sets a boolean indicating if blur noise is enabled
  71021. */
  71022. get blurNoise(): boolean;
  71023. set blurNoise(value: boolean);
  71024. /**
  71025. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71026. */
  71027. get pentagonBokeh(): boolean;
  71028. set pentagonBokeh(value: boolean);
  71029. /**
  71030. * Gets or sets the highlight grain amount
  71031. */
  71032. get highlightsGain(): number;
  71033. set highlightsGain(value: number);
  71034. /**
  71035. * Gets or sets the highlight threshold
  71036. */
  71037. get highlightsThreshold(): number;
  71038. set highlightsThreshold(value: number);
  71039. /**
  71040. * Sets the amount of blur at the edges
  71041. * @param amount blur amount
  71042. */
  71043. setEdgeBlur(amount: number): void;
  71044. /**
  71045. * Sets edge blur to 0
  71046. */
  71047. disableEdgeBlur(): void;
  71048. /**
  71049. * Sets the amout of grain
  71050. * @param amount Amount of grain
  71051. */
  71052. setGrainAmount(amount: number): void;
  71053. /**
  71054. * Set grain amount to 0
  71055. */
  71056. disableGrain(): void;
  71057. /**
  71058. * Sets the chromatic aberration amount
  71059. * @param amount amount of chromatic aberration
  71060. */
  71061. setChromaticAberration(amount: number): void;
  71062. /**
  71063. * Sets chromatic aberration amount to 0
  71064. */
  71065. disableChromaticAberration(): void;
  71066. /**
  71067. * Sets the EdgeDistortion amount
  71068. * @param amount amount of EdgeDistortion
  71069. */
  71070. setEdgeDistortion(amount: number): void;
  71071. /**
  71072. * Sets edge distortion to 0
  71073. */
  71074. disableEdgeDistortion(): void;
  71075. /**
  71076. * Sets the FocusDistance amount
  71077. * @param amount amount of FocusDistance
  71078. */
  71079. setFocusDistance(amount: number): void;
  71080. /**
  71081. * Disables depth of field
  71082. */
  71083. disableDepthOfField(): void;
  71084. /**
  71085. * Sets the Aperture amount
  71086. * @param amount amount of Aperture
  71087. */
  71088. setAperture(amount: number): void;
  71089. /**
  71090. * Sets the DarkenOutOfFocus amount
  71091. * @param amount amount of DarkenOutOfFocus
  71092. */
  71093. setDarkenOutOfFocus(amount: number): void;
  71094. private _pentagonBokehIsEnabled;
  71095. /**
  71096. * Creates a pentagon bokeh effect
  71097. */
  71098. enablePentagonBokeh(): void;
  71099. /**
  71100. * Disables the pentagon bokeh effect
  71101. */
  71102. disablePentagonBokeh(): void;
  71103. /**
  71104. * Enables noise blur
  71105. */
  71106. enableNoiseBlur(): void;
  71107. /**
  71108. * Disables noise blur
  71109. */
  71110. disableNoiseBlur(): void;
  71111. /**
  71112. * Sets the HighlightsGain amount
  71113. * @param amount amount of HighlightsGain
  71114. */
  71115. setHighlightsGain(amount: number): void;
  71116. /**
  71117. * Sets the HighlightsThreshold amount
  71118. * @param amount amount of HighlightsThreshold
  71119. */
  71120. setHighlightsThreshold(amount: number): void;
  71121. /**
  71122. * Disables highlights
  71123. */
  71124. disableHighlights(): void;
  71125. /**
  71126. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71127. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71128. */
  71129. dispose(disableDepthRender?: boolean): void;
  71130. private _createChromaticAberrationPostProcess;
  71131. private _createHighlightsPostProcess;
  71132. private _createDepthOfFieldPostProcess;
  71133. private _createGrainTexture;
  71134. }
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * Contains all parameters needed for the prepass to perform
  71139. * screen space subsurface scattering
  71140. */
  71141. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71142. /**
  71143. * Is subsurface enabled
  71144. */
  71145. enabled: boolean;
  71146. /**
  71147. * Name of the configuration
  71148. */
  71149. name: string;
  71150. /**
  71151. * Textures that should be present in the MRT for this effect to work
  71152. */
  71153. readonly texturesRequired: number[];
  71154. }
  71155. }
  71156. declare module BABYLON {
  71157. /** @hidden */
  71158. export var ssao2PixelShader: {
  71159. name: string;
  71160. shader: string;
  71161. };
  71162. }
  71163. declare module BABYLON {
  71164. /** @hidden */
  71165. export var ssaoCombinePixelShader: {
  71166. name: string;
  71167. shader: string;
  71168. };
  71169. }
  71170. declare module BABYLON {
  71171. /**
  71172. * Render pipeline to produce ssao effect
  71173. */
  71174. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71175. /**
  71176. * @ignore
  71177. * The PassPostProcess id in the pipeline that contains the original scene color
  71178. */
  71179. SSAOOriginalSceneColorEffect: string;
  71180. /**
  71181. * @ignore
  71182. * The SSAO PostProcess id in the pipeline
  71183. */
  71184. SSAORenderEffect: string;
  71185. /**
  71186. * @ignore
  71187. * The horizontal blur PostProcess id in the pipeline
  71188. */
  71189. SSAOBlurHRenderEffect: string;
  71190. /**
  71191. * @ignore
  71192. * The vertical blur PostProcess id in the pipeline
  71193. */
  71194. SSAOBlurVRenderEffect: string;
  71195. /**
  71196. * @ignore
  71197. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71198. */
  71199. SSAOCombineRenderEffect: string;
  71200. /**
  71201. * The output strength of the SSAO post-process. Default value is 1.0.
  71202. */
  71203. totalStrength: number;
  71204. /**
  71205. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71206. */
  71207. maxZ: number;
  71208. /**
  71209. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71210. */
  71211. minZAspect: number;
  71212. private _samples;
  71213. /**
  71214. * Number of samples used for the SSAO calculations. Default value is 8
  71215. */
  71216. set samples(n: number);
  71217. get samples(): number;
  71218. private _textureSamples;
  71219. /**
  71220. * Number of samples to use for antialiasing
  71221. */
  71222. set textureSamples(n: number);
  71223. get textureSamples(): number;
  71224. /**
  71225. * Force rendering the geometry through geometry buffer
  71226. */
  71227. private _forceGeometryBuffer;
  71228. /**
  71229. * Ratio object used for SSAO ratio and blur ratio
  71230. */
  71231. private _ratio;
  71232. /**
  71233. * Dynamically generated sphere sampler.
  71234. */
  71235. private _sampleSphere;
  71236. /**
  71237. * Blur filter offsets
  71238. */
  71239. private _samplerOffsets;
  71240. private _expensiveBlur;
  71241. /**
  71242. * If bilateral blur should be used
  71243. */
  71244. set expensiveBlur(b: boolean);
  71245. get expensiveBlur(): boolean;
  71246. /**
  71247. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71248. */
  71249. radius: number;
  71250. /**
  71251. * The base color of the SSAO post-process
  71252. * The final result is "base + ssao" between [0, 1]
  71253. */
  71254. base: number;
  71255. /**
  71256. * Support test.
  71257. */
  71258. static get IsSupported(): boolean;
  71259. private _scene;
  71260. private _randomTexture;
  71261. private _originalColorPostProcess;
  71262. private _ssaoPostProcess;
  71263. private _blurHPostProcess;
  71264. private _blurVPostProcess;
  71265. private _ssaoCombinePostProcess;
  71266. private _prePassRenderer;
  71267. /**
  71268. * Gets active scene
  71269. */
  71270. get scene(): Scene;
  71271. /**
  71272. * @constructor
  71273. * @param name The rendering pipeline name
  71274. * @param scene The scene linked to this pipeline
  71275. * @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 }
  71276. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71277. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71278. */
  71279. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71280. /**
  71281. * Get the class name
  71282. * @returns "SSAO2RenderingPipeline"
  71283. */
  71284. getClassName(): string;
  71285. /**
  71286. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71287. */
  71288. dispose(disableGeometryBufferRenderer?: boolean): void;
  71289. private _createBlurPostProcess;
  71290. /** @hidden */
  71291. _rebuild(): void;
  71292. private _bits;
  71293. private _radicalInverse_VdC;
  71294. private _hammersley;
  71295. private _hemisphereSample_uniform;
  71296. private _generateHemisphere;
  71297. private _getDefinesForSSAO;
  71298. private _createSSAOPostProcess;
  71299. private _createSSAOCombinePostProcess;
  71300. private _createRandomTexture;
  71301. /**
  71302. * Serialize the rendering pipeline (Used when exporting)
  71303. * @returns the serialized object
  71304. */
  71305. serialize(): any;
  71306. /**
  71307. * Parse the serialized pipeline
  71308. * @param source Source pipeline.
  71309. * @param scene The scene to load the pipeline to.
  71310. * @param rootUrl The URL of the serialized pipeline.
  71311. * @returns An instantiated pipeline from the serialized object.
  71312. */
  71313. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71314. }
  71315. }
  71316. declare module BABYLON {
  71317. /** @hidden */
  71318. export var ssaoPixelShader: {
  71319. name: string;
  71320. shader: string;
  71321. };
  71322. }
  71323. declare module BABYLON {
  71324. /**
  71325. * Render pipeline to produce ssao effect
  71326. */
  71327. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71328. /**
  71329. * @ignore
  71330. * The PassPostProcess id in the pipeline that contains the original scene color
  71331. */
  71332. SSAOOriginalSceneColorEffect: string;
  71333. /**
  71334. * @ignore
  71335. * The SSAO PostProcess id in the pipeline
  71336. */
  71337. SSAORenderEffect: string;
  71338. /**
  71339. * @ignore
  71340. * The horizontal blur PostProcess id in the pipeline
  71341. */
  71342. SSAOBlurHRenderEffect: string;
  71343. /**
  71344. * @ignore
  71345. * The vertical blur PostProcess id in the pipeline
  71346. */
  71347. SSAOBlurVRenderEffect: string;
  71348. /**
  71349. * @ignore
  71350. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71351. */
  71352. SSAOCombineRenderEffect: string;
  71353. /**
  71354. * The output strength of the SSAO post-process. Default value is 1.0.
  71355. */
  71356. totalStrength: number;
  71357. /**
  71358. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71359. */
  71360. radius: number;
  71361. /**
  71362. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71363. * Must not be equal to fallOff and superior to fallOff.
  71364. * Default value is 0.0075
  71365. */
  71366. area: number;
  71367. /**
  71368. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71369. * Must not be equal to area and inferior to area.
  71370. * Default value is 0.000001
  71371. */
  71372. fallOff: number;
  71373. /**
  71374. * The base color of the SSAO post-process
  71375. * The final result is "base + ssao" between [0, 1]
  71376. */
  71377. base: number;
  71378. private _scene;
  71379. private _depthTexture;
  71380. private _randomTexture;
  71381. private _originalColorPostProcess;
  71382. private _ssaoPostProcess;
  71383. private _blurHPostProcess;
  71384. private _blurVPostProcess;
  71385. private _ssaoCombinePostProcess;
  71386. private _firstUpdate;
  71387. /**
  71388. * Gets active scene
  71389. */
  71390. get scene(): Scene;
  71391. /**
  71392. * @constructor
  71393. * @param name - The rendering pipeline name
  71394. * @param scene - The scene linked to this pipeline
  71395. * @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 }
  71396. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71397. */
  71398. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71399. /**
  71400. * Get the class name
  71401. * @returns "SSAORenderingPipeline"
  71402. */
  71403. getClassName(): string;
  71404. /**
  71405. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71406. */
  71407. dispose(disableDepthRender?: boolean): void;
  71408. private _createBlurPostProcess;
  71409. /** @hidden */
  71410. _rebuild(): void;
  71411. private _createSSAOPostProcess;
  71412. private _createSSAOCombinePostProcess;
  71413. private _createRandomTexture;
  71414. }
  71415. }
  71416. declare module BABYLON {
  71417. /**
  71418. * Contains all parameters needed for the prepass to perform
  71419. * screen space reflections
  71420. */
  71421. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71422. /**
  71423. * Is ssr enabled
  71424. */
  71425. enabled: boolean;
  71426. /**
  71427. * Name of the configuration
  71428. */
  71429. name: string;
  71430. /**
  71431. * Textures that should be present in the MRT for this effect to work
  71432. */
  71433. readonly texturesRequired: number[];
  71434. }
  71435. }
  71436. declare module BABYLON {
  71437. /** @hidden */
  71438. export var screenSpaceReflectionPixelShader: {
  71439. name: string;
  71440. shader: string;
  71441. };
  71442. }
  71443. declare module BABYLON {
  71444. /**
  71445. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71446. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71447. */
  71448. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71449. /**
  71450. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71451. */
  71452. threshold: number;
  71453. /**
  71454. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71455. */
  71456. strength: number;
  71457. /**
  71458. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71459. */
  71460. reflectionSpecularFalloffExponent: number;
  71461. /**
  71462. * 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]
  71463. */
  71464. step: number;
  71465. /**
  71466. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71467. */
  71468. roughnessFactor: number;
  71469. private _forceGeometryBuffer;
  71470. private _geometryBufferRenderer;
  71471. private _prePassRenderer;
  71472. private _enableSmoothReflections;
  71473. private _reflectionSamples;
  71474. private _smoothSteps;
  71475. /**
  71476. * Gets a string identifying the name of the class
  71477. * @returns "ScreenSpaceReflectionPostProcess" string
  71478. */
  71479. getClassName(): string;
  71480. /**
  71481. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71482. * @param name The name of the effect.
  71483. * @param scene The scene containing the objects to calculate reflections.
  71484. * @param options The required width/height ratio to downsize to before computing the render pass.
  71485. * @param camera The camera to apply the render pass to.
  71486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71487. * @param engine The engine which the post process will be applied. (default: current engine)
  71488. * @param reusable If the post process can be reused on the same frame. (default: false)
  71489. * @param textureType Type of textures used when performing the post process. (default: 0)
  71490. * @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)
  71491. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71492. */
  71493. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71494. /**
  71495. * Gets wether or not smoothing reflections is enabled.
  71496. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71497. */
  71498. get enableSmoothReflections(): boolean;
  71499. /**
  71500. * Sets wether or not smoothing reflections is enabled.
  71501. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71502. */
  71503. set enableSmoothReflections(enabled: boolean);
  71504. /**
  71505. * Gets the number of samples taken while computing reflections. More samples count is high,
  71506. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71507. */
  71508. get reflectionSamples(): number;
  71509. /**
  71510. * Sets the number of samples taken while computing reflections. More samples count is high,
  71511. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71512. */
  71513. set reflectionSamples(samples: number);
  71514. /**
  71515. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71516. * more the post-process will require GPU power and can generate a drop in FPS.
  71517. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71518. */
  71519. get smoothSteps(): number;
  71520. set smoothSteps(steps: number);
  71521. private _updateEffectDefines;
  71522. /** @hidden */
  71523. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71524. }
  71525. }
  71526. declare module BABYLON {
  71527. /** @hidden */
  71528. export var standardPixelShader: {
  71529. name: string;
  71530. shader: string;
  71531. };
  71532. }
  71533. declare module BABYLON {
  71534. /**
  71535. * Standard rendering pipeline
  71536. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71537. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71538. */
  71539. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71540. /**
  71541. * Public members
  71542. */
  71543. /**
  71544. * Post-process which contains the original scene color before the pipeline applies all the effects
  71545. */
  71546. originalPostProcess: Nullable<PostProcess>;
  71547. /**
  71548. * Post-process used to down scale an image x4
  71549. */
  71550. downSampleX4PostProcess: Nullable<PostProcess>;
  71551. /**
  71552. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71553. */
  71554. brightPassPostProcess: Nullable<PostProcess>;
  71555. /**
  71556. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71557. */
  71558. blurHPostProcesses: PostProcess[];
  71559. /**
  71560. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71561. */
  71562. blurVPostProcesses: PostProcess[];
  71563. /**
  71564. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71565. */
  71566. textureAdderPostProcess: Nullable<PostProcess>;
  71567. /**
  71568. * Post-process used to create volumetric lighting effect
  71569. */
  71570. volumetricLightPostProcess: Nullable<PostProcess>;
  71571. /**
  71572. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71573. */
  71574. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71575. /**
  71576. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71577. */
  71578. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71579. /**
  71580. * Post-process used to merge the volumetric light effect and the real scene color
  71581. */
  71582. volumetricLightMergePostProces: Nullable<PostProcess>;
  71583. /**
  71584. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71585. */
  71586. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71587. /**
  71588. * Base post-process used to calculate the average luminance of the final image for HDR
  71589. */
  71590. luminancePostProcess: Nullable<PostProcess>;
  71591. /**
  71592. * Post-processes used to create down sample post-processes in order to get
  71593. * the average luminance of the final image for HDR
  71594. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71595. */
  71596. luminanceDownSamplePostProcesses: PostProcess[];
  71597. /**
  71598. * Post-process used to create a HDR effect (light adaptation)
  71599. */
  71600. hdrPostProcess: Nullable<PostProcess>;
  71601. /**
  71602. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71603. */
  71604. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71605. /**
  71606. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71607. */
  71608. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71609. /**
  71610. * Post-process used to merge the final HDR post-process and the real scene color
  71611. */
  71612. hdrFinalPostProcess: Nullable<PostProcess>;
  71613. /**
  71614. * Post-process used to create a lens flare effect
  71615. */
  71616. lensFlarePostProcess: Nullable<PostProcess>;
  71617. /**
  71618. * Post-process that merges the result of the lens flare post-process and the real scene color
  71619. */
  71620. lensFlareComposePostProcess: Nullable<PostProcess>;
  71621. /**
  71622. * Post-process used to create a motion blur effect
  71623. */
  71624. motionBlurPostProcess: Nullable<PostProcess>;
  71625. /**
  71626. * Post-process used to create a depth of field effect
  71627. */
  71628. depthOfFieldPostProcess: Nullable<PostProcess>;
  71629. /**
  71630. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71631. */
  71632. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71633. /**
  71634. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71635. */
  71636. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71637. /**
  71638. * Represents the brightness threshold in order to configure the illuminated surfaces
  71639. */
  71640. brightThreshold: number;
  71641. /**
  71642. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71643. */
  71644. blurWidth: number;
  71645. /**
  71646. * Sets if the blur for highlighted surfaces must be only horizontal
  71647. */
  71648. horizontalBlur: boolean;
  71649. /**
  71650. * Gets the overall exposure used by the pipeline
  71651. */
  71652. get exposure(): number;
  71653. /**
  71654. * Sets the overall exposure used by the pipeline
  71655. */
  71656. set exposure(value: number);
  71657. /**
  71658. * Texture used typically to simulate "dirty" on camera lens
  71659. */
  71660. lensTexture: Nullable<Texture>;
  71661. /**
  71662. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71663. */
  71664. volumetricLightCoefficient: number;
  71665. /**
  71666. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71667. */
  71668. volumetricLightPower: number;
  71669. /**
  71670. * Used the set the blur intensity to smooth the volumetric lights
  71671. */
  71672. volumetricLightBlurScale: number;
  71673. /**
  71674. * Light (spot or directional) used to generate the volumetric lights rays
  71675. * The source light must have a shadow generate so the pipeline can get its
  71676. * depth map
  71677. */
  71678. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71679. /**
  71680. * For eye adaptation, represents the minimum luminance the eye can see
  71681. */
  71682. hdrMinimumLuminance: number;
  71683. /**
  71684. * For eye adaptation, represents the decrease luminance speed
  71685. */
  71686. hdrDecreaseRate: number;
  71687. /**
  71688. * For eye adaptation, represents the increase luminance speed
  71689. */
  71690. hdrIncreaseRate: number;
  71691. /**
  71692. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71693. */
  71694. get hdrAutoExposure(): boolean;
  71695. /**
  71696. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71697. */
  71698. set hdrAutoExposure(value: boolean);
  71699. /**
  71700. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71701. */
  71702. lensColorTexture: Nullable<Texture>;
  71703. /**
  71704. * The overall strengh for the lens flare effect
  71705. */
  71706. lensFlareStrength: number;
  71707. /**
  71708. * Dispersion coefficient for lens flare ghosts
  71709. */
  71710. lensFlareGhostDispersal: number;
  71711. /**
  71712. * Main lens flare halo width
  71713. */
  71714. lensFlareHaloWidth: number;
  71715. /**
  71716. * Based on the lens distortion effect, defines how much the lens flare result
  71717. * is distorted
  71718. */
  71719. lensFlareDistortionStrength: number;
  71720. /**
  71721. * Configures the blur intensity used for for lens flare (halo)
  71722. */
  71723. lensFlareBlurWidth: number;
  71724. /**
  71725. * Lens star texture must be used to simulate rays on the flares and is available
  71726. * in the documentation
  71727. */
  71728. lensStarTexture: Nullable<Texture>;
  71729. /**
  71730. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71731. * flare effect by taking account of the dirt texture
  71732. */
  71733. lensFlareDirtTexture: Nullable<Texture>;
  71734. /**
  71735. * Represents the focal length for the depth of field effect
  71736. */
  71737. depthOfFieldDistance: number;
  71738. /**
  71739. * Represents the blur intensity for the blurred part of the depth of field effect
  71740. */
  71741. depthOfFieldBlurWidth: number;
  71742. /**
  71743. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71744. */
  71745. get motionStrength(): number;
  71746. /**
  71747. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71748. */
  71749. set motionStrength(strength: number);
  71750. /**
  71751. * Gets wether or not the motion blur post-process is object based or screen based.
  71752. */
  71753. get objectBasedMotionBlur(): boolean;
  71754. /**
  71755. * Sets wether or not the motion blur post-process should be object based or screen based
  71756. */
  71757. set objectBasedMotionBlur(value: boolean);
  71758. /**
  71759. * List of animations for the pipeline (IAnimatable implementation)
  71760. */
  71761. animations: Animation[];
  71762. /**
  71763. * Private members
  71764. */
  71765. private _scene;
  71766. private _currentDepthOfFieldSource;
  71767. private _basePostProcess;
  71768. private _fixedExposure;
  71769. private _currentExposure;
  71770. private _hdrAutoExposure;
  71771. private _hdrCurrentLuminance;
  71772. private _motionStrength;
  71773. private _isObjectBasedMotionBlur;
  71774. private _floatTextureType;
  71775. private _camerasToBeAttached;
  71776. private _ratio;
  71777. private _bloomEnabled;
  71778. private _depthOfFieldEnabled;
  71779. private _vlsEnabled;
  71780. private _lensFlareEnabled;
  71781. private _hdrEnabled;
  71782. private _motionBlurEnabled;
  71783. private _fxaaEnabled;
  71784. private _screenSpaceReflectionsEnabled;
  71785. private _motionBlurSamples;
  71786. private _volumetricLightStepsCount;
  71787. private _samples;
  71788. /**
  71789. * @ignore
  71790. * Specifies if the bloom pipeline is enabled
  71791. */
  71792. get BloomEnabled(): boolean;
  71793. set BloomEnabled(enabled: boolean);
  71794. /**
  71795. * @ignore
  71796. * Specifies if the depth of field pipeline is enabed
  71797. */
  71798. get DepthOfFieldEnabled(): boolean;
  71799. set DepthOfFieldEnabled(enabled: boolean);
  71800. /**
  71801. * @ignore
  71802. * Specifies if the lens flare pipeline is enabed
  71803. */
  71804. get LensFlareEnabled(): boolean;
  71805. set LensFlareEnabled(enabled: boolean);
  71806. /**
  71807. * @ignore
  71808. * Specifies if the HDR pipeline is enabled
  71809. */
  71810. get HDREnabled(): boolean;
  71811. set HDREnabled(enabled: boolean);
  71812. /**
  71813. * @ignore
  71814. * Specifies if the volumetric lights scattering effect is enabled
  71815. */
  71816. get VLSEnabled(): boolean;
  71817. set VLSEnabled(enabled: boolean);
  71818. /**
  71819. * @ignore
  71820. * Specifies if the motion blur effect is enabled
  71821. */
  71822. get MotionBlurEnabled(): boolean;
  71823. set MotionBlurEnabled(enabled: boolean);
  71824. /**
  71825. * Specifies if anti-aliasing is enabled
  71826. */
  71827. get fxaaEnabled(): boolean;
  71828. set fxaaEnabled(enabled: boolean);
  71829. /**
  71830. * Specifies if screen space reflections are enabled.
  71831. */
  71832. get screenSpaceReflectionsEnabled(): boolean;
  71833. set screenSpaceReflectionsEnabled(enabled: boolean);
  71834. /**
  71835. * Specifies the number of steps used to calculate the volumetric lights
  71836. * Typically in interval [50, 200]
  71837. */
  71838. get volumetricLightStepsCount(): number;
  71839. set volumetricLightStepsCount(count: number);
  71840. /**
  71841. * Specifies the number of samples used for the motion blur effect
  71842. * Typically in interval [16, 64]
  71843. */
  71844. get motionBlurSamples(): number;
  71845. set motionBlurSamples(samples: number);
  71846. /**
  71847. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71848. */
  71849. get samples(): number;
  71850. set samples(sampleCount: number);
  71851. /**
  71852. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71853. * @constructor
  71854. * @param name The rendering pipeline name
  71855. * @param scene The scene linked to this pipeline
  71856. * @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)
  71857. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71858. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71859. */
  71860. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71861. private _buildPipeline;
  71862. private _createDownSampleX4PostProcess;
  71863. private _createBrightPassPostProcess;
  71864. private _createBlurPostProcesses;
  71865. private _createTextureAdderPostProcess;
  71866. private _createVolumetricLightPostProcess;
  71867. private _createLuminancePostProcesses;
  71868. private _createHdrPostProcess;
  71869. private _createLensFlarePostProcess;
  71870. private _createDepthOfFieldPostProcess;
  71871. private _createMotionBlurPostProcess;
  71872. private _getDepthTexture;
  71873. private _disposePostProcesses;
  71874. /**
  71875. * Dispose of the pipeline and stop all post processes
  71876. */
  71877. dispose(): void;
  71878. /**
  71879. * Serialize the rendering pipeline (Used when exporting)
  71880. * @returns the serialized object
  71881. */
  71882. serialize(): any;
  71883. /**
  71884. * Parse the serialized pipeline
  71885. * @param source Source pipeline.
  71886. * @param scene The scene to load the pipeline to.
  71887. * @param rootUrl The URL of the serialized pipeline.
  71888. * @returns An instantiated pipeline from the serialized object.
  71889. */
  71890. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71891. /**
  71892. * Luminance steps
  71893. */
  71894. static LuminanceSteps: number;
  71895. }
  71896. }
  71897. declare module BABYLON {
  71898. /** @hidden */
  71899. export var stereoscopicInterlacePixelShader: {
  71900. name: string;
  71901. shader: string;
  71902. };
  71903. }
  71904. declare module BABYLON {
  71905. /**
  71906. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71907. */
  71908. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71909. private _stepSize;
  71910. private _passedProcess;
  71911. /**
  71912. * Gets a string identifying the name of the class
  71913. * @returns "StereoscopicInterlacePostProcessI" string
  71914. */
  71915. getClassName(): string;
  71916. /**
  71917. * Initializes a StereoscopicInterlacePostProcessI
  71918. * @param name The name of the effect.
  71919. * @param rigCameras The rig cameras to be appled to the post process
  71920. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71921. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71923. * @param engine The engine which the post process will be applied. (default: current engine)
  71924. * @param reusable If the post process can be reused on the same frame. (default: false)
  71925. */
  71926. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71927. }
  71928. /**
  71929. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71930. */
  71931. export class StereoscopicInterlacePostProcess extends PostProcess {
  71932. private _stepSize;
  71933. private _passedProcess;
  71934. /**
  71935. * Gets a string identifying the name of the class
  71936. * @returns "StereoscopicInterlacePostProcess" string
  71937. */
  71938. getClassName(): string;
  71939. /**
  71940. * Initializes a StereoscopicInterlacePostProcess
  71941. * @param name The name of the effect.
  71942. * @param rigCameras The rig cameras to be appled to the post process
  71943. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71945. * @param engine The engine which the post process will be applied. (default: current engine)
  71946. * @param reusable If the post process can be reused on the same frame. (default: false)
  71947. */
  71948. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71949. }
  71950. }
  71951. declare module BABYLON {
  71952. /** @hidden */
  71953. export var tonemapPixelShader: {
  71954. name: string;
  71955. shader: string;
  71956. };
  71957. }
  71958. declare module BABYLON {
  71959. /** Defines operator used for tonemapping */
  71960. export enum TonemappingOperator {
  71961. /** Hable */
  71962. Hable = 0,
  71963. /** Reinhard */
  71964. Reinhard = 1,
  71965. /** HejiDawson */
  71966. HejiDawson = 2,
  71967. /** Photographic */
  71968. Photographic = 3
  71969. }
  71970. /**
  71971. * Defines a post process to apply tone mapping
  71972. */
  71973. export class TonemapPostProcess extends PostProcess {
  71974. private _operator;
  71975. /** Defines the required exposure adjustement */
  71976. exposureAdjustment: number;
  71977. /**
  71978. * Gets a string identifying the name of the class
  71979. * @returns "TonemapPostProcess" string
  71980. */
  71981. getClassName(): string;
  71982. /**
  71983. * Creates a new TonemapPostProcess
  71984. * @param name defines the name of the postprocess
  71985. * @param _operator defines the operator to use
  71986. * @param exposureAdjustment defines the required exposure adjustement
  71987. * @param camera defines the camera to use (can be null)
  71988. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71989. * @param engine defines the hosting engine (can be ignore if camera is set)
  71990. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71991. */
  71992. constructor(name: string, _operator: TonemappingOperator,
  71993. /** Defines the required exposure adjustement */
  71994. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71995. }
  71996. }
  71997. declare module BABYLON {
  71998. /** @hidden */
  71999. export var volumetricLightScatteringPixelShader: {
  72000. name: string;
  72001. shader: string;
  72002. };
  72003. }
  72004. declare module BABYLON {
  72005. /** @hidden */
  72006. export var volumetricLightScatteringPassVertexShader: {
  72007. name: string;
  72008. shader: string;
  72009. };
  72010. }
  72011. declare module BABYLON {
  72012. /** @hidden */
  72013. export var volumetricLightScatteringPassPixelShader: {
  72014. name: string;
  72015. shader: string;
  72016. };
  72017. }
  72018. declare module BABYLON {
  72019. /**
  72020. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72021. */
  72022. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72023. private _volumetricLightScatteringPass;
  72024. private _volumetricLightScatteringRTT;
  72025. private _viewPort;
  72026. private _screenCoordinates;
  72027. private _cachedDefines;
  72028. /**
  72029. * If not undefined, the mesh position is computed from the attached node position
  72030. */
  72031. attachedNode: {
  72032. position: Vector3;
  72033. };
  72034. /**
  72035. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72036. */
  72037. customMeshPosition: Vector3;
  72038. /**
  72039. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72040. */
  72041. useCustomMeshPosition: boolean;
  72042. /**
  72043. * If the post-process should inverse the light scattering direction
  72044. */
  72045. invert: boolean;
  72046. /**
  72047. * The internal mesh used by the post-process
  72048. */
  72049. mesh: Mesh;
  72050. /**
  72051. * @hidden
  72052. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72053. */
  72054. get useDiffuseColor(): boolean;
  72055. set useDiffuseColor(useDiffuseColor: boolean);
  72056. /**
  72057. * Array containing the excluded meshes not rendered in the internal pass
  72058. */
  72059. excludedMeshes: AbstractMesh[];
  72060. /**
  72061. * Controls the overall intensity of the post-process
  72062. */
  72063. exposure: number;
  72064. /**
  72065. * Dissipates each sample's contribution in range [0, 1]
  72066. */
  72067. decay: number;
  72068. /**
  72069. * Controls the overall intensity of each sample
  72070. */
  72071. weight: number;
  72072. /**
  72073. * Controls the density of each sample
  72074. */
  72075. density: number;
  72076. /**
  72077. * @constructor
  72078. * @param name The post-process name
  72079. * @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)
  72080. * @param camera The camera that the post-process will be attached to
  72081. * @param mesh The mesh used to create the light scattering
  72082. * @param samples The post-process quality, default 100
  72083. * @param samplingModeThe post-process filtering mode
  72084. * @param engine The babylon engine
  72085. * @param reusable If the post-process is reusable
  72086. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72087. */
  72088. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72089. /**
  72090. * Returns the string "VolumetricLightScatteringPostProcess"
  72091. * @returns "VolumetricLightScatteringPostProcess"
  72092. */
  72093. getClassName(): string;
  72094. private _isReady;
  72095. /**
  72096. * Sets the new light position for light scattering effect
  72097. * @param position The new custom light position
  72098. */
  72099. setCustomMeshPosition(position: Vector3): void;
  72100. /**
  72101. * Returns the light position for light scattering effect
  72102. * @return Vector3 The custom light position
  72103. */
  72104. getCustomMeshPosition(): Vector3;
  72105. /**
  72106. * Disposes the internal assets and detaches the post-process from the camera
  72107. */
  72108. dispose(camera: Camera): void;
  72109. /**
  72110. * Returns the render target texture used by the post-process
  72111. * @return the render target texture used by the post-process
  72112. */
  72113. getPass(): RenderTargetTexture;
  72114. private _meshExcluded;
  72115. private _createPass;
  72116. private _updateMeshScreenCoordinates;
  72117. /**
  72118. * Creates a default mesh for the Volumeric Light Scattering post-process
  72119. * @param name The mesh name
  72120. * @param scene The scene where to create the mesh
  72121. * @return the default mesh
  72122. */
  72123. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72124. }
  72125. }
  72126. declare module BABYLON {
  72127. /** @hidden */
  72128. export var screenSpaceCurvaturePixelShader: {
  72129. name: string;
  72130. shader: string;
  72131. };
  72132. }
  72133. declare module BABYLON {
  72134. /**
  72135. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72136. */
  72137. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72138. /**
  72139. * Defines how much ridge the curvature effect displays.
  72140. */
  72141. ridge: number;
  72142. /**
  72143. * Defines how much valley the curvature effect displays.
  72144. */
  72145. valley: number;
  72146. private _geometryBufferRenderer;
  72147. /**
  72148. * Gets a string identifying the name of the class
  72149. * @returns "ScreenSpaceCurvaturePostProcess" string
  72150. */
  72151. getClassName(): string;
  72152. /**
  72153. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72154. * @param name The name of the effect.
  72155. * @param scene The scene containing the objects to blur according to their velocity.
  72156. * @param options The required width/height ratio to downsize to before computing the render pass.
  72157. * @param camera The camera to apply the render pass to.
  72158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72159. * @param engine The engine which the post process will be applied. (default: current engine)
  72160. * @param reusable If the post process can be reused on the same frame. (default: false)
  72161. * @param textureType Type of textures used when performing the post process. (default: 0)
  72162. * @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)
  72163. */
  72164. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72165. /**
  72166. * Support test.
  72167. */
  72168. static get IsSupported(): boolean;
  72169. /** @hidden */
  72170. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72171. }
  72172. }
  72173. declare module BABYLON {
  72174. interface Scene {
  72175. /** @hidden (Backing field) */
  72176. _boundingBoxRenderer: BoundingBoxRenderer;
  72177. /** @hidden (Backing field) */
  72178. _forceShowBoundingBoxes: boolean;
  72179. /**
  72180. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72181. */
  72182. forceShowBoundingBoxes: boolean;
  72183. /**
  72184. * Gets the bounding box renderer associated with the scene
  72185. * @returns a BoundingBoxRenderer
  72186. */
  72187. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72188. }
  72189. interface AbstractMesh {
  72190. /** @hidden (Backing field) */
  72191. _showBoundingBox: boolean;
  72192. /**
  72193. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72194. */
  72195. showBoundingBox: boolean;
  72196. }
  72197. /**
  72198. * Component responsible of rendering the bounding box of the meshes in a scene.
  72199. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72200. */
  72201. export class BoundingBoxRenderer implements ISceneComponent {
  72202. /**
  72203. * The component name helpfull to identify the component in the list of scene components.
  72204. */
  72205. readonly name: string;
  72206. /**
  72207. * The scene the component belongs to.
  72208. */
  72209. scene: Scene;
  72210. /**
  72211. * Color of the bounding box lines placed in front of an object
  72212. */
  72213. frontColor: Color3;
  72214. /**
  72215. * Color of the bounding box lines placed behind an object
  72216. */
  72217. backColor: Color3;
  72218. /**
  72219. * Defines if the renderer should show the back lines or not
  72220. */
  72221. showBackLines: boolean;
  72222. /**
  72223. * Observable raised before rendering a bounding box
  72224. */
  72225. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72226. /**
  72227. * Observable raised after rendering a bounding box
  72228. */
  72229. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72230. /**
  72231. * @hidden
  72232. */
  72233. renderList: SmartArray<BoundingBox>;
  72234. private _colorShader;
  72235. private _vertexBuffers;
  72236. private _indexBuffer;
  72237. private _fillIndexBuffer;
  72238. private _fillIndexData;
  72239. /**
  72240. * Instantiates a new bounding box renderer in a scene.
  72241. * @param scene the scene the renderer renders in
  72242. */
  72243. constructor(scene: Scene);
  72244. /**
  72245. * Registers the component in a given scene
  72246. */
  72247. register(): void;
  72248. private _evaluateSubMesh;
  72249. private _activeMesh;
  72250. private _prepareRessources;
  72251. private _createIndexBuffer;
  72252. /**
  72253. * Rebuilds the elements related to this component in case of
  72254. * context lost for instance.
  72255. */
  72256. rebuild(): void;
  72257. /**
  72258. * @hidden
  72259. */
  72260. reset(): void;
  72261. /**
  72262. * Render the bounding boxes of a specific rendering group
  72263. * @param renderingGroupId defines the rendering group to render
  72264. */
  72265. render(renderingGroupId: number): void;
  72266. /**
  72267. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72268. * @param mesh Define the mesh to render the occlusion bounding box for
  72269. */
  72270. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72271. /**
  72272. * Dispose and release the resources attached to this renderer.
  72273. */
  72274. dispose(): void;
  72275. }
  72276. }
  72277. declare module BABYLON {
  72278. interface Scene {
  72279. /** @hidden (Backing field) */
  72280. _depthRenderer: {
  72281. [id: string]: DepthRenderer;
  72282. };
  72283. /**
  72284. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72285. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72286. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72287. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72288. * @returns the created depth renderer
  72289. */
  72290. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72291. /**
  72292. * Disables a depth renderer for a given camera
  72293. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72294. */
  72295. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72296. }
  72297. /**
  72298. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72299. * in several rendering techniques.
  72300. */
  72301. export class DepthRendererSceneComponent implements ISceneComponent {
  72302. /**
  72303. * The component name helpfull to identify the component in the list of scene components.
  72304. */
  72305. readonly name: string;
  72306. /**
  72307. * The scene the component belongs to.
  72308. */
  72309. scene: Scene;
  72310. /**
  72311. * Creates a new instance of the component for the given scene
  72312. * @param scene Defines the scene to register the component in
  72313. */
  72314. constructor(scene: Scene);
  72315. /**
  72316. * Registers the component in a given scene
  72317. */
  72318. register(): void;
  72319. /**
  72320. * Rebuilds the elements related to this component in case of
  72321. * context lost for instance.
  72322. */
  72323. rebuild(): void;
  72324. /**
  72325. * Disposes the component and the associated ressources
  72326. */
  72327. dispose(): void;
  72328. private _gatherRenderTargets;
  72329. private _gatherActiveCameraRenderTargets;
  72330. }
  72331. }
  72332. declare module BABYLON {
  72333. interface AbstractScene {
  72334. /** @hidden (Backing field) */
  72335. _prePassRenderer: Nullable<PrePassRenderer>;
  72336. /**
  72337. * Gets or Sets the current prepass renderer associated to the scene.
  72338. */
  72339. prePassRenderer: Nullable<PrePassRenderer>;
  72340. /**
  72341. * Enables the prepass and associates it with the scene
  72342. * @returns the PrePassRenderer
  72343. */
  72344. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72345. /**
  72346. * Disables the prepass associated with the scene
  72347. */
  72348. disablePrePassRenderer(): void;
  72349. }
  72350. /**
  72351. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72352. * in several rendering techniques.
  72353. */
  72354. export class PrePassRendererSceneComponent implements ISceneComponent {
  72355. /**
  72356. * The component name helpful to identify the component in the list of scene components.
  72357. */
  72358. readonly name: string;
  72359. /**
  72360. * The scene the component belongs to.
  72361. */
  72362. scene: Scene;
  72363. /**
  72364. * Creates a new instance of the component for the given scene
  72365. * @param scene Defines the scene to register the component in
  72366. */
  72367. constructor(scene: Scene);
  72368. /**
  72369. * Registers the component in a given scene
  72370. */
  72371. register(): void;
  72372. private _beforeCameraDraw;
  72373. private _afterCameraDraw;
  72374. private _beforeClearStage;
  72375. /**
  72376. * Rebuilds the elements related to this component in case of
  72377. * context lost for instance.
  72378. */
  72379. rebuild(): void;
  72380. /**
  72381. * Disposes the component and the associated ressources
  72382. */
  72383. dispose(): void;
  72384. }
  72385. }
  72386. declare module BABYLON {
  72387. /** @hidden */
  72388. export var fibonacci: {
  72389. name: string;
  72390. shader: string;
  72391. };
  72392. }
  72393. declare module BABYLON {
  72394. /** @hidden */
  72395. export var diffusionProfile: {
  72396. name: string;
  72397. shader: string;
  72398. };
  72399. }
  72400. declare module BABYLON {
  72401. /** @hidden */
  72402. export var subSurfaceScatteringPixelShader: {
  72403. name: string;
  72404. shader: string;
  72405. };
  72406. }
  72407. declare module BABYLON {
  72408. /**
  72409. * Sub surface scattering post process
  72410. */
  72411. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72412. /**
  72413. * Gets a string identifying the name of the class
  72414. * @returns "SubSurfaceScatteringPostProcess" string
  72415. */
  72416. getClassName(): string;
  72417. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72418. }
  72419. }
  72420. declare module BABYLON {
  72421. /**
  72422. * Contains all parameters needed for the prepass to perform
  72423. * screen space subsurface scattering
  72424. */
  72425. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72426. /** @hidden */
  72427. static _SceneComponentInitialization: (scene: Scene) => void;
  72428. private _ssDiffusionS;
  72429. private _ssFilterRadii;
  72430. private _ssDiffusionD;
  72431. /**
  72432. * Post process to attach for screen space subsurface scattering
  72433. */
  72434. postProcess: SubSurfaceScatteringPostProcess;
  72435. /**
  72436. * Diffusion profile color for subsurface scattering
  72437. */
  72438. get ssDiffusionS(): number[];
  72439. /**
  72440. * Diffusion profile max color channel value for subsurface scattering
  72441. */
  72442. get ssDiffusionD(): number[];
  72443. /**
  72444. * Diffusion profile filter radius for subsurface scattering
  72445. */
  72446. get ssFilterRadii(): number[];
  72447. /**
  72448. * Is subsurface enabled
  72449. */
  72450. enabled: boolean;
  72451. /**
  72452. * Name of the configuration
  72453. */
  72454. name: string;
  72455. /**
  72456. * Diffusion profile colors for subsurface scattering
  72457. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72458. * See ...
  72459. * Note that you can only store up to 5 of them
  72460. */
  72461. ssDiffusionProfileColors: Color3[];
  72462. /**
  72463. * Defines the ratio real world => scene units.
  72464. * Used for subsurface scattering
  72465. */
  72466. metersPerUnit: number;
  72467. /**
  72468. * Textures that should be present in the MRT for this effect to work
  72469. */
  72470. readonly texturesRequired: number[];
  72471. private _scene;
  72472. /**
  72473. * Builds a subsurface configuration object
  72474. * @param scene The scene
  72475. */
  72476. constructor(scene: Scene);
  72477. /**
  72478. * Adds a new diffusion profile.
  72479. * Useful for more realistic subsurface scattering on diverse materials.
  72480. * @param color The color of the diffusion profile. Should be the average color of the material.
  72481. * @return The index of the diffusion profile for the material subsurface configuration
  72482. */
  72483. addDiffusionProfile(color: Color3): number;
  72484. /**
  72485. * Creates the sss post process
  72486. * @return The created post process
  72487. */
  72488. createPostProcess(): SubSurfaceScatteringPostProcess;
  72489. /**
  72490. * Deletes all diffusion profiles.
  72491. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72492. */
  72493. clearAllDiffusionProfiles(): void;
  72494. /**
  72495. * Disposes this object
  72496. */
  72497. dispose(): void;
  72498. /**
  72499. * @hidden
  72500. * https://zero-radiance.github.io/post/sampling-diffusion/
  72501. *
  72502. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72503. * ------------------------------------------------------------------------------------
  72504. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72505. * PDF[r, phi, s] = r * R[r, phi, s]
  72506. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72507. * ------------------------------------------------------------------------------------
  72508. * We importance sample the color channel with the widest scattering distance.
  72509. */
  72510. getDiffusionProfileParameters(color: Color3): number;
  72511. /**
  72512. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72513. * 'u' is the random number (the value of the CDF): [0, 1).
  72514. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72515. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72516. */
  72517. private _sampleBurleyDiffusionProfile;
  72518. }
  72519. }
  72520. declare module BABYLON {
  72521. interface AbstractScene {
  72522. /** @hidden (Backing field) */
  72523. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72524. /**
  72525. * Gets or Sets the current prepass renderer associated to the scene.
  72526. */
  72527. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72528. /**
  72529. * Enables the subsurface effect for prepass
  72530. * @returns the SubSurfaceConfiguration
  72531. */
  72532. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72533. /**
  72534. * Disables the subsurface effect for prepass
  72535. */
  72536. disableSubSurfaceForPrePass(): void;
  72537. }
  72538. /**
  72539. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72540. * in several rendering techniques.
  72541. */
  72542. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72543. /**
  72544. * The component name helpful to identify the component in the list of scene components.
  72545. */
  72546. readonly name: string;
  72547. /**
  72548. * The scene the component belongs to.
  72549. */
  72550. scene: Scene;
  72551. /**
  72552. * Creates a new instance of the component for the given scene
  72553. * @param scene Defines the scene to register the component in
  72554. */
  72555. constructor(scene: Scene);
  72556. /**
  72557. * Registers the component in a given scene
  72558. */
  72559. register(): void;
  72560. /**
  72561. * Serializes the component data to the specified json object
  72562. * @param serializationObject The object to serialize to
  72563. */
  72564. serialize(serializationObject: any): void;
  72565. /**
  72566. * Adds all the elements from the container to the scene
  72567. * @param container the container holding the elements
  72568. */
  72569. addFromContainer(container: AbstractScene): void;
  72570. /**
  72571. * Removes all the elements in the container from the scene
  72572. * @param container contains the elements to remove
  72573. * @param dispose if the removed element should be disposed (default: false)
  72574. */
  72575. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72576. /**
  72577. * Rebuilds the elements related to this component in case of
  72578. * context lost for instance.
  72579. */
  72580. rebuild(): void;
  72581. /**
  72582. * Disposes the component and the associated ressources
  72583. */
  72584. dispose(): void;
  72585. }
  72586. }
  72587. declare module BABYLON {
  72588. /** @hidden */
  72589. export var outlinePixelShader: {
  72590. name: string;
  72591. shader: string;
  72592. };
  72593. }
  72594. declare module BABYLON {
  72595. /** @hidden */
  72596. export var outlineVertexShader: {
  72597. name: string;
  72598. shader: string;
  72599. };
  72600. }
  72601. declare module BABYLON {
  72602. interface Scene {
  72603. /** @hidden */
  72604. _outlineRenderer: OutlineRenderer;
  72605. /**
  72606. * Gets the outline renderer associated with the scene
  72607. * @returns a OutlineRenderer
  72608. */
  72609. getOutlineRenderer(): OutlineRenderer;
  72610. }
  72611. interface AbstractMesh {
  72612. /** @hidden (Backing field) */
  72613. _renderOutline: boolean;
  72614. /**
  72615. * Gets or sets a boolean indicating if the outline must be rendered as well
  72616. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72617. */
  72618. renderOutline: boolean;
  72619. /** @hidden (Backing field) */
  72620. _renderOverlay: boolean;
  72621. /**
  72622. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72623. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72624. */
  72625. renderOverlay: boolean;
  72626. }
  72627. /**
  72628. * This class is responsible to draw bothe outline/overlay of meshes.
  72629. * It should not be used directly but through the available method on mesh.
  72630. */
  72631. export class OutlineRenderer implements ISceneComponent {
  72632. /**
  72633. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72634. */
  72635. private static _StencilReference;
  72636. /**
  72637. * The name of the component. Each component must have a unique name.
  72638. */
  72639. name: string;
  72640. /**
  72641. * The scene the component belongs to.
  72642. */
  72643. scene: Scene;
  72644. /**
  72645. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72646. */
  72647. zOffset: number;
  72648. private _engine;
  72649. private _effect;
  72650. private _cachedDefines;
  72651. private _savedDepthWrite;
  72652. /**
  72653. * Instantiates a new outline renderer. (There could be only one per scene).
  72654. * @param scene Defines the scene it belongs to
  72655. */
  72656. constructor(scene: Scene);
  72657. /**
  72658. * Register the component to one instance of a scene.
  72659. */
  72660. register(): void;
  72661. /**
  72662. * Rebuilds the elements related to this component in case of
  72663. * context lost for instance.
  72664. */
  72665. rebuild(): void;
  72666. /**
  72667. * Disposes the component and the associated ressources.
  72668. */
  72669. dispose(): void;
  72670. /**
  72671. * Renders the outline in the canvas.
  72672. * @param subMesh Defines the sumesh to render
  72673. * @param batch Defines the batch of meshes in case of instances
  72674. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72675. */
  72676. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72677. /**
  72678. * Returns whether or not the outline renderer is ready for a given submesh.
  72679. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72680. * @param subMesh Defines the submesh to check readyness for
  72681. * @param useInstances Defines wheter wee are trying to render instances or not
  72682. * @returns true if ready otherwise false
  72683. */
  72684. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72685. private _beforeRenderingMesh;
  72686. private _afterRenderingMesh;
  72687. }
  72688. }
  72689. declare module BABYLON {
  72690. /**
  72691. * Defines the basic options interface of a Sprite Frame Source Size.
  72692. */
  72693. export interface ISpriteJSONSpriteSourceSize {
  72694. /**
  72695. * number of the original width of the Frame
  72696. */
  72697. w: number;
  72698. /**
  72699. * number of the original height of the Frame
  72700. */
  72701. h: number;
  72702. }
  72703. /**
  72704. * Defines the basic options interface of a Sprite Frame Data.
  72705. */
  72706. export interface ISpriteJSONSpriteFrameData {
  72707. /**
  72708. * number of the x offset of the Frame
  72709. */
  72710. x: number;
  72711. /**
  72712. * number of the y offset of the Frame
  72713. */
  72714. y: number;
  72715. /**
  72716. * number of the width of the Frame
  72717. */
  72718. w: number;
  72719. /**
  72720. * number of the height of the Frame
  72721. */
  72722. h: number;
  72723. }
  72724. /**
  72725. * Defines the basic options interface of a JSON Sprite.
  72726. */
  72727. export interface ISpriteJSONSprite {
  72728. /**
  72729. * string name of the Frame
  72730. */
  72731. filename: string;
  72732. /**
  72733. * ISpriteJSONSpriteFrame basic object of the frame data
  72734. */
  72735. frame: ISpriteJSONSpriteFrameData;
  72736. /**
  72737. * boolean to flag is the frame was rotated.
  72738. */
  72739. rotated: boolean;
  72740. /**
  72741. * boolean to flag is the frame was trimmed.
  72742. */
  72743. trimmed: boolean;
  72744. /**
  72745. * ISpriteJSONSpriteFrame basic object of the source data
  72746. */
  72747. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72748. /**
  72749. * ISpriteJSONSpriteFrame basic object of the source data
  72750. */
  72751. sourceSize: ISpriteJSONSpriteSourceSize;
  72752. }
  72753. /**
  72754. * Defines the basic options interface of a JSON atlas.
  72755. */
  72756. export interface ISpriteJSONAtlas {
  72757. /**
  72758. * Array of objects that contain the frame data.
  72759. */
  72760. frames: Array<ISpriteJSONSprite>;
  72761. /**
  72762. * object basic object containing the sprite meta data.
  72763. */
  72764. meta?: object;
  72765. }
  72766. }
  72767. declare module BABYLON {
  72768. /** @hidden */
  72769. export var spriteMapPixelShader: {
  72770. name: string;
  72771. shader: string;
  72772. };
  72773. }
  72774. declare module BABYLON {
  72775. /** @hidden */
  72776. export var spriteMapVertexShader: {
  72777. name: string;
  72778. shader: string;
  72779. };
  72780. }
  72781. declare module BABYLON {
  72782. /**
  72783. * Defines the basic options interface of a SpriteMap
  72784. */
  72785. export interface ISpriteMapOptions {
  72786. /**
  72787. * Vector2 of the number of cells in the grid.
  72788. */
  72789. stageSize?: Vector2;
  72790. /**
  72791. * Vector2 of the size of the output plane in World Units.
  72792. */
  72793. outputSize?: Vector2;
  72794. /**
  72795. * Vector3 of the position of the output plane in World Units.
  72796. */
  72797. outputPosition?: Vector3;
  72798. /**
  72799. * Vector3 of the rotation of the output plane.
  72800. */
  72801. outputRotation?: Vector3;
  72802. /**
  72803. * number of layers that the system will reserve in resources.
  72804. */
  72805. layerCount?: number;
  72806. /**
  72807. * number of max animation frames a single cell will reserve in resources.
  72808. */
  72809. maxAnimationFrames?: number;
  72810. /**
  72811. * number cell index of the base tile when the system compiles.
  72812. */
  72813. baseTile?: number;
  72814. /**
  72815. * boolean flip the sprite after its been repositioned by the framing data.
  72816. */
  72817. flipU?: boolean;
  72818. /**
  72819. * Vector3 scalar of the global RGB values of the SpriteMap.
  72820. */
  72821. colorMultiply?: Vector3;
  72822. }
  72823. /**
  72824. * Defines the IDisposable interface in order to be cleanable from resources.
  72825. */
  72826. export interface ISpriteMap extends IDisposable {
  72827. /**
  72828. * String name of the SpriteMap.
  72829. */
  72830. name: string;
  72831. /**
  72832. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72833. */
  72834. atlasJSON: ISpriteJSONAtlas;
  72835. /**
  72836. * Texture of the SpriteMap.
  72837. */
  72838. spriteSheet: Texture;
  72839. /**
  72840. * The parameters to initialize the SpriteMap with.
  72841. */
  72842. options: ISpriteMapOptions;
  72843. }
  72844. /**
  72845. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72846. */
  72847. export class SpriteMap implements ISpriteMap {
  72848. /** The Name of the spriteMap */
  72849. name: string;
  72850. /** The JSON file with the frame and meta data */
  72851. atlasJSON: ISpriteJSONAtlas;
  72852. /** The systems Sprite Sheet Texture */
  72853. spriteSheet: Texture;
  72854. /** Arguments passed with the Constructor */
  72855. options: ISpriteMapOptions;
  72856. /** Public Sprite Storage array, parsed from atlasJSON */
  72857. sprites: Array<ISpriteJSONSprite>;
  72858. /** Returns the Number of Sprites in the System */
  72859. get spriteCount(): number;
  72860. /** Returns the Position of Output Plane*/
  72861. get position(): Vector3;
  72862. /** Returns the Position of Output Plane*/
  72863. set position(v: Vector3);
  72864. /** Returns the Rotation of Output Plane*/
  72865. get rotation(): Vector3;
  72866. /** Returns the Rotation of Output Plane*/
  72867. set rotation(v: Vector3);
  72868. /** Sets the AnimationMap*/
  72869. get animationMap(): RawTexture;
  72870. /** Sets the AnimationMap*/
  72871. set animationMap(v: RawTexture);
  72872. /** Scene that the SpriteMap was created in */
  72873. private _scene;
  72874. /** Texture Buffer of Float32 that holds tile frame data*/
  72875. private _frameMap;
  72876. /** Texture Buffers of Float32 that holds tileMap data*/
  72877. private _tileMaps;
  72878. /** Texture Buffer of Float32 that holds Animation Data*/
  72879. private _animationMap;
  72880. /** Custom ShaderMaterial Central to the System*/
  72881. private _material;
  72882. /** Custom ShaderMaterial Central to the System*/
  72883. private _output;
  72884. /** Systems Time Ticker*/
  72885. private _time;
  72886. /**
  72887. * Creates a new SpriteMap
  72888. * @param name defines the SpriteMaps Name
  72889. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72890. * @param spriteSheet is the Texture that the Sprites are on.
  72891. * @param options a basic deployment configuration
  72892. * @param scene The Scene that the map is deployed on
  72893. */
  72894. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72895. /**
  72896. * Returns tileID location
  72897. * @returns Vector2 the cell position ID
  72898. */
  72899. getTileID(): Vector2;
  72900. /**
  72901. * Gets the UV location of the mouse over the SpriteMap.
  72902. * @returns Vector2 the UV position of the mouse interaction
  72903. */
  72904. getMousePosition(): Vector2;
  72905. /**
  72906. * Creates the "frame" texture Buffer
  72907. * -------------------------------------
  72908. * Structure of frames
  72909. * "filename": "Falling-Water-2.png",
  72910. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72911. * "rotated": true,
  72912. * "trimmed": true,
  72913. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72914. * "sourceSize": {"w":32,"h":32}
  72915. * @returns RawTexture of the frameMap
  72916. */
  72917. private _createFrameBuffer;
  72918. /**
  72919. * Creates the tileMap texture Buffer
  72920. * @param buffer normally and array of numbers, or a false to generate from scratch
  72921. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72922. * @returns RawTexture of the tileMap
  72923. */
  72924. private _createTileBuffer;
  72925. /**
  72926. * Modifies the data of the tileMaps
  72927. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72928. * @param pos is the iVector2 Coordinates of the Tile
  72929. * @param tile The SpriteIndex of the new Tile
  72930. */
  72931. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72932. /**
  72933. * Creates the animationMap texture Buffer
  72934. * @param buffer normally and array of numbers, or a false to generate from scratch
  72935. * @returns RawTexture of the animationMap
  72936. */
  72937. private _createTileAnimationBuffer;
  72938. /**
  72939. * Modifies the data of the animationMap
  72940. * @param cellID is the Index of the Sprite
  72941. * @param _frame is the target Animation frame
  72942. * @param toCell is the Target Index of the next frame of the animation
  72943. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72944. * @param speed is a global scalar of the time variable on the map.
  72945. */
  72946. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72947. /**
  72948. * Exports the .tilemaps file
  72949. */
  72950. saveTileMaps(): void;
  72951. /**
  72952. * Imports the .tilemaps file
  72953. * @param url of the .tilemaps file
  72954. */
  72955. loadTileMaps(url: string): void;
  72956. /**
  72957. * Release associated resources
  72958. */
  72959. dispose(): void;
  72960. }
  72961. }
  72962. declare module BABYLON {
  72963. /**
  72964. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72965. * @see https://doc.babylonjs.com/babylon101/sprites
  72966. */
  72967. export class SpritePackedManager extends SpriteManager {
  72968. /** defines the packed manager's name */
  72969. name: string;
  72970. /**
  72971. * Creates a new sprite manager from a packed sprite sheet
  72972. * @param name defines the manager's name
  72973. * @param imgUrl defines the sprite sheet url
  72974. * @param capacity defines the maximum allowed number of sprites
  72975. * @param scene defines the hosting scene
  72976. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72977. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72978. * @param samplingMode defines the smapling mode to use with spritesheet
  72979. * @param fromPacked set to true; do not alter
  72980. */
  72981. constructor(
  72982. /** defines the packed manager's name */
  72983. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72984. }
  72985. }
  72986. declare module BABYLON {
  72987. /**
  72988. * Defines the list of states available for a task inside a AssetsManager
  72989. */
  72990. export enum AssetTaskState {
  72991. /**
  72992. * Initialization
  72993. */
  72994. INIT = 0,
  72995. /**
  72996. * Running
  72997. */
  72998. RUNNING = 1,
  72999. /**
  73000. * Done
  73001. */
  73002. DONE = 2,
  73003. /**
  73004. * Error
  73005. */
  73006. ERROR = 3
  73007. }
  73008. /**
  73009. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73010. */
  73011. export abstract class AbstractAssetTask {
  73012. /**
  73013. * Task name
  73014. */ name: string;
  73015. /**
  73016. * Callback called when the task is successful
  73017. */
  73018. onSuccess: (task: any) => void;
  73019. /**
  73020. * Callback called when the task is not successful
  73021. */
  73022. onError: (task: any, message?: string, exception?: any) => void;
  73023. /**
  73024. * Creates a new AssetsManager
  73025. * @param name defines the name of the task
  73026. */
  73027. constructor(
  73028. /**
  73029. * Task name
  73030. */ name: string);
  73031. private _isCompleted;
  73032. private _taskState;
  73033. private _errorObject;
  73034. /**
  73035. * Get if the task is completed
  73036. */
  73037. get isCompleted(): boolean;
  73038. /**
  73039. * Gets the current state of the task
  73040. */
  73041. get taskState(): AssetTaskState;
  73042. /**
  73043. * Gets the current error object (if task is in error)
  73044. */
  73045. get errorObject(): {
  73046. message?: string;
  73047. exception?: any;
  73048. };
  73049. /**
  73050. * Internal only
  73051. * @hidden
  73052. */
  73053. _setErrorObject(message?: string, exception?: any): void;
  73054. /**
  73055. * Execute the current task
  73056. * @param scene defines the scene where you want your assets to be loaded
  73057. * @param onSuccess is a callback called when the task is successfully executed
  73058. * @param onError is a callback called if an error occurs
  73059. */
  73060. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73061. /**
  73062. * Execute the current task
  73063. * @param scene defines the scene where you want your assets to be loaded
  73064. * @param onSuccess is a callback called when the task is successfully executed
  73065. * @param onError is a callback called if an error occurs
  73066. */
  73067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73068. /**
  73069. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73070. * This can be used with failed tasks that have the reason for failure fixed.
  73071. */
  73072. reset(): void;
  73073. private onErrorCallback;
  73074. private onDoneCallback;
  73075. }
  73076. /**
  73077. * Define the interface used by progress events raised during assets loading
  73078. */
  73079. export interface IAssetsProgressEvent {
  73080. /**
  73081. * Defines the number of remaining tasks to process
  73082. */
  73083. remainingCount: number;
  73084. /**
  73085. * Defines the total number of tasks
  73086. */
  73087. totalCount: number;
  73088. /**
  73089. * Defines the task that was just processed
  73090. */
  73091. task: AbstractAssetTask;
  73092. }
  73093. /**
  73094. * Class used to share progress information about assets loading
  73095. */
  73096. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73097. /**
  73098. * Defines the number of remaining tasks to process
  73099. */
  73100. remainingCount: number;
  73101. /**
  73102. * Defines the total number of tasks
  73103. */
  73104. totalCount: number;
  73105. /**
  73106. * Defines the task that was just processed
  73107. */
  73108. task: AbstractAssetTask;
  73109. /**
  73110. * Creates a AssetsProgressEvent
  73111. * @param remainingCount defines the number of remaining tasks to process
  73112. * @param totalCount defines the total number of tasks
  73113. * @param task defines the task that was just processed
  73114. */
  73115. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73116. }
  73117. /**
  73118. * Define a task used by AssetsManager to load assets into a container
  73119. */
  73120. export class ContainerAssetTask extends AbstractAssetTask {
  73121. /**
  73122. * Defines the name of the task
  73123. */
  73124. name: string;
  73125. /**
  73126. * Defines the list of mesh's names you want to load
  73127. */
  73128. meshesNames: any;
  73129. /**
  73130. * Defines the root url to use as a base to load your meshes and associated resources
  73131. */
  73132. rootUrl: string;
  73133. /**
  73134. * Defines the filename or File of the scene to load from
  73135. */
  73136. sceneFilename: string | File;
  73137. /**
  73138. * Get the loaded asset container
  73139. */
  73140. loadedContainer: AssetContainer;
  73141. /**
  73142. * Gets the list of loaded meshes
  73143. */
  73144. loadedMeshes: Array<AbstractMesh>;
  73145. /**
  73146. * Gets the list of loaded particle systems
  73147. */
  73148. loadedParticleSystems: Array<IParticleSystem>;
  73149. /**
  73150. * Gets the list of loaded skeletons
  73151. */
  73152. loadedSkeletons: Array<Skeleton>;
  73153. /**
  73154. * Gets the list of loaded animation groups
  73155. */
  73156. loadedAnimationGroups: Array<AnimationGroup>;
  73157. /**
  73158. * Callback called when the task is successful
  73159. */
  73160. onSuccess: (task: ContainerAssetTask) => void;
  73161. /**
  73162. * Callback called when the task is successful
  73163. */
  73164. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73165. /**
  73166. * Creates a new ContainerAssetTask
  73167. * @param name defines the name of the task
  73168. * @param meshesNames defines the list of mesh's names you want to load
  73169. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73170. * @param sceneFilename defines the filename or File of the scene to load from
  73171. */
  73172. constructor(
  73173. /**
  73174. * Defines the name of the task
  73175. */
  73176. name: string,
  73177. /**
  73178. * Defines the list of mesh's names you want to load
  73179. */
  73180. meshesNames: any,
  73181. /**
  73182. * Defines the root url to use as a base to load your meshes and associated resources
  73183. */
  73184. rootUrl: string,
  73185. /**
  73186. * Defines the filename or File of the scene to load from
  73187. */
  73188. sceneFilename: string | File);
  73189. /**
  73190. * Execute the current task
  73191. * @param scene defines the scene where you want your assets to be loaded
  73192. * @param onSuccess is a callback called when the task is successfully executed
  73193. * @param onError is a callback called if an error occurs
  73194. */
  73195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73196. }
  73197. /**
  73198. * Define a task used by AssetsManager to load meshes
  73199. */
  73200. export class MeshAssetTask extends AbstractAssetTask {
  73201. /**
  73202. * Defines the name of the task
  73203. */
  73204. name: string;
  73205. /**
  73206. * Defines the list of mesh's names you want to load
  73207. */
  73208. meshesNames: any;
  73209. /**
  73210. * Defines the root url to use as a base to load your meshes and associated resources
  73211. */
  73212. rootUrl: string;
  73213. /**
  73214. * Defines the filename or File of the scene to load from
  73215. */
  73216. sceneFilename: string | File;
  73217. /**
  73218. * Gets the list of loaded meshes
  73219. */
  73220. loadedMeshes: Array<AbstractMesh>;
  73221. /**
  73222. * Gets the list of loaded particle systems
  73223. */
  73224. loadedParticleSystems: Array<IParticleSystem>;
  73225. /**
  73226. * Gets the list of loaded skeletons
  73227. */
  73228. loadedSkeletons: Array<Skeleton>;
  73229. /**
  73230. * Gets the list of loaded animation groups
  73231. */
  73232. loadedAnimationGroups: Array<AnimationGroup>;
  73233. /**
  73234. * Callback called when the task is successful
  73235. */
  73236. onSuccess: (task: MeshAssetTask) => void;
  73237. /**
  73238. * Callback called when the task is successful
  73239. */
  73240. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73241. /**
  73242. * Creates a new MeshAssetTask
  73243. * @param name defines the name of the task
  73244. * @param meshesNames defines the list of mesh's names you want to load
  73245. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73246. * @param sceneFilename defines the filename or File of the scene to load from
  73247. */
  73248. constructor(
  73249. /**
  73250. * Defines the name of the task
  73251. */
  73252. name: string,
  73253. /**
  73254. * Defines the list of mesh's names you want to load
  73255. */
  73256. meshesNames: any,
  73257. /**
  73258. * Defines the root url to use as a base to load your meshes and associated resources
  73259. */
  73260. rootUrl: string,
  73261. /**
  73262. * Defines the filename or File of the scene to load from
  73263. */
  73264. sceneFilename: string | File);
  73265. /**
  73266. * Execute the current task
  73267. * @param scene defines the scene where you want your assets to be loaded
  73268. * @param onSuccess is a callback called when the task is successfully executed
  73269. * @param onError is a callback called if an error occurs
  73270. */
  73271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73272. }
  73273. /**
  73274. * Define a task used by AssetsManager to load text content
  73275. */
  73276. export class TextFileAssetTask extends AbstractAssetTask {
  73277. /**
  73278. * Defines the name of the task
  73279. */
  73280. name: string;
  73281. /**
  73282. * Defines the location of the file to load
  73283. */
  73284. url: string;
  73285. /**
  73286. * Gets the loaded text string
  73287. */
  73288. text: string;
  73289. /**
  73290. * Callback called when the task is successful
  73291. */
  73292. onSuccess: (task: TextFileAssetTask) => void;
  73293. /**
  73294. * Callback called when the task is successful
  73295. */
  73296. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73297. /**
  73298. * Creates a new TextFileAssetTask object
  73299. * @param name defines the name of the task
  73300. * @param url defines the location of the file to load
  73301. */
  73302. constructor(
  73303. /**
  73304. * Defines the name of the task
  73305. */
  73306. name: string,
  73307. /**
  73308. * Defines the location of the file to load
  73309. */
  73310. url: string);
  73311. /**
  73312. * Execute the current task
  73313. * @param scene defines the scene where you want your assets to be loaded
  73314. * @param onSuccess is a callback called when the task is successfully executed
  73315. * @param onError is a callback called if an error occurs
  73316. */
  73317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73318. }
  73319. /**
  73320. * Define a task used by AssetsManager to load binary data
  73321. */
  73322. export class BinaryFileAssetTask extends AbstractAssetTask {
  73323. /**
  73324. * Defines the name of the task
  73325. */
  73326. name: string;
  73327. /**
  73328. * Defines the location of the file to load
  73329. */
  73330. url: string;
  73331. /**
  73332. * Gets the lodaded data (as an array buffer)
  73333. */
  73334. data: ArrayBuffer;
  73335. /**
  73336. * Callback called when the task is successful
  73337. */
  73338. onSuccess: (task: BinaryFileAssetTask) => void;
  73339. /**
  73340. * Callback called when the task is successful
  73341. */
  73342. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73343. /**
  73344. * Creates a new BinaryFileAssetTask object
  73345. * @param name defines the name of the new task
  73346. * @param url defines the location of the file to load
  73347. */
  73348. constructor(
  73349. /**
  73350. * Defines the name of the task
  73351. */
  73352. name: string,
  73353. /**
  73354. * Defines the location of the file to load
  73355. */
  73356. url: string);
  73357. /**
  73358. * Execute the current task
  73359. * @param scene defines the scene where you want your assets to be loaded
  73360. * @param onSuccess is a callback called when the task is successfully executed
  73361. * @param onError is a callback called if an error occurs
  73362. */
  73363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73364. }
  73365. /**
  73366. * Define a task used by AssetsManager to load images
  73367. */
  73368. export class ImageAssetTask extends AbstractAssetTask {
  73369. /**
  73370. * Defines the name of the task
  73371. */
  73372. name: string;
  73373. /**
  73374. * Defines the location of the image to load
  73375. */
  73376. url: string;
  73377. /**
  73378. * Gets the loaded images
  73379. */
  73380. image: HTMLImageElement;
  73381. /**
  73382. * Callback called when the task is successful
  73383. */
  73384. onSuccess: (task: ImageAssetTask) => void;
  73385. /**
  73386. * Callback called when the task is successful
  73387. */
  73388. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73389. /**
  73390. * Creates a new ImageAssetTask
  73391. * @param name defines the name of the task
  73392. * @param url defines the location of the image to load
  73393. */
  73394. constructor(
  73395. /**
  73396. * Defines the name of the task
  73397. */
  73398. name: string,
  73399. /**
  73400. * Defines the location of the image to load
  73401. */
  73402. url: string);
  73403. /**
  73404. * Execute the current task
  73405. * @param scene defines the scene where you want your assets to be loaded
  73406. * @param onSuccess is a callback called when the task is successfully executed
  73407. * @param onError is a callback called if an error occurs
  73408. */
  73409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73410. }
  73411. /**
  73412. * Defines the interface used by texture loading tasks
  73413. */
  73414. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73415. /**
  73416. * Gets the loaded texture
  73417. */
  73418. texture: TEX;
  73419. }
  73420. /**
  73421. * Define a task used by AssetsManager to load 2D textures
  73422. */
  73423. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73424. /**
  73425. * Defines the name of the task
  73426. */
  73427. name: string;
  73428. /**
  73429. * Defines the location of the file to load
  73430. */
  73431. url: string;
  73432. /**
  73433. * Defines if mipmap should not be generated (default is false)
  73434. */
  73435. noMipmap?: boolean | undefined;
  73436. /**
  73437. * Defines if texture must be inverted on Y axis (default is true)
  73438. */
  73439. invertY: boolean;
  73440. /**
  73441. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73442. */
  73443. samplingMode: number;
  73444. /**
  73445. * Gets the loaded texture
  73446. */
  73447. texture: Texture;
  73448. /**
  73449. * Callback called when the task is successful
  73450. */
  73451. onSuccess: (task: TextureAssetTask) => void;
  73452. /**
  73453. * Callback called when the task is successful
  73454. */
  73455. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73456. /**
  73457. * Creates a new TextureAssetTask object
  73458. * @param name defines the name of the task
  73459. * @param url defines the location of the file to load
  73460. * @param noMipmap defines if mipmap should not be generated (default is false)
  73461. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73462. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73463. */
  73464. constructor(
  73465. /**
  73466. * Defines the name of the task
  73467. */
  73468. name: string,
  73469. /**
  73470. * Defines the location of the file to load
  73471. */
  73472. url: string,
  73473. /**
  73474. * Defines if mipmap should not be generated (default is false)
  73475. */
  73476. noMipmap?: boolean | undefined,
  73477. /**
  73478. * Defines if texture must be inverted on Y axis (default is true)
  73479. */
  73480. invertY?: boolean,
  73481. /**
  73482. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73483. */
  73484. samplingMode?: number);
  73485. /**
  73486. * Execute the current task
  73487. * @param scene defines the scene where you want your assets to be loaded
  73488. * @param onSuccess is a callback called when the task is successfully executed
  73489. * @param onError is a callback called if an error occurs
  73490. */
  73491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73492. }
  73493. /**
  73494. * Define a task used by AssetsManager to load cube textures
  73495. */
  73496. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73497. /**
  73498. * Defines the name of the task
  73499. */
  73500. name: string;
  73501. /**
  73502. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73503. */
  73504. url: string;
  73505. /**
  73506. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73507. */
  73508. extensions?: string[] | undefined;
  73509. /**
  73510. * Defines if mipmaps should not be generated (default is false)
  73511. */
  73512. noMipmap?: boolean | undefined;
  73513. /**
  73514. * Defines the explicit list of files (undefined by default)
  73515. */
  73516. files?: string[] | undefined;
  73517. /**
  73518. * Gets the loaded texture
  73519. */
  73520. texture: CubeTexture;
  73521. /**
  73522. * Callback called when the task is successful
  73523. */
  73524. onSuccess: (task: CubeTextureAssetTask) => void;
  73525. /**
  73526. * Callback called when the task is successful
  73527. */
  73528. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73529. /**
  73530. * Creates a new CubeTextureAssetTask
  73531. * @param name defines the name of the task
  73532. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73533. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73534. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73535. * @param files defines the explicit list of files (undefined by default)
  73536. */
  73537. constructor(
  73538. /**
  73539. * Defines the name of the task
  73540. */
  73541. name: string,
  73542. /**
  73543. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73544. */
  73545. url: string,
  73546. /**
  73547. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73548. */
  73549. extensions?: string[] | undefined,
  73550. /**
  73551. * Defines if mipmaps should not be generated (default is false)
  73552. */
  73553. noMipmap?: boolean | undefined,
  73554. /**
  73555. * Defines the explicit list of files (undefined by default)
  73556. */
  73557. files?: string[] | undefined);
  73558. /**
  73559. * Execute the current task
  73560. * @param scene defines the scene where you want your assets to be loaded
  73561. * @param onSuccess is a callback called when the task is successfully executed
  73562. * @param onError is a callback called if an error occurs
  73563. */
  73564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73565. }
  73566. /**
  73567. * Define a task used by AssetsManager to load HDR cube textures
  73568. */
  73569. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73570. /**
  73571. * Defines the name of the task
  73572. */
  73573. name: string;
  73574. /**
  73575. * Defines the location of the file to load
  73576. */
  73577. url: string;
  73578. /**
  73579. * Defines the desired size (the more it increases the longer the generation will be)
  73580. */
  73581. size: number;
  73582. /**
  73583. * Defines if mipmaps should not be generated (default is false)
  73584. */
  73585. noMipmap: boolean;
  73586. /**
  73587. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73588. */
  73589. generateHarmonics: boolean;
  73590. /**
  73591. * 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)
  73592. */
  73593. gammaSpace: boolean;
  73594. /**
  73595. * Internal Use Only
  73596. */
  73597. reserved: boolean;
  73598. /**
  73599. * Gets the loaded texture
  73600. */
  73601. texture: HDRCubeTexture;
  73602. /**
  73603. * Callback called when the task is successful
  73604. */
  73605. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73606. /**
  73607. * Callback called when the task is successful
  73608. */
  73609. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73610. /**
  73611. * Creates a new HDRCubeTextureAssetTask object
  73612. * @param name defines the name of the task
  73613. * @param url defines the location of the file to load
  73614. * @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.
  73615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73616. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73617. * @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)
  73618. * @param reserved Internal use only
  73619. */
  73620. constructor(
  73621. /**
  73622. * Defines the name of the task
  73623. */
  73624. name: string,
  73625. /**
  73626. * Defines the location of the file to load
  73627. */
  73628. url: string,
  73629. /**
  73630. * Defines the desired size (the more it increases the longer the generation will be)
  73631. */
  73632. size: number,
  73633. /**
  73634. * Defines if mipmaps should not be generated (default is false)
  73635. */
  73636. noMipmap?: boolean,
  73637. /**
  73638. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73639. */
  73640. generateHarmonics?: boolean,
  73641. /**
  73642. * 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)
  73643. */
  73644. gammaSpace?: boolean,
  73645. /**
  73646. * Internal Use Only
  73647. */
  73648. reserved?: boolean);
  73649. /**
  73650. * Execute the current task
  73651. * @param scene defines the scene where you want your assets to be loaded
  73652. * @param onSuccess is a callback called when the task is successfully executed
  73653. * @param onError is a callback called if an error occurs
  73654. */
  73655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73656. }
  73657. /**
  73658. * Define a task used by AssetsManager to load Equirectangular cube textures
  73659. */
  73660. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73661. /**
  73662. * Defines the name of the task
  73663. */
  73664. name: string;
  73665. /**
  73666. * Defines the location of the file to load
  73667. */
  73668. url: string;
  73669. /**
  73670. * Defines the desired size (the more it increases the longer the generation will be)
  73671. */
  73672. size: number;
  73673. /**
  73674. * Defines if mipmaps should not be generated (default is false)
  73675. */
  73676. noMipmap: boolean;
  73677. /**
  73678. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73679. * but the standard material would require them in Gamma space) (default is true)
  73680. */
  73681. gammaSpace: boolean;
  73682. /**
  73683. * Gets the loaded texture
  73684. */
  73685. texture: EquiRectangularCubeTexture;
  73686. /**
  73687. * Callback called when the task is successful
  73688. */
  73689. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73690. /**
  73691. * Callback called when the task is successful
  73692. */
  73693. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73694. /**
  73695. * Creates a new EquiRectangularCubeTextureAssetTask object
  73696. * @param name defines the name of the task
  73697. * @param url defines the location of the file to load
  73698. * @param size defines the desired size (the more it increases the longer the generation will be)
  73699. * If the size is omitted this implies you are using a preprocessed cubemap.
  73700. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73701. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73702. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73703. * (default is true)
  73704. */
  73705. constructor(
  73706. /**
  73707. * Defines the name of the task
  73708. */
  73709. name: string,
  73710. /**
  73711. * Defines the location of the file to load
  73712. */
  73713. url: string,
  73714. /**
  73715. * Defines the desired size (the more it increases the longer the generation will be)
  73716. */
  73717. size: number,
  73718. /**
  73719. * Defines if mipmaps should not be generated (default is false)
  73720. */
  73721. noMipmap?: boolean,
  73722. /**
  73723. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73724. * but the standard material would require them in Gamma space) (default is true)
  73725. */
  73726. gammaSpace?: boolean);
  73727. /**
  73728. * Execute the current task
  73729. * @param scene defines the scene where you want your assets to be loaded
  73730. * @param onSuccess is a callback called when the task is successfully executed
  73731. * @param onError is a callback called if an error occurs
  73732. */
  73733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73734. }
  73735. /**
  73736. * This class can be used to easily import assets into a scene
  73737. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73738. */
  73739. export class AssetsManager {
  73740. private _scene;
  73741. private _isLoading;
  73742. protected _tasks: AbstractAssetTask[];
  73743. protected _waitingTasksCount: number;
  73744. protected _totalTasksCount: number;
  73745. /**
  73746. * Callback called when all tasks are processed
  73747. */
  73748. onFinish: (tasks: AbstractAssetTask[]) => void;
  73749. /**
  73750. * Callback called when a task is successful
  73751. */
  73752. onTaskSuccess: (task: AbstractAssetTask) => void;
  73753. /**
  73754. * Callback called when a task had an error
  73755. */
  73756. onTaskError: (task: AbstractAssetTask) => void;
  73757. /**
  73758. * Callback called when a task is done (whatever the result is)
  73759. */
  73760. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73761. /**
  73762. * Observable called when all tasks are processed
  73763. */
  73764. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73765. /**
  73766. * Observable called when a task had an error
  73767. */
  73768. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73769. /**
  73770. * Observable called when all tasks were executed
  73771. */
  73772. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73773. /**
  73774. * Observable called when a task is done (whatever the result is)
  73775. */
  73776. onProgressObservable: Observable<IAssetsProgressEvent>;
  73777. /**
  73778. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73779. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73780. */
  73781. useDefaultLoadingScreen: boolean;
  73782. /**
  73783. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73784. * when all assets have been downloaded.
  73785. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73786. */
  73787. autoHideLoadingUI: boolean;
  73788. /**
  73789. * Creates a new AssetsManager
  73790. * @param scene defines the scene to work on
  73791. */
  73792. constructor(scene: Scene);
  73793. /**
  73794. * Add a ContainerAssetTask to the list of active tasks
  73795. * @param taskName defines the name of the new task
  73796. * @param meshesNames defines the name of meshes to load
  73797. * @param rootUrl defines the root url to use to locate files
  73798. * @param sceneFilename defines the filename of the scene file
  73799. * @returns a new ContainerAssetTask object
  73800. */
  73801. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73802. /**
  73803. * Add a MeshAssetTask to the list of active tasks
  73804. * @param taskName defines the name of the new task
  73805. * @param meshesNames defines the name of meshes to load
  73806. * @param rootUrl defines the root url to use to locate files
  73807. * @param sceneFilename defines the filename of the scene file
  73808. * @returns a new MeshAssetTask object
  73809. */
  73810. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73811. /**
  73812. * Add a TextFileAssetTask to the list of active tasks
  73813. * @param taskName defines the name of the new task
  73814. * @param url defines the url of the file to load
  73815. * @returns a new TextFileAssetTask object
  73816. */
  73817. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73818. /**
  73819. * Add a BinaryFileAssetTask to the list of active tasks
  73820. * @param taskName defines the name of the new task
  73821. * @param url defines the url of the file to load
  73822. * @returns a new BinaryFileAssetTask object
  73823. */
  73824. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73825. /**
  73826. * Add a ImageAssetTask to the list of active tasks
  73827. * @param taskName defines the name of the new task
  73828. * @param url defines the url of the file to load
  73829. * @returns a new ImageAssetTask object
  73830. */
  73831. addImageTask(taskName: string, url: string): ImageAssetTask;
  73832. /**
  73833. * Add a TextureAssetTask to the list of active tasks
  73834. * @param taskName defines the name of the new task
  73835. * @param url defines the url of the file to load
  73836. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73837. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73838. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73839. * @returns a new TextureAssetTask object
  73840. */
  73841. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73842. /**
  73843. * Add a CubeTextureAssetTask to the list of active tasks
  73844. * @param taskName defines the name of the new task
  73845. * @param url defines the url of the file to load
  73846. * @param extensions defines the extension to use to load the cube map (can be null)
  73847. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73848. * @param files defines the list of files to load (can be null)
  73849. * @returns a new CubeTextureAssetTask object
  73850. */
  73851. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73852. /**
  73853. *
  73854. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73855. * @param taskName defines the name of the new task
  73856. * @param url defines the url of the file to load
  73857. * @param size defines the size you want for the cubemap (can be null)
  73858. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73859. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73860. * @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)
  73861. * @param reserved Internal use only
  73862. * @returns a new HDRCubeTextureAssetTask object
  73863. */
  73864. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73865. /**
  73866. *
  73867. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73868. * @param taskName defines the name of the new task
  73869. * @param url defines the url of the file to load
  73870. * @param size defines the size you want for the cubemap (can be null)
  73871. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73872. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73873. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73874. * @returns a new EquiRectangularCubeTextureAssetTask object
  73875. */
  73876. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73877. /**
  73878. * Remove a task from the assets manager.
  73879. * @param task the task to remove
  73880. */
  73881. removeTask(task: AbstractAssetTask): void;
  73882. private _decreaseWaitingTasksCount;
  73883. private _runTask;
  73884. /**
  73885. * Reset the AssetsManager and remove all tasks
  73886. * @return the current instance of the AssetsManager
  73887. */
  73888. reset(): AssetsManager;
  73889. /**
  73890. * Start the loading process
  73891. * @return the current instance of the AssetsManager
  73892. */
  73893. load(): AssetsManager;
  73894. /**
  73895. * Start the loading process as an async operation
  73896. * @return a promise returning the list of failed tasks
  73897. */
  73898. loadAsync(): Promise<void>;
  73899. }
  73900. }
  73901. declare module BABYLON {
  73902. /**
  73903. * Wrapper class for promise with external resolve and reject.
  73904. */
  73905. export class Deferred<T> {
  73906. /**
  73907. * The promise associated with this deferred object.
  73908. */
  73909. readonly promise: Promise<T>;
  73910. private _resolve;
  73911. private _reject;
  73912. /**
  73913. * The resolve method of the promise associated with this deferred object.
  73914. */
  73915. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73916. /**
  73917. * The reject method of the promise associated with this deferred object.
  73918. */
  73919. get reject(): (reason?: any) => void;
  73920. /**
  73921. * Constructor for this deferred object.
  73922. */
  73923. constructor();
  73924. }
  73925. }
  73926. declare module BABYLON {
  73927. /**
  73928. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73929. */
  73930. export class MeshExploder {
  73931. private _centerMesh;
  73932. private _meshes;
  73933. private _meshesOrigins;
  73934. private _toCenterVectors;
  73935. private _scaledDirection;
  73936. private _newPosition;
  73937. private _centerPosition;
  73938. /**
  73939. * Explodes meshes from a center mesh.
  73940. * @param meshes The meshes to explode.
  73941. * @param centerMesh The mesh to be center of explosion.
  73942. */
  73943. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73944. private _setCenterMesh;
  73945. /**
  73946. * Get class name
  73947. * @returns "MeshExploder"
  73948. */
  73949. getClassName(): string;
  73950. /**
  73951. * "Exploded meshes"
  73952. * @returns Array of meshes with the centerMesh at index 0.
  73953. */
  73954. getMeshes(): Array<Mesh>;
  73955. /**
  73956. * Explodes meshes giving a specific direction
  73957. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73958. */
  73959. explode(direction?: number): void;
  73960. }
  73961. }
  73962. declare module BABYLON {
  73963. /**
  73964. * Class used to help managing file picking and drag'n'drop
  73965. */
  73966. export class FilesInput {
  73967. /**
  73968. * List of files ready to be loaded
  73969. */
  73970. static get FilesToLoad(): {
  73971. [key: string]: File;
  73972. };
  73973. /**
  73974. * Callback called when a file is processed
  73975. */
  73976. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73977. private _engine;
  73978. private _currentScene;
  73979. private _sceneLoadedCallback;
  73980. private _progressCallback;
  73981. private _additionalRenderLoopLogicCallback;
  73982. private _textureLoadingCallback;
  73983. private _startingProcessingFilesCallback;
  73984. private _onReloadCallback;
  73985. private _errorCallback;
  73986. private _elementToMonitor;
  73987. private _sceneFileToLoad;
  73988. private _filesToLoad;
  73989. /**
  73990. * Creates a new FilesInput
  73991. * @param engine defines the rendering engine
  73992. * @param scene defines the hosting scene
  73993. * @param sceneLoadedCallback callback called when scene is loaded
  73994. * @param progressCallback callback called to track progress
  73995. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73996. * @param textureLoadingCallback callback called when a texture is loading
  73997. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73998. * @param onReloadCallback callback called when a reload is requested
  73999. * @param errorCallback callback call if an error occurs
  74000. */
  74001. 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>);
  74002. private _dragEnterHandler;
  74003. private _dragOverHandler;
  74004. private _dropHandler;
  74005. /**
  74006. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74007. * @param elementToMonitor defines the DOM element to track
  74008. */
  74009. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74010. /** Gets the current list of files to load */
  74011. get filesToLoad(): File[];
  74012. /**
  74013. * Release all associated resources
  74014. */
  74015. dispose(): void;
  74016. private renderFunction;
  74017. private drag;
  74018. private drop;
  74019. private _traverseFolder;
  74020. private _processFiles;
  74021. /**
  74022. * Load files from a drop event
  74023. * @param event defines the drop event to use as source
  74024. */
  74025. loadFiles(event: any): void;
  74026. private _processReload;
  74027. /**
  74028. * Reload the current scene from the loaded files
  74029. */
  74030. reload(): void;
  74031. }
  74032. }
  74033. declare module BABYLON {
  74034. /**
  74035. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74036. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74037. */
  74038. export class SceneOptimization {
  74039. /**
  74040. * Defines the priority of this optimization (0 by default which means first in the list)
  74041. */
  74042. priority: number;
  74043. /**
  74044. * Gets a string describing the action executed by the current optimization
  74045. * @returns description string
  74046. */
  74047. getDescription(): string;
  74048. /**
  74049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74050. * @param scene defines the current scene where to apply this optimization
  74051. * @param optimizer defines the current optimizer
  74052. * @returns true if everything that can be done was applied
  74053. */
  74054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74055. /**
  74056. * Creates the SceneOptimization object
  74057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74058. * @param desc defines the description associated with the optimization
  74059. */
  74060. constructor(
  74061. /**
  74062. * Defines the priority of this optimization (0 by default which means first in the list)
  74063. */
  74064. priority?: number);
  74065. }
  74066. /**
  74067. * Defines an optimization used to reduce the size of render target textures
  74068. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74069. */
  74070. export class TextureOptimization extends SceneOptimization {
  74071. /**
  74072. * Defines the priority of this optimization (0 by default which means first in the list)
  74073. */
  74074. priority: number;
  74075. /**
  74076. * 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
  74077. */
  74078. maximumSize: number;
  74079. /**
  74080. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74081. */
  74082. step: number;
  74083. /**
  74084. * Gets a string describing the action executed by the current optimization
  74085. * @returns description string
  74086. */
  74087. getDescription(): string;
  74088. /**
  74089. * Creates the TextureOptimization object
  74090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74091. * @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
  74092. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74093. */
  74094. constructor(
  74095. /**
  74096. * Defines the priority of this optimization (0 by default which means first in the list)
  74097. */
  74098. priority?: number,
  74099. /**
  74100. * 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
  74101. */
  74102. maximumSize?: number,
  74103. /**
  74104. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74105. */
  74106. step?: number);
  74107. /**
  74108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74109. * @param scene defines the current scene where to apply this optimization
  74110. * @param optimizer defines the current optimizer
  74111. * @returns true if everything that can be done was applied
  74112. */
  74113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74114. }
  74115. /**
  74116. * Defines an optimization used to increase or decrease the rendering resolution
  74117. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74118. */
  74119. export class HardwareScalingOptimization extends SceneOptimization {
  74120. /**
  74121. * Defines the priority of this optimization (0 by default which means first in the list)
  74122. */
  74123. priority: number;
  74124. /**
  74125. * Defines the maximum scale to use (2 by default)
  74126. */
  74127. maximumScale: number;
  74128. /**
  74129. * Defines the step to use between two passes (0.5 by default)
  74130. */
  74131. step: number;
  74132. private _currentScale;
  74133. private _directionOffset;
  74134. /**
  74135. * Gets a string describing the action executed by the current optimization
  74136. * @return description string
  74137. */
  74138. getDescription(): string;
  74139. /**
  74140. * Creates the HardwareScalingOptimization object
  74141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74142. * @param maximumScale defines the maximum scale to use (2 by default)
  74143. * @param step defines the step to use between two passes (0.5 by default)
  74144. */
  74145. constructor(
  74146. /**
  74147. * Defines the priority of this optimization (0 by default which means first in the list)
  74148. */
  74149. priority?: number,
  74150. /**
  74151. * Defines the maximum scale to use (2 by default)
  74152. */
  74153. maximumScale?: number,
  74154. /**
  74155. * Defines the step to use between two passes (0.5 by default)
  74156. */
  74157. step?: number);
  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 remove shadows
  74168. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74169. */
  74170. export class ShadowsOptimization 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 post-processes off
  74186. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74187. */
  74188. export class PostProcessesOptimization 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 used to turn lens flares off
  74204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74205. */
  74206. export class LensFlaresOptimization extends SceneOptimization {
  74207. /**
  74208. * Gets a string describing the action executed by the current optimization
  74209. * @return description string
  74210. */
  74211. getDescription(): string;
  74212. /**
  74213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74214. * @param scene defines the current scene where to apply this optimization
  74215. * @param optimizer defines the current optimizer
  74216. * @returns true if everything that can be done was applied
  74217. */
  74218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74219. }
  74220. /**
  74221. * Defines an optimization based on user defined callback.
  74222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74223. */
  74224. export class CustomOptimization extends SceneOptimization {
  74225. /**
  74226. * Callback called to apply the custom optimization.
  74227. */
  74228. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74229. /**
  74230. * Callback called to get custom description
  74231. */
  74232. onGetDescription: () => string;
  74233. /**
  74234. * Gets a string describing the action executed by the current optimization
  74235. * @returns 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 particles off
  74248. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74249. */
  74250. export class ParticlesOptimization 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 turn render targets off
  74266. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74267. */
  74268. export class RenderTargetsOptimization extends SceneOptimization {
  74269. /**
  74270. * Gets a string describing the action executed by the current optimization
  74271. * @return description string
  74272. */
  74273. getDescription(): string;
  74274. /**
  74275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74276. * @param scene defines the current scene where to apply this optimization
  74277. * @param optimizer defines the current optimizer
  74278. * @returns true if everything that can be done was applied
  74279. */
  74280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74281. }
  74282. /**
  74283. * Defines an optimization used to merge meshes with compatible materials
  74284. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74285. */
  74286. export class MergeMeshesOptimization extends SceneOptimization {
  74287. private static _UpdateSelectionTree;
  74288. /**
  74289. * Gets or sets a boolean which defines if optimization octree has to be updated
  74290. */
  74291. static get UpdateSelectionTree(): boolean;
  74292. /**
  74293. * Gets or sets a boolean which defines if optimization octree has to be updated
  74294. */
  74295. static set UpdateSelectionTree(value: boolean);
  74296. /**
  74297. * Gets a string describing the action executed by the current optimization
  74298. * @return description string
  74299. */
  74300. getDescription(): string;
  74301. private _canBeMerged;
  74302. /**
  74303. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74304. * @param scene defines the current scene where to apply this optimization
  74305. * @param optimizer defines the current optimizer
  74306. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74307. * @returns true if everything that can be done was applied
  74308. */
  74309. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74310. }
  74311. /**
  74312. * Defines a list of options used by SceneOptimizer
  74313. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74314. */
  74315. export class SceneOptimizerOptions {
  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. * Gets the list of optimizations to apply
  74326. */
  74327. optimizations: SceneOptimization[];
  74328. /**
  74329. * Creates a new list of options used by SceneOptimizer
  74330. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74331. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74332. */
  74333. constructor(
  74334. /**
  74335. * Defines the target frame rate to reach (60 by default)
  74336. */
  74337. targetFrameRate?: number,
  74338. /**
  74339. * Defines the interval between two checkes (2000ms by default)
  74340. */
  74341. trackerDuration?: number);
  74342. /**
  74343. * Add a new optimization
  74344. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74345. * @returns the current SceneOptimizerOptions
  74346. */
  74347. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74348. /**
  74349. * Add a new custom optimization
  74350. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74351. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74352. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74353. * @returns the current SceneOptimizerOptions
  74354. */
  74355. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74356. /**
  74357. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74358. * @param targetFrameRate defines the target frame rate (60 by default)
  74359. * @returns a SceneOptimizerOptions object
  74360. */
  74361. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74362. /**
  74363. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74364. * @param targetFrameRate defines the target frame rate (60 by default)
  74365. * @returns a SceneOptimizerOptions object
  74366. */
  74367. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74368. /**
  74369. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74370. * @param targetFrameRate defines the target frame rate (60 by default)
  74371. * @returns a SceneOptimizerOptions object
  74372. */
  74373. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74374. }
  74375. /**
  74376. * Class used to run optimizations in order to reach a target frame rate
  74377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74378. */
  74379. export class SceneOptimizer implements IDisposable {
  74380. private _isRunning;
  74381. private _options;
  74382. private _scene;
  74383. private _currentPriorityLevel;
  74384. private _targetFrameRate;
  74385. private _trackerDuration;
  74386. private _currentFrameRate;
  74387. private _sceneDisposeObserver;
  74388. private _improvementMode;
  74389. /**
  74390. * Defines an observable called when the optimizer reaches the target frame rate
  74391. */
  74392. onSuccessObservable: Observable<SceneOptimizer>;
  74393. /**
  74394. * Defines an observable called when the optimizer enables an optimization
  74395. */
  74396. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74397. /**
  74398. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74399. */
  74400. onFailureObservable: Observable<SceneOptimizer>;
  74401. /**
  74402. * Gets a boolean indicating if the optimizer is in improvement mode
  74403. */
  74404. get isInImprovementMode(): boolean;
  74405. /**
  74406. * Gets the current priority level (0 at start)
  74407. */
  74408. get currentPriorityLevel(): number;
  74409. /**
  74410. * Gets the current frame rate checked by the SceneOptimizer
  74411. */
  74412. get currentFrameRate(): number;
  74413. /**
  74414. * Gets or sets the current target frame rate (60 by default)
  74415. */
  74416. get targetFrameRate(): number;
  74417. /**
  74418. * Gets or sets the current target frame rate (60 by default)
  74419. */
  74420. set targetFrameRate(value: number);
  74421. /**
  74422. * Gets or sets the current interval between two checks (every 2000ms by default)
  74423. */
  74424. get trackerDuration(): number;
  74425. /**
  74426. * Gets or sets the current interval between two checks (every 2000ms by default)
  74427. */
  74428. set trackerDuration(value: number);
  74429. /**
  74430. * Gets the list of active optimizations
  74431. */
  74432. get optimizations(): SceneOptimization[];
  74433. /**
  74434. * Creates a new SceneOptimizer
  74435. * @param scene defines the scene to work on
  74436. * @param options defines the options to use with the SceneOptimizer
  74437. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74438. * @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)
  74439. */
  74440. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74441. /**
  74442. * Stops the current optimizer
  74443. */
  74444. stop(): void;
  74445. /**
  74446. * Reset the optimizer to initial step (current priority level = 0)
  74447. */
  74448. reset(): void;
  74449. /**
  74450. * Start the optimizer. By default it will try to reach a specific framerate
  74451. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74452. */
  74453. start(): void;
  74454. private _checkCurrentState;
  74455. /**
  74456. * Release all resources
  74457. */
  74458. dispose(): void;
  74459. /**
  74460. * Helper function to create a SceneOptimizer with one single line of code
  74461. * @param scene defines the scene to work on
  74462. * @param options defines the options to use with the SceneOptimizer
  74463. * @param onSuccess defines a callback to call on success
  74464. * @param onFailure defines a callback to call on failure
  74465. * @returns the new SceneOptimizer object
  74466. */
  74467. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74468. }
  74469. }
  74470. declare module BABYLON {
  74471. /**
  74472. * Class used to serialize a scene into a string
  74473. */
  74474. export class SceneSerializer {
  74475. /**
  74476. * Clear cache used by a previous serialization
  74477. */
  74478. static ClearCache(): void;
  74479. /**
  74480. * Serialize a scene into a JSON compatible object
  74481. * @param scene defines the scene to serialize
  74482. * @returns a JSON compatible object
  74483. */
  74484. static Serialize(scene: Scene): any;
  74485. /**
  74486. * Serialize a mesh into a JSON compatible object
  74487. * @param toSerialize defines the mesh to serialize
  74488. * @param withParents defines if parents must be serialized as well
  74489. * @param withChildren defines if children must be serialized as well
  74490. * @returns a JSON compatible object
  74491. */
  74492. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74493. }
  74494. }
  74495. declare module BABYLON {
  74496. /**
  74497. * Class used to host texture specific utilities
  74498. */
  74499. export class TextureTools {
  74500. /**
  74501. * Uses the GPU to create a copy texture rescaled at a given size
  74502. * @param texture Texture to copy from
  74503. * @param width defines the desired width
  74504. * @param height defines the desired height
  74505. * @param useBilinearMode defines if bilinear mode has to be used
  74506. * @return the generated texture
  74507. */
  74508. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74509. }
  74510. }
  74511. declare module BABYLON {
  74512. /**
  74513. * This represents the different options available for the video capture.
  74514. */
  74515. export interface VideoRecorderOptions {
  74516. /** Defines the mime type of the video. */
  74517. mimeType: string;
  74518. /** Defines the FPS the video should be recorded at. */
  74519. fps: number;
  74520. /** Defines the chunk size for the recording data. */
  74521. recordChunckSize: number;
  74522. /** The audio tracks to attach to the recording. */
  74523. audioTracks?: MediaStreamTrack[];
  74524. }
  74525. /**
  74526. * This can help with recording videos from BabylonJS.
  74527. * This is based on the available WebRTC functionalities of the browser.
  74528. *
  74529. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74530. */
  74531. export class VideoRecorder {
  74532. private static readonly _defaultOptions;
  74533. /**
  74534. * Returns whether or not the VideoRecorder is available in your browser.
  74535. * @param engine Defines the Babylon Engine.
  74536. * @returns true if supported otherwise false.
  74537. */
  74538. static IsSupported(engine: Engine): boolean;
  74539. private readonly _options;
  74540. private _canvas;
  74541. private _mediaRecorder;
  74542. private _recordedChunks;
  74543. private _fileName;
  74544. private _resolve;
  74545. private _reject;
  74546. /**
  74547. * True when a recording is already in progress.
  74548. */
  74549. get isRecording(): boolean;
  74550. /**
  74551. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74552. * @param engine Defines the BabylonJS Engine you wish to record.
  74553. * @param options Defines options that can be used to customize the capture.
  74554. */
  74555. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74556. /**
  74557. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74558. */
  74559. stopRecording(): void;
  74560. /**
  74561. * Starts recording the canvas for a max duration specified in parameters.
  74562. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74563. * If null no automatic download will start and you can rely on the promise to get the data back.
  74564. * @param maxDuration Defines the maximum recording time in seconds.
  74565. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74566. * @return A promise callback at the end of the recording with the video data in Blob.
  74567. */
  74568. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74569. /**
  74570. * Releases internal resources used during the recording.
  74571. */
  74572. dispose(): void;
  74573. private _handleDataAvailable;
  74574. private _handleError;
  74575. private _handleStop;
  74576. }
  74577. }
  74578. declare module BABYLON {
  74579. /**
  74580. * Class containing a set of static utilities functions for screenshots
  74581. */
  74582. export class ScreenshotTools {
  74583. /**
  74584. * Captures a screenshot of the current rendering
  74585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74586. * @param engine defines the rendering engine
  74587. * @param camera defines the source camera
  74588. * @param size This parameter can be set to a single number or to an object with the
  74589. * following (optional) properties: precision, width, height. If a single number is passed,
  74590. * it will be used for both width and height. If an object is passed, the screenshot size
  74591. * will be derived from the parameters. The precision property is a multiplier allowing
  74592. * rendering at a higher or lower resolution
  74593. * @param successCallback defines the callback receives a single parameter which contains the
  74594. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74595. * src parameter of an <img> to display it
  74596. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74597. * Check your browser for supported MIME types
  74598. */
  74599. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74600. /**
  74601. * Captures a screenshot of the current rendering
  74602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74603. * @param engine defines the rendering engine
  74604. * @param camera defines the source camera
  74605. * @param size This parameter can be set to a single number or to an object with the
  74606. * following (optional) properties: precision, width, height. If a single number is passed,
  74607. * it will be used for both width and height. If an object is passed, the screenshot size
  74608. * will be derived from the parameters. The precision property is a multiplier allowing
  74609. * rendering at a higher or lower resolution
  74610. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74611. * Check your browser for supported MIME types
  74612. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74613. * to the src parameter of an <img> to display it
  74614. */
  74615. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74616. /**
  74617. * Generates an image screenshot from the specified camera.
  74618. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74619. * @param engine The engine to use for rendering
  74620. * @param camera The camera to use for rendering
  74621. * @param size This parameter can be set to a single number or to an object with the
  74622. * following (optional) properties: precision, width, height. If a single number is passed,
  74623. * it will be used for both width and height. If an object is passed, the screenshot size
  74624. * will be derived from the parameters. The precision property is a multiplier allowing
  74625. * rendering at a higher or lower resolution
  74626. * @param successCallback The callback receives a single parameter which contains the
  74627. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74628. * src parameter of an <img> to display it
  74629. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74630. * Check your browser for supported MIME types
  74631. * @param samples Texture samples (default: 1)
  74632. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74633. * @param fileName A name for for the downloaded file.
  74634. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74635. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74636. */
  74637. 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;
  74638. /**
  74639. * Generates an image screenshot from the specified camera.
  74640. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74641. * @param engine The engine to use for rendering
  74642. * @param camera The camera to use for rendering
  74643. * @param size This parameter can be set to a single number or to an object with the
  74644. * following (optional) properties: precision, width, height. If a single number is passed,
  74645. * it will be used for both width and height. If an object is passed, the screenshot size
  74646. * will be derived from the parameters. The precision property is a multiplier allowing
  74647. * rendering at a higher or lower resolution
  74648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74649. * Check your browser for supported MIME types
  74650. * @param samples Texture samples (default: 1)
  74651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74652. * @param fileName A name for for the downloaded file.
  74653. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74655. * to the src parameter of an <img> to display it
  74656. */
  74657. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74658. /**
  74659. * Gets height and width for screenshot size
  74660. * @private
  74661. */
  74662. private static _getScreenshotSize;
  74663. }
  74664. }
  74665. declare module BABYLON {
  74666. /**
  74667. * Interface for a data buffer
  74668. */
  74669. export interface IDataBuffer {
  74670. /**
  74671. * Reads bytes from the data buffer.
  74672. * @param byteOffset The byte offset to read
  74673. * @param byteLength The byte length to read
  74674. * @returns A promise that resolves when the bytes are read
  74675. */
  74676. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74677. /**
  74678. * The byte length of the buffer.
  74679. */
  74680. readonly byteLength: number;
  74681. }
  74682. /**
  74683. * Utility class for reading from a data buffer
  74684. */
  74685. export class DataReader {
  74686. /**
  74687. * The data buffer associated with this data reader.
  74688. */
  74689. readonly buffer: IDataBuffer;
  74690. /**
  74691. * The current byte offset from the beginning of the data buffer.
  74692. */
  74693. byteOffset: number;
  74694. private _dataView;
  74695. private _dataByteOffset;
  74696. /**
  74697. * Constructor
  74698. * @param buffer The buffer to read
  74699. */
  74700. constructor(buffer: IDataBuffer);
  74701. /**
  74702. * Loads the given byte length.
  74703. * @param byteLength The byte length to load
  74704. * @returns A promise that resolves when the load is complete
  74705. */
  74706. loadAsync(byteLength: number): Promise<void>;
  74707. /**
  74708. * Read a unsigned 32-bit integer from the currently loaded data range.
  74709. * @returns The 32-bit integer read
  74710. */
  74711. readUint32(): number;
  74712. /**
  74713. * Read a byte array from the currently loaded data range.
  74714. * @param byteLength The byte length to read
  74715. * @returns The byte array read
  74716. */
  74717. readUint8Array(byteLength: number): Uint8Array;
  74718. /**
  74719. * Read a string from the currently loaded data range.
  74720. * @param byteLength The byte length to read
  74721. * @returns The string read
  74722. */
  74723. readString(byteLength: number): string;
  74724. /**
  74725. * Skips the given byte length the currently loaded data range.
  74726. * @param byteLength The byte length to skip
  74727. */
  74728. skipBytes(byteLength: number): void;
  74729. }
  74730. }
  74731. declare module BABYLON {
  74732. /**
  74733. * Class for storing data to local storage if available or in-memory storage otherwise
  74734. */
  74735. export class DataStorage {
  74736. private static _Storage;
  74737. private static _GetStorage;
  74738. /**
  74739. * Reads a string from the data storage
  74740. * @param key The key to read
  74741. * @param defaultValue The value if the key doesn't exist
  74742. * @returns The string value
  74743. */
  74744. static ReadString(key: string, defaultValue: string): string;
  74745. /**
  74746. * Writes a string to the data storage
  74747. * @param key The key to write
  74748. * @param value The value to write
  74749. */
  74750. static WriteString(key: string, value: string): void;
  74751. /**
  74752. * Reads a boolean from the data storage
  74753. * @param key The key to read
  74754. * @param defaultValue The value if the key doesn't exist
  74755. * @returns The boolean value
  74756. */
  74757. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74758. /**
  74759. * Writes a boolean to the data storage
  74760. * @param key The key to write
  74761. * @param value The value to write
  74762. */
  74763. static WriteBoolean(key: string, value: boolean): void;
  74764. /**
  74765. * Reads a number from the data storage
  74766. * @param key The key to read
  74767. * @param defaultValue The value if the key doesn't exist
  74768. * @returns The number value
  74769. */
  74770. static ReadNumber(key: string, defaultValue: number): number;
  74771. /**
  74772. * Writes a number to the data storage
  74773. * @param key The key to write
  74774. * @param value The value to write
  74775. */
  74776. static WriteNumber(key: string, value: number): void;
  74777. }
  74778. }
  74779. declare module BABYLON {
  74780. /**
  74781. * Class used to record delta files between 2 scene states
  74782. */
  74783. export class SceneRecorder {
  74784. private _trackedScene;
  74785. private _savedJSON;
  74786. /**
  74787. * Track a given scene. This means the current scene state will be considered the original state
  74788. * @param scene defines the scene to track
  74789. */
  74790. track(scene: Scene): void;
  74791. /**
  74792. * Get the delta between current state and original state
  74793. * @returns a string containing the delta
  74794. */
  74795. getDelta(): any;
  74796. private _compareArray;
  74797. private _compareObjects;
  74798. private _compareCollections;
  74799. private static GetShadowGeneratorById;
  74800. /**
  74801. * Apply a given delta to a given scene
  74802. * @param deltaJSON defines the JSON containing the delta
  74803. * @param scene defines the scene to apply the delta to
  74804. */
  74805. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74806. private static _ApplyPropertiesToEntity;
  74807. private static _ApplyDeltaForEntity;
  74808. }
  74809. }
  74810. declare module BABYLON {
  74811. /**
  74812. * A 3D trajectory consisting of an order list of vectors describing a
  74813. * path of motion through 3D space.
  74814. */
  74815. export class Trajectory {
  74816. private _points;
  74817. private readonly _segmentLength;
  74818. /**
  74819. * Serialize to JSON.
  74820. * @returns serialized JSON string
  74821. */
  74822. serialize(): string;
  74823. /**
  74824. * Deserialize from JSON.
  74825. * @param json serialized JSON string
  74826. * @returns deserialized Trajectory
  74827. */
  74828. static Deserialize(json: string): Trajectory;
  74829. /**
  74830. * Create a new empty Trajectory.
  74831. * @param segmentLength radius of discretization for Trajectory points
  74832. */
  74833. constructor(segmentLength?: number);
  74834. /**
  74835. * Get the length of the Trajectory.
  74836. * @returns length of the Trajectory
  74837. */
  74838. getLength(): number;
  74839. /**
  74840. * Append a new point to the Trajectory.
  74841. * NOTE: This implementation has many allocations.
  74842. * @param point point to append to the Trajectory
  74843. */
  74844. add(point: DeepImmutable<Vector3>): void;
  74845. /**
  74846. * Create a new Trajectory with a segment length chosen to make it
  74847. * probable that the new Trajectory will have a specified number of
  74848. * segments. This operation is imprecise.
  74849. * @param targetResolution number of segments desired
  74850. * @returns new Trajectory with approximately the requested number of segments
  74851. */
  74852. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74853. /**
  74854. * Convert Trajectory segments into tokenized representation. This
  74855. * representation is an array of numbers where each nth number is the
  74856. * index of the token which is most similar to the nth segment of the
  74857. * Trajectory.
  74858. * @param tokens list of vectors which serve as discrete tokens
  74859. * @returns list of indices of most similar token per segment
  74860. */
  74861. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74862. private static _forwardDir;
  74863. private static _inverseFromVec;
  74864. private static _upDir;
  74865. private static _fromToVec;
  74866. private static _lookMatrix;
  74867. /**
  74868. * Transform the rotation (i.e., direction) of a segment to isolate
  74869. * the relative transformation represented by the segment. This operation
  74870. * may or may not succeed due to singularities in the equations that define
  74871. * motion relativity in this context.
  74872. * @param priorVec the origin of the prior segment
  74873. * @param fromVec the origin of the current segment
  74874. * @param toVec the destination of the current segment
  74875. * @param result reference to output variable
  74876. * @returns whether or not transformation was successful
  74877. */
  74878. private static _transformSegmentDirToRef;
  74879. private static _bestMatch;
  74880. private static _score;
  74881. private static _bestScore;
  74882. /**
  74883. * Determine which token vector is most similar to the
  74884. * segment vector.
  74885. * @param segment segment vector
  74886. * @param tokens token vector list
  74887. * @returns index of the most similar token to the segment
  74888. */
  74889. private static _tokenizeSegment;
  74890. }
  74891. /**
  74892. * Class representing a set of known, named trajectories to which Trajectories can be
  74893. * added and using which Trajectories can be recognized.
  74894. */
  74895. export class TrajectoryClassifier {
  74896. private _maximumAllowableMatchCost;
  74897. private _vector3Alphabet;
  74898. private _levenshteinAlphabet;
  74899. private _nameToDescribedTrajectory;
  74900. /**
  74901. * Serialize to JSON.
  74902. * @returns JSON serialization
  74903. */
  74904. serialize(): string;
  74905. /**
  74906. * Deserialize from JSON.
  74907. * @param json JSON serialization
  74908. * @returns deserialized TrajectorySet
  74909. */
  74910. static Deserialize(json: string): TrajectoryClassifier;
  74911. /**
  74912. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74913. * VERY naive, need to be generating these things from known
  74914. * sets. Better version later, probably eliminating this one.
  74915. * @returns auto-generated TrajectorySet
  74916. */
  74917. static Generate(): TrajectoryClassifier;
  74918. private constructor();
  74919. /**
  74920. * Add a new Trajectory to the set with a given name.
  74921. * @param trajectory new Trajectory to be added
  74922. * @param classification name to which to add the Trajectory
  74923. */
  74924. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74925. /**
  74926. * Remove a known named trajectory and all Trajectories associated with it.
  74927. * @param classification name to remove
  74928. * @returns whether anything was removed
  74929. */
  74930. deleteClassification(classification: string): boolean;
  74931. /**
  74932. * Attempt to recognize a Trajectory from among all the classifications
  74933. * already known to the classifier.
  74934. * @param trajectory Trajectory to be recognized
  74935. * @returns classification of Trajectory if recognized, null otherwise
  74936. */
  74937. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74938. }
  74939. }
  74940. declare module BABYLON {
  74941. /**
  74942. * An interface for all Hit test features
  74943. */
  74944. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74945. /**
  74946. * Triggered when new babylon (transformed) hit test results are available
  74947. */
  74948. onHitTestResultObservable: Observable<T[]>;
  74949. }
  74950. /**
  74951. * Options used for hit testing
  74952. */
  74953. export interface IWebXRLegacyHitTestOptions {
  74954. /**
  74955. * Only test when user interacted with the scene. Default - hit test every frame
  74956. */
  74957. testOnPointerDownOnly?: boolean;
  74958. /**
  74959. * The node to use to transform the local results to world coordinates
  74960. */
  74961. worldParentNode?: TransformNode;
  74962. }
  74963. /**
  74964. * Interface defining the babylon result of raycasting/hit-test
  74965. */
  74966. export interface IWebXRLegacyHitResult {
  74967. /**
  74968. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74969. */
  74970. transformationMatrix: Matrix;
  74971. /**
  74972. * The native hit test result
  74973. */
  74974. xrHitResult: XRHitResult | XRHitTestResult;
  74975. }
  74976. /**
  74977. * The currently-working hit-test module.
  74978. * Hit test (or Ray-casting) is used to interact with the real world.
  74979. * For further information read here - https://github.com/immersive-web/hit-test
  74980. */
  74981. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74982. /**
  74983. * options to use when constructing this feature
  74984. */
  74985. readonly options: IWebXRLegacyHitTestOptions;
  74986. private _direction;
  74987. private _mat;
  74988. private _onSelectEnabled;
  74989. private _origin;
  74990. /**
  74991. * The module's name
  74992. */
  74993. static readonly Name: string;
  74994. /**
  74995. * The (Babylon) version of this module.
  74996. * This is an integer representing the implementation version.
  74997. * This number does not correspond to the WebXR specs version
  74998. */
  74999. static readonly Version: number;
  75000. /**
  75001. * Populated with the last native XR Hit Results
  75002. */
  75003. lastNativeXRHitResults: XRHitResult[];
  75004. /**
  75005. * Triggered when new babylon (transformed) hit test results are available
  75006. */
  75007. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75008. /**
  75009. * Creates a new instance of the (legacy version) hit test feature
  75010. * @param _xrSessionManager an instance of WebXRSessionManager
  75011. * @param options options to use when constructing this feature
  75012. */
  75013. constructor(_xrSessionManager: WebXRSessionManager,
  75014. /**
  75015. * options to use when constructing this feature
  75016. */
  75017. options?: IWebXRLegacyHitTestOptions);
  75018. /**
  75019. * execute a hit test with an XR Ray
  75020. *
  75021. * @param xrSession a native xrSession that will execute this hit test
  75022. * @param xrRay the ray (position and direction) to use for ray-casting
  75023. * @param referenceSpace native XR reference space to use for the hit-test
  75024. * @param filter filter function that will filter the results
  75025. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75026. */
  75027. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75028. /**
  75029. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75030. * @param event the (select) event to use to select with
  75031. * @param referenceSpace the reference space to use for this hit test
  75032. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75033. */
  75034. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75035. /**
  75036. * attach this feature
  75037. * Will usually be called by the features manager
  75038. *
  75039. * @returns true if successful.
  75040. */
  75041. attach(): boolean;
  75042. /**
  75043. * detach this feature.
  75044. * Will usually be called by the features manager
  75045. *
  75046. * @returns true if successful.
  75047. */
  75048. detach(): boolean;
  75049. /**
  75050. * Dispose this feature and all of the resources attached
  75051. */
  75052. dispose(): void;
  75053. protected _onXRFrame(frame: XRFrame): void;
  75054. private _onHitTestResults;
  75055. private _onSelect;
  75056. }
  75057. }
  75058. declare module BABYLON {
  75059. /**
  75060. * Options used for hit testing (version 2)
  75061. */
  75062. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75063. /**
  75064. * Do not create a permanent hit test. Will usually be used when only
  75065. * transient inputs are needed.
  75066. */
  75067. disablePermanentHitTest?: boolean;
  75068. /**
  75069. * Enable transient (for example touch-based) hit test inspections
  75070. */
  75071. enableTransientHitTest?: boolean;
  75072. /**
  75073. * Offset ray for the permanent hit test
  75074. */
  75075. offsetRay?: Vector3;
  75076. /**
  75077. * Offset ray for the transient hit test
  75078. */
  75079. transientOffsetRay?: Vector3;
  75080. /**
  75081. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75082. */
  75083. useReferenceSpace?: boolean;
  75084. /**
  75085. * Override the default entity type(s) of the hit-test result
  75086. */
  75087. entityTypes?: XRHitTestTrackableType[];
  75088. }
  75089. /**
  75090. * Interface defining the babylon result of hit-test
  75091. */
  75092. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75093. /**
  75094. * The input source that generated this hit test (if transient)
  75095. */
  75096. inputSource?: XRInputSource;
  75097. /**
  75098. * Is this a transient hit test
  75099. */
  75100. isTransient?: boolean;
  75101. /**
  75102. * Position of the hit test result
  75103. */
  75104. position: Vector3;
  75105. /**
  75106. * Rotation of the hit test result
  75107. */
  75108. rotationQuaternion: Quaternion;
  75109. /**
  75110. * The native hit test result
  75111. */
  75112. xrHitResult: XRHitTestResult;
  75113. }
  75114. /**
  75115. * The currently-working hit-test module.
  75116. * Hit test (or Ray-casting) is used to interact with the real world.
  75117. * For further information read here - https://github.com/immersive-web/hit-test
  75118. *
  75119. * Tested on chrome (mobile) 80.
  75120. */
  75121. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75122. /**
  75123. * options to use when constructing this feature
  75124. */
  75125. readonly options: IWebXRHitTestOptions;
  75126. private _tmpMat;
  75127. private _tmpPos;
  75128. private _tmpQuat;
  75129. private _transientXrHitTestSource;
  75130. private _xrHitTestSource;
  75131. private initHitTestSource;
  75132. /**
  75133. * The module's name
  75134. */
  75135. static readonly Name: string;
  75136. /**
  75137. * The (Babylon) version of this module.
  75138. * This is an integer representing the implementation version.
  75139. * This number does not correspond to the WebXR specs version
  75140. */
  75141. static readonly Version: number;
  75142. /**
  75143. * When set to true, each hit test will have its own position/rotation objects
  75144. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75145. * the developers will clone them or copy them as they see fit.
  75146. */
  75147. autoCloneTransformation: boolean;
  75148. /**
  75149. * Triggered when new babylon (transformed) hit test results are available
  75150. * Note - this will be called when results come back from the device. It can be an empty array!!
  75151. */
  75152. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75153. /**
  75154. * Use this to temporarily pause hit test checks.
  75155. */
  75156. paused: boolean;
  75157. /**
  75158. * Creates a new instance of the hit test feature
  75159. * @param _xrSessionManager an instance of WebXRSessionManager
  75160. * @param options options to use when constructing this feature
  75161. */
  75162. constructor(_xrSessionManager: WebXRSessionManager,
  75163. /**
  75164. * options to use when constructing this feature
  75165. */
  75166. options?: IWebXRHitTestOptions);
  75167. /**
  75168. * attach this feature
  75169. * Will usually be called by the features manager
  75170. *
  75171. * @returns true if successful.
  75172. */
  75173. attach(): boolean;
  75174. /**
  75175. * detach this feature.
  75176. * Will usually be called by the features manager
  75177. *
  75178. * @returns true if successful.
  75179. */
  75180. detach(): boolean;
  75181. /**
  75182. * Dispose this feature and all of the resources attached
  75183. */
  75184. dispose(): void;
  75185. protected _onXRFrame(frame: XRFrame): void;
  75186. private _processWebXRHitTestResult;
  75187. }
  75188. }
  75189. declare module BABYLON {
  75190. /**
  75191. * Configuration options of the anchor system
  75192. */
  75193. export interface IWebXRAnchorSystemOptions {
  75194. /**
  75195. * a node that will be used to convert local to world coordinates
  75196. */
  75197. worldParentNode?: TransformNode;
  75198. /**
  75199. * If set to true a reference of the created anchors will be kept until the next session starts
  75200. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75201. */
  75202. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75203. }
  75204. /**
  75205. * A babylon container for an XR Anchor
  75206. */
  75207. export interface IWebXRAnchor {
  75208. /**
  75209. * A babylon-assigned ID for this anchor
  75210. */
  75211. id: number;
  75212. /**
  75213. * Transformation matrix to apply to an object attached to this anchor
  75214. */
  75215. transformationMatrix: Matrix;
  75216. /**
  75217. * The native anchor object
  75218. */
  75219. xrAnchor: XRAnchor;
  75220. /**
  75221. * if defined, this object will be constantly updated by the anchor's position and rotation
  75222. */
  75223. attachedNode?: TransformNode;
  75224. }
  75225. /**
  75226. * An implementation of the anchor system for WebXR.
  75227. * For further information see https://github.com/immersive-web/anchors/
  75228. */
  75229. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75230. private _options;
  75231. private _lastFrameDetected;
  75232. private _trackedAnchors;
  75233. private _referenceSpaceForFrameAnchors;
  75234. private _futureAnchors;
  75235. /**
  75236. * The module's name
  75237. */
  75238. static readonly Name: string;
  75239. /**
  75240. * The (Babylon) version of this module.
  75241. * This is an integer representing the implementation version.
  75242. * This number does not correspond to the WebXR specs version
  75243. */
  75244. static readonly Version: number;
  75245. /**
  75246. * Observers registered here will be executed when a new anchor was added to the session
  75247. */
  75248. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75249. /**
  75250. * Observers registered here will be executed when an anchor was removed from the session
  75251. */
  75252. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75253. /**
  75254. * Observers registered here will be executed when an existing anchor updates
  75255. * This can execute N times every frame
  75256. */
  75257. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75258. /**
  75259. * Set the reference space to use for anchor creation, when not using a hit test.
  75260. * Will default to the session's reference space if not defined
  75261. */
  75262. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75263. /**
  75264. * constructs a new anchor system
  75265. * @param _xrSessionManager an instance of WebXRSessionManager
  75266. * @param _options configuration object for this feature
  75267. */
  75268. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75269. private _tmpVector;
  75270. private _tmpQuaternion;
  75271. private _populateTmpTransformation;
  75272. /**
  75273. * Create a new anchor point using a hit test result at a specific point in the scene
  75274. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75275. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75276. *
  75277. * @param hitTestResult The hit test result to use for this anchor creation
  75278. * @param position an optional position offset for this anchor
  75279. * @param rotationQuaternion an optional rotation offset for this anchor
  75280. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75281. */
  75282. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75283. /**
  75284. * Add a new anchor at a specific position and rotation
  75285. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75286. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75287. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75288. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75289. *
  75290. * @param position the position in which to add an anchor
  75291. * @param rotationQuaternion an optional rotation for the anchor transformation
  75292. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75293. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75294. */
  75295. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75296. /**
  75297. * detach this feature.
  75298. * Will usually be called by the features manager
  75299. *
  75300. * @returns true if successful.
  75301. */
  75302. detach(): boolean;
  75303. /**
  75304. * Dispose this feature and all of the resources attached
  75305. */
  75306. dispose(): void;
  75307. protected _onXRFrame(frame: XRFrame): void;
  75308. /**
  75309. * avoiding using Array.find for global support.
  75310. * @param xrAnchor the plane to find in the array
  75311. */
  75312. private _findIndexInAnchorArray;
  75313. private _updateAnchorWithXRFrame;
  75314. private _createAnchorAtTransformation;
  75315. }
  75316. }
  75317. declare module BABYLON {
  75318. /**
  75319. * Options used in the plane detector module
  75320. */
  75321. export interface IWebXRPlaneDetectorOptions {
  75322. /**
  75323. * The node to use to transform the local results to world coordinates
  75324. */
  75325. worldParentNode?: TransformNode;
  75326. /**
  75327. * If set to true a reference of the created planes will be kept until the next session starts
  75328. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75329. */
  75330. doNotRemovePlanesOnSessionEnded?: boolean;
  75331. }
  75332. /**
  75333. * A babylon interface for a WebXR plane.
  75334. * A Plane is actually a polygon, built from N points in space
  75335. *
  75336. * Supported in chrome 79, not supported in canary 81 ATM
  75337. */
  75338. export interface IWebXRPlane {
  75339. /**
  75340. * a babylon-assigned ID for this polygon
  75341. */
  75342. id: number;
  75343. /**
  75344. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75345. */
  75346. polygonDefinition: Array<Vector3>;
  75347. /**
  75348. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75349. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75350. */
  75351. transformationMatrix: Matrix;
  75352. /**
  75353. * the native xr-plane object
  75354. */
  75355. xrPlane: XRPlane;
  75356. }
  75357. /**
  75358. * The plane detector is used to detect planes in the real world when in AR
  75359. * For more information see https://github.com/immersive-web/real-world-geometry/
  75360. */
  75361. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75362. private _options;
  75363. private _detectedPlanes;
  75364. private _enabled;
  75365. private _lastFrameDetected;
  75366. /**
  75367. * The module's name
  75368. */
  75369. static readonly Name: string;
  75370. /**
  75371. * The (Babylon) version of this module.
  75372. * This is an integer representing the implementation version.
  75373. * This number does not correspond to the WebXR specs version
  75374. */
  75375. static readonly Version: number;
  75376. /**
  75377. * Observers registered here will be executed when a new plane was added to the session
  75378. */
  75379. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75380. /**
  75381. * Observers registered here will be executed when a plane is no longer detected in the session
  75382. */
  75383. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75384. /**
  75385. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75386. * This can execute N times every frame
  75387. */
  75388. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75389. /**
  75390. * construct a new Plane Detector
  75391. * @param _xrSessionManager an instance of xr Session manager
  75392. * @param _options configuration to use when constructing this feature
  75393. */
  75394. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75395. /**
  75396. * detach this feature.
  75397. * Will usually be called by the features manager
  75398. *
  75399. * @returns true if successful.
  75400. */
  75401. detach(): boolean;
  75402. /**
  75403. * Dispose this feature and all of the resources attached
  75404. */
  75405. dispose(): void;
  75406. protected _onXRFrame(frame: XRFrame): void;
  75407. private _init;
  75408. private _updatePlaneWithXRPlane;
  75409. /**
  75410. * avoiding using Array.find for global support.
  75411. * @param xrPlane the plane to find in the array
  75412. */
  75413. private findIndexInPlaneArray;
  75414. }
  75415. }
  75416. declare module BABYLON {
  75417. /**
  75418. * Options interface for the background remover plugin
  75419. */
  75420. export interface IWebXRBackgroundRemoverOptions {
  75421. /**
  75422. * Further background meshes to disable when entering AR
  75423. */
  75424. backgroundMeshes?: AbstractMesh[];
  75425. /**
  75426. * flags to configure the removal of the environment helper.
  75427. * If not set, the entire background will be removed. If set, flags should be set as well.
  75428. */
  75429. environmentHelperRemovalFlags?: {
  75430. /**
  75431. * Should the skybox be removed (default false)
  75432. */
  75433. skyBox?: boolean;
  75434. /**
  75435. * Should the ground be removed (default false)
  75436. */
  75437. ground?: boolean;
  75438. };
  75439. /**
  75440. * don't disable the environment helper
  75441. */
  75442. ignoreEnvironmentHelper?: boolean;
  75443. }
  75444. /**
  75445. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75446. */
  75447. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75448. /**
  75449. * read-only options to be used in this module
  75450. */
  75451. readonly options: IWebXRBackgroundRemoverOptions;
  75452. /**
  75453. * The module's name
  75454. */
  75455. static readonly Name: string;
  75456. /**
  75457. * The (Babylon) version of this module.
  75458. * This is an integer representing the implementation version.
  75459. * This number does not correspond to the WebXR specs version
  75460. */
  75461. static readonly Version: number;
  75462. /**
  75463. * registered observers will be triggered when the background state changes
  75464. */
  75465. onBackgroundStateChangedObservable: Observable<boolean>;
  75466. /**
  75467. * constructs a new background remover module
  75468. * @param _xrSessionManager the session manager for this module
  75469. * @param options read-only options to be used in this module
  75470. */
  75471. constructor(_xrSessionManager: WebXRSessionManager,
  75472. /**
  75473. * read-only options to be used in this module
  75474. */
  75475. options?: IWebXRBackgroundRemoverOptions);
  75476. /**
  75477. * attach this feature
  75478. * Will usually be called by the features manager
  75479. *
  75480. * @returns true if successful.
  75481. */
  75482. attach(): boolean;
  75483. /**
  75484. * detach this feature.
  75485. * Will usually be called by the features manager
  75486. *
  75487. * @returns true if successful.
  75488. */
  75489. detach(): boolean;
  75490. /**
  75491. * Dispose this feature and all of the resources attached
  75492. */
  75493. dispose(): void;
  75494. protected _onXRFrame(_xrFrame: XRFrame): void;
  75495. private _setBackgroundState;
  75496. }
  75497. }
  75498. declare module BABYLON {
  75499. /**
  75500. * Options for the controller physics feature
  75501. */
  75502. export class IWebXRControllerPhysicsOptions {
  75503. /**
  75504. * Should the headset get its own impostor
  75505. */
  75506. enableHeadsetImpostor?: boolean;
  75507. /**
  75508. * Optional parameters for the headset impostor
  75509. */
  75510. headsetImpostorParams?: {
  75511. /**
  75512. * The type of impostor to create. Default is sphere
  75513. */
  75514. impostorType: number;
  75515. /**
  75516. * the size of the impostor. Defaults to 10cm
  75517. */
  75518. impostorSize?: number | {
  75519. width: number;
  75520. height: number;
  75521. depth: number;
  75522. };
  75523. /**
  75524. * Friction definitions
  75525. */
  75526. friction?: number;
  75527. /**
  75528. * Restitution
  75529. */
  75530. restitution?: number;
  75531. };
  75532. /**
  75533. * The physics properties of the future impostors
  75534. */
  75535. physicsProperties?: {
  75536. /**
  75537. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75538. * Note that this requires a physics engine that supports mesh impostors!
  75539. */
  75540. useControllerMesh?: boolean;
  75541. /**
  75542. * The type of impostor to create. Default is sphere
  75543. */
  75544. impostorType?: number;
  75545. /**
  75546. * the size of the impostor. Defaults to 10cm
  75547. */
  75548. impostorSize?: number | {
  75549. width: number;
  75550. height: number;
  75551. depth: number;
  75552. };
  75553. /**
  75554. * Friction definitions
  75555. */
  75556. friction?: number;
  75557. /**
  75558. * Restitution
  75559. */
  75560. restitution?: number;
  75561. };
  75562. /**
  75563. * the xr input to use with this pointer selection
  75564. */
  75565. xrInput: WebXRInput;
  75566. }
  75567. /**
  75568. * Add physics impostor to your webxr controllers,
  75569. * including naive calculation of their linear and angular velocity
  75570. */
  75571. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75572. private readonly _options;
  75573. private _attachController;
  75574. private _controllers;
  75575. private _debugMode;
  75576. private _delta;
  75577. private _headsetImpostor?;
  75578. private _headsetMesh?;
  75579. private _lastTimestamp;
  75580. private _tmpQuaternion;
  75581. private _tmpVector;
  75582. /**
  75583. * The module's name
  75584. */
  75585. static readonly Name: string;
  75586. /**
  75587. * The (Babylon) version of this module.
  75588. * This is an integer representing the implementation version.
  75589. * This number does not correspond to the webxr specs version
  75590. */
  75591. static readonly Version: number;
  75592. /**
  75593. * Construct a new Controller Physics Feature
  75594. * @param _xrSessionManager the corresponding xr session manager
  75595. * @param _options options to create this feature with
  75596. */
  75597. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75598. /**
  75599. * @hidden
  75600. * enable debugging - will show console outputs and the impostor mesh
  75601. */
  75602. _enablePhysicsDebug(): void;
  75603. /**
  75604. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75605. * @param xrController the controller to add
  75606. */
  75607. addController(xrController: WebXRInputSource): void;
  75608. /**
  75609. * attach this feature
  75610. * Will usually be called by the features manager
  75611. *
  75612. * @returns true if successful.
  75613. */
  75614. attach(): boolean;
  75615. /**
  75616. * detach this feature.
  75617. * Will usually be called by the features manager
  75618. *
  75619. * @returns true if successful.
  75620. */
  75621. detach(): boolean;
  75622. /**
  75623. * Get the headset impostor, if enabled
  75624. * @returns the impostor
  75625. */
  75626. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75627. /**
  75628. * Get the physics impostor of a specific controller.
  75629. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75630. * @param controller the controller or the controller id of which to get the impostor
  75631. * @returns the impostor or null
  75632. */
  75633. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75634. /**
  75635. * Update the physics properties provided in the constructor
  75636. * @param newProperties the new properties object
  75637. */
  75638. setPhysicsProperties(newProperties: {
  75639. impostorType?: number;
  75640. impostorSize?: number | {
  75641. width: number;
  75642. height: number;
  75643. depth: number;
  75644. };
  75645. friction?: number;
  75646. restitution?: number;
  75647. }): void;
  75648. protected _onXRFrame(_xrFrame: any): void;
  75649. private _detachController;
  75650. }
  75651. }
  75652. declare module BABYLON {
  75653. /**
  75654. * A babylon interface for a "WebXR" feature point.
  75655. * Represents the position and confidence value of a given feature point.
  75656. */
  75657. export interface IWebXRFeaturePoint {
  75658. /**
  75659. * Represents the position of the feature point in world space.
  75660. */
  75661. position: Vector3;
  75662. /**
  75663. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75664. */
  75665. confidenceValue: number;
  75666. }
  75667. /**
  75668. * The feature point system is used to detect feature points from real world geometry.
  75669. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75670. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75671. */
  75672. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75673. private _enabled;
  75674. private _featurePointCloud;
  75675. /**
  75676. * The module's name
  75677. */
  75678. static readonly Name: string;
  75679. /**
  75680. * The (Babylon) version of this module.
  75681. * This is an integer representing the implementation version.
  75682. * This number does not correspond to the WebXR specs version
  75683. */
  75684. static readonly Version: number;
  75685. /**
  75686. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75687. * Will notify the observers about which feature points have been added.
  75688. */
  75689. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75690. /**
  75691. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75692. * Will notify the observers about which feature points have been updated.
  75693. */
  75694. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75695. /**
  75696. * The current feature point cloud maintained across frames.
  75697. */
  75698. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75699. /**
  75700. * construct the feature point system
  75701. * @param _xrSessionManager an instance of xr Session manager
  75702. */
  75703. constructor(_xrSessionManager: WebXRSessionManager);
  75704. /**
  75705. * Detach this feature.
  75706. * Will usually be called by the features manager
  75707. *
  75708. * @returns true if successful.
  75709. */
  75710. detach(): boolean;
  75711. /**
  75712. * Dispose this feature and all of the resources attached
  75713. */
  75714. dispose(): void;
  75715. /**
  75716. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75717. */
  75718. protected _onXRFrame(frame: XRFrame): void;
  75719. /**
  75720. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75721. */
  75722. private _init;
  75723. }
  75724. }
  75725. declare module BABYLON {
  75726. /**
  75727. * Configuration interface for the hand tracking feature
  75728. */
  75729. export interface IWebXRHandTrackingOptions {
  75730. /**
  75731. * The xrInput that will be used as source for new hands
  75732. */
  75733. xrInput: WebXRInput;
  75734. /**
  75735. * Configuration object for the joint meshes
  75736. */
  75737. jointMeshes?: {
  75738. /**
  75739. * Should the meshes created be invisible (defaults to false)
  75740. */
  75741. invisible?: boolean;
  75742. /**
  75743. * A source mesh to be used to create instances. Defaults to a sphere.
  75744. * This mesh will be the source for all other (25) meshes.
  75745. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75746. */
  75747. sourceMesh?: Mesh;
  75748. /**
  75749. * This function will be called after a mesh was created for a specific joint.
  75750. * Using this function you can either manipulate the instance or return a new mesh.
  75751. * When returning a new mesh the instance created before will be disposed
  75752. */
  75753. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  75754. /**
  75755. * Should the source mesh stay visible. Defaults to false
  75756. */
  75757. keepOriginalVisible?: boolean;
  75758. /**
  75759. * Scale factor for all instances (defaults to 2)
  75760. */
  75761. scaleFactor?: number;
  75762. /**
  75763. * Should each instance have its own physics impostor
  75764. */
  75765. enablePhysics?: boolean;
  75766. /**
  75767. * If enabled, override default physics properties
  75768. */
  75769. physicsProps?: {
  75770. friction?: number;
  75771. restitution?: number;
  75772. impostorType?: number;
  75773. };
  75774. /**
  75775. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75776. */
  75777. handMesh?: AbstractMesh;
  75778. };
  75779. }
  75780. /**
  75781. * Parts of the hands divided to writs and finger names
  75782. */
  75783. export const enum HandPart {
  75784. /**
  75785. * HandPart - Wrist
  75786. */
  75787. WRIST = "wrist",
  75788. /**
  75789. * HandPart - The THumb
  75790. */
  75791. THUMB = "thumb",
  75792. /**
  75793. * HandPart - Index finger
  75794. */
  75795. INDEX = "index",
  75796. /**
  75797. * HandPart - Middle finger
  75798. */
  75799. MIDDLE = "middle",
  75800. /**
  75801. * HandPart - Ring finger
  75802. */
  75803. RING = "ring",
  75804. /**
  75805. * HandPart - Little finger
  75806. */
  75807. LITTLE = "little"
  75808. }
  75809. /**
  75810. * Representing a single hand (with its corresponding native XRHand object)
  75811. */
  75812. export class WebXRHand implements IDisposable {
  75813. /** the controller to which the hand correlates */
  75814. readonly xrController: WebXRInputSource;
  75815. /** the meshes to be used to track the hand joints */
  75816. readonly trackedMeshes: AbstractMesh[];
  75817. /**
  75818. * Hand-parts definition (key is HandPart)
  75819. */
  75820. handPartsDefinition: {
  75821. [key: string]: number[];
  75822. };
  75823. /**
  75824. * Populate the HandPartsDefinition object.
  75825. * This is called as a side effect since certain browsers don't have XRHand defined.
  75826. */
  75827. private generateHandPartsDefinition;
  75828. /**
  75829. * Construct a new hand object
  75830. * @param xrController the controller to which the hand correlates
  75831. * @param trackedMeshes the meshes to be used to track the hand joints
  75832. */
  75833. constructor(
  75834. /** the controller to which the hand correlates */
  75835. xrController: WebXRInputSource,
  75836. /** the meshes to be used to track the hand joints */
  75837. trackedMeshes: AbstractMesh[]);
  75838. /**
  75839. * Update this hand from the latest xr frame
  75840. * @param xrFrame xrFrame to update from
  75841. * @param referenceSpace The current viewer reference space
  75842. * @param scaleFactor optional scale factor for the meshes
  75843. */
  75844. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75845. /**
  75846. * Get meshes of part of the hand
  75847. * @param part the part of hand to get
  75848. * @returns An array of meshes that correlate to the hand part requested
  75849. */
  75850. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75851. /**
  75852. * Dispose this Hand object
  75853. */
  75854. dispose(): void;
  75855. }
  75856. /**
  75857. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75858. */
  75859. export class WebXRHandTracking extends WebXRAbstractFeature {
  75860. /**
  75861. * options to use when constructing this feature
  75862. */
  75863. readonly options: IWebXRHandTrackingOptions;
  75864. private static _idCounter;
  75865. /**
  75866. * The module's name
  75867. */
  75868. static readonly Name: string;
  75869. /**
  75870. * The (Babylon) version of this module.
  75871. * This is an integer representing the implementation version.
  75872. * This number does not correspond to the WebXR specs version
  75873. */
  75874. static readonly Version: number;
  75875. /**
  75876. * This observable will notify registered observers when a new hand object was added and initialized
  75877. */
  75878. onHandAddedObservable: Observable<WebXRHand>;
  75879. /**
  75880. * This observable will notify its observers right before the hand object is disposed
  75881. */
  75882. onHandRemovedObservable: Observable<WebXRHand>;
  75883. private _hands;
  75884. /**
  75885. * Creates a new instance of the hit test feature
  75886. * @param _xrSessionManager an instance of WebXRSessionManager
  75887. * @param options options to use when constructing this feature
  75888. */
  75889. constructor(_xrSessionManager: WebXRSessionManager,
  75890. /**
  75891. * options to use when constructing this feature
  75892. */
  75893. options: IWebXRHandTrackingOptions);
  75894. /**
  75895. * Check if the needed objects are defined.
  75896. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75897. */
  75898. isCompatible(): boolean;
  75899. /**
  75900. * attach this feature
  75901. * Will usually be called by the features manager
  75902. *
  75903. * @returns true if successful.
  75904. */
  75905. attach(): boolean;
  75906. /**
  75907. * detach this feature.
  75908. * Will usually be called by the features manager
  75909. *
  75910. * @returns true if successful.
  75911. */
  75912. detach(): boolean;
  75913. /**
  75914. * Dispose this feature and all of the resources attached
  75915. */
  75916. dispose(): void;
  75917. /**
  75918. * Get the hand object according to the controller id
  75919. * @param controllerId the controller id to which we want to get the hand
  75920. * @returns null if not found or the WebXRHand object if found
  75921. */
  75922. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75923. /**
  75924. * Get a hand object according to the requested handedness
  75925. * @param handedness the handedness to request
  75926. * @returns null if not found or the WebXRHand object if found
  75927. */
  75928. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75929. protected _onXRFrame(_xrFrame: XRFrame): void;
  75930. private _attachHand;
  75931. private _detachHand;
  75932. }
  75933. }
  75934. declare module BABYLON {
  75935. /**
  75936. * The motion controller class for all microsoft mixed reality controllers
  75937. */
  75938. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75939. protected readonly _mapping: {
  75940. defaultButton: {
  75941. valueNodeName: string;
  75942. unpressedNodeName: string;
  75943. pressedNodeName: string;
  75944. };
  75945. defaultAxis: {
  75946. valueNodeName: string;
  75947. minNodeName: string;
  75948. maxNodeName: string;
  75949. };
  75950. buttons: {
  75951. "xr-standard-trigger": {
  75952. rootNodeName: string;
  75953. componentProperty: string;
  75954. states: string[];
  75955. };
  75956. "xr-standard-squeeze": {
  75957. rootNodeName: string;
  75958. componentProperty: string;
  75959. states: string[];
  75960. };
  75961. "xr-standard-touchpad": {
  75962. rootNodeName: string;
  75963. labelAnchorNodeName: string;
  75964. touchPointNodeName: string;
  75965. };
  75966. "xr-standard-thumbstick": {
  75967. rootNodeName: string;
  75968. componentProperty: string;
  75969. states: string[];
  75970. };
  75971. };
  75972. axes: {
  75973. "xr-standard-touchpad": {
  75974. "x-axis": {
  75975. rootNodeName: string;
  75976. };
  75977. "y-axis": {
  75978. rootNodeName: string;
  75979. };
  75980. };
  75981. "xr-standard-thumbstick": {
  75982. "x-axis": {
  75983. rootNodeName: string;
  75984. };
  75985. "y-axis": {
  75986. rootNodeName: string;
  75987. };
  75988. };
  75989. };
  75990. };
  75991. /**
  75992. * The base url used to load the left and right controller models
  75993. */
  75994. static MODEL_BASE_URL: string;
  75995. /**
  75996. * The name of the left controller model file
  75997. */
  75998. static MODEL_LEFT_FILENAME: string;
  75999. /**
  76000. * The name of the right controller model file
  76001. */
  76002. static MODEL_RIGHT_FILENAME: string;
  76003. profileId: string;
  76004. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76005. protected _getFilenameAndPath(): {
  76006. filename: string;
  76007. path: string;
  76008. };
  76009. protected _getModelLoadingConstraints(): boolean;
  76010. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76011. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76012. protected _updateModel(): void;
  76013. }
  76014. }
  76015. declare module BABYLON {
  76016. /**
  76017. * The motion controller class for oculus touch (quest, rift).
  76018. * This class supports legacy mapping as well the standard xr mapping
  76019. */
  76020. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76021. private _forceLegacyControllers;
  76022. private _modelRootNode;
  76023. /**
  76024. * The base url used to load the left and right controller models
  76025. */
  76026. static MODEL_BASE_URL: string;
  76027. /**
  76028. * The name of the left controller model file
  76029. */
  76030. static MODEL_LEFT_FILENAME: string;
  76031. /**
  76032. * The name of the right controller model file
  76033. */
  76034. static MODEL_RIGHT_FILENAME: string;
  76035. /**
  76036. * Base Url for the Quest controller model.
  76037. */
  76038. static QUEST_MODEL_BASE_URL: string;
  76039. profileId: string;
  76040. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76041. protected _getFilenameAndPath(): {
  76042. filename: string;
  76043. path: string;
  76044. };
  76045. protected _getModelLoadingConstraints(): boolean;
  76046. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76047. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76048. protected _updateModel(): void;
  76049. /**
  76050. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76051. * between the touch and touch 2.
  76052. */
  76053. private _isQuest;
  76054. }
  76055. }
  76056. declare module BABYLON {
  76057. /**
  76058. * The motion controller class for the standard HTC-Vive controllers
  76059. */
  76060. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76061. private _modelRootNode;
  76062. /**
  76063. * The base url used to load the left and right controller models
  76064. */
  76065. static MODEL_BASE_URL: string;
  76066. /**
  76067. * File name for the controller model.
  76068. */
  76069. static MODEL_FILENAME: string;
  76070. profileId: string;
  76071. /**
  76072. * Create a new Vive motion controller object
  76073. * @param scene the scene to use to create this controller
  76074. * @param gamepadObject the corresponding gamepad object
  76075. * @param handedness the handedness of the controller
  76076. */
  76077. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76078. protected _getFilenameAndPath(): {
  76079. filename: string;
  76080. path: string;
  76081. };
  76082. protected _getModelLoadingConstraints(): boolean;
  76083. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76084. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76085. protected _updateModel(): void;
  76086. }
  76087. }
  76088. declare module BABYLON {
  76089. /**
  76090. * A cursor which tracks a point on a path
  76091. */
  76092. export class PathCursor {
  76093. private path;
  76094. /**
  76095. * Stores path cursor callbacks for when an onchange event is triggered
  76096. */
  76097. private _onchange;
  76098. /**
  76099. * The value of the path cursor
  76100. */
  76101. value: number;
  76102. /**
  76103. * The animation array of the path cursor
  76104. */
  76105. animations: Animation[];
  76106. /**
  76107. * Initializes the path cursor
  76108. * @param path The path to track
  76109. */
  76110. constructor(path: Path2);
  76111. /**
  76112. * Gets the cursor point on the path
  76113. * @returns A point on the path cursor at the cursor location
  76114. */
  76115. getPoint(): Vector3;
  76116. /**
  76117. * Moves the cursor ahead by the step amount
  76118. * @param step The amount to move the cursor forward
  76119. * @returns This path cursor
  76120. */
  76121. moveAhead(step?: number): PathCursor;
  76122. /**
  76123. * Moves the cursor behind by the step amount
  76124. * @param step The amount to move the cursor back
  76125. * @returns This path cursor
  76126. */
  76127. moveBack(step?: number): PathCursor;
  76128. /**
  76129. * Moves the cursor by the step amount
  76130. * If the step amount is greater than one, an exception is thrown
  76131. * @param step The amount to move the cursor
  76132. * @returns This path cursor
  76133. */
  76134. move(step: number): PathCursor;
  76135. /**
  76136. * Ensures that the value is limited between zero and one
  76137. * @returns This path cursor
  76138. */
  76139. private ensureLimits;
  76140. /**
  76141. * Runs onchange callbacks on change (used by the animation engine)
  76142. * @returns This path cursor
  76143. */
  76144. private raiseOnChange;
  76145. /**
  76146. * Executes a function on change
  76147. * @param f A path cursor onchange callback
  76148. * @returns This path cursor
  76149. */
  76150. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76151. }
  76152. }
  76153. declare module BABYLON {
  76154. /** @hidden */
  76155. export var blurPixelShader: {
  76156. name: string;
  76157. shader: string;
  76158. };
  76159. }
  76160. declare module BABYLON {
  76161. /** @hidden */
  76162. export var pointCloudVertexDeclaration: {
  76163. name: string;
  76164. shader: string;
  76165. };
  76166. }
  76167. // Mixins
  76168. interface Window {
  76169. mozIndexedDB: IDBFactory;
  76170. webkitIndexedDB: IDBFactory;
  76171. msIndexedDB: IDBFactory;
  76172. webkitURL: typeof URL;
  76173. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76174. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76175. WebGLRenderingContext: WebGLRenderingContext;
  76176. MSGesture: MSGesture;
  76177. CANNON: any;
  76178. AudioContext: AudioContext;
  76179. webkitAudioContext: AudioContext;
  76180. PointerEvent: any;
  76181. Math: Math;
  76182. Uint8Array: Uint8ArrayConstructor;
  76183. Float32Array: Float32ArrayConstructor;
  76184. mozURL: typeof URL;
  76185. msURL: typeof URL;
  76186. VRFrameData: any; // WebVR, from specs 1.1
  76187. DracoDecoderModule: any;
  76188. setImmediate(handler: (...args: any[]) => void): number;
  76189. }
  76190. interface HTMLCanvasElement {
  76191. requestPointerLock(): void;
  76192. msRequestPointerLock?(): void;
  76193. mozRequestPointerLock?(): void;
  76194. webkitRequestPointerLock?(): void;
  76195. /** Track wether a record is in progress */
  76196. isRecording: boolean;
  76197. /** Capture Stream method defined by some browsers */
  76198. captureStream(fps?: number): MediaStream;
  76199. }
  76200. interface CanvasRenderingContext2D {
  76201. msImageSmoothingEnabled: boolean;
  76202. }
  76203. interface MouseEvent {
  76204. mozMovementX: number;
  76205. mozMovementY: number;
  76206. webkitMovementX: number;
  76207. webkitMovementY: number;
  76208. msMovementX: number;
  76209. msMovementY: number;
  76210. }
  76211. interface Navigator {
  76212. mozGetVRDevices: (any: any) => any;
  76213. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76214. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76215. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76216. webkitGetGamepads(): Gamepad[];
  76217. msGetGamepads(): Gamepad[];
  76218. webkitGamepads(): Gamepad[];
  76219. }
  76220. interface HTMLVideoElement {
  76221. mozSrcObject: any;
  76222. }
  76223. interface Math {
  76224. fround(x: number): number;
  76225. imul(a: number, b: number): number;
  76226. }
  76227. interface WebGLRenderingContext {
  76228. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76229. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76230. vertexAttribDivisor(index: number, divisor: number): void;
  76231. createVertexArray(): any;
  76232. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76233. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76234. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76235. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76236. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76237. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76238. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76239. // Queries
  76240. createQuery(): WebGLQuery;
  76241. deleteQuery(query: WebGLQuery): void;
  76242. beginQuery(target: number, query: WebGLQuery): void;
  76243. endQuery(target: number): void;
  76244. getQueryParameter(query: WebGLQuery, pname: number): any;
  76245. getQuery(target: number, pname: number): any;
  76246. MAX_SAMPLES: number;
  76247. RGBA8: number;
  76248. READ_FRAMEBUFFER: number;
  76249. DRAW_FRAMEBUFFER: number;
  76250. UNIFORM_BUFFER: number;
  76251. HALF_FLOAT_OES: number;
  76252. RGBA16F: number;
  76253. RGBA32F: number;
  76254. R32F: number;
  76255. RG32F: number;
  76256. RGB32F: number;
  76257. R16F: number;
  76258. RG16F: number;
  76259. RGB16F: number;
  76260. RED: number;
  76261. RG: number;
  76262. R8: number;
  76263. RG8: number;
  76264. UNSIGNED_INT_24_8: number;
  76265. DEPTH24_STENCIL8: number;
  76266. MIN: number;
  76267. MAX: number;
  76268. /* Multiple Render Targets */
  76269. drawBuffers(buffers: number[]): void;
  76270. readBuffer(src: number): void;
  76271. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76272. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76273. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76274. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76275. // Occlusion Query
  76276. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76277. ANY_SAMPLES_PASSED: number;
  76278. QUERY_RESULT_AVAILABLE: number;
  76279. QUERY_RESULT: number;
  76280. }
  76281. interface WebGLProgram {
  76282. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76283. }
  76284. interface EXT_disjoint_timer_query {
  76285. QUERY_COUNTER_BITS_EXT: number;
  76286. TIME_ELAPSED_EXT: number;
  76287. TIMESTAMP_EXT: number;
  76288. GPU_DISJOINT_EXT: number;
  76289. QUERY_RESULT_EXT: number;
  76290. QUERY_RESULT_AVAILABLE_EXT: number;
  76291. queryCounterEXT(query: WebGLQuery, target: number): void;
  76292. createQueryEXT(): WebGLQuery;
  76293. beginQueryEXT(target: number, query: WebGLQuery): void;
  76294. endQueryEXT(target: number): void;
  76295. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76296. deleteQueryEXT(query: WebGLQuery): void;
  76297. }
  76298. interface WebGLUniformLocation {
  76299. _currentState: any;
  76300. }
  76301. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76302. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76303. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76304. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76305. interface WebGLRenderingContext {
  76306. readonly RASTERIZER_DISCARD: number;
  76307. readonly DEPTH_COMPONENT24: number;
  76308. readonly TEXTURE_3D: number;
  76309. readonly TEXTURE_2D_ARRAY: number;
  76310. readonly TEXTURE_COMPARE_FUNC: number;
  76311. readonly TEXTURE_COMPARE_MODE: number;
  76312. readonly COMPARE_REF_TO_TEXTURE: number;
  76313. readonly TEXTURE_WRAP_R: number;
  76314. readonly HALF_FLOAT: number;
  76315. readonly RGB8: number;
  76316. readonly RED_INTEGER: number;
  76317. readonly RG_INTEGER: number;
  76318. readonly RGB_INTEGER: number;
  76319. readonly RGBA_INTEGER: number;
  76320. readonly R8_SNORM: number;
  76321. readonly RG8_SNORM: number;
  76322. readonly RGB8_SNORM: number;
  76323. readonly RGBA8_SNORM: number;
  76324. readonly R8I: number;
  76325. readonly RG8I: number;
  76326. readonly RGB8I: number;
  76327. readonly RGBA8I: number;
  76328. readonly R8UI: number;
  76329. readonly RG8UI: number;
  76330. readonly RGB8UI: number;
  76331. readonly RGBA8UI: number;
  76332. readonly R16I: number;
  76333. readonly RG16I: number;
  76334. readonly RGB16I: number;
  76335. readonly RGBA16I: number;
  76336. readonly R16UI: number;
  76337. readonly RG16UI: number;
  76338. readonly RGB16UI: number;
  76339. readonly RGBA16UI: number;
  76340. readonly R32I: number;
  76341. readonly RG32I: number;
  76342. readonly RGB32I: number;
  76343. readonly RGBA32I: number;
  76344. readonly R32UI: number;
  76345. readonly RG32UI: number;
  76346. readonly RGB32UI: number;
  76347. readonly RGBA32UI: number;
  76348. readonly RGB10_A2UI: number;
  76349. readonly R11F_G11F_B10F: number;
  76350. readonly RGB9_E5: number;
  76351. readonly RGB10_A2: number;
  76352. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76353. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76354. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76355. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76356. readonly DEPTH_COMPONENT32F: number;
  76357. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76358. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76359. 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;
  76360. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76361. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76362. readonly TRANSFORM_FEEDBACK: number;
  76363. readonly INTERLEAVED_ATTRIBS: number;
  76364. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76365. createTransformFeedback(): WebGLTransformFeedback;
  76366. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76367. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76368. beginTransformFeedback(primitiveMode: number): void;
  76369. endTransformFeedback(): void;
  76370. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76371. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76372. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76373. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76374. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76375. }
  76376. interface ImageBitmap {
  76377. readonly width: number;
  76378. readonly height: number;
  76379. close(): void;
  76380. }
  76381. interface WebGLQuery extends WebGLObject {
  76382. }
  76383. declare var WebGLQuery: {
  76384. prototype: WebGLQuery;
  76385. new(): WebGLQuery;
  76386. };
  76387. interface WebGLSampler extends WebGLObject {
  76388. }
  76389. declare var WebGLSampler: {
  76390. prototype: WebGLSampler;
  76391. new(): WebGLSampler;
  76392. };
  76393. interface WebGLSync extends WebGLObject {
  76394. }
  76395. declare var WebGLSync: {
  76396. prototype: WebGLSync;
  76397. new(): WebGLSync;
  76398. };
  76399. interface WebGLTransformFeedback extends WebGLObject {
  76400. }
  76401. declare var WebGLTransformFeedback: {
  76402. prototype: WebGLTransformFeedback;
  76403. new(): WebGLTransformFeedback;
  76404. };
  76405. interface WebGLVertexArrayObject extends WebGLObject {
  76406. }
  76407. declare var WebGLVertexArrayObject: {
  76408. prototype: WebGLVertexArrayObject;
  76409. new(): WebGLVertexArrayObject;
  76410. };
  76411. // Type definitions for WebVR API
  76412. // Project: https://w3c.github.io/webvr/
  76413. // Definitions by: six a <https://github.com/lostfictions>
  76414. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76415. interface VRDisplay extends EventTarget {
  76416. /**
  76417. * Dictionary of capabilities describing the VRDisplay.
  76418. */
  76419. readonly capabilities: VRDisplayCapabilities;
  76420. /**
  76421. * z-depth defining the far plane of the eye view frustum
  76422. * enables mapping of values in the render target depth
  76423. * attachment to scene coordinates. Initially set to 10000.0.
  76424. */
  76425. depthFar: number;
  76426. /**
  76427. * z-depth defining the near plane of the eye view frustum
  76428. * enables mapping of values in the render target depth
  76429. * attachment to scene coordinates. Initially set to 0.01.
  76430. */
  76431. depthNear: number;
  76432. /**
  76433. * An identifier for this distinct VRDisplay. Used as an
  76434. * association point in the Gamepad API.
  76435. */
  76436. readonly displayId: number;
  76437. /**
  76438. * A display name, a user-readable name identifying it.
  76439. */
  76440. readonly displayName: string;
  76441. readonly isConnected: boolean;
  76442. readonly isPresenting: boolean;
  76443. /**
  76444. * If this VRDisplay supports room-scale experiences, the optional
  76445. * stage attribute contains details on the room-scale parameters.
  76446. */
  76447. readonly stageParameters: VRStageParameters | null;
  76448. /**
  76449. * Passing the value returned by `requestAnimationFrame` to
  76450. * `cancelAnimationFrame` will unregister the callback.
  76451. * @param handle Define the hanle of the request to cancel
  76452. */
  76453. cancelAnimationFrame(handle: number): void;
  76454. /**
  76455. * Stops presenting to the VRDisplay.
  76456. * @returns a promise to know when it stopped
  76457. */
  76458. exitPresent(): Promise<void>;
  76459. /**
  76460. * Return the current VREyeParameters for the given eye.
  76461. * @param whichEye Define the eye we want the parameter for
  76462. * @returns the eye parameters
  76463. */
  76464. getEyeParameters(whichEye: string): VREyeParameters;
  76465. /**
  76466. * Populates the passed VRFrameData with the information required to render
  76467. * the current frame.
  76468. * @param frameData Define the data structure to populate
  76469. * @returns true if ok otherwise false
  76470. */
  76471. getFrameData(frameData: VRFrameData): boolean;
  76472. /**
  76473. * Get the layers currently being presented.
  76474. * @returns the list of VR layers
  76475. */
  76476. getLayers(): VRLayer[];
  76477. /**
  76478. * Return a VRPose containing the future predicted pose of the VRDisplay
  76479. * when the current frame will be presented. The value returned will not
  76480. * change until JavaScript has returned control to the browser.
  76481. *
  76482. * The VRPose will contain the position, orientation, velocity,
  76483. * and acceleration of each of these properties.
  76484. * @returns the pose object
  76485. */
  76486. getPose(): VRPose;
  76487. /**
  76488. * Return the current instantaneous pose of the VRDisplay, with no
  76489. * prediction applied.
  76490. * @returns the current instantaneous pose
  76491. */
  76492. getImmediatePose(): VRPose;
  76493. /**
  76494. * The callback passed to `requestAnimationFrame` will be called
  76495. * any time a new frame should be rendered. When the VRDisplay is
  76496. * presenting the callback will be called at the native refresh
  76497. * rate of the HMD. When not presenting this function acts
  76498. * identically to how window.requestAnimationFrame acts. Content should
  76499. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76500. * asynchronously from other displays and at differing refresh rates.
  76501. * @param callback Define the eaction to run next frame
  76502. * @returns the request handle it
  76503. */
  76504. requestAnimationFrame(callback: FrameRequestCallback): number;
  76505. /**
  76506. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76507. * Repeat calls while already presenting will update the VRLayers being displayed.
  76508. * @param layers Define the list of layer to present
  76509. * @returns a promise to know when the request has been fulfilled
  76510. */
  76511. requestPresent(layers: VRLayer[]): Promise<void>;
  76512. /**
  76513. * Reset the pose for this display, treating its current position and
  76514. * orientation as the "origin/zero" values. VRPose.position,
  76515. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76516. * updated when calling resetPose(). This should be called in only
  76517. * sitting-space experiences.
  76518. */
  76519. resetPose(): void;
  76520. /**
  76521. * The VRLayer provided to the VRDisplay will be captured and presented
  76522. * in the HMD. Calling this function has the same effect on the source
  76523. * canvas as any other operation that uses its source image, and canvases
  76524. * created without preserveDrawingBuffer set to true will be cleared.
  76525. * @param pose Define the pose to submit
  76526. */
  76527. submitFrame(pose?: VRPose): void;
  76528. }
  76529. declare var VRDisplay: {
  76530. prototype: VRDisplay;
  76531. new(): VRDisplay;
  76532. };
  76533. interface VRLayer {
  76534. leftBounds?: number[] | Float32Array | null;
  76535. rightBounds?: number[] | Float32Array | null;
  76536. source?: HTMLCanvasElement | null;
  76537. }
  76538. interface VRDisplayCapabilities {
  76539. readonly canPresent: boolean;
  76540. readonly hasExternalDisplay: boolean;
  76541. readonly hasOrientation: boolean;
  76542. readonly hasPosition: boolean;
  76543. readonly maxLayers: number;
  76544. }
  76545. interface VREyeParameters {
  76546. /** @deprecated */
  76547. readonly fieldOfView: VRFieldOfView;
  76548. readonly offset: Float32Array;
  76549. readonly renderHeight: number;
  76550. readonly renderWidth: number;
  76551. }
  76552. interface VRFieldOfView {
  76553. readonly downDegrees: number;
  76554. readonly leftDegrees: number;
  76555. readonly rightDegrees: number;
  76556. readonly upDegrees: number;
  76557. }
  76558. interface VRFrameData {
  76559. readonly leftProjectionMatrix: Float32Array;
  76560. readonly leftViewMatrix: Float32Array;
  76561. readonly pose: VRPose;
  76562. readonly rightProjectionMatrix: Float32Array;
  76563. readonly rightViewMatrix: Float32Array;
  76564. readonly timestamp: number;
  76565. }
  76566. interface VRPose {
  76567. readonly angularAcceleration: Float32Array | null;
  76568. readonly angularVelocity: Float32Array | null;
  76569. readonly linearAcceleration: Float32Array | null;
  76570. readonly linearVelocity: Float32Array | null;
  76571. readonly orientation: Float32Array | null;
  76572. readonly position: Float32Array | null;
  76573. readonly timestamp: number;
  76574. }
  76575. interface VRStageParameters {
  76576. sittingToStandingTransform?: Float32Array;
  76577. sizeX?: number;
  76578. sizeY?: number;
  76579. }
  76580. interface Navigator {
  76581. getVRDisplays(): Promise<VRDisplay[]>;
  76582. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76583. }
  76584. interface Window {
  76585. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76586. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76587. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76588. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76589. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76590. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76591. }
  76592. interface Gamepad {
  76593. readonly displayId: number;
  76594. }
  76595. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76596. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76597. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76598. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76599. type XRHandedness = "none" | "left" | "right";
  76600. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76601. type XREye = "none" | "left" | "right";
  76602. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76603. interface XRSpace extends EventTarget {}
  76604. interface XRRenderState {
  76605. depthNear?: number;
  76606. depthFar?: number;
  76607. inlineVerticalFieldOfView?: number;
  76608. baseLayer?: XRWebGLLayer;
  76609. }
  76610. interface XRInputSource {
  76611. handedness: XRHandedness;
  76612. targetRayMode: XRTargetRayMode;
  76613. targetRaySpace: XRSpace;
  76614. gripSpace: XRSpace | undefined;
  76615. gamepad: Gamepad | undefined;
  76616. profiles: Array<string>;
  76617. hand: XRHand | undefined;
  76618. }
  76619. interface XRSessionInit {
  76620. optionalFeatures?: string[];
  76621. requiredFeatures?: string[];
  76622. }
  76623. interface XRSession {
  76624. addEventListener: Function;
  76625. removeEventListener: Function;
  76626. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76627. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76628. requestAnimationFrame: Function;
  76629. end(): Promise<void>;
  76630. renderState: XRRenderState;
  76631. inputSources: Array<XRInputSource>;
  76632. // hit test
  76633. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76634. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76635. // legacy AR hit test
  76636. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76637. // legacy plane detection
  76638. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76639. }
  76640. interface XRReferenceSpace extends XRSpace {
  76641. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76642. onreset: any;
  76643. }
  76644. type XRPlaneSet = Set<XRPlane>;
  76645. type XRAnchorSet = Set<XRAnchor>;
  76646. interface XRFrame {
  76647. session: XRSession;
  76648. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76649. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76650. // AR
  76651. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76652. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76653. // Anchors
  76654. trackedAnchors?: XRAnchorSet;
  76655. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76656. // Planes
  76657. worldInformation: {
  76658. detectedPlanes?: XRPlaneSet;
  76659. };
  76660. // Hand tracking
  76661. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76662. }
  76663. interface XRViewerPose extends XRPose {
  76664. views: Array<XRView>;
  76665. }
  76666. interface XRPose {
  76667. transform: XRRigidTransform;
  76668. emulatedPosition: boolean;
  76669. }
  76670. interface XRWebGLLayerOptions {
  76671. antialias?: boolean;
  76672. depth?: boolean;
  76673. stencil?: boolean;
  76674. alpha?: boolean;
  76675. multiview?: boolean;
  76676. framebufferScaleFactor?: number;
  76677. }
  76678. declare var XRWebGLLayer: {
  76679. prototype: XRWebGLLayer;
  76680. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76681. };
  76682. interface XRWebGLLayer {
  76683. framebuffer: WebGLFramebuffer;
  76684. framebufferWidth: number;
  76685. framebufferHeight: number;
  76686. getViewport: Function;
  76687. }
  76688. declare class XRRigidTransform {
  76689. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76690. position: DOMPointReadOnly;
  76691. orientation: DOMPointReadOnly;
  76692. matrix: Float32Array;
  76693. inverse: XRRigidTransform;
  76694. }
  76695. interface XRView {
  76696. eye: XREye;
  76697. projectionMatrix: Float32Array;
  76698. transform: XRRigidTransform;
  76699. }
  76700. interface XRInputSourceChangeEvent {
  76701. session: XRSession;
  76702. removed: Array<XRInputSource>;
  76703. added: Array<XRInputSource>;
  76704. }
  76705. interface XRInputSourceEvent extends Event {
  76706. readonly frame: XRFrame;
  76707. readonly inputSource: XRInputSource;
  76708. }
  76709. // Experimental(er) features
  76710. declare class XRRay {
  76711. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76712. origin: DOMPointReadOnly;
  76713. direction: DOMPointReadOnly;
  76714. matrix: Float32Array;
  76715. }
  76716. declare enum XRHitTestTrackableType {
  76717. "point",
  76718. "plane",
  76719. "mesh",
  76720. }
  76721. interface XRHitResult {
  76722. hitMatrix: Float32Array;
  76723. }
  76724. interface XRTransientInputHitTestResult {
  76725. readonly inputSource: XRInputSource;
  76726. readonly results: Array<XRHitTestResult>;
  76727. }
  76728. interface XRHitTestResult {
  76729. getPose(baseSpace: XRSpace): XRPose | undefined;
  76730. // When anchor system is enabled
  76731. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76732. }
  76733. interface XRHitTestSource {
  76734. cancel(): void;
  76735. }
  76736. interface XRTransientInputHitTestSource {
  76737. cancel(): void;
  76738. }
  76739. interface XRHitTestOptionsInit {
  76740. space: XRSpace;
  76741. entityTypes?: Array<XRHitTestTrackableType>;
  76742. offsetRay?: XRRay;
  76743. }
  76744. interface XRTransientInputHitTestOptionsInit {
  76745. profile: string;
  76746. entityTypes?: Array<XRHitTestTrackableType>;
  76747. offsetRay?: XRRay;
  76748. }
  76749. interface XRAnchor {
  76750. anchorSpace: XRSpace;
  76751. delete(): void;
  76752. }
  76753. interface XRPlane {
  76754. orientation: "Horizontal" | "Vertical";
  76755. planeSpace: XRSpace;
  76756. polygon: Array<DOMPointReadOnly>;
  76757. lastChangedTime: number;
  76758. }
  76759. interface XRJointSpace extends XRSpace {}
  76760. interface XRJointPose extends XRPose {
  76761. radius: number | undefined;
  76762. }
  76763. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76764. readonly length: number;
  76765. [index: number]: XRJointSpace;
  76766. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76767. readonly WRIST: number;
  76768. readonly THUMB_METACARPAL: number;
  76769. readonly THUMB_PHALANX_PROXIMAL: number;
  76770. readonly THUMB_PHALANX_DISTAL: number;
  76771. readonly THUMB_PHALANX_TIP: number;
  76772. readonly INDEX_METACARPAL: number;
  76773. readonly INDEX_PHALANX_PROXIMAL: number;
  76774. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76775. readonly INDEX_PHALANX_DISTAL: number;
  76776. readonly INDEX_PHALANX_TIP: number;
  76777. readonly MIDDLE_METACARPAL: number;
  76778. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76779. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76780. readonly MIDDLE_PHALANX_DISTAL: number;
  76781. readonly MIDDLE_PHALANX_TIP: number;
  76782. readonly RING_METACARPAL: number;
  76783. readonly RING_PHALANX_PROXIMAL: number;
  76784. readonly RING_PHALANX_INTERMEDIATE: number;
  76785. readonly RING_PHALANX_DISTAL: number;
  76786. readonly RING_PHALANX_TIP: number;
  76787. readonly LITTLE_METACARPAL: number;
  76788. readonly LITTLE_PHALANX_PROXIMAL: number;
  76789. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76790. readonly LITTLE_PHALANX_DISTAL: number;
  76791. readonly LITTLE_PHALANX_TIP: number;
  76792. }
  76793. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76794. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76795. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76796. interface XRSession {
  76797. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76798. }
  76799. interface XRFrame {
  76800. featurePointCloud? : Array<number>;
  76801. }
  76802. /**
  76803. * @ignore
  76804. */
  76805. declare module BABYLON.GLTF2.Exporter {
  76806. }
  76807. /**
  76808. * @ignore
  76809. */
  76810. declare module BABYLON.GLTF1 {
  76811. }
  76812. declare module BABYLON.GUI {
  76813. /**
  76814. * Class used to specific a value and its associated unit
  76815. */
  76816. export class ValueAndUnit {
  76817. /** defines the unit to store */
  76818. unit: number;
  76819. /** defines a boolean indicating if the value can be negative */
  76820. negativeValueAllowed: boolean;
  76821. private _value;
  76822. private _originalUnit;
  76823. /**
  76824. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76825. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76826. */
  76827. ignoreAdaptiveScaling: boolean;
  76828. /**
  76829. * Creates a new ValueAndUnit
  76830. * @param value defines the value to store
  76831. * @param unit defines the unit to store
  76832. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76833. */
  76834. constructor(value: number,
  76835. /** defines the unit to store */
  76836. unit?: number,
  76837. /** defines a boolean indicating if the value can be negative */
  76838. negativeValueAllowed?: boolean);
  76839. /** Gets a boolean indicating if the value is a percentage */
  76840. get isPercentage(): boolean;
  76841. /** Gets a boolean indicating if the value is store as pixel */
  76842. get isPixel(): boolean;
  76843. /** Gets direct internal value */
  76844. get internalValue(): number;
  76845. /**
  76846. * Gets value as pixel
  76847. * @param host defines the root host
  76848. * @param refValue defines the reference value for percentages
  76849. * @returns the value as pixel
  76850. */
  76851. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76852. /**
  76853. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76854. * @param value defines the value to store
  76855. * @param unit defines the unit to store
  76856. * @returns the current ValueAndUnit
  76857. */
  76858. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76859. /**
  76860. * Gets the value accordingly to its unit
  76861. * @param host defines the root host
  76862. * @returns the value
  76863. */
  76864. getValue(host: AdvancedDynamicTexture): number;
  76865. /**
  76866. * Gets a string representation of the value
  76867. * @param host defines the root host
  76868. * @param decimals defines an optional number of decimals to display
  76869. * @returns a string
  76870. */
  76871. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76872. /**
  76873. * Store a value parsed from a string
  76874. * @param source defines the source string
  76875. * @returns true if the value was successfully parsed
  76876. */
  76877. fromString(source: string | number): boolean;
  76878. private static _Regex;
  76879. private static _UNITMODE_PERCENTAGE;
  76880. private static _UNITMODE_PIXEL;
  76881. /** UNITMODE_PERCENTAGE */
  76882. static get UNITMODE_PERCENTAGE(): number;
  76883. /** UNITMODE_PIXEL */
  76884. static get UNITMODE_PIXEL(): number;
  76885. }
  76886. }
  76887. declare module BABYLON.GUI {
  76888. /**
  76889. * Define a style used by control to automatically setup properties based on a template.
  76890. * Only support font related properties so far
  76891. */
  76892. export class Style implements BABYLON.IDisposable {
  76893. private _fontFamily;
  76894. private _fontStyle;
  76895. private _fontWeight;
  76896. /** @hidden */
  76897. _host: AdvancedDynamicTexture;
  76898. /** @hidden */
  76899. _fontSize: ValueAndUnit;
  76900. /**
  76901. * BABYLON.Observable raised when the style values are changed
  76902. */
  76903. onChangedObservable: BABYLON.Observable<Style>;
  76904. /**
  76905. * Creates a new style object
  76906. * @param host defines the AdvancedDynamicTexture which hosts this style
  76907. */
  76908. constructor(host: AdvancedDynamicTexture);
  76909. /**
  76910. * Gets or sets the font size
  76911. */
  76912. get fontSize(): string | number;
  76913. set fontSize(value: string | number);
  76914. /**
  76915. * Gets or sets the font family
  76916. */
  76917. get fontFamily(): string;
  76918. set fontFamily(value: string);
  76919. /**
  76920. * Gets or sets the font style
  76921. */
  76922. get fontStyle(): string;
  76923. set fontStyle(value: string);
  76924. /** Gets or sets font weight */
  76925. get fontWeight(): string;
  76926. set fontWeight(value: string);
  76927. /** Dispose all associated resources */
  76928. dispose(): void;
  76929. }
  76930. }
  76931. declare module BABYLON.GUI {
  76932. /**
  76933. * Class used to transport BABYLON.Vector2 information for pointer events
  76934. */
  76935. export class Vector2WithInfo extends BABYLON.Vector2 {
  76936. /** defines the current mouse button index */
  76937. buttonIndex: number;
  76938. /**
  76939. * Creates a new Vector2WithInfo
  76940. * @param source defines the vector2 data to transport
  76941. * @param buttonIndex defines the current mouse button index
  76942. */
  76943. constructor(source: BABYLON.Vector2,
  76944. /** defines the current mouse button index */
  76945. buttonIndex?: number);
  76946. }
  76947. /** Class used to provide 2D matrix features */
  76948. export class Matrix2D {
  76949. /** Gets the internal array of 6 floats used to store matrix data */
  76950. m: Float32Array;
  76951. /**
  76952. * Creates a new matrix
  76953. * @param m00 defines value for (0, 0)
  76954. * @param m01 defines value for (0, 1)
  76955. * @param m10 defines value for (1, 0)
  76956. * @param m11 defines value for (1, 1)
  76957. * @param m20 defines value for (2, 0)
  76958. * @param m21 defines value for (2, 1)
  76959. */
  76960. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76961. /**
  76962. * Fills the matrix from direct values
  76963. * @param m00 defines value for (0, 0)
  76964. * @param m01 defines value for (0, 1)
  76965. * @param m10 defines value for (1, 0)
  76966. * @param m11 defines value for (1, 1)
  76967. * @param m20 defines value for (2, 0)
  76968. * @param m21 defines value for (2, 1)
  76969. * @returns the current modified matrix
  76970. */
  76971. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76972. /**
  76973. * Gets matrix determinant
  76974. * @returns the determinant
  76975. */
  76976. determinant(): number;
  76977. /**
  76978. * Inverses the matrix and stores it in a target matrix
  76979. * @param result defines the target matrix
  76980. * @returns the current matrix
  76981. */
  76982. invertToRef(result: Matrix2D): Matrix2D;
  76983. /**
  76984. * Multiplies the current matrix with another one
  76985. * @param other defines the second operand
  76986. * @param result defines the target matrix
  76987. * @returns the current matrix
  76988. */
  76989. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76990. /**
  76991. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76992. * @param x defines the x coordinate to transform
  76993. * @param y defines the x coordinate to transform
  76994. * @param result defines the target vector2
  76995. * @returns the current matrix
  76996. */
  76997. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76998. /**
  76999. * Creates an identity matrix
  77000. * @returns a new matrix
  77001. */
  77002. static Identity(): Matrix2D;
  77003. /**
  77004. * Creates a translation matrix and stores it in a target matrix
  77005. * @param x defines the x coordinate of the translation
  77006. * @param y defines the y coordinate of the translation
  77007. * @param result defines the target matrix
  77008. */
  77009. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77010. /**
  77011. * Creates a scaling matrix and stores it in a target matrix
  77012. * @param x defines the x coordinate of the scaling
  77013. * @param y defines the y coordinate of the scaling
  77014. * @param result defines the target matrix
  77015. */
  77016. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77017. /**
  77018. * Creates a rotation matrix and stores it in a target matrix
  77019. * @param angle defines the rotation angle
  77020. * @param result defines the target matrix
  77021. */
  77022. static RotationToRef(angle: number, result: Matrix2D): void;
  77023. private static _TempPreTranslationMatrix;
  77024. private static _TempPostTranslationMatrix;
  77025. private static _TempRotationMatrix;
  77026. private static _TempScalingMatrix;
  77027. private static _TempCompose0;
  77028. private static _TempCompose1;
  77029. private static _TempCompose2;
  77030. /**
  77031. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77032. * @param tx defines the x coordinate of the translation
  77033. * @param ty defines the y coordinate of the translation
  77034. * @param angle defines the rotation angle
  77035. * @param scaleX defines the x coordinate of the scaling
  77036. * @param scaleY defines the y coordinate of the scaling
  77037. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77038. * @param result defines the target matrix
  77039. */
  77040. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77041. }
  77042. }
  77043. declare module BABYLON.GUI {
  77044. /**
  77045. * Class used to store 2D control sizes
  77046. */
  77047. export class Measure {
  77048. /** defines left coordinate */
  77049. left: number;
  77050. /** defines top coordinate */
  77051. top: number;
  77052. /** defines width dimension */
  77053. width: number;
  77054. /** defines height dimension */
  77055. height: number;
  77056. /**
  77057. * Creates a new measure
  77058. * @param left defines left coordinate
  77059. * @param top defines top coordinate
  77060. * @param width defines width dimension
  77061. * @param height defines height dimension
  77062. */
  77063. constructor(
  77064. /** defines left coordinate */
  77065. left: number,
  77066. /** defines top coordinate */
  77067. top: number,
  77068. /** defines width dimension */
  77069. width: number,
  77070. /** defines height dimension */
  77071. height: number);
  77072. /**
  77073. * Copy from another measure
  77074. * @param other defines the other measure to copy from
  77075. */
  77076. copyFrom(other: Measure): void;
  77077. /**
  77078. * Copy from a group of 4 floats
  77079. * @param left defines left coordinate
  77080. * @param top defines top coordinate
  77081. * @param width defines width dimension
  77082. * @param height defines height dimension
  77083. */
  77084. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77085. /**
  77086. * Computes the axis aligned bounding box measure for two given measures
  77087. * @param a Input measure
  77088. * @param b Input measure
  77089. * @param result the resulting bounding measure
  77090. */
  77091. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77092. /**
  77093. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77094. * @param transform the matrix to transform the measure before computing the AABB
  77095. * @param addX number to add to left
  77096. * @param addY number to add to top
  77097. * @param addWidth number to add to width
  77098. * @param addHeight number to add to height
  77099. * @param result the resulting AABB
  77100. */
  77101. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77102. /**
  77103. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77104. * @param transform the matrix to transform the measure before computing the AABB
  77105. * @param result the resulting AABB
  77106. */
  77107. transformToRef(transform: Matrix2D, result: Measure): void;
  77108. /**
  77109. * Check equality between this measure and another one
  77110. * @param other defines the other measures
  77111. * @returns true if both measures are equals
  77112. */
  77113. isEqualsTo(other: Measure): boolean;
  77114. /**
  77115. * Creates an empty measure
  77116. * @returns a new measure
  77117. */
  77118. static Empty(): Measure;
  77119. }
  77120. }
  77121. declare module BABYLON.GUI {
  77122. /**
  77123. * Interface used to define a control that can receive focus
  77124. */
  77125. export interface IFocusableControl {
  77126. /**
  77127. * Function called when the control receives the focus
  77128. */
  77129. onFocus(): void;
  77130. /**
  77131. * Function called when the control loses the focus
  77132. */
  77133. onBlur(): void;
  77134. /**
  77135. * Function called to let the control handle keyboard events
  77136. * @param evt defines the current keyboard event
  77137. */
  77138. processKeyboard(evt: KeyboardEvent): void;
  77139. /**
  77140. * Function called to get the list of controls that should not steal the focus from this control
  77141. * @returns an array of controls
  77142. */
  77143. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77144. }
  77145. /**
  77146. * Class used to create texture to support 2D GUI elements
  77147. * @see https://doc.babylonjs.com/how_to/gui
  77148. */
  77149. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77150. private _isDirty;
  77151. private _renderObserver;
  77152. private _resizeObserver;
  77153. private _preKeyboardObserver;
  77154. private _pointerMoveObserver;
  77155. private _pointerObserver;
  77156. private _canvasPointerOutObserver;
  77157. private _canvasBlurObserver;
  77158. private _background;
  77159. /** @hidden */
  77160. _rootContainer: Container;
  77161. /** @hidden */
  77162. _lastPickedControl: Control;
  77163. /** @hidden */
  77164. _lastControlOver: {
  77165. [pointerId: number]: Control;
  77166. };
  77167. /** @hidden */
  77168. _lastControlDown: {
  77169. [pointerId: number]: Control;
  77170. };
  77171. /** @hidden */
  77172. _capturingControl: {
  77173. [pointerId: number]: Control;
  77174. };
  77175. /** @hidden */
  77176. _shouldBlockPointer: boolean;
  77177. /** @hidden */
  77178. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77179. /** @hidden */
  77180. _linkedControls: Control[];
  77181. private _isFullscreen;
  77182. private _fullscreenViewport;
  77183. private _idealWidth;
  77184. private _idealHeight;
  77185. private _useSmallestIdeal;
  77186. private _renderAtIdealSize;
  77187. private _focusedControl;
  77188. private _blockNextFocusCheck;
  77189. private _renderScale;
  77190. private _rootElement;
  77191. private _cursorChanged;
  77192. private _defaultMousePointerId;
  77193. /** @hidden */
  77194. _numLayoutCalls: number;
  77195. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77196. get numLayoutCalls(): number;
  77197. /** @hidden */
  77198. _numRenderCalls: number;
  77199. /** Gets the number of render calls made the last time the ADT has been rendered */
  77200. get numRenderCalls(): number;
  77201. /**
  77202. * Define type to string to ensure compatibility across browsers
  77203. * Safari doesn't support DataTransfer constructor
  77204. */
  77205. private _clipboardData;
  77206. /**
  77207. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77208. */
  77209. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77210. /**
  77211. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77212. */
  77213. onControlPickedObservable: BABYLON.Observable<Control>;
  77214. /**
  77215. * BABYLON.Observable event triggered before layout is evaluated
  77216. */
  77217. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77218. /**
  77219. * BABYLON.Observable event triggered after the layout was evaluated
  77220. */
  77221. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77222. /**
  77223. * BABYLON.Observable event triggered before the texture is rendered
  77224. */
  77225. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77226. /**
  77227. * BABYLON.Observable event triggered after the texture was rendered
  77228. */
  77229. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77230. /**
  77231. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77232. */
  77233. premulAlpha: boolean;
  77234. /**
  77235. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77236. * Useful when you want more antialiasing
  77237. */
  77238. get renderScale(): number;
  77239. set renderScale(value: number);
  77240. /** Gets or sets the background color */
  77241. get background(): string;
  77242. set background(value: string);
  77243. /**
  77244. * Gets or sets the ideal width used to design controls.
  77245. * The GUI will then rescale everything accordingly
  77246. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77247. */
  77248. get idealWidth(): number;
  77249. set idealWidth(value: number);
  77250. /**
  77251. * Gets or sets the ideal height used to design controls.
  77252. * The GUI will then rescale everything accordingly
  77253. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77254. */
  77255. get idealHeight(): number;
  77256. set idealHeight(value: number);
  77257. /**
  77258. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77259. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77260. */
  77261. get useSmallestIdeal(): boolean;
  77262. set useSmallestIdeal(value: boolean);
  77263. /**
  77264. * Gets or sets a boolean indicating if adaptive scaling must be used
  77265. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77266. */
  77267. get renderAtIdealSize(): boolean;
  77268. set renderAtIdealSize(value: boolean);
  77269. /**
  77270. * Gets the ratio used when in "ideal mode"
  77271. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77272. * */
  77273. get idealRatio(): number;
  77274. /**
  77275. * Gets the underlying layer used to render the texture when in fullscreen mode
  77276. */
  77277. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77278. /**
  77279. * Gets the root container control
  77280. */
  77281. get rootContainer(): Container;
  77282. /**
  77283. * Returns an array containing the root container.
  77284. * This is mostly used to let the Inspector introspects the ADT
  77285. * @returns an array containing the rootContainer
  77286. */
  77287. getChildren(): Array<Container>;
  77288. /**
  77289. * Will return all controls that are inside this texture
  77290. * @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
  77291. * @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
  77292. * @return all child controls
  77293. */
  77294. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77295. /**
  77296. * Gets or sets the current focused control
  77297. */
  77298. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77299. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77300. /**
  77301. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77302. */
  77303. get isForeground(): boolean;
  77304. set isForeground(value: boolean);
  77305. /**
  77306. * Gets or set information about clipboardData
  77307. */
  77308. get clipboardData(): string;
  77309. set clipboardData(value: string);
  77310. /**
  77311. * Creates a new AdvancedDynamicTexture
  77312. * @param name defines the name of the texture
  77313. * @param width defines the width of the texture
  77314. * @param height defines the height of the texture
  77315. * @param scene defines the hosting scene
  77316. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77317. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77318. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77319. */
  77320. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77321. /**
  77322. * Get the current class name of the texture useful for serialization or dynamic coding.
  77323. * @returns "AdvancedDynamicTexture"
  77324. */
  77325. getClassName(): string;
  77326. /**
  77327. * Function used to execute a function on all controls
  77328. * @param func defines the function to execute
  77329. * @param container defines the container where controls belong. If null the root container will be used
  77330. */
  77331. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77332. private _useInvalidateRectOptimization;
  77333. /**
  77334. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77335. */
  77336. get useInvalidateRectOptimization(): boolean;
  77337. set useInvalidateRectOptimization(value: boolean);
  77338. private _invalidatedRectangle;
  77339. /**
  77340. * Invalidates a rectangle area on the gui texture
  77341. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77342. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77343. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77344. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77345. */
  77346. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77347. /**
  77348. * Marks the texture as dirty forcing a complete update
  77349. */
  77350. markAsDirty(): void;
  77351. /**
  77352. * Helper function used to create a new style
  77353. * @returns a new style
  77354. * @see https://doc.babylonjs.com/how_to/gui#styles
  77355. */
  77356. createStyle(): Style;
  77357. /**
  77358. * Adds a new control to the root container
  77359. * @param control defines the control to add
  77360. * @returns the current texture
  77361. */
  77362. addControl(control: Control): AdvancedDynamicTexture;
  77363. /**
  77364. * Removes a control from the root container
  77365. * @param control defines the control to remove
  77366. * @returns the current texture
  77367. */
  77368. removeControl(control: Control): AdvancedDynamicTexture;
  77369. /**
  77370. * Release all resources
  77371. */
  77372. dispose(): void;
  77373. private _onResize;
  77374. /** @hidden */
  77375. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77376. /**
  77377. * Get screen coordinates for a vector3
  77378. * @param position defines the position to project
  77379. * @param worldMatrix defines the world matrix to use
  77380. * @returns the projected position
  77381. */
  77382. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77383. private _checkUpdate;
  77384. private _clearMeasure;
  77385. private _render;
  77386. /** @hidden */
  77387. _changeCursor(cursor: string): void;
  77388. /** @hidden */
  77389. _registerLastControlDown(control: Control, pointerId: number): void;
  77390. private _doPicking;
  77391. /** @hidden */
  77392. _cleanControlAfterRemovalFromList(list: {
  77393. [pointerId: number]: Control;
  77394. }, control: Control): void;
  77395. /** @hidden */
  77396. _cleanControlAfterRemoval(control: Control): void;
  77397. /** Attach to all scene events required to support pointer events */
  77398. attach(): void;
  77399. /** @hidden */
  77400. private onClipboardCopy;
  77401. /** @hidden */
  77402. private onClipboardCut;
  77403. /** @hidden */
  77404. private onClipboardPaste;
  77405. /**
  77406. * Register the clipboard Events onto the canvas
  77407. */
  77408. registerClipboardEvents(): void;
  77409. /**
  77410. * Unregister the clipboard Events from the canvas
  77411. */
  77412. unRegisterClipboardEvents(): void;
  77413. /**
  77414. * Connect the texture to a hosting mesh to enable interactions
  77415. * @param mesh defines the mesh to attach to
  77416. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77417. */
  77418. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77419. /**
  77420. * Move the focus to a specific control
  77421. * @param control defines the control which will receive the focus
  77422. */
  77423. moveFocusToControl(control: IFocusableControl): void;
  77424. private _manageFocus;
  77425. private _attachToOnPointerOut;
  77426. private _attachToOnBlur;
  77427. /**
  77428. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77429. * @param mesh defines the mesh which will receive the texture
  77430. * @param width defines the texture width (1024 by default)
  77431. * @param height defines the texture height (1024 by default)
  77432. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77433. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77434. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77435. * @returns a new AdvancedDynamicTexture
  77436. */
  77437. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77438. /**
  77439. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77440. * In this mode the texture will rely on a layer for its rendering.
  77441. * This allows it to be treated like any other layer.
  77442. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77443. * LayerMask is set through advancedTexture.layer.layerMask
  77444. * @param name defines name for the texture
  77445. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77446. * @param scene defines the hsoting scene
  77447. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77448. * @returns a new AdvancedDynamicTexture
  77449. */
  77450. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77451. }
  77452. }
  77453. declare module BABYLON.GUI {
  77454. /**
  77455. * Root class used for all 2D controls
  77456. * @see https://doc.babylonjs.com/how_to/gui#controls
  77457. */
  77458. export class Control {
  77459. /** defines the name of the control */
  77460. name?: string | undefined;
  77461. /**
  77462. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77463. */
  77464. static AllowAlphaInheritance: boolean;
  77465. private _alpha;
  77466. private _alphaSet;
  77467. private _zIndex;
  77468. /** @hidden */
  77469. _host: AdvancedDynamicTexture;
  77470. /** Gets or sets the control parent */
  77471. parent: BABYLON.Nullable<Container>;
  77472. /** @hidden */
  77473. _currentMeasure: Measure;
  77474. private _fontFamily;
  77475. private _fontStyle;
  77476. private _fontWeight;
  77477. private _fontSize;
  77478. private _font;
  77479. /** @hidden */
  77480. _width: ValueAndUnit;
  77481. /** @hidden */
  77482. _height: ValueAndUnit;
  77483. /** @hidden */
  77484. protected _fontOffset: {
  77485. ascent: number;
  77486. height: number;
  77487. descent: number;
  77488. };
  77489. private _color;
  77490. private _style;
  77491. private _styleObserver;
  77492. /** @hidden */
  77493. protected _horizontalAlignment: number;
  77494. /** @hidden */
  77495. protected _verticalAlignment: number;
  77496. /** @hidden */
  77497. protected _isDirty: boolean;
  77498. /** @hidden */
  77499. protected _wasDirty: boolean;
  77500. /** @hidden */
  77501. _tempParentMeasure: Measure;
  77502. /** @hidden */
  77503. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77504. /** @hidden */
  77505. protected _cachedParentMeasure: Measure;
  77506. private _paddingLeft;
  77507. private _paddingRight;
  77508. private _paddingTop;
  77509. private _paddingBottom;
  77510. /** @hidden */
  77511. _left: ValueAndUnit;
  77512. /** @hidden */
  77513. _top: ValueAndUnit;
  77514. private _scaleX;
  77515. private _scaleY;
  77516. private _rotation;
  77517. private _transformCenterX;
  77518. private _transformCenterY;
  77519. /** @hidden */
  77520. _transformMatrix: Matrix2D;
  77521. /** @hidden */
  77522. protected _invertTransformMatrix: Matrix2D;
  77523. /** @hidden */
  77524. protected _transformedPosition: BABYLON.Vector2;
  77525. private _isMatrixDirty;
  77526. private _cachedOffsetX;
  77527. private _cachedOffsetY;
  77528. private _isVisible;
  77529. private _isHighlighted;
  77530. /** @hidden */
  77531. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77532. private _fontSet;
  77533. private _dummyVector2;
  77534. private _downCount;
  77535. private _enterCount;
  77536. private _doNotRender;
  77537. private _downPointerIds;
  77538. protected _isEnabled: boolean;
  77539. protected _disabledColor: string;
  77540. protected _disabledColorItem: string;
  77541. /** @hidden */
  77542. protected _rebuildLayout: boolean;
  77543. /** @hidden */
  77544. _customData: any;
  77545. /** @hidden */
  77546. _isClipped: boolean;
  77547. /** @hidden */
  77548. _automaticSize: boolean;
  77549. /** @hidden */
  77550. _tag: any;
  77551. /**
  77552. * 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
  77553. */
  77554. uniqueId: number;
  77555. /**
  77556. * Gets or sets an object used to store user defined information for the node
  77557. */
  77558. metadata: any;
  77559. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77560. isHitTestVisible: boolean;
  77561. /** Gets or sets a boolean indicating if the control can block pointer events */
  77562. isPointerBlocker: boolean;
  77563. /** Gets or sets a boolean indicating if the control can be focusable */
  77564. isFocusInvisible: boolean;
  77565. /**
  77566. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77567. * 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
  77568. */
  77569. clipChildren: boolean;
  77570. /**
  77571. * Gets or sets a boolean indicating that control content must be clipped
  77572. * 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
  77573. */
  77574. clipContent: boolean;
  77575. /**
  77576. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77577. */
  77578. useBitmapCache: boolean;
  77579. private _cacheData;
  77580. private _shadowOffsetX;
  77581. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77582. get shadowOffsetX(): number;
  77583. set shadowOffsetX(value: number);
  77584. private _shadowOffsetY;
  77585. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77586. get shadowOffsetY(): number;
  77587. set shadowOffsetY(value: number);
  77588. private _shadowBlur;
  77589. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77590. get shadowBlur(): number;
  77591. set shadowBlur(value: number);
  77592. private _shadowColor;
  77593. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77594. get shadowColor(): string;
  77595. set shadowColor(value: string);
  77596. /** Gets or sets the cursor to use when the control is hovered */
  77597. hoverCursor: string;
  77598. /** @hidden */
  77599. protected _linkOffsetX: ValueAndUnit;
  77600. /** @hidden */
  77601. protected _linkOffsetY: ValueAndUnit;
  77602. /** Gets the control type name */
  77603. get typeName(): string;
  77604. /**
  77605. * Get the current class name of the control.
  77606. * @returns current class name
  77607. */
  77608. getClassName(): string;
  77609. /**
  77610. * An event triggered when pointer wheel is scrolled
  77611. */
  77612. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77613. /**
  77614. * An event triggered when the pointer move over the control.
  77615. */
  77616. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77617. /**
  77618. * An event triggered when the pointer move out of the control.
  77619. */
  77620. onPointerOutObservable: BABYLON.Observable<Control>;
  77621. /**
  77622. * An event triggered when the pointer taps the control
  77623. */
  77624. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77625. /**
  77626. * An event triggered when pointer up
  77627. */
  77628. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77629. /**
  77630. * An event triggered when a control is clicked on
  77631. */
  77632. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77633. /**
  77634. * An event triggered when pointer enters the control
  77635. */
  77636. onPointerEnterObservable: BABYLON.Observable<Control>;
  77637. /**
  77638. * An event triggered when the control is marked as dirty
  77639. */
  77640. onDirtyObservable: BABYLON.Observable<Control>;
  77641. /**
  77642. * An event triggered before drawing the control
  77643. */
  77644. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77645. /**
  77646. * An event triggered after the control was drawn
  77647. */
  77648. onAfterDrawObservable: BABYLON.Observable<Control>;
  77649. /**
  77650. * An event triggered when the control has been disposed
  77651. */
  77652. onDisposeObservable: BABYLON.Observable<Control>;
  77653. /**
  77654. * Get the hosting AdvancedDynamicTexture
  77655. */
  77656. get host(): AdvancedDynamicTexture;
  77657. /** Gets or set information about font offsets (used to render and align text) */
  77658. get fontOffset(): {
  77659. ascent: number;
  77660. height: number;
  77661. descent: number;
  77662. };
  77663. set fontOffset(offset: {
  77664. ascent: number;
  77665. height: number;
  77666. descent: number;
  77667. });
  77668. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77669. get alpha(): number;
  77670. set alpha(value: number);
  77671. /**
  77672. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77673. */
  77674. get isHighlighted(): boolean;
  77675. set isHighlighted(value: boolean);
  77676. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77677. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77678. */
  77679. get scaleX(): number;
  77680. set scaleX(value: number);
  77681. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77682. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77683. */
  77684. get scaleY(): number;
  77685. set scaleY(value: number);
  77686. /** Gets or sets the rotation angle (0 by default)
  77687. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77688. */
  77689. get rotation(): number;
  77690. set rotation(value: number);
  77691. /** Gets or sets the transformation center on Y axis (0 by default)
  77692. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77693. */
  77694. get transformCenterY(): number;
  77695. set transformCenterY(value: number);
  77696. /** Gets or sets the transformation center on X axis (0 by default)
  77697. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77698. */
  77699. get transformCenterX(): number;
  77700. set transformCenterX(value: number);
  77701. /**
  77702. * Gets or sets the horizontal alignment
  77703. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77704. */
  77705. get horizontalAlignment(): number;
  77706. set horizontalAlignment(value: number);
  77707. /**
  77708. * Gets or sets the vertical alignment
  77709. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77710. */
  77711. get verticalAlignment(): number;
  77712. set verticalAlignment(value: number);
  77713. /**
  77714. * Gets or sets a fixed ratio for this control.
  77715. * When different from 0, the ratio is used to compute the "second" dimension.
  77716. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77717. * second dimension is computed as first dimension * fixedRatio
  77718. */
  77719. fixedRatio: number;
  77720. private _fixedRatioMasterIsWidth;
  77721. /**
  77722. * Gets or sets control width
  77723. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77724. */
  77725. get width(): string | number;
  77726. set width(value: string | number);
  77727. /**
  77728. * Gets or sets the control width in pixel
  77729. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77730. */
  77731. get widthInPixels(): number;
  77732. set widthInPixels(value: number);
  77733. /**
  77734. * Gets or sets control height
  77735. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77736. */
  77737. get height(): string | number;
  77738. set height(value: string | number);
  77739. /**
  77740. * Gets or sets control height in pixel
  77741. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77742. */
  77743. get heightInPixels(): number;
  77744. set heightInPixels(value: number);
  77745. /** Gets or set font family */
  77746. get fontFamily(): string;
  77747. set fontFamily(value: string);
  77748. /** Gets or sets font style */
  77749. get fontStyle(): string;
  77750. set fontStyle(value: string);
  77751. /** Gets or sets font weight */
  77752. get fontWeight(): string;
  77753. set fontWeight(value: string);
  77754. /**
  77755. * Gets or sets style
  77756. * @see https://doc.babylonjs.com/how_to/gui#styles
  77757. */
  77758. get style(): BABYLON.Nullable<Style>;
  77759. set style(value: BABYLON.Nullable<Style>);
  77760. /** @hidden */
  77761. get _isFontSizeInPercentage(): boolean;
  77762. /** Gets or sets font size in pixels */
  77763. get fontSizeInPixels(): number;
  77764. set fontSizeInPixels(value: number);
  77765. /** Gets or sets font size */
  77766. get fontSize(): string | number;
  77767. set fontSize(value: string | number);
  77768. /** Gets or sets foreground color */
  77769. get color(): string;
  77770. set color(value: string);
  77771. /** Gets or sets z index which is used to reorder controls on the z axis */
  77772. get zIndex(): number;
  77773. set zIndex(value: number);
  77774. /** Gets or sets a boolean indicating if the control can be rendered */
  77775. get notRenderable(): boolean;
  77776. set notRenderable(value: boolean);
  77777. /** Gets or sets a boolean indicating if the control is visible */
  77778. get isVisible(): boolean;
  77779. set isVisible(value: boolean);
  77780. /** Gets a boolean indicating that the control needs to update its rendering */
  77781. get isDirty(): boolean;
  77782. /**
  77783. * Gets the current linked mesh (or null if none)
  77784. */
  77785. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77786. /**
  77787. * Gets or sets a value indicating the padding to use on the left of the control
  77788. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77789. */
  77790. get paddingLeft(): string | number;
  77791. set paddingLeft(value: string | number);
  77792. /**
  77793. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77794. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77795. */
  77796. get paddingLeftInPixels(): number;
  77797. set paddingLeftInPixels(value: number);
  77798. /**
  77799. * Gets or sets a value indicating the padding to use on the right of the control
  77800. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77801. */
  77802. get paddingRight(): string | number;
  77803. set paddingRight(value: string | number);
  77804. /**
  77805. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77806. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77807. */
  77808. get paddingRightInPixels(): number;
  77809. set paddingRightInPixels(value: number);
  77810. /**
  77811. * Gets or sets a value indicating the padding to use on the top of the control
  77812. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77813. */
  77814. get paddingTop(): string | number;
  77815. set paddingTop(value: string | number);
  77816. /**
  77817. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77818. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77819. */
  77820. get paddingTopInPixels(): number;
  77821. set paddingTopInPixels(value: number);
  77822. /**
  77823. * Gets or sets a value indicating the padding to use on the bottom of the control
  77824. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77825. */
  77826. get paddingBottom(): string | number;
  77827. set paddingBottom(value: string | number);
  77828. /**
  77829. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77830. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77831. */
  77832. get paddingBottomInPixels(): number;
  77833. set paddingBottomInPixels(value: number);
  77834. /**
  77835. * Gets or sets a value indicating the left coordinate of the control
  77836. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77837. */
  77838. get left(): string | number;
  77839. set left(value: string | number);
  77840. /**
  77841. * Gets or sets a value indicating the left coordinate in pixels of the control
  77842. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77843. */
  77844. get leftInPixels(): number;
  77845. set leftInPixels(value: number);
  77846. /**
  77847. * Gets or sets a value indicating the top coordinate of the control
  77848. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77849. */
  77850. get top(): string | number;
  77851. set top(value: string | number);
  77852. /**
  77853. * Gets or sets a value indicating the top coordinate in pixels of the control
  77854. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77855. */
  77856. get topInPixels(): number;
  77857. set topInPixels(value: number);
  77858. /**
  77859. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77860. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77861. */
  77862. get linkOffsetX(): string | number;
  77863. set linkOffsetX(value: string | number);
  77864. /**
  77865. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77866. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77867. */
  77868. get linkOffsetXInPixels(): number;
  77869. set linkOffsetXInPixels(value: number);
  77870. /**
  77871. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77872. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77873. */
  77874. get linkOffsetY(): string | number;
  77875. set linkOffsetY(value: string | number);
  77876. /**
  77877. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77878. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77879. */
  77880. get linkOffsetYInPixels(): number;
  77881. set linkOffsetYInPixels(value: number);
  77882. /** Gets the center coordinate on X axis */
  77883. get centerX(): number;
  77884. /** Gets the center coordinate on Y axis */
  77885. get centerY(): number;
  77886. /** Gets or sets if control is Enabled*/
  77887. get isEnabled(): boolean;
  77888. set isEnabled(value: boolean);
  77889. /** Gets or sets background color of control if it's disabled*/
  77890. get disabledColor(): string;
  77891. set disabledColor(value: string);
  77892. /** Gets or sets front color of control if it's disabled*/
  77893. get disabledColorItem(): string;
  77894. set disabledColorItem(value: string);
  77895. /**
  77896. * Creates a new control
  77897. * @param name defines the name of the control
  77898. */
  77899. constructor(
  77900. /** defines the name of the control */
  77901. name?: string | undefined);
  77902. /** @hidden */
  77903. protected _getTypeName(): string;
  77904. /**
  77905. * Gets the first ascendant in the hierarchy of the given type
  77906. * @param className defines the required type
  77907. * @returns the ascendant or null if not found
  77908. */
  77909. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77910. /** @hidden */
  77911. _resetFontCache(): void;
  77912. /**
  77913. * Determines if a container is an ascendant of the current control
  77914. * @param container defines the container to look for
  77915. * @returns true if the container is one of the ascendant of the control
  77916. */
  77917. isAscendant(container: Control): boolean;
  77918. /**
  77919. * Gets coordinates in local control space
  77920. * @param globalCoordinates defines the coordinates to transform
  77921. * @returns the new coordinates in local space
  77922. */
  77923. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77924. /**
  77925. * Gets coordinates in local control space
  77926. * @param globalCoordinates defines the coordinates to transform
  77927. * @param result defines the target vector2 where to store the result
  77928. * @returns the current control
  77929. */
  77930. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77931. /**
  77932. * Gets coordinates in parent local control space
  77933. * @param globalCoordinates defines the coordinates to transform
  77934. * @returns the new coordinates in parent local space
  77935. */
  77936. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77937. /**
  77938. * Move the current control to a vector3 position projected onto the screen.
  77939. * @param position defines the target position
  77940. * @param scene defines the hosting scene
  77941. */
  77942. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77943. /**
  77944. * Will store all controls that have this control as ascendant in a given array
  77945. * @param results defines the array where to store the descendants
  77946. * @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
  77947. * @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
  77948. */
  77949. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77950. /**
  77951. * Will return all controls that have this control as ascendant
  77952. * @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
  77953. * @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
  77954. * @return all child controls
  77955. */
  77956. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77957. /**
  77958. * Link current control with a target mesh
  77959. * @param mesh defines the mesh to link with
  77960. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77961. */
  77962. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77963. /** @hidden */
  77964. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77965. /** @hidden */
  77966. _offsetLeft(offset: number): void;
  77967. /** @hidden */
  77968. _offsetTop(offset: number): void;
  77969. /** @hidden */
  77970. _markMatrixAsDirty(): void;
  77971. /** @hidden */
  77972. _flagDescendantsAsMatrixDirty(): void;
  77973. /** @hidden */
  77974. _intersectsRect(rect: Measure): boolean;
  77975. /** @hidden */
  77976. protected invalidateRect(): void;
  77977. /** @hidden */
  77978. _markAsDirty(force?: boolean): void;
  77979. /** @hidden */
  77980. _markAllAsDirty(): void;
  77981. /** @hidden */
  77982. _link(host: AdvancedDynamicTexture): void;
  77983. /** @hidden */
  77984. protected _transform(context?: CanvasRenderingContext2D): void;
  77985. /** @hidden */
  77986. _renderHighlight(context: CanvasRenderingContext2D): void;
  77987. /** @hidden */
  77988. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77989. /** @hidden */
  77990. protected _applyStates(context: CanvasRenderingContext2D): void;
  77991. /** @hidden */
  77992. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77993. /** @hidden */
  77994. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77995. protected _evaluateClippingState(parentMeasure: Measure): void;
  77996. /** @hidden */
  77997. _measure(): void;
  77998. /** @hidden */
  77999. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78000. /** @hidden */
  78001. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78002. /** @hidden */
  78003. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78004. /** @hidden */
  78005. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78006. private static _ClipMeasure;
  78007. private _tmpMeasureA;
  78008. private _clip;
  78009. /** @hidden */
  78010. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78011. /** @hidden */
  78012. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78013. /**
  78014. * Tests if a given coordinates belong to the current control
  78015. * @param x defines x coordinate to test
  78016. * @param y defines y coordinate to test
  78017. * @returns true if the coordinates are inside the control
  78018. */
  78019. contains(x: number, y: number): boolean;
  78020. /** @hidden */
  78021. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78022. /** @hidden */
  78023. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78024. /** @hidden */
  78025. _onPointerEnter(target: Control): boolean;
  78026. /** @hidden */
  78027. _onPointerOut(target: Control, force?: boolean): void;
  78028. /** @hidden */
  78029. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78030. /** @hidden */
  78031. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78032. /** @hidden */
  78033. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78034. /** @hidden */
  78035. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78036. /** @hidden */
  78037. _onCanvasBlur(): void;
  78038. /** @hidden */
  78039. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78040. private _prepareFont;
  78041. /** Releases associated resources */
  78042. dispose(): void;
  78043. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78044. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78045. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78046. private static _VERTICAL_ALIGNMENT_TOP;
  78047. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78048. private static _VERTICAL_ALIGNMENT_CENTER;
  78049. /** HORIZONTAL_ALIGNMENT_LEFT */
  78050. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78051. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78052. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78053. /** HORIZONTAL_ALIGNMENT_CENTER */
  78054. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78055. /** VERTICAL_ALIGNMENT_TOP */
  78056. static get VERTICAL_ALIGNMENT_TOP(): number;
  78057. /** VERTICAL_ALIGNMENT_BOTTOM */
  78058. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78059. /** VERTICAL_ALIGNMENT_CENTER */
  78060. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78061. private static _FontHeightSizes;
  78062. /** @hidden */
  78063. static _GetFontOffset(font: string): {
  78064. ascent: number;
  78065. height: number;
  78066. descent: number;
  78067. };
  78068. /**
  78069. * Creates a stack panel that can be used to render headers
  78070. * @param control defines the control to associate with the header
  78071. * @param text defines the text of the header
  78072. * @param size defines the size of the header
  78073. * @param options defines options used to configure the header
  78074. * @returns a new StackPanel
  78075. * @ignore
  78076. * @hidden
  78077. */
  78078. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78079. isHorizontal: boolean;
  78080. controlFirst: boolean;
  78081. }) => any;
  78082. /** @hidden */
  78083. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78084. }
  78085. }
  78086. declare module BABYLON.GUI {
  78087. /**
  78088. * Root class for 2D containers
  78089. * @see https://doc.babylonjs.com/how_to/gui#containers
  78090. */
  78091. export class Container extends Control {
  78092. name?: string | undefined;
  78093. /** @hidden */
  78094. _children: Control[];
  78095. /** @hidden */
  78096. protected _measureForChildren: Measure;
  78097. /** @hidden */
  78098. protected _background: string;
  78099. /** @hidden */
  78100. protected _adaptWidthToChildren: boolean;
  78101. /** @hidden */
  78102. protected _adaptHeightToChildren: boolean;
  78103. /**
  78104. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78105. */
  78106. logLayoutCycleErrors: boolean;
  78107. /**
  78108. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78109. */
  78110. maxLayoutCycle: number;
  78111. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78112. get adaptHeightToChildren(): boolean;
  78113. set adaptHeightToChildren(value: boolean);
  78114. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78115. get adaptWidthToChildren(): boolean;
  78116. set adaptWidthToChildren(value: boolean);
  78117. /** Gets or sets background color */
  78118. get background(): string;
  78119. set background(value: string);
  78120. /** Gets the list of children */
  78121. get children(): Control[];
  78122. /**
  78123. * Creates a new Container
  78124. * @param name defines the name of the container
  78125. */
  78126. constructor(name?: string | undefined);
  78127. protected _getTypeName(): string;
  78128. _flagDescendantsAsMatrixDirty(): void;
  78129. /**
  78130. * Gets a child using its name
  78131. * @param name defines the child name to look for
  78132. * @returns the child control if found
  78133. */
  78134. getChildByName(name: string): BABYLON.Nullable<Control>;
  78135. /**
  78136. * Gets a child using its type and its name
  78137. * @param name defines the child name to look for
  78138. * @param type defines the child type to look for
  78139. * @returns the child control if found
  78140. */
  78141. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78142. /**
  78143. * Search for a specific control in children
  78144. * @param control defines the control to look for
  78145. * @returns true if the control is in child list
  78146. */
  78147. containsControl(control: Control): boolean;
  78148. /**
  78149. * Adds a new control to the current container
  78150. * @param control defines the control to add
  78151. * @returns the current container
  78152. */
  78153. addControl(control: BABYLON.Nullable<Control>): Container;
  78154. /**
  78155. * Removes all controls from the current container
  78156. * @returns the current container
  78157. */
  78158. clearControls(): Container;
  78159. /**
  78160. * Removes a control from the current container
  78161. * @param control defines the control to remove
  78162. * @returns the current container
  78163. */
  78164. removeControl(control: Control): Container;
  78165. /** @hidden */
  78166. _reOrderControl(control: Control): void;
  78167. /** @hidden */
  78168. _offsetLeft(offset: number): void;
  78169. /** @hidden */
  78170. _offsetTop(offset: number): void;
  78171. /** @hidden */
  78172. _markAllAsDirty(): void;
  78173. /** @hidden */
  78174. protected _localDraw(context: CanvasRenderingContext2D): void;
  78175. /** @hidden */
  78176. _link(host: AdvancedDynamicTexture): void;
  78177. /** @hidden */
  78178. protected _beforeLayout(): void;
  78179. /** @hidden */
  78180. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78181. /** @hidden */
  78182. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78183. protected _postMeasure(): void;
  78184. /** @hidden */
  78185. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78186. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78187. /** @hidden */
  78188. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78189. /** @hidden */
  78190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78191. /** Releases associated resources */
  78192. dispose(): void;
  78193. }
  78194. }
  78195. declare module BABYLON.GUI {
  78196. /** Class used to create rectangle container */
  78197. export class Rectangle extends Container {
  78198. name?: string | undefined;
  78199. private _thickness;
  78200. private _cornerRadius;
  78201. /** Gets or sets border thickness */
  78202. get thickness(): number;
  78203. set thickness(value: number);
  78204. /** Gets or sets the corner radius angle */
  78205. get cornerRadius(): number;
  78206. set cornerRadius(value: number);
  78207. /**
  78208. * Creates a new Rectangle
  78209. * @param name defines the control name
  78210. */
  78211. constructor(name?: string | undefined);
  78212. protected _getTypeName(): string;
  78213. protected _localDraw(context: CanvasRenderingContext2D): void;
  78214. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78215. private _drawRoundedRect;
  78216. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78217. }
  78218. }
  78219. declare module BABYLON.GUI {
  78220. /**
  78221. * Enum that determines the text-wrapping mode to use.
  78222. */
  78223. export enum TextWrapping {
  78224. /**
  78225. * Clip the text when it's larger than Control.width; this is the default mode.
  78226. */
  78227. Clip = 0,
  78228. /**
  78229. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78230. */
  78231. WordWrap = 1,
  78232. /**
  78233. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78234. */
  78235. Ellipsis = 2
  78236. }
  78237. /**
  78238. * Class used to create text block control
  78239. */
  78240. export class TextBlock extends Control {
  78241. /**
  78242. * Defines the name of the control
  78243. */
  78244. name?: string | undefined;
  78245. private _text;
  78246. private _textWrapping;
  78247. private _textHorizontalAlignment;
  78248. private _textVerticalAlignment;
  78249. private _lines;
  78250. private _resizeToFit;
  78251. private _lineSpacing;
  78252. private _outlineWidth;
  78253. private _outlineColor;
  78254. private _underline;
  78255. private _lineThrough;
  78256. /**
  78257. * An event triggered after the text is changed
  78258. */
  78259. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78260. /**
  78261. * An event triggered after the text was broken up into lines
  78262. */
  78263. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78264. /**
  78265. * Function used to split a string into words. By default, a string is split at each space character found
  78266. */
  78267. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78268. /**
  78269. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78270. */
  78271. get lines(): any[];
  78272. /**
  78273. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78274. */
  78275. get resizeToFit(): boolean;
  78276. /**
  78277. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78278. */
  78279. set resizeToFit(value: boolean);
  78280. /**
  78281. * Gets or sets a boolean indicating if text must be wrapped
  78282. */
  78283. get textWrapping(): TextWrapping | boolean;
  78284. /**
  78285. * Gets or sets a boolean indicating if text must be wrapped
  78286. */
  78287. set textWrapping(value: TextWrapping | boolean);
  78288. /**
  78289. * Gets or sets text to display
  78290. */
  78291. get text(): string;
  78292. /**
  78293. * Gets or sets text to display
  78294. */
  78295. set text(value: string);
  78296. /**
  78297. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78298. */
  78299. get textHorizontalAlignment(): number;
  78300. /**
  78301. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78302. */
  78303. set textHorizontalAlignment(value: number);
  78304. /**
  78305. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78306. */
  78307. get textVerticalAlignment(): number;
  78308. /**
  78309. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78310. */
  78311. set textVerticalAlignment(value: number);
  78312. /**
  78313. * Gets or sets line spacing value
  78314. */
  78315. set lineSpacing(value: string | number);
  78316. /**
  78317. * Gets or sets line spacing value
  78318. */
  78319. get lineSpacing(): string | number;
  78320. /**
  78321. * Gets or sets outlineWidth of the text to display
  78322. */
  78323. get outlineWidth(): number;
  78324. /**
  78325. * Gets or sets outlineWidth of the text to display
  78326. */
  78327. set outlineWidth(value: number);
  78328. /**
  78329. * Gets or sets a boolean indicating that text must have underline
  78330. */
  78331. get underline(): boolean;
  78332. /**
  78333. * Gets or sets a boolean indicating that text must have underline
  78334. */
  78335. set underline(value: boolean);
  78336. /**
  78337. * Gets or sets an boolean indicating that text must be crossed out
  78338. */
  78339. get lineThrough(): boolean;
  78340. /**
  78341. * Gets or sets an boolean indicating that text must be crossed out
  78342. */
  78343. set lineThrough(value: boolean);
  78344. /**
  78345. * Gets or sets outlineColor of the text to display
  78346. */
  78347. get outlineColor(): string;
  78348. /**
  78349. * Gets or sets outlineColor of the text to display
  78350. */
  78351. set outlineColor(value: string);
  78352. /**
  78353. * Creates a new TextBlock object
  78354. * @param name defines the name of the control
  78355. * @param text defines the text to display (emptry string by default)
  78356. */
  78357. constructor(
  78358. /**
  78359. * Defines the name of the control
  78360. */
  78361. name?: string | undefined, text?: string);
  78362. protected _getTypeName(): string;
  78363. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78364. private _drawText;
  78365. /** @hidden */
  78366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78367. protected _applyStates(context: CanvasRenderingContext2D): void;
  78368. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78369. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78370. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78371. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78372. protected _renderLines(context: CanvasRenderingContext2D): void;
  78373. /**
  78374. * Given a width constraint applied on the text block, find the expected height
  78375. * @returns expected height
  78376. */
  78377. computeExpectedHeight(): number;
  78378. dispose(): void;
  78379. }
  78380. }
  78381. declare module BABYLON.GUI {
  78382. /**
  78383. * Class used to create 2D images
  78384. */
  78385. export class Image extends Control {
  78386. name?: string | undefined;
  78387. private _workingCanvas;
  78388. private _domImage;
  78389. private _imageWidth;
  78390. private _imageHeight;
  78391. private _loaded;
  78392. private _stretch;
  78393. private _source;
  78394. private _autoScale;
  78395. private _sourceLeft;
  78396. private _sourceTop;
  78397. private _sourceWidth;
  78398. private _sourceHeight;
  78399. private _svgAttributesComputationCompleted;
  78400. private _isSVG;
  78401. private _cellWidth;
  78402. private _cellHeight;
  78403. private _cellId;
  78404. private _populateNinePatchSlicesFromImage;
  78405. private _sliceLeft;
  78406. private _sliceRight;
  78407. private _sliceTop;
  78408. private _sliceBottom;
  78409. private _detectPointerOnOpaqueOnly;
  78410. private _imageDataCache;
  78411. /**
  78412. * BABYLON.Observable notified when the content is loaded
  78413. */
  78414. onImageLoadedObservable: BABYLON.Observable<Image>;
  78415. /**
  78416. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78417. */
  78418. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78419. /**
  78420. * Gets a boolean indicating that the content is loaded
  78421. */
  78422. get isLoaded(): boolean;
  78423. /**
  78424. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78425. */
  78426. get populateNinePatchSlicesFromImage(): boolean;
  78427. set populateNinePatchSlicesFromImage(value: boolean);
  78428. /**
  78429. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78430. * Beware using this as this will comsume more memory as the image has to be stored twice
  78431. */
  78432. get detectPointerOnOpaqueOnly(): boolean;
  78433. set detectPointerOnOpaqueOnly(value: boolean);
  78434. /**
  78435. * Gets or sets the left value for slicing (9-patch)
  78436. */
  78437. get sliceLeft(): number;
  78438. set sliceLeft(value: number);
  78439. /**
  78440. * Gets or sets the right value for slicing (9-patch)
  78441. */
  78442. get sliceRight(): number;
  78443. set sliceRight(value: number);
  78444. /**
  78445. * Gets or sets the top value for slicing (9-patch)
  78446. */
  78447. get sliceTop(): number;
  78448. set sliceTop(value: number);
  78449. /**
  78450. * Gets or sets the bottom value for slicing (9-patch)
  78451. */
  78452. get sliceBottom(): number;
  78453. set sliceBottom(value: number);
  78454. /**
  78455. * Gets or sets the left coordinate in the source image
  78456. */
  78457. get sourceLeft(): number;
  78458. set sourceLeft(value: number);
  78459. /**
  78460. * Gets or sets the top coordinate in the source image
  78461. */
  78462. get sourceTop(): number;
  78463. set sourceTop(value: number);
  78464. /**
  78465. * Gets or sets the width to capture in the source image
  78466. */
  78467. get sourceWidth(): number;
  78468. set sourceWidth(value: number);
  78469. /**
  78470. * Gets or sets the height to capture in the source image
  78471. */
  78472. get sourceHeight(): number;
  78473. set sourceHeight(value: number);
  78474. /** Indicates if the format of the image is SVG */
  78475. get isSVG(): boolean;
  78476. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78477. get svgAttributesComputationCompleted(): boolean;
  78478. /**
  78479. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78480. * @see https://doc.babylonjs.com/how_to/gui#image
  78481. */
  78482. get autoScale(): boolean;
  78483. set autoScale(value: boolean);
  78484. /** Gets or sets the streching mode used by the image */
  78485. get stretch(): number;
  78486. set stretch(value: number);
  78487. /** @hidden */
  78488. _rotate90(n: number, preserveProperties?: boolean): Image;
  78489. private _handleRotationForSVGImage;
  78490. private _rotate90SourceProperties;
  78491. /**
  78492. * Gets or sets the internal DOM image used to render the control
  78493. */
  78494. set domImage(value: HTMLImageElement);
  78495. get domImage(): HTMLImageElement;
  78496. private _onImageLoaded;
  78497. private _extractNinePatchSliceDataFromImage;
  78498. /**
  78499. * Gets or sets image source url
  78500. */
  78501. set source(value: BABYLON.Nullable<string>);
  78502. /**
  78503. * Checks for svg document with icon id present
  78504. */
  78505. private _svgCheck;
  78506. /**
  78507. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78508. * given external svg file and icon id
  78509. */
  78510. private _getSVGAttribs;
  78511. /**
  78512. * Gets or sets the cell width to use when animation sheet is enabled
  78513. * @see https://doc.babylonjs.com/how_to/gui#image
  78514. */
  78515. get cellWidth(): number;
  78516. set cellWidth(value: number);
  78517. /**
  78518. * Gets or sets the cell height to use when animation sheet is enabled
  78519. * @see https://doc.babylonjs.com/how_to/gui#image
  78520. */
  78521. get cellHeight(): number;
  78522. set cellHeight(value: number);
  78523. /**
  78524. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78525. * @see https://doc.babylonjs.com/how_to/gui#image
  78526. */
  78527. get cellId(): number;
  78528. set cellId(value: number);
  78529. /**
  78530. * Creates a new Image
  78531. * @param name defines the control name
  78532. * @param url defines the image url
  78533. */
  78534. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78535. /**
  78536. * Tests if a given coordinates belong to the current control
  78537. * @param x defines x coordinate to test
  78538. * @param y defines y coordinate to test
  78539. * @returns true if the coordinates are inside the control
  78540. */
  78541. contains(x: number, y: number): boolean;
  78542. protected _getTypeName(): string;
  78543. /** Force the control to synchronize with its content */
  78544. synchronizeSizeWithContent(): void;
  78545. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78546. private _prepareWorkingCanvasForOpaqueDetection;
  78547. private _drawImage;
  78548. _draw(context: CanvasRenderingContext2D): void;
  78549. private _renderCornerPatch;
  78550. private _renderNinePatch;
  78551. dispose(): void;
  78552. /** STRETCH_NONE */
  78553. static readonly STRETCH_NONE: number;
  78554. /** STRETCH_FILL */
  78555. static readonly STRETCH_FILL: number;
  78556. /** STRETCH_UNIFORM */
  78557. static readonly STRETCH_UNIFORM: number;
  78558. /** STRETCH_EXTEND */
  78559. static readonly STRETCH_EXTEND: number;
  78560. /** NINE_PATCH */
  78561. static readonly STRETCH_NINE_PATCH: number;
  78562. }
  78563. }
  78564. declare module BABYLON.GUI {
  78565. /**
  78566. * Class used to create 2D buttons
  78567. */
  78568. export class Button extends Rectangle {
  78569. name?: string | undefined;
  78570. /**
  78571. * Function called to generate a pointer enter animation
  78572. */
  78573. pointerEnterAnimation: () => void;
  78574. /**
  78575. * Function called to generate a pointer out animation
  78576. */
  78577. pointerOutAnimation: () => void;
  78578. /**
  78579. * Function called to generate a pointer down animation
  78580. */
  78581. pointerDownAnimation: () => void;
  78582. /**
  78583. * Function called to generate a pointer up animation
  78584. */
  78585. pointerUpAnimation: () => void;
  78586. /**
  78587. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78588. */
  78589. delegatePickingToChildren: boolean;
  78590. private _image;
  78591. /**
  78592. * Returns the image part of the button (if any)
  78593. */
  78594. get image(): BABYLON.Nullable<Image>;
  78595. private _textBlock;
  78596. /**
  78597. * Returns the image part of the button (if any)
  78598. */
  78599. get textBlock(): BABYLON.Nullable<TextBlock>;
  78600. /**
  78601. * Creates a new Button
  78602. * @param name defines the name of the button
  78603. */
  78604. constructor(name?: string | undefined);
  78605. protected _getTypeName(): string;
  78606. /** @hidden */
  78607. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78608. /** @hidden */
  78609. _onPointerEnter(target: Control): boolean;
  78610. /** @hidden */
  78611. _onPointerOut(target: Control, force?: boolean): void;
  78612. /** @hidden */
  78613. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78614. /** @hidden */
  78615. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78616. /**
  78617. * Creates a new button made with an image and a text
  78618. * @param name defines the name of the button
  78619. * @param text defines the text of the button
  78620. * @param imageUrl defines the url of the image
  78621. * @returns a new Button
  78622. */
  78623. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78624. /**
  78625. * Creates a new button made with an image
  78626. * @param name defines the name of the button
  78627. * @param imageUrl defines the url of the image
  78628. * @returns a new Button
  78629. */
  78630. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78631. /**
  78632. * Creates a new button made with a text
  78633. * @param name defines the name of the button
  78634. * @param text defines the text of the button
  78635. * @returns a new Button
  78636. */
  78637. static CreateSimpleButton(name: string, text: string): Button;
  78638. /**
  78639. * Creates a new button made with an image and a centered text
  78640. * @param name defines the name of the button
  78641. * @param text defines the text of the button
  78642. * @param imageUrl defines the url of the image
  78643. * @returns a new Button
  78644. */
  78645. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78646. }
  78647. }
  78648. declare module BABYLON.GUI {
  78649. /**
  78650. * Class used to create a 2D stack panel container
  78651. */
  78652. export class StackPanel extends Container {
  78653. name?: string | undefined;
  78654. private _isVertical;
  78655. private _manualWidth;
  78656. private _manualHeight;
  78657. private _doNotTrackManualChanges;
  78658. /**
  78659. * Gets or sets a boolean indicating that layou warnings should be ignored
  78660. */
  78661. ignoreLayoutWarnings: boolean;
  78662. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78663. get isVertical(): boolean;
  78664. set isVertical(value: boolean);
  78665. /**
  78666. * Gets or sets panel width.
  78667. * This value should not be set when in horizontal mode as it will be computed automatically
  78668. */
  78669. set width(value: string | number);
  78670. get width(): string | number;
  78671. /**
  78672. * Gets or sets panel height.
  78673. * This value should not be set when in vertical mode as it will be computed automatically
  78674. */
  78675. set height(value: string | number);
  78676. get height(): string | number;
  78677. /**
  78678. * Creates a new StackPanel
  78679. * @param name defines control name
  78680. */
  78681. constructor(name?: string | undefined);
  78682. protected _getTypeName(): string;
  78683. /** @hidden */
  78684. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78685. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78686. protected _postMeasure(): void;
  78687. }
  78688. }
  78689. declare module BABYLON.GUI {
  78690. /**
  78691. * Class used to represent a 2D checkbox
  78692. */
  78693. export class Checkbox extends Control {
  78694. name?: string | undefined;
  78695. private _isChecked;
  78696. private _background;
  78697. private _checkSizeRatio;
  78698. private _thickness;
  78699. /** Gets or sets border thickness */
  78700. get thickness(): number;
  78701. set thickness(value: number);
  78702. /**
  78703. * BABYLON.Observable raised when isChecked property changes
  78704. */
  78705. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78706. /** Gets or sets a value indicating the ratio between overall size and check size */
  78707. get checkSizeRatio(): number;
  78708. set checkSizeRatio(value: number);
  78709. /** Gets or sets background color */
  78710. get background(): string;
  78711. set background(value: string);
  78712. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78713. get isChecked(): boolean;
  78714. set isChecked(value: boolean);
  78715. /**
  78716. * Creates a new CheckBox
  78717. * @param name defines the control name
  78718. */
  78719. constructor(name?: string | undefined);
  78720. protected _getTypeName(): string;
  78721. /** @hidden */
  78722. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78723. /** @hidden */
  78724. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78725. /**
  78726. * Utility function to easily create a checkbox with a header
  78727. * @param title defines the label to use for the header
  78728. * @param onValueChanged defines the callback to call when value changes
  78729. * @returns a StackPanel containing the checkbox and a textBlock
  78730. */
  78731. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78732. }
  78733. }
  78734. declare module BABYLON.GUI {
  78735. /**
  78736. * Class used to store key control properties
  78737. */
  78738. export class KeyPropertySet {
  78739. /** Width */
  78740. width?: string;
  78741. /** Height */
  78742. height?: string;
  78743. /** Left padding */
  78744. paddingLeft?: string;
  78745. /** Right padding */
  78746. paddingRight?: string;
  78747. /** Top padding */
  78748. paddingTop?: string;
  78749. /** Bottom padding */
  78750. paddingBottom?: string;
  78751. /** Foreground color */
  78752. color?: string;
  78753. /** Background color */
  78754. background?: string;
  78755. }
  78756. /**
  78757. * Class used to create virtual keyboard
  78758. */
  78759. export class VirtualKeyboard extends StackPanel {
  78760. /** BABYLON.Observable raised when a key is pressed */
  78761. onKeyPressObservable: BABYLON.Observable<string>;
  78762. /** Gets or sets default key button width */
  78763. defaultButtonWidth: string;
  78764. /** Gets or sets default key button height */
  78765. defaultButtonHeight: string;
  78766. /** Gets or sets default key button left padding */
  78767. defaultButtonPaddingLeft: string;
  78768. /** Gets or sets default key button right padding */
  78769. defaultButtonPaddingRight: string;
  78770. /** Gets or sets default key button top padding */
  78771. defaultButtonPaddingTop: string;
  78772. /** Gets or sets default key button bottom padding */
  78773. defaultButtonPaddingBottom: string;
  78774. /** Gets or sets default key button foreground color */
  78775. defaultButtonColor: string;
  78776. /** Gets or sets default key button background color */
  78777. defaultButtonBackground: string;
  78778. /** Gets or sets shift button foreground color */
  78779. shiftButtonColor: string;
  78780. /** Gets or sets shift button thickness*/
  78781. selectedShiftThickness: number;
  78782. /** Gets shift key state */
  78783. shiftState: number;
  78784. protected _getTypeName(): string;
  78785. private _createKey;
  78786. /**
  78787. * Adds a new row of keys
  78788. * @param keys defines the list of keys to add
  78789. * @param propertySets defines the associated property sets
  78790. */
  78791. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78792. /**
  78793. * Set the shift key to a specific state
  78794. * @param shiftState defines the new shift state
  78795. */
  78796. applyShiftState(shiftState: number): void;
  78797. private _currentlyConnectedInputText;
  78798. private _connectedInputTexts;
  78799. private _onKeyPressObserver;
  78800. /** Gets the input text control currently attached to the keyboard */
  78801. get connectedInputText(): BABYLON.Nullable<InputText>;
  78802. /**
  78803. * Connects the keyboard with an input text control
  78804. *
  78805. * @param input defines the target control
  78806. */
  78807. connect(input: InputText): void;
  78808. /**
  78809. * Disconnects the keyboard from connected InputText controls
  78810. *
  78811. * @param input optionally defines a target control, otherwise all are disconnected
  78812. */
  78813. disconnect(input?: InputText): void;
  78814. private _removeConnectedInputObservables;
  78815. /**
  78816. * Release all resources
  78817. */
  78818. dispose(): void;
  78819. /**
  78820. * Creates a new keyboard using a default layout
  78821. *
  78822. * @param name defines control name
  78823. * @returns a new VirtualKeyboard
  78824. */
  78825. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78826. }
  78827. }
  78828. declare module BABYLON.GUI {
  78829. /**
  78830. * Class used to create input text control
  78831. */
  78832. export class InputText extends Control implements IFocusableControl {
  78833. name?: string | undefined;
  78834. private _text;
  78835. private _placeholderText;
  78836. private _background;
  78837. private _focusedBackground;
  78838. private _focusedColor;
  78839. private _placeholderColor;
  78840. private _thickness;
  78841. private _margin;
  78842. private _autoStretchWidth;
  78843. private _maxWidth;
  78844. private _isFocused;
  78845. private _blinkTimeout;
  78846. private _blinkIsEven;
  78847. private _cursorOffset;
  78848. private _scrollLeft;
  78849. private _textWidth;
  78850. private _clickedCoordinate;
  78851. private _deadKey;
  78852. private _addKey;
  78853. private _currentKey;
  78854. private _isTextHighlightOn;
  78855. private _textHighlightColor;
  78856. private _highligherOpacity;
  78857. private _highlightedText;
  78858. private _startHighlightIndex;
  78859. private _endHighlightIndex;
  78860. private _cursorIndex;
  78861. private _onFocusSelectAll;
  78862. private _isPointerDown;
  78863. private _onClipboardObserver;
  78864. private _onPointerDblTapObserver;
  78865. /** @hidden */
  78866. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78867. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78868. promptMessage: string;
  78869. /** Force disable prompt on mobile device */
  78870. disableMobilePrompt: boolean;
  78871. /** BABYLON.Observable raised when the text changes */
  78872. onTextChangedObservable: BABYLON.Observable<InputText>;
  78873. /** BABYLON.Observable raised just before an entered character is to be added */
  78874. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78875. /** BABYLON.Observable raised when the control gets the focus */
  78876. onFocusObservable: BABYLON.Observable<InputText>;
  78877. /** BABYLON.Observable raised when the control loses the focus */
  78878. onBlurObservable: BABYLON.Observable<InputText>;
  78879. /**Observable raised when the text is highlighted */
  78880. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78881. /**Observable raised when copy event is triggered */
  78882. onTextCopyObservable: BABYLON.Observable<InputText>;
  78883. /** BABYLON.Observable raised when cut event is triggered */
  78884. onTextCutObservable: BABYLON.Observable<InputText>;
  78885. /** BABYLON.Observable raised when paste event is triggered */
  78886. onTextPasteObservable: BABYLON.Observable<InputText>;
  78887. /** BABYLON.Observable raised when a key event was processed */
  78888. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78889. /** Gets or sets the maximum width allowed by the control */
  78890. get maxWidth(): string | number;
  78891. /** Gets the maximum width allowed by the control in pixels */
  78892. get maxWidthInPixels(): number;
  78893. set maxWidth(value: string | number);
  78894. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78895. get highligherOpacity(): number;
  78896. set highligherOpacity(value: number);
  78897. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78898. get onFocusSelectAll(): boolean;
  78899. set onFocusSelectAll(value: boolean);
  78900. /** Gets or sets the text hightlight color */
  78901. get textHighlightColor(): string;
  78902. set textHighlightColor(value: string);
  78903. /** Gets or sets control margin */
  78904. get margin(): string;
  78905. /** Gets control margin in pixels */
  78906. get marginInPixels(): number;
  78907. set margin(value: string);
  78908. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78909. get autoStretchWidth(): boolean;
  78910. set autoStretchWidth(value: boolean);
  78911. /** Gets or sets border thickness */
  78912. get thickness(): number;
  78913. set thickness(value: number);
  78914. /** Gets or sets the background color when focused */
  78915. get focusedBackground(): string;
  78916. set focusedBackground(value: string);
  78917. /** Gets or sets the background color when focused */
  78918. get focusedColor(): string;
  78919. set focusedColor(value: string);
  78920. /** Gets or sets the background color */
  78921. get background(): string;
  78922. set background(value: string);
  78923. /** Gets or sets the placeholder color */
  78924. get placeholderColor(): string;
  78925. set placeholderColor(value: string);
  78926. /** Gets or sets the text displayed when the control is empty */
  78927. get placeholderText(): string;
  78928. set placeholderText(value: string);
  78929. /** Gets or sets the dead key flag */
  78930. get deadKey(): boolean;
  78931. set deadKey(flag: boolean);
  78932. /** Gets or sets the highlight text */
  78933. get highlightedText(): string;
  78934. set highlightedText(text: string);
  78935. /** Gets or sets if the current key should be added */
  78936. get addKey(): boolean;
  78937. set addKey(flag: boolean);
  78938. /** Gets or sets the value of the current key being entered */
  78939. get currentKey(): string;
  78940. set currentKey(key: string);
  78941. /** Gets or sets the text displayed in the control */
  78942. get text(): string;
  78943. set text(value: string);
  78944. /** Gets or sets control width */
  78945. get width(): string | number;
  78946. set width(value: string | number);
  78947. /**
  78948. * Creates a new InputText
  78949. * @param name defines the control name
  78950. * @param text defines the text of the control
  78951. */
  78952. constructor(name?: string | undefined, text?: string);
  78953. /** @hidden */
  78954. onBlur(): void;
  78955. /** @hidden */
  78956. onFocus(): void;
  78957. protected _getTypeName(): string;
  78958. /**
  78959. * Function called to get the list of controls that should not steal the focus from this control
  78960. * @returns an array of controls
  78961. */
  78962. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78963. /** @hidden */
  78964. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78965. /** @hidden */
  78966. private _updateValueFromCursorIndex;
  78967. /** @hidden */
  78968. private _processDblClick;
  78969. /** @hidden */
  78970. private _selectAllText;
  78971. /**
  78972. * Handles the keyboard event
  78973. * @param evt Defines the KeyboardEvent
  78974. */
  78975. processKeyboard(evt: KeyboardEvent): void;
  78976. /** @hidden */
  78977. private _onCopyText;
  78978. /** @hidden */
  78979. private _onCutText;
  78980. /** @hidden */
  78981. private _onPasteText;
  78982. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78983. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78984. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78985. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78986. protected _beforeRenderText(text: string): string;
  78987. dispose(): void;
  78988. }
  78989. }
  78990. declare module BABYLON.GUI {
  78991. /**
  78992. * Class used to create a 2D grid container
  78993. */
  78994. export class Grid extends Container {
  78995. name?: string | undefined;
  78996. private _rowDefinitions;
  78997. private _columnDefinitions;
  78998. private _cells;
  78999. private _childControls;
  79000. /**
  79001. * Gets the number of columns
  79002. */
  79003. get columnCount(): number;
  79004. /**
  79005. * Gets the number of rows
  79006. */
  79007. get rowCount(): number;
  79008. /** Gets the list of children */
  79009. get children(): Control[];
  79010. /** Gets the list of cells (e.g. the containers) */
  79011. get cells(): {
  79012. [key: string]: Container;
  79013. };
  79014. /**
  79015. * Gets the definition of a specific row
  79016. * @param index defines the index of the row
  79017. * @returns the row definition
  79018. */
  79019. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79020. /**
  79021. * Gets the definition of a specific column
  79022. * @param index defines the index of the column
  79023. * @returns the column definition
  79024. */
  79025. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79026. /**
  79027. * Adds a new row to the grid
  79028. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79029. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79030. * @returns the current grid
  79031. */
  79032. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79033. /**
  79034. * Adds a new column to the grid
  79035. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79036. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79037. * @returns the current grid
  79038. */
  79039. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79040. /**
  79041. * Update a row definition
  79042. * @param index defines the index of the row to update
  79043. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79044. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79045. * @returns the current grid
  79046. */
  79047. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79048. /**
  79049. * Update a column definition
  79050. * @param index defines the index of the column to update
  79051. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79052. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79053. * @returns the current grid
  79054. */
  79055. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79056. /**
  79057. * Gets the list of children stored in a specific cell
  79058. * @param row defines the row to check
  79059. * @param column defines the column to check
  79060. * @returns the list of controls
  79061. */
  79062. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79063. /**
  79064. * Gets a string representing the child cell info (row x column)
  79065. * @param child defines the control to get info from
  79066. * @returns a string containing the child cell info (row x column)
  79067. */
  79068. getChildCellInfo(child: Control): string;
  79069. private _removeCell;
  79070. private _offsetCell;
  79071. /**
  79072. * Remove a column definition at specified index
  79073. * @param index defines the index of the column to remove
  79074. * @returns the current grid
  79075. */
  79076. removeColumnDefinition(index: number): Grid;
  79077. /**
  79078. * Remove a row definition at specified index
  79079. * @param index defines the index of the row to remove
  79080. * @returns the current grid
  79081. */
  79082. removeRowDefinition(index: number): Grid;
  79083. /**
  79084. * Adds a new control to the current grid
  79085. * @param control defines the control to add
  79086. * @param row defines the row where to add the control (0 by default)
  79087. * @param column defines the column where to add the control (0 by default)
  79088. * @returns the current grid
  79089. */
  79090. addControl(control: Control, row?: number, column?: number): Grid;
  79091. /**
  79092. * Removes a control from the current container
  79093. * @param control defines the control to remove
  79094. * @returns the current container
  79095. */
  79096. removeControl(control: Control): Container;
  79097. /**
  79098. * Creates a new Grid
  79099. * @param name defines control name
  79100. */
  79101. constructor(name?: string | undefined);
  79102. protected _getTypeName(): string;
  79103. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79104. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79105. _flagDescendantsAsMatrixDirty(): void;
  79106. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79107. /** Releases associated resources */
  79108. dispose(): void;
  79109. }
  79110. }
  79111. declare module BABYLON.GUI {
  79112. /** Class used to create color pickers */
  79113. export class ColorPicker extends Control {
  79114. name?: string | undefined;
  79115. private static _Epsilon;
  79116. private _colorWheelCanvas;
  79117. private _value;
  79118. private _tmpColor;
  79119. private _pointerStartedOnSquare;
  79120. private _pointerStartedOnWheel;
  79121. private _squareLeft;
  79122. private _squareTop;
  79123. private _squareSize;
  79124. private _h;
  79125. private _s;
  79126. private _v;
  79127. private _lastPointerDownID;
  79128. /**
  79129. * BABYLON.Observable raised when the value changes
  79130. */
  79131. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79132. /** Gets or sets the color of the color picker */
  79133. get value(): BABYLON.Color3;
  79134. set value(value: BABYLON.Color3);
  79135. /**
  79136. * Gets or sets control width
  79137. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79138. */
  79139. get width(): string | number;
  79140. set width(value: string | number);
  79141. /**
  79142. * Gets or sets control height
  79143. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79144. */
  79145. get height(): string | number;
  79146. /** Gets or sets control height */
  79147. set height(value: string | number);
  79148. /** Gets or sets control size */
  79149. get size(): string | number;
  79150. set size(value: string | number);
  79151. /**
  79152. * Creates a new ColorPicker
  79153. * @param name defines the control name
  79154. */
  79155. constructor(name?: string | undefined);
  79156. protected _getTypeName(): string;
  79157. /** @hidden */
  79158. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79159. private _updateSquareProps;
  79160. private _drawGradientSquare;
  79161. private _drawCircle;
  79162. private _createColorWheelCanvas;
  79163. /** @hidden */
  79164. _draw(context: CanvasRenderingContext2D): void;
  79165. private _pointerIsDown;
  79166. private _updateValueFromPointer;
  79167. private _isPointOnSquare;
  79168. private _isPointOnWheel;
  79169. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79170. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79171. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79172. _onCanvasBlur(): void;
  79173. /**
  79174. * This function expands the color picker by creating a color picker dialog with manual
  79175. * color value input and the ability to save colors into an array to be used later in
  79176. * subsequent launches of the dialogue.
  79177. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79178. * @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.
  79179. * @returns picked color as a hex string and the saved colors array as hex strings.
  79180. */
  79181. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79182. pickerWidth?: string;
  79183. pickerHeight?: string;
  79184. headerHeight?: string;
  79185. lastColor?: string;
  79186. swatchLimit?: number;
  79187. numSwatchesPerLine?: number;
  79188. savedColors?: Array<string>;
  79189. }): Promise<{
  79190. savedColors?: string[];
  79191. pickedColor: string;
  79192. }>;
  79193. }
  79194. }
  79195. declare module BABYLON.GUI {
  79196. /** Class used to create 2D ellipse containers */
  79197. export class Ellipse extends Container {
  79198. name?: string | undefined;
  79199. private _thickness;
  79200. /** Gets or sets border thickness */
  79201. get thickness(): number;
  79202. set thickness(value: number);
  79203. /**
  79204. * Creates a new Ellipse
  79205. * @param name defines the control name
  79206. */
  79207. constructor(name?: string | undefined);
  79208. protected _getTypeName(): string;
  79209. protected _localDraw(context: CanvasRenderingContext2D): void;
  79210. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79211. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79212. }
  79213. }
  79214. declare module BABYLON.GUI {
  79215. /**
  79216. * Class used to create a password control
  79217. */
  79218. export class InputPassword extends InputText {
  79219. protected _beforeRenderText(text: string): string;
  79220. }
  79221. }
  79222. declare module BABYLON.GUI {
  79223. /** Class used to render 2D lines */
  79224. export class Line extends Control {
  79225. name?: string | undefined;
  79226. private _lineWidth;
  79227. private _x1;
  79228. private _y1;
  79229. private _x2;
  79230. private _y2;
  79231. private _dash;
  79232. private _connectedControl;
  79233. private _connectedControlDirtyObserver;
  79234. /** Gets or sets the dash pattern */
  79235. get dash(): Array<number>;
  79236. set dash(value: Array<number>);
  79237. /** Gets or sets the control connected with the line end */
  79238. get connectedControl(): Control;
  79239. set connectedControl(value: Control);
  79240. /** Gets or sets start coordinates on X axis */
  79241. get x1(): string | number;
  79242. set x1(value: string | number);
  79243. /** Gets or sets start coordinates on Y axis */
  79244. get y1(): string | number;
  79245. set y1(value: string | number);
  79246. /** Gets or sets end coordinates on X axis */
  79247. get x2(): string | number;
  79248. set x2(value: string | number);
  79249. /** Gets or sets end coordinates on Y axis */
  79250. get y2(): string | number;
  79251. set y2(value: string | number);
  79252. /** Gets or sets line width */
  79253. get lineWidth(): number;
  79254. set lineWidth(value: number);
  79255. /** Gets or sets horizontal alignment */
  79256. set horizontalAlignment(value: number);
  79257. /** Gets or sets vertical alignment */
  79258. set verticalAlignment(value: number);
  79259. private get _effectiveX2();
  79260. private get _effectiveY2();
  79261. /**
  79262. * Creates a new Line
  79263. * @param name defines the control name
  79264. */
  79265. constructor(name?: string | undefined);
  79266. protected _getTypeName(): string;
  79267. _draw(context: CanvasRenderingContext2D): void;
  79268. _measure(): void;
  79269. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79270. /**
  79271. * Move one end of the line given 3D cartesian coordinates.
  79272. * @param position Targeted world position
  79273. * @param scene BABYLON.Scene
  79274. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79275. */
  79276. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79277. /**
  79278. * Move one end of the line to a position in screen absolute space.
  79279. * @param projectedPosition Position in screen absolute space (X, Y)
  79280. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79281. */
  79282. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79283. }
  79284. }
  79285. declare module BABYLON.GUI {
  79286. /**
  79287. * Class used to store a point for a MultiLine object.
  79288. * The point can be pure 2D coordinates, a mesh or a control
  79289. */
  79290. export class MultiLinePoint {
  79291. private _multiLine;
  79292. private _x;
  79293. private _y;
  79294. private _control;
  79295. private _mesh;
  79296. private _controlObserver;
  79297. private _meshObserver;
  79298. /** @hidden */
  79299. _point: BABYLON.Vector2;
  79300. /**
  79301. * Creates a new MultiLinePoint
  79302. * @param multiLine defines the source MultiLine object
  79303. */
  79304. constructor(multiLine: MultiLine);
  79305. /** Gets or sets x coordinate */
  79306. get x(): string | number;
  79307. set x(value: string | number);
  79308. /** Gets or sets y coordinate */
  79309. get y(): string | number;
  79310. set y(value: string | number);
  79311. /** Gets or sets the control associated with this point */
  79312. get control(): BABYLON.Nullable<Control>;
  79313. set control(value: BABYLON.Nullable<Control>);
  79314. /** Gets or sets the mesh associated with this point */
  79315. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79316. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79317. /** Resets links */
  79318. resetLinks(): void;
  79319. /**
  79320. * Gets a translation vector
  79321. * @returns the translation vector
  79322. */
  79323. translate(): BABYLON.Vector2;
  79324. private _translatePoint;
  79325. /** Release associated resources */
  79326. dispose(): void;
  79327. }
  79328. }
  79329. declare module BABYLON.GUI {
  79330. /**
  79331. * Class used to create multi line control
  79332. */
  79333. export class MultiLine extends Control {
  79334. name?: string | undefined;
  79335. private _lineWidth;
  79336. private _dash;
  79337. private _points;
  79338. private _minX;
  79339. private _minY;
  79340. private _maxX;
  79341. private _maxY;
  79342. /**
  79343. * Creates a new MultiLine
  79344. * @param name defines the control name
  79345. */
  79346. constructor(name?: string | undefined);
  79347. /** Gets or sets dash pattern */
  79348. get dash(): Array<number>;
  79349. set dash(value: Array<number>);
  79350. /**
  79351. * Gets point stored at specified index
  79352. * @param index defines the index to look for
  79353. * @returns the requested point if found
  79354. */
  79355. getAt(index: number): MultiLinePoint;
  79356. /** Function called when a point is updated */
  79357. onPointUpdate: () => void;
  79358. /**
  79359. * Adds new points to the point collection
  79360. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79361. * @returns the list of created MultiLinePoint
  79362. */
  79363. add(...items: (AbstractMesh | Control | {
  79364. x: string | number;
  79365. y: string | number;
  79366. })[]): MultiLinePoint[];
  79367. /**
  79368. * Adds a new point to the point collection
  79369. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79370. * @returns the created MultiLinePoint
  79371. */
  79372. push(item?: (AbstractMesh | Control | {
  79373. x: string | number;
  79374. y: string | number;
  79375. })): MultiLinePoint;
  79376. /**
  79377. * Remove a specific value or point from the active point collection
  79378. * @param value defines the value or point to remove
  79379. */
  79380. remove(value: number | MultiLinePoint): void;
  79381. /**
  79382. * Resets this object to initial state (no point)
  79383. */
  79384. reset(): void;
  79385. /**
  79386. * Resets all links
  79387. */
  79388. resetLinks(): void;
  79389. /** Gets or sets line width */
  79390. get lineWidth(): number;
  79391. set lineWidth(value: number);
  79392. set horizontalAlignment(value: number);
  79393. set verticalAlignment(value: number);
  79394. protected _getTypeName(): string;
  79395. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79396. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79397. _measure(): void;
  79398. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79399. dispose(): void;
  79400. }
  79401. }
  79402. declare module BABYLON.GUI {
  79403. /**
  79404. * Class used to create radio button controls
  79405. */
  79406. export class RadioButton extends Control {
  79407. name?: string | undefined;
  79408. private _isChecked;
  79409. private _background;
  79410. private _checkSizeRatio;
  79411. private _thickness;
  79412. /** Gets or sets border thickness */
  79413. get thickness(): number;
  79414. set thickness(value: number);
  79415. /** Gets or sets group name */
  79416. group: string;
  79417. /** BABYLON.Observable raised when isChecked is changed */
  79418. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79419. /** Gets or sets a value indicating the ratio between overall size and check size */
  79420. get checkSizeRatio(): number;
  79421. set checkSizeRatio(value: number);
  79422. /** Gets or sets background color */
  79423. get background(): string;
  79424. set background(value: string);
  79425. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79426. get isChecked(): boolean;
  79427. set isChecked(value: boolean);
  79428. /**
  79429. * Creates a new RadioButton
  79430. * @param name defines the control name
  79431. */
  79432. constructor(name?: string | undefined);
  79433. protected _getTypeName(): string;
  79434. _draw(context: CanvasRenderingContext2D): void;
  79435. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79436. /**
  79437. * Utility function to easily create a radio button with a header
  79438. * @param title defines the label to use for the header
  79439. * @param group defines the group to use for the radio button
  79440. * @param isChecked defines the initial state of the radio button
  79441. * @param onValueChanged defines the callback to call when value changes
  79442. * @returns a StackPanel containing the radio button and a textBlock
  79443. */
  79444. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79445. }
  79446. }
  79447. declare module BABYLON.GUI {
  79448. /**
  79449. * Class used to create slider controls
  79450. */
  79451. export class BaseSlider extends Control {
  79452. name?: string | undefined;
  79453. protected _thumbWidth: ValueAndUnit;
  79454. private _minimum;
  79455. private _maximum;
  79456. private _value;
  79457. private _isVertical;
  79458. protected _barOffset: ValueAndUnit;
  79459. private _isThumbClamped;
  79460. protected _displayThumb: boolean;
  79461. private _step;
  79462. private _lastPointerDownID;
  79463. protected _effectiveBarOffset: number;
  79464. protected _renderLeft: number;
  79465. protected _renderTop: number;
  79466. protected _renderWidth: number;
  79467. protected _renderHeight: number;
  79468. protected _backgroundBoxLength: number;
  79469. protected _backgroundBoxThickness: number;
  79470. protected _effectiveThumbThickness: number;
  79471. /** BABYLON.Observable raised when the sldier value changes */
  79472. onValueChangedObservable: BABYLON.Observable<number>;
  79473. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79474. get displayThumb(): boolean;
  79475. set displayThumb(value: boolean);
  79476. /** Gets or sets a step to apply to values (0 by default) */
  79477. get step(): number;
  79478. set step(value: number);
  79479. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79480. get barOffset(): string | number;
  79481. /** Gets main bar offset in pixels*/
  79482. get barOffsetInPixels(): number;
  79483. set barOffset(value: string | number);
  79484. /** Gets or sets thumb width */
  79485. get thumbWidth(): string | number;
  79486. /** Gets thumb width in pixels */
  79487. get thumbWidthInPixels(): number;
  79488. set thumbWidth(value: string | number);
  79489. /** Gets or sets minimum value */
  79490. get minimum(): number;
  79491. set minimum(value: number);
  79492. /** Gets or sets maximum value */
  79493. get maximum(): number;
  79494. set maximum(value: number);
  79495. /** Gets or sets current value */
  79496. get value(): number;
  79497. set value(value: number);
  79498. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79499. get isVertical(): boolean;
  79500. set isVertical(value: boolean);
  79501. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79502. get isThumbClamped(): boolean;
  79503. set isThumbClamped(value: boolean);
  79504. /**
  79505. * Creates a new BaseSlider
  79506. * @param name defines the control name
  79507. */
  79508. constructor(name?: string | undefined);
  79509. protected _getTypeName(): string;
  79510. protected _getThumbPosition(): number;
  79511. protected _getThumbThickness(type: string): number;
  79512. protected _prepareRenderingData(type: string): void;
  79513. private _pointerIsDown;
  79514. /** @hidden */
  79515. protected _updateValueFromPointer(x: number, y: number): void;
  79516. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79517. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79518. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79519. _onCanvasBlur(): void;
  79520. }
  79521. }
  79522. declare module BABYLON.GUI {
  79523. /**
  79524. * Class used to create slider controls
  79525. */
  79526. export class Slider extends BaseSlider {
  79527. name?: string | undefined;
  79528. private _background;
  79529. private _borderColor;
  79530. private _thumbColor;
  79531. private _isThumbCircle;
  79532. protected _displayValueBar: boolean;
  79533. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79534. get displayValueBar(): boolean;
  79535. set displayValueBar(value: boolean);
  79536. /** Gets or sets border color */
  79537. get borderColor(): string;
  79538. set borderColor(value: string);
  79539. /** Gets or sets background color */
  79540. get background(): string;
  79541. set background(value: string);
  79542. /** Gets or sets thumb's color */
  79543. get thumbColor(): string;
  79544. set thumbColor(value: string);
  79545. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79546. get isThumbCircle(): boolean;
  79547. set isThumbCircle(value: boolean);
  79548. /**
  79549. * Creates a new Slider
  79550. * @param name defines the control name
  79551. */
  79552. constructor(name?: string | undefined);
  79553. protected _getTypeName(): string;
  79554. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79555. }
  79556. }
  79557. declare module BABYLON.GUI {
  79558. /** Class used to create a RadioGroup
  79559. * which contains groups of radio buttons
  79560. */
  79561. export class SelectorGroup {
  79562. /** name of SelectorGroup */
  79563. name: string;
  79564. private _groupPanel;
  79565. private _selectors;
  79566. private _groupHeader;
  79567. /**
  79568. * Creates a new SelectorGroup
  79569. * @param name of group, used as a group heading
  79570. */
  79571. constructor(
  79572. /** name of SelectorGroup */
  79573. name: string);
  79574. /** Gets the groupPanel of the SelectorGroup */
  79575. get groupPanel(): StackPanel;
  79576. /** Gets the selectors array */
  79577. get selectors(): StackPanel[];
  79578. /** Gets and sets the group header */
  79579. get header(): string;
  79580. set header(label: string);
  79581. /** @hidden */
  79582. private _addGroupHeader;
  79583. /** @hidden*/
  79584. _getSelector(selectorNb: number): StackPanel | undefined;
  79585. /** Removes the selector at the given position
  79586. * @param selectorNb the position of the selector within the group
  79587. */
  79588. removeSelector(selectorNb: number): void;
  79589. }
  79590. /** Class used to create a CheckboxGroup
  79591. * which contains groups of checkbox buttons
  79592. */
  79593. export class CheckboxGroup extends SelectorGroup {
  79594. /** Adds a checkbox as a control
  79595. * @param text is the label for the selector
  79596. * @param func is the function called when the Selector is checked
  79597. * @param checked is true when Selector is checked
  79598. */
  79599. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79600. /** @hidden */
  79601. _setSelectorLabel(selectorNb: number, label: string): void;
  79602. /** @hidden */
  79603. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79604. /** @hidden */
  79605. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79606. /** @hidden */
  79607. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79608. }
  79609. /** Class used to create a RadioGroup
  79610. * which contains groups of radio buttons
  79611. */
  79612. export class RadioGroup extends SelectorGroup {
  79613. private _selectNb;
  79614. /** Adds a radio button as a control
  79615. * @param label is the label for the selector
  79616. * @param func is the function called when the Selector is checked
  79617. * @param checked is true when Selector is checked
  79618. */
  79619. addRadio(label: string, func?: (n: number) => void, checked?: boolean): 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 create a SliderGroup
  79630. * which contains groups of slider buttons
  79631. */
  79632. export class SliderGroup extends SelectorGroup {
  79633. /**
  79634. * Adds a slider to the SelectorGroup
  79635. * @param label is the label for the SliderBar
  79636. * @param func is the function called when the Slider moves
  79637. * @param unit is a string describing the units used, eg degrees or metres
  79638. * @param min is the minimum value for the Slider
  79639. * @param max is the maximum value for the Slider
  79640. * @param value is the start value for the Slider between min and max
  79641. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79642. */
  79643. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79644. /** @hidden */
  79645. _setSelectorLabel(selectorNb: number, label: string): void;
  79646. /** @hidden */
  79647. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79648. /** @hidden */
  79649. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79650. /** @hidden */
  79651. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79652. }
  79653. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79654. * @see https://doc.babylonjs.com/how_to/selector
  79655. */
  79656. export class SelectionPanel extends Rectangle {
  79657. /** name of SelectionPanel */
  79658. name: string;
  79659. /** an array of SelectionGroups */
  79660. groups: SelectorGroup[];
  79661. private _panel;
  79662. private _buttonColor;
  79663. private _buttonBackground;
  79664. private _headerColor;
  79665. private _barColor;
  79666. private _barHeight;
  79667. private _spacerHeight;
  79668. private _labelColor;
  79669. private _groups;
  79670. private _bars;
  79671. /**
  79672. * Creates a new SelectionPanel
  79673. * @param name of SelectionPanel
  79674. * @param groups is an array of SelectionGroups
  79675. */
  79676. constructor(
  79677. /** name of SelectionPanel */
  79678. name: string,
  79679. /** an array of SelectionGroups */
  79680. groups?: SelectorGroup[]);
  79681. protected _getTypeName(): string;
  79682. /** Gets the (stack) panel of the SelectionPanel */
  79683. get panel(): StackPanel;
  79684. /** Gets or sets the headerColor */
  79685. get headerColor(): string;
  79686. set headerColor(color: string);
  79687. private _setHeaderColor;
  79688. /** Gets or sets the button color */
  79689. get buttonColor(): string;
  79690. set buttonColor(color: string);
  79691. private _setbuttonColor;
  79692. /** Gets or sets the label color */
  79693. get labelColor(): string;
  79694. set labelColor(color: string);
  79695. private _setLabelColor;
  79696. /** Gets or sets the button background */
  79697. get buttonBackground(): string;
  79698. set buttonBackground(color: string);
  79699. private _setButtonBackground;
  79700. /** Gets or sets the color of separator bar */
  79701. get barColor(): string;
  79702. set barColor(color: string);
  79703. private _setBarColor;
  79704. /** Gets or sets the height of separator bar */
  79705. get barHeight(): string;
  79706. set barHeight(value: string);
  79707. private _setBarHeight;
  79708. /** Gets or sets the height of spacers*/
  79709. get spacerHeight(): string;
  79710. set spacerHeight(value: string);
  79711. private _setSpacerHeight;
  79712. /** Adds a bar between groups */
  79713. private _addSpacer;
  79714. /** Add a group to the selection panel
  79715. * @param group is the selector group to add
  79716. */
  79717. addGroup(group: SelectorGroup): void;
  79718. /** Remove the group from the given position
  79719. * @param groupNb is the position of the group in the list
  79720. */
  79721. removeGroup(groupNb: number): void;
  79722. /** Change a group header label
  79723. * @param label is the new group header label
  79724. * @param groupNb is the number of the group to relabel
  79725. * */
  79726. setHeaderName(label: string, groupNb: number): void;
  79727. /** Change selector label to the one given
  79728. * @param label is the new selector label
  79729. * @param groupNb is the number of the groupcontaining the selector
  79730. * @param selectorNb is the number of the selector within a group to relabel
  79731. * */
  79732. relabel(label: string, groupNb: number, selectorNb: number): void;
  79733. /** For a given group position remove the selector at the given position
  79734. * @param groupNb is the number of the group to remove the selector from
  79735. * @param selectorNb is the number of the selector within the group
  79736. */
  79737. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79738. /** For a given group position of correct type add a checkbox button
  79739. * @param groupNb is the number of the group to remove the selector from
  79740. * @param label is the label for the selector
  79741. * @param func is the function called when the Selector is checked
  79742. * @param checked is true when Selector is checked
  79743. */
  79744. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79745. /** For a given group position of correct type add a radio button
  79746. * @param groupNb is the number of the group to remove the selector from
  79747. * @param label is the label for the selector
  79748. * @param func is the function called when the Selector is checked
  79749. * @param checked is true when Selector is checked
  79750. */
  79751. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79752. /**
  79753. * For a given slider group add a slider
  79754. * @param groupNb is the number of the group to add the slider to
  79755. * @param label is the label for the Slider
  79756. * @param func is the function called when the Slider moves
  79757. * @param unit is a string describing the units used, eg degrees or metres
  79758. * @param min is the minimum value for the Slider
  79759. * @param max is the maximum value for the Slider
  79760. * @param value is the start value for the Slider between min and max
  79761. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79762. */
  79763. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79764. }
  79765. }
  79766. declare module BABYLON.GUI {
  79767. /**
  79768. * Class used to hold a the container for ScrollViewer
  79769. * @hidden
  79770. */
  79771. export class _ScrollViewerWindow extends Container {
  79772. parentClientWidth: number;
  79773. parentClientHeight: number;
  79774. private _freezeControls;
  79775. private _parentMeasure;
  79776. private _oldLeft;
  79777. private _oldTop;
  79778. get freezeControls(): boolean;
  79779. set freezeControls(value: boolean);
  79780. private _bucketWidth;
  79781. private _bucketHeight;
  79782. private _buckets;
  79783. private _bucketLen;
  79784. get bucketWidth(): number;
  79785. get bucketHeight(): number;
  79786. setBucketSizes(width: number, height: number): void;
  79787. private _useBuckets;
  79788. private _makeBuckets;
  79789. private _dispatchInBuckets;
  79790. private _updateMeasures;
  79791. private _updateChildrenMeasures;
  79792. private _restoreMeasures;
  79793. /**
  79794. * Creates a new ScrollViewerWindow
  79795. * @param name of ScrollViewerWindow
  79796. */
  79797. constructor(name?: string);
  79798. protected _getTypeName(): string;
  79799. /** @hidden */
  79800. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79801. /** @hidden */
  79802. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79803. private _scrollChildren;
  79804. private _scrollChildrenWithBuckets;
  79805. /** @hidden */
  79806. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79807. protected _postMeasure(): void;
  79808. }
  79809. }
  79810. declare module BABYLON.GUI {
  79811. /**
  79812. * Class used to create slider controls
  79813. */
  79814. export class ScrollBar extends BaseSlider {
  79815. name?: string | undefined;
  79816. private _background;
  79817. private _borderColor;
  79818. private _tempMeasure;
  79819. /** Gets or sets border color */
  79820. get borderColor(): string;
  79821. set borderColor(value: string);
  79822. /** Gets or sets background color */
  79823. get background(): string;
  79824. set background(value: string);
  79825. /**
  79826. * Creates a new Slider
  79827. * @param name defines the control name
  79828. */
  79829. constructor(name?: string | undefined);
  79830. protected _getTypeName(): string;
  79831. protected _getThumbThickness(): number;
  79832. _draw(context: CanvasRenderingContext2D): void;
  79833. private _first;
  79834. private _originX;
  79835. private _originY;
  79836. /** @hidden */
  79837. protected _updateValueFromPointer(x: number, y: number): void;
  79838. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79839. }
  79840. }
  79841. declare module BABYLON.GUI {
  79842. /**
  79843. * Class used to create slider controls
  79844. */
  79845. export class ImageScrollBar extends BaseSlider {
  79846. name?: string | undefined;
  79847. private _backgroundBaseImage;
  79848. private _backgroundImage;
  79849. private _thumbImage;
  79850. private _thumbBaseImage;
  79851. private _thumbLength;
  79852. private _thumbHeight;
  79853. private _barImageHeight;
  79854. private _tempMeasure;
  79855. /** Number of 90° rotation to apply on the images when in vertical mode */
  79856. num90RotationInVerticalMode: number;
  79857. /**
  79858. * Gets or sets the image used to render the background for horizontal bar
  79859. */
  79860. get backgroundImage(): Image;
  79861. set backgroundImage(value: Image);
  79862. /**
  79863. * Gets or sets the image used to render the thumb
  79864. */
  79865. get thumbImage(): Image;
  79866. set thumbImage(value: Image);
  79867. /**
  79868. * Gets or sets the length of the thumb
  79869. */
  79870. get thumbLength(): number;
  79871. set thumbLength(value: number);
  79872. /**
  79873. * Gets or sets the height of the thumb
  79874. */
  79875. get thumbHeight(): number;
  79876. set thumbHeight(value: number);
  79877. /**
  79878. * Gets or sets the height of the bar image
  79879. */
  79880. get barImageHeight(): number;
  79881. set barImageHeight(value: number);
  79882. /**
  79883. * Creates a new ImageScrollBar
  79884. * @param name defines the control name
  79885. */
  79886. constructor(name?: string | undefined);
  79887. protected _getTypeName(): string;
  79888. protected _getThumbThickness(): number;
  79889. _draw(context: CanvasRenderingContext2D): void;
  79890. private _first;
  79891. private _originX;
  79892. private _originY;
  79893. /** @hidden */
  79894. protected _updateValueFromPointer(x: number, y: number): void;
  79895. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79896. }
  79897. }
  79898. declare module BABYLON.GUI {
  79899. /**
  79900. * Class used to hold a viewer window and sliders in a grid
  79901. */
  79902. export class ScrollViewer extends Rectangle {
  79903. private _grid;
  79904. private _horizontalBarSpace;
  79905. private _verticalBarSpace;
  79906. private _dragSpace;
  79907. private _horizontalBar;
  79908. private _verticalBar;
  79909. private _barColor;
  79910. private _barBackground;
  79911. private _barImage;
  79912. private _horizontalBarImage;
  79913. private _verticalBarImage;
  79914. private _barBackgroundImage;
  79915. private _horizontalBarBackgroundImage;
  79916. private _verticalBarBackgroundImage;
  79917. private _barSize;
  79918. private _window;
  79919. private _pointerIsOver;
  79920. private _wheelPrecision;
  79921. private _onWheelObserver;
  79922. private _clientWidth;
  79923. private _clientHeight;
  79924. private _useImageBar;
  79925. private _thumbLength;
  79926. private _thumbHeight;
  79927. private _barImageHeight;
  79928. private _horizontalBarImageHeight;
  79929. private _verticalBarImageHeight;
  79930. private _oldWindowContentsWidth;
  79931. private _oldWindowContentsHeight;
  79932. /**
  79933. * Gets the horizontal scrollbar
  79934. */
  79935. get horizontalBar(): ScrollBar | ImageScrollBar;
  79936. /**
  79937. * Gets the vertical scrollbar
  79938. */
  79939. get verticalBar(): ScrollBar | ImageScrollBar;
  79940. /**
  79941. * Adds a new control to the current container
  79942. * @param control defines the control to add
  79943. * @returns the current container
  79944. */
  79945. addControl(control: BABYLON.Nullable<Control>): Container;
  79946. /**
  79947. * Removes a control from the current container
  79948. * @param control defines the control to remove
  79949. * @returns the current container
  79950. */
  79951. removeControl(control: Control): Container;
  79952. /** Gets the list of children */
  79953. get children(): Control[];
  79954. _flagDescendantsAsMatrixDirty(): void;
  79955. /**
  79956. * Freezes or unfreezes the controls in the window.
  79957. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79958. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79959. */
  79960. get freezeControls(): boolean;
  79961. set freezeControls(value: boolean);
  79962. /** Gets the bucket width */
  79963. get bucketWidth(): number;
  79964. /** Gets the bucket height */
  79965. get bucketHeight(): number;
  79966. /**
  79967. * Sets the bucket sizes.
  79968. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79969. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79970. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79971. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79972. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79973. * used), that's why it is not enabled by default.
  79974. * @param width width of the bucket
  79975. * @param height height of the bucket
  79976. */
  79977. setBucketSizes(width: number, height: number): void;
  79978. private _forceHorizontalBar;
  79979. private _forceVerticalBar;
  79980. /**
  79981. * Forces the horizontal scroll bar to be displayed
  79982. */
  79983. get forceHorizontalBar(): boolean;
  79984. set forceHorizontalBar(value: boolean);
  79985. /**
  79986. * Forces the vertical scroll bar to be displayed
  79987. */
  79988. get forceVerticalBar(): boolean;
  79989. set forceVerticalBar(value: boolean);
  79990. /**
  79991. * Creates a new ScrollViewer
  79992. * @param name of ScrollViewer
  79993. */
  79994. constructor(name?: string, isImageBased?: boolean);
  79995. /** Reset the scroll viewer window to initial size */
  79996. resetWindow(): void;
  79997. protected _getTypeName(): string;
  79998. private _buildClientSizes;
  79999. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80000. protected _postMeasure(): void;
  80001. /**
  80002. * Gets or sets the mouse wheel precision
  80003. * from 0 to 1 with a default value of 0.05
  80004. * */
  80005. get wheelPrecision(): number;
  80006. set wheelPrecision(value: number);
  80007. /** Gets or sets the scroll bar container background color */
  80008. get scrollBackground(): string;
  80009. set scrollBackground(color: string);
  80010. /** Gets or sets the bar color */
  80011. get barColor(): string;
  80012. set barColor(color: string);
  80013. /** Gets or sets the bar image */
  80014. get thumbImage(): Image;
  80015. set thumbImage(value: Image);
  80016. /** Gets or sets the horizontal bar image */
  80017. get horizontalThumbImage(): Image;
  80018. set horizontalThumbImage(value: Image);
  80019. /** Gets or sets the vertical bar image */
  80020. get verticalThumbImage(): Image;
  80021. set verticalThumbImage(value: Image);
  80022. /** Gets or sets the size of the bar */
  80023. get barSize(): number;
  80024. set barSize(value: number);
  80025. /** Gets or sets the length of the thumb */
  80026. get thumbLength(): number;
  80027. set thumbLength(value: number);
  80028. /** Gets or sets the height of the thumb */
  80029. get thumbHeight(): number;
  80030. set thumbHeight(value: number);
  80031. /** Gets or sets the height of the bar image */
  80032. get barImageHeight(): number;
  80033. set barImageHeight(value: number);
  80034. /** Gets or sets the height of the horizontal bar image */
  80035. get horizontalBarImageHeight(): number;
  80036. set horizontalBarImageHeight(value: number);
  80037. /** Gets or sets the height of the vertical bar image */
  80038. get verticalBarImageHeight(): number;
  80039. set verticalBarImageHeight(value: number);
  80040. /** Gets or sets the bar background */
  80041. get barBackground(): string;
  80042. set barBackground(color: string);
  80043. /** Gets or sets the bar background image */
  80044. get barImage(): Image;
  80045. set barImage(value: Image);
  80046. /** Gets or sets the horizontal bar background image */
  80047. get horizontalBarImage(): Image;
  80048. set horizontalBarImage(value: Image);
  80049. /** Gets or sets the vertical bar background image */
  80050. get verticalBarImage(): Image;
  80051. set verticalBarImage(value: Image);
  80052. private _setWindowPosition;
  80053. /** @hidden */
  80054. private _updateScroller;
  80055. _link(host: AdvancedDynamicTexture): void;
  80056. /** @hidden */
  80057. private _addBar;
  80058. /** @hidden */
  80059. private _attachWheel;
  80060. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80061. /** Releases associated resources */
  80062. dispose(): void;
  80063. }
  80064. }
  80065. declare module BABYLON.GUI {
  80066. /** Class used to render a grid */
  80067. export class DisplayGrid extends Control {
  80068. name?: string | undefined;
  80069. private _cellWidth;
  80070. private _cellHeight;
  80071. private _minorLineTickness;
  80072. private _minorLineColor;
  80073. private _majorLineTickness;
  80074. private _majorLineColor;
  80075. private _majorLineFrequency;
  80076. private _background;
  80077. private _displayMajorLines;
  80078. private _displayMinorLines;
  80079. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80080. get displayMinorLines(): boolean;
  80081. set displayMinorLines(value: boolean);
  80082. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80083. get displayMajorLines(): boolean;
  80084. set displayMajorLines(value: boolean);
  80085. /** Gets or sets background color (Black by default) */
  80086. get background(): string;
  80087. set background(value: string);
  80088. /** Gets or sets the width of each cell (20 by default) */
  80089. get cellWidth(): number;
  80090. set cellWidth(value: number);
  80091. /** Gets or sets the height of each cell (20 by default) */
  80092. get cellHeight(): number;
  80093. set cellHeight(value: number);
  80094. /** Gets or sets the tickness of minor lines (1 by default) */
  80095. get minorLineTickness(): number;
  80096. set minorLineTickness(value: number);
  80097. /** Gets or sets the color of minor lines (DarkGray by default) */
  80098. get minorLineColor(): string;
  80099. set minorLineColor(value: string);
  80100. /** Gets or sets the tickness of major lines (2 by default) */
  80101. get majorLineTickness(): number;
  80102. set majorLineTickness(value: number);
  80103. /** Gets or sets the color of major lines (White by default) */
  80104. get majorLineColor(): string;
  80105. set majorLineColor(value: string);
  80106. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80107. get majorLineFrequency(): number;
  80108. set majorLineFrequency(value: number);
  80109. /**
  80110. * Creates a new GridDisplayRectangle
  80111. * @param name defines the control name
  80112. */
  80113. constructor(name?: string | undefined);
  80114. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80115. protected _getTypeName(): string;
  80116. }
  80117. }
  80118. declare module BABYLON.GUI {
  80119. /**
  80120. * Class used to create slider controls based on images
  80121. */
  80122. export class ImageBasedSlider extends BaseSlider {
  80123. name?: string | undefined;
  80124. private _backgroundImage;
  80125. private _thumbImage;
  80126. private _valueBarImage;
  80127. private _tempMeasure;
  80128. get displayThumb(): boolean;
  80129. set displayThumb(value: boolean);
  80130. /**
  80131. * Gets or sets the image used to render the background
  80132. */
  80133. get backgroundImage(): Image;
  80134. set backgroundImage(value: Image);
  80135. /**
  80136. * Gets or sets the image used to render the value bar
  80137. */
  80138. get valueBarImage(): Image;
  80139. set valueBarImage(value: Image);
  80140. /**
  80141. * Gets or sets the image used to render the thumb
  80142. */
  80143. get thumbImage(): Image;
  80144. set thumbImage(value: Image);
  80145. /**
  80146. * Creates a new ImageBasedSlider
  80147. * @param name defines the control name
  80148. */
  80149. constructor(name?: string | undefined);
  80150. protected _getTypeName(): string;
  80151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80152. }
  80153. }
  80154. declare module BABYLON.GUI {
  80155. /**
  80156. * Forcing an export so that this code will execute
  80157. * @hidden
  80158. */
  80159. const name = "Statics";
  80160. }
  80161. declare module BABYLON.GUI {
  80162. /**
  80163. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80164. */
  80165. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80166. /**
  80167. * Define the instrumented AdvancedDynamicTexture.
  80168. */
  80169. texture: AdvancedDynamicTexture;
  80170. private _captureRenderTime;
  80171. private _renderTime;
  80172. private _captureLayoutTime;
  80173. private _layoutTime;
  80174. private _onBeginRenderObserver;
  80175. private _onEndRenderObserver;
  80176. private _onBeginLayoutObserver;
  80177. private _onEndLayoutObserver;
  80178. /**
  80179. * Gets the perf counter used to capture render time
  80180. */
  80181. get renderTimeCounter(): BABYLON.PerfCounter;
  80182. /**
  80183. * Gets the perf counter used to capture layout time
  80184. */
  80185. get layoutTimeCounter(): BABYLON.PerfCounter;
  80186. /**
  80187. * Enable or disable the render time capture
  80188. */
  80189. get captureRenderTime(): boolean;
  80190. set captureRenderTime(value: boolean);
  80191. /**
  80192. * Enable or disable the layout time capture
  80193. */
  80194. get captureLayoutTime(): boolean;
  80195. set captureLayoutTime(value: boolean);
  80196. /**
  80197. * Instantiates a new advanced dynamic texture instrumentation.
  80198. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80199. * @param texture Defines the AdvancedDynamicTexture to instrument
  80200. */
  80201. constructor(
  80202. /**
  80203. * Define the instrumented AdvancedDynamicTexture.
  80204. */
  80205. texture: AdvancedDynamicTexture);
  80206. /**
  80207. * Dispose and release associated resources.
  80208. */
  80209. dispose(): void;
  80210. }
  80211. }
  80212. declare module BABYLON.GUI {
  80213. /**
  80214. * Class used to load GUI via XML.
  80215. */
  80216. export class XmlLoader {
  80217. private _nodes;
  80218. private _nodeTypes;
  80219. private _isLoaded;
  80220. private _objectAttributes;
  80221. private _parentClass;
  80222. /**
  80223. * Create a new xml loader
  80224. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80225. */
  80226. constructor(parentClass?: null);
  80227. private _getChainElement;
  80228. private _getClassAttribute;
  80229. private _createGuiElement;
  80230. private _parseGrid;
  80231. private _parseElement;
  80232. private _prepareSourceElement;
  80233. private _parseElementsFromSource;
  80234. private _parseXml;
  80235. /**
  80236. * Gets if the loading has finished.
  80237. * @returns whether the loading has finished or not
  80238. */
  80239. isLoaded(): boolean;
  80240. /**
  80241. * Gets a loaded node / control by id.
  80242. * @param id the Controls id set in the xml
  80243. * @returns element of type Control
  80244. */
  80245. getNodeById(id: string): any;
  80246. /**
  80247. * Gets all loaded nodes / controls
  80248. * @returns Array of controls
  80249. */
  80250. getNodes(): any;
  80251. /**
  80252. * Initiates the xml layout loading
  80253. * @param xmlFile defines the xml layout to load
  80254. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80255. * @param callback defines the callback called on layout load.
  80256. */
  80257. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80258. }
  80259. }
  80260. declare module BABYLON.GUI {
  80261. /**
  80262. * Class used to create containers for controls
  80263. */
  80264. export class Container3D extends Control3D {
  80265. private _blockLayout;
  80266. /**
  80267. * Gets the list of child controls
  80268. */
  80269. protected _children: Control3D[];
  80270. /**
  80271. * Gets the list of child controls
  80272. */
  80273. get children(): Array<Control3D>;
  80274. /**
  80275. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80276. * This is helpful to optimize layout operation when adding multiple children in a row
  80277. */
  80278. get blockLayout(): boolean;
  80279. set blockLayout(value: boolean);
  80280. /**
  80281. * Creates a new container
  80282. * @param name defines the container name
  80283. */
  80284. constructor(name?: string);
  80285. /**
  80286. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80287. * @returns the current container
  80288. */
  80289. updateLayout(): Container3D;
  80290. /**
  80291. * Gets a boolean indicating if the given control is in the children of this control
  80292. * @param control defines the control to check
  80293. * @returns true if the control is in the child list
  80294. */
  80295. containsControl(control: Control3D): boolean;
  80296. /**
  80297. * Adds a control to the children of this control
  80298. * @param control defines the control to add
  80299. * @returns the current container
  80300. */
  80301. addControl(control: Control3D): Container3D;
  80302. /**
  80303. * This function will be called everytime a new control is added
  80304. */
  80305. protected _arrangeChildren(): void;
  80306. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80307. /**
  80308. * Removes a control from the children of this control
  80309. * @param control defines the control to remove
  80310. * @returns the current container
  80311. */
  80312. removeControl(control: Control3D): Container3D;
  80313. protected _getTypeName(): string;
  80314. /**
  80315. * Releases all associated resources
  80316. */
  80317. dispose(): void;
  80318. /** Control rotation will remain unchanged */
  80319. static readonly UNSET_ORIENTATION: number;
  80320. /** Control will rotate to make it look at sphere central axis */
  80321. static readonly FACEORIGIN_ORIENTATION: number;
  80322. /** Control will rotate to make it look back at sphere central axis */
  80323. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80324. /** Control will rotate to look at z axis (0, 0, 1) */
  80325. static readonly FACEFORWARD_ORIENTATION: number;
  80326. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80327. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80328. }
  80329. }
  80330. declare module BABYLON.GUI {
  80331. /**
  80332. * Class used to manage 3D user interface
  80333. * @see https://doc.babylonjs.com/how_to/gui3d
  80334. */
  80335. export class GUI3DManager implements BABYLON.IDisposable {
  80336. private _scene;
  80337. private _sceneDisposeObserver;
  80338. private _utilityLayer;
  80339. private _rootContainer;
  80340. private _pointerObserver;
  80341. private _pointerOutObserver;
  80342. /** @hidden */
  80343. _lastPickedControl: Control3D;
  80344. /** @hidden */
  80345. _lastControlOver: {
  80346. [pointerId: number]: Control3D;
  80347. };
  80348. /** @hidden */
  80349. _lastControlDown: {
  80350. [pointerId: number]: Control3D;
  80351. };
  80352. /**
  80353. * BABYLON.Observable raised when the point picked by the pointer events changed
  80354. */
  80355. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80356. /** @hidden */
  80357. _sharedMaterials: {
  80358. [key: string]: BABYLON.Material;
  80359. };
  80360. /** Gets the hosting scene */
  80361. get scene(): BABYLON.Scene;
  80362. /** Gets associated utility layer */
  80363. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80364. /**
  80365. * Creates a new GUI3DManager
  80366. * @param scene
  80367. */
  80368. constructor(scene?: BABYLON.Scene);
  80369. private _handlePointerOut;
  80370. private _doPicking;
  80371. /**
  80372. * Gets the root container
  80373. */
  80374. get rootContainer(): Container3D;
  80375. /**
  80376. * Gets a boolean indicating if the given control is in the root child list
  80377. * @param control defines the control to check
  80378. * @returns true if the control is in the root child list
  80379. */
  80380. containsControl(control: Control3D): boolean;
  80381. /**
  80382. * Adds a control to the root child list
  80383. * @param control defines the control to add
  80384. * @returns the current manager
  80385. */
  80386. addControl(control: Control3D): GUI3DManager;
  80387. /**
  80388. * Removes a control from the root child list
  80389. * @param control defines the control to remove
  80390. * @returns the current container
  80391. */
  80392. removeControl(control: Control3D): GUI3DManager;
  80393. /**
  80394. * Releases all associated resources
  80395. */
  80396. dispose(): void;
  80397. }
  80398. }
  80399. declare module BABYLON.GUI {
  80400. /**
  80401. * Class used to transport BABYLON.Vector3 information for pointer events
  80402. */
  80403. export class Vector3WithInfo extends BABYLON.Vector3 {
  80404. /** defines the current mouse button index */
  80405. buttonIndex: number;
  80406. /**
  80407. * Creates a new Vector3WithInfo
  80408. * @param source defines the vector3 data to transport
  80409. * @param buttonIndex defines the current mouse button index
  80410. */
  80411. constructor(source: BABYLON.Vector3,
  80412. /** defines the current mouse button index */
  80413. buttonIndex?: number);
  80414. }
  80415. }
  80416. declare module BABYLON.GUI {
  80417. /**
  80418. * Class used as base class for controls
  80419. */
  80420. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80421. /** Defines the control name */
  80422. name?: string | undefined;
  80423. /** @hidden */
  80424. _host: GUI3DManager;
  80425. private _node;
  80426. private _downCount;
  80427. private _enterCount;
  80428. private _downPointerIds;
  80429. private _isVisible;
  80430. /** Gets or sets the control position in world space */
  80431. get position(): BABYLON.Vector3;
  80432. set position(value: BABYLON.Vector3);
  80433. /** Gets or sets the control scaling in world space */
  80434. get scaling(): BABYLON.Vector3;
  80435. set scaling(value: BABYLON.Vector3);
  80436. /** Callback used to start pointer enter animation */
  80437. pointerEnterAnimation: () => void;
  80438. /** Callback used to start pointer out animation */
  80439. pointerOutAnimation: () => void;
  80440. /** Callback used to start pointer down animation */
  80441. pointerDownAnimation: () => void;
  80442. /** Callback used to start pointer up animation */
  80443. pointerUpAnimation: () => void;
  80444. /**
  80445. * An event triggered when the pointer move over the control
  80446. */
  80447. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80448. /**
  80449. * An event triggered when the pointer move out of the control
  80450. */
  80451. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80452. /**
  80453. * An event triggered when the pointer taps the control
  80454. */
  80455. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80456. /**
  80457. * An event triggered when pointer is up
  80458. */
  80459. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80460. /**
  80461. * An event triggered when a control is clicked on (with a mouse)
  80462. */
  80463. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80464. /**
  80465. * An event triggered when pointer enters the control
  80466. */
  80467. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80468. /**
  80469. * Gets or sets the parent container
  80470. */
  80471. parent: BABYLON.Nullable<Container3D>;
  80472. private _behaviors;
  80473. /**
  80474. * Gets the list of attached behaviors
  80475. * @see https://doc.babylonjs.com/features/behaviour
  80476. */
  80477. get behaviors(): BABYLON.Behavior<Control3D>[];
  80478. /**
  80479. * Attach a behavior to the control
  80480. * @see https://doc.babylonjs.com/features/behaviour
  80481. * @param behavior defines the behavior to attach
  80482. * @returns the current control
  80483. */
  80484. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80485. /**
  80486. * Remove an attached behavior
  80487. * @see https://doc.babylonjs.com/features/behaviour
  80488. * @param behavior defines the behavior to attach
  80489. * @returns the current control
  80490. */
  80491. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80492. /**
  80493. * Gets an attached behavior by name
  80494. * @param name defines the name of the behavior to look for
  80495. * @see https://doc.babylonjs.com/features/behaviour
  80496. * @returns null if behavior was not found else the requested behavior
  80497. */
  80498. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80499. /** Gets or sets a boolean indicating if the control is visible */
  80500. get isVisible(): boolean;
  80501. set isVisible(value: boolean);
  80502. /**
  80503. * Creates a new control
  80504. * @param name defines the control name
  80505. */
  80506. constructor(
  80507. /** Defines the control name */
  80508. name?: string | undefined);
  80509. /**
  80510. * Gets a string representing the class name
  80511. */
  80512. get typeName(): string;
  80513. /**
  80514. * Get the current class name of the control.
  80515. * @returns current class name
  80516. */
  80517. getClassName(): string;
  80518. protected _getTypeName(): string;
  80519. /**
  80520. * Gets the transform node used by this control
  80521. */
  80522. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80523. /**
  80524. * Gets the mesh used to render this control
  80525. */
  80526. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80527. /**
  80528. * Link the control as child of the given node
  80529. * @param node defines the node to link to. Use null to unlink the control
  80530. * @returns the current control
  80531. */
  80532. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80533. /** @hidden **/
  80534. _prepareNode(scene: BABYLON.Scene): void;
  80535. /**
  80536. * Node creation.
  80537. * Can be overriden by children
  80538. * @param scene defines the scene where the node must be attached
  80539. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80540. */
  80541. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80542. /**
  80543. * Affect a material to the given mesh
  80544. * @param mesh defines the mesh which will represent the control
  80545. */
  80546. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80547. /** @hidden */
  80548. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80549. /** @hidden */
  80550. _onPointerEnter(target: Control3D): boolean;
  80551. /** @hidden */
  80552. _onPointerOut(target: Control3D): void;
  80553. /** @hidden */
  80554. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80555. /** @hidden */
  80556. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80557. /** @hidden */
  80558. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80559. /** @hidden */
  80560. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80561. /** @hidden */
  80562. _disposeNode(): void;
  80563. /**
  80564. * Releases all associated resources
  80565. */
  80566. dispose(): void;
  80567. }
  80568. }
  80569. declare module BABYLON.GUI {
  80570. /**
  80571. * Class used as a root to all buttons
  80572. */
  80573. export class AbstractButton3D extends Control3D {
  80574. /**
  80575. * Creates a new button
  80576. * @param name defines the control name
  80577. */
  80578. constructor(name?: string);
  80579. protected _getTypeName(): string;
  80580. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80581. }
  80582. }
  80583. declare module BABYLON.GUI {
  80584. /**
  80585. * Class used to create a button in 3D
  80586. */
  80587. export class Button3D extends AbstractButton3D {
  80588. /** @hidden */
  80589. protected _currentMaterial: BABYLON.Material;
  80590. private _facadeTexture;
  80591. private _content;
  80592. private _contentResolution;
  80593. private _contentScaleRatio;
  80594. /**
  80595. * Gets or sets the texture resolution used to render content (512 by default)
  80596. */
  80597. get contentResolution(): BABYLON.int;
  80598. set contentResolution(value: BABYLON.int);
  80599. /**
  80600. * Gets or sets the texture scale ratio used to render content (2 by default)
  80601. */
  80602. get contentScaleRatio(): number;
  80603. set contentScaleRatio(value: number);
  80604. protected _disposeFacadeTexture(): void;
  80605. protected _resetContent(): void;
  80606. /**
  80607. * Creates a new button
  80608. * @param name defines the control name
  80609. */
  80610. constructor(name?: string);
  80611. /**
  80612. * Gets or sets the GUI 2D content used to display the button's facade
  80613. */
  80614. get content(): Control;
  80615. set content(value: Control);
  80616. /**
  80617. * Apply the facade texture (created from the content property).
  80618. * This function can be overloaded by child classes
  80619. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80620. */
  80621. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80622. protected _getTypeName(): string;
  80623. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80624. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80625. /**
  80626. * Releases all associated resources
  80627. */
  80628. dispose(): void;
  80629. }
  80630. }
  80631. declare module BABYLON.GUI {
  80632. /**
  80633. * Abstract class used to create a container panel deployed on the surface of a volume
  80634. */
  80635. export abstract class VolumeBasedPanel extends Container3D {
  80636. private _columns;
  80637. private _rows;
  80638. private _rowThenColum;
  80639. private _orientation;
  80640. protected _cellWidth: number;
  80641. protected _cellHeight: number;
  80642. /**
  80643. * Gets or sets the distance between elements
  80644. */
  80645. margin: number;
  80646. /**
  80647. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80648. * | Value | Type | Description |
  80649. * | ----- | ----------------------------------- | ----------- |
  80650. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80651. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80652. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80653. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80654. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80655. */
  80656. get orientation(): number;
  80657. set orientation(value: number);
  80658. /**
  80659. * Gets or sets the number of columns requested (10 by default).
  80660. * The panel will automatically compute the number of rows based on number of child controls.
  80661. */
  80662. get columns(): BABYLON.int;
  80663. set columns(value: BABYLON.int);
  80664. /**
  80665. * Gets or sets a the number of rows requested.
  80666. * The panel will automatically compute the number of columns based on number of child controls.
  80667. */
  80668. get rows(): BABYLON.int;
  80669. set rows(value: BABYLON.int);
  80670. /**
  80671. * Creates new VolumeBasedPanel
  80672. */
  80673. constructor();
  80674. protected _arrangeChildren(): void;
  80675. /** Child classes must implement this function to provide correct control positioning */
  80676. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80677. /** Child classes can implement this function to provide additional processing */
  80678. protected _finalProcessing(): void;
  80679. }
  80680. }
  80681. declare module BABYLON.GUI {
  80682. /**
  80683. * Class used to create a container panel deployed on the surface of a cylinder
  80684. */
  80685. export class CylinderPanel extends VolumeBasedPanel {
  80686. private _radius;
  80687. /**
  80688. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80689. */
  80690. get radius(): BABYLON.float;
  80691. set radius(value: BABYLON.float);
  80692. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80693. private _cylindricalMapping;
  80694. }
  80695. }
  80696. declare module BABYLON.GUI {
  80697. /** @hidden */
  80698. export var fluentVertexShader: {
  80699. name: string;
  80700. shader: string;
  80701. };
  80702. }
  80703. declare module BABYLON.GUI {
  80704. /** @hidden */
  80705. export var fluentPixelShader: {
  80706. name: string;
  80707. shader: string;
  80708. };
  80709. }
  80710. declare module BABYLON.GUI {
  80711. /** @hidden */
  80712. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80713. INNERGLOW: boolean;
  80714. BORDER: boolean;
  80715. HOVERLIGHT: boolean;
  80716. TEXTURE: boolean;
  80717. constructor();
  80718. }
  80719. /**
  80720. * Class used to render controls with fluent desgin
  80721. */
  80722. export class FluentMaterial extends BABYLON.PushMaterial {
  80723. /**
  80724. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80725. */
  80726. innerGlowColorIntensity: number;
  80727. /**
  80728. * Gets or sets the inner glow color (white by default)
  80729. */
  80730. innerGlowColor: BABYLON.Color3;
  80731. /**
  80732. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80733. */
  80734. albedoColor: BABYLON.Color3;
  80735. /**
  80736. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80737. */
  80738. renderBorders: boolean;
  80739. /**
  80740. * Gets or sets border width (default is 0.5)
  80741. */
  80742. borderWidth: number;
  80743. /**
  80744. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80745. */
  80746. edgeSmoothingValue: number;
  80747. /**
  80748. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80749. */
  80750. borderMinValue: number;
  80751. /**
  80752. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80753. */
  80754. renderHoverLight: boolean;
  80755. /**
  80756. * Gets or sets the radius used to render the hover light (default is 1.0)
  80757. */
  80758. hoverRadius: number;
  80759. /**
  80760. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80761. */
  80762. hoverColor: BABYLON.Color4;
  80763. /**
  80764. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80765. */
  80766. hoverPosition: BABYLON.Vector3;
  80767. private _albedoTexture;
  80768. /** Gets or sets the texture to use for albedo color */
  80769. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80770. /**
  80771. * Creates a new Fluent material
  80772. * @param name defines the name of the material
  80773. * @param scene defines the hosting scene
  80774. */
  80775. constructor(name: string, scene: BABYLON.Scene);
  80776. needAlphaBlending(): boolean;
  80777. needAlphaTesting(): boolean;
  80778. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80779. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80780. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80781. getActiveTextures(): BABYLON.BaseTexture[];
  80782. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80783. dispose(forceDisposeEffect?: boolean): void;
  80784. clone(name: string): FluentMaterial;
  80785. serialize(): any;
  80786. getClassName(): string;
  80787. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80788. }
  80789. }
  80790. declare module BABYLON.GUI {
  80791. /**
  80792. * Class used to create a holographic button in 3D
  80793. */
  80794. export class HolographicButton extends Button3D {
  80795. private _backPlate;
  80796. private _textPlate;
  80797. private _frontPlate;
  80798. private _text;
  80799. private _imageUrl;
  80800. private _shareMaterials;
  80801. private _frontMaterial;
  80802. private _backMaterial;
  80803. private _plateMaterial;
  80804. private _pickedPointObserver;
  80805. private _tooltipFade;
  80806. private _tooltipTextBlock;
  80807. private _tooltipTexture;
  80808. private _tooltipMesh;
  80809. private _tooltipHoverObserver;
  80810. private _tooltipOutObserver;
  80811. private _disposeTooltip;
  80812. /**
  80813. * Rendering ground id of all the mesh in the button
  80814. */
  80815. set renderingGroupId(id: number);
  80816. get renderingGroupId(): number;
  80817. /**
  80818. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80819. */
  80820. set tooltipText(text: BABYLON.Nullable<string>);
  80821. get tooltipText(): BABYLON.Nullable<string>;
  80822. /**
  80823. * Gets or sets text for the button
  80824. */
  80825. get text(): string;
  80826. set text(value: string);
  80827. /**
  80828. * Gets or sets the image url for the button
  80829. */
  80830. get imageUrl(): string;
  80831. set imageUrl(value: string);
  80832. /**
  80833. * Gets the back material used by this button
  80834. */
  80835. get backMaterial(): FluentMaterial;
  80836. /**
  80837. * Gets the front material used by this button
  80838. */
  80839. get frontMaterial(): FluentMaterial;
  80840. /**
  80841. * Gets the plate material used by this button
  80842. */
  80843. get plateMaterial(): BABYLON.StandardMaterial;
  80844. /**
  80845. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80846. */
  80847. get shareMaterials(): boolean;
  80848. /**
  80849. * Creates a new button
  80850. * @param name defines the control name
  80851. */
  80852. constructor(name?: string, shareMaterials?: boolean);
  80853. protected _getTypeName(): string;
  80854. private _rebuildContent;
  80855. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80856. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80857. private _createBackMaterial;
  80858. private _createFrontMaterial;
  80859. private _createPlateMaterial;
  80860. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80861. /**
  80862. * Releases all associated resources
  80863. */
  80864. dispose(): void;
  80865. }
  80866. }
  80867. declare module BABYLON.GUI {
  80868. /**
  80869. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80870. */
  80871. export class MeshButton3D extends Button3D {
  80872. /** @hidden */
  80873. protected _currentMesh: BABYLON.Mesh;
  80874. /**
  80875. * Creates a new 3D button based on a mesh
  80876. * @param mesh mesh to become a 3D button
  80877. * @param name defines the control name
  80878. */
  80879. constructor(mesh: BABYLON.Mesh, name?: string);
  80880. protected _getTypeName(): string;
  80881. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80882. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80883. }
  80884. }
  80885. declare module BABYLON.GUI {
  80886. /**
  80887. * Class used to create a container panel deployed on the surface of a plane
  80888. */
  80889. export class PlanePanel extends VolumeBasedPanel {
  80890. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80891. }
  80892. }
  80893. declare module BABYLON.GUI {
  80894. /**
  80895. * Class used to create a container panel where items get randomized planar mapping
  80896. */
  80897. export class ScatterPanel extends VolumeBasedPanel {
  80898. private _iteration;
  80899. /**
  80900. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80901. */
  80902. get iteration(): BABYLON.float;
  80903. set iteration(value: BABYLON.float);
  80904. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80905. private _scatterMapping;
  80906. protected _finalProcessing(): void;
  80907. }
  80908. }
  80909. declare module BABYLON.GUI {
  80910. /**
  80911. * Class used to create a container panel deployed on the surface of a sphere
  80912. */
  80913. export class SpherePanel extends VolumeBasedPanel {
  80914. private _radius;
  80915. /**
  80916. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80917. */
  80918. get radius(): BABYLON.float;
  80919. set radius(value: BABYLON.float);
  80920. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80921. private _sphericalMapping;
  80922. }
  80923. }
  80924. declare module BABYLON.GUI {
  80925. /**
  80926. * Class used to create a stack panel in 3D on XY plane
  80927. */
  80928. export class StackPanel3D extends Container3D {
  80929. private _isVertical;
  80930. /**
  80931. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80932. */
  80933. get isVertical(): boolean;
  80934. set isVertical(value: boolean);
  80935. /**
  80936. * Gets or sets the distance between elements
  80937. */
  80938. margin: number;
  80939. /**
  80940. * Creates new StackPanel
  80941. * @param isVertical
  80942. */
  80943. constructor(isVertical?: boolean);
  80944. protected _arrangeChildren(): void;
  80945. }
  80946. }
  80947. declare module BABYLON {
  80948. /**
  80949. * Configuration for glTF validation
  80950. */
  80951. export interface IGLTFValidationConfiguration {
  80952. /**
  80953. * The url of the glTF validator.
  80954. */
  80955. url: string;
  80956. }
  80957. /**
  80958. * glTF validation
  80959. */
  80960. export class GLTFValidation {
  80961. /**
  80962. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80963. */
  80964. static Configuration: IGLTFValidationConfiguration;
  80965. private static _LoadScriptPromise;
  80966. /**
  80967. * Validate a glTF asset using the glTF-Validator.
  80968. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80969. * @param rootUrl The root url for the glTF
  80970. * @param fileName The file name for the glTF
  80971. * @param getExternalResource The callback to get external resources for the glTF validator
  80972. * @returns A promise that resolves with the glTF validation results once complete
  80973. */
  80974. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80975. }
  80976. }
  80977. declare module BABYLON {
  80978. /**
  80979. * Mode that determines the coordinate system to use.
  80980. */
  80981. export enum GLTFLoaderCoordinateSystemMode {
  80982. /**
  80983. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80984. */
  80985. AUTO = 0,
  80986. /**
  80987. * Sets the useRightHandedSystem flag on the scene.
  80988. */
  80989. FORCE_RIGHT_HANDED = 1
  80990. }
  80991. /**
  80992. * Mode that determines what animations will start.
  80993. */
  80994. export enum GLTFLoaderAnimationStartMode {
  80995. /**
  80996. * No animation will start.
  80997. */
  80998. NONE = 0,
  80999. /**
  81000. * The first animation will start.
  81001. */
  81002. FIRST = 1,
  81003. /**
  81004. * All animations will start.
  81005. */
  81006. ALL = 2
  81007. }
  81008. /**
  81009. * Interface that contains the data for the glTF asset.
  81010. */
  81011. export interface IGLTFLoaderData {
  81012. /**
  81013. * The object that represents the glTF JSON.
  81014. */
  81015. json: Object;
  81016. /**
  81017. * The BIN chunk of a binary glTF.
  81018. */
  81019. bin: Nullable<IDataBuffer>;
  81020. }
  81021. /**
  81022. * Interface for extending the loader.
  81023. */
  81024. export interface IGLTFLoaderExtension {
  81025. /**
  81026. * The name of this extension.
  81027. */
  81028. readonly name: string;
  81029. /**
  81030. * Defines whether this extension is enabled.
  81031. */
  81032. enabled: boolean;
  81033. /**
  81034. * Defines the order of this extension.
  81035. * The loader sorts the extensions using these values when loading.
  81036. */
  81037. order?: number;
  81038. }
  81039. /**
  81040. * Loader state.
  81041. */
  81042. export enum GLTFLoaderState {
  81043. /**
  81044. * The asset is loading.
  81045. */
  81046. LOADING = 0,
  81047. /**
  81048. * The asset is ready for rendering.
  81049. */
  81050. READY = 1,
  81051. /**
  81052. * The asset is completely loaded.
  81053. */
  81054. COMPLETE = 2
  81055. }
  81056. /** @hidden */
  81057. export interface IImportMeshAsyncOutput {
  81058. meshes: AbstractMesh[];
  81059. particleSystems: IParticleSystem[];
  81060. skeletons: Skeleton[];
  81061. animationGroups: AnimationGroup[];
  81062. lights: Light[];
  81063. transformNodes: TransformNode[];
  81064. }
  81065. /** @hidden */
  81066. export interface IGLTFLoader extends IDisposable {
  81067. readonly state: Nullable<GLTFLoaderState>;
  81068. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81069. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81070. }
  81071. /**
  81072. * File loader for loading glTF files into a scene.
  81073. */
  81074. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81075. /** @hidden */
  81076. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81077. /** @hidden */
  81078. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81079. /**
  81080. * Raised when the asset has been parsed
  81081. */
  81082. onParsedObservable: Observable<IGLTFLoaderData>;
  81083. private _onParsedObserver;
  81084. /**
  81085. * Raised when the asset has been parsed
  81086. */
  81087. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81088. /**
  81089. * 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.
  81090. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81091. * Defaults to true.
  81092. * @hidden
  81093. */
  81094. static IncrementalLoading: boolean;
  81095. /**
  81096. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81097. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81098. * @hidden
  81099. */
  81100. static HomogeneousCoordinates: boolean;
  81101. /**
  81102. * The coordinate system mode. Defaults to AUTO.
  81103. */
  81104. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81105. /**
  81106. * The animation start mode. Defaults to FIRST.
  81107. */
  81108. animationStartMode: GLTFLoaderAnimationStartMode;
  81109. /**
  81110. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81111. */
  81112. compileMaterials: boolean;
  81113. /**
  81114. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81115. */
  81116. useClipPlane: boolean;
  81117. /**
  81118. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81119. */
  81120. compileShadowGenerators: boolean;
  81121. /**
  81122. * Defines if the Alpha blended materials are only applied as coverage.
  81123. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81124. * If true, no extra effects are applied to transparent pixels.
  81125. */
  81126. transparencyAsCoverage: boolean;
  81127. /**
  81128. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81129. * Enabling will disable offline support and glTF validator.
  81130. * Defaults to false.
  81131. */
  81132. useRangeRequests: boolean;
  81133. /**
  81134. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81135. */
  81136. createInstances: boolean;
  81137. /**
  81138. * 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.
  81139. */
  81140. alwaysComputeBoundingBox: boolean;
  81141. /**
  81142. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81143. */
  81144. loadAllMaterials: boolean;
  81145. /**
  81146. * Function called before loading a url referenced by the asset.
  81147. */
  81148. preprocessUrlAsync: (url: string) => Promise<string>;
  81149. /**
  81150. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81151. * 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, ...)
  81152. */
  81153. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81154. private _onMeshLoadedObserver;
  81155. /**
  81156. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81157. * 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, ...)
  81158. */
  81159. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81160. /**
  81161. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81162. */
  81163. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81164. private _onTextureLoadedObserver;
  81165. /**
  81166. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81167. */
  81168. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81169. /**
  81170. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81171. */
  81172. readonly onMaterialLoadedObservable: Observable<Material>;
  81173. private _onMaterialLoadedObserver;
  81174. /**
  81175. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81176. */
  81177. set onMaterialLoaded(callback: (material: Material) => void);
  81178. /**
  81179. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81180. */
  81181. readonly onCameraLoadedObservable: Observable<Camera>;
  81182. private _onCameraLoadedObserver;
  81183. /**
  81184. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81185. */
  81186. set onCameraLoaded(callback: (camera: Camera) => void);
  81187. /**
  81188. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81189. * For assets with LODs, raised when all of the LODs are complete.
  81190. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81191. */
  81192. readonly onCompleteObservable: Observable<void>;
  81193. private _onCompleteObserver;
  81194. /**
  81195. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81196. * For assets with LODs, raised when all of the LODs are complete.
  81197. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81198. */
  81199. set onComplete(callback: () => void);
  81200. /**
  81201. * Observable raised when an error occurs.
  81202. */
  81203. readonly onErrorObservable: Observable<any>;
  81204. private _onErrorObserver;
  81205. /**
  81206. * Callback raised when an error occurs.
  81207. */
  81208. set onError(callback: (reason: any) => void);
  81209. /**
  81210. * Observable raised after the loader is disposed.
  81211. */
  81212. readonly onDisposeObservable: Observable<void>;
  81213. private _onDisposeObserver;
  81214. /**
  81215. * Callback raised after the loader is disposed.
  81216. */
  81217. set onDispose(callback: () => void);
  81218. /**
  81219. * Observable raised after a loader extension is created.
  81220. * Set additional options for a loader extension in this event.
  81221. */
  81222. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81223. private _onExtensionLoadedObserver;
  81224. /**
  81225. * Callback raised after a loader extension is created.
  81226. */
  81227. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81228. /**
  81229. * Defines if the loader logging is enabled.
  81230. */
  81231. get loggingEnabled(): boolean;
  81232. set loggingEnabled(value: boolean);
  81233. /**
  81234. * Defines if the loader should capture performance counters.
  81235. */
  81236. get capturePerformanceCounters(): boolean;
  81237. set capturePerformanceCounters(value: boolean);
  81238. /**
  81239. * Defines if the loader should validate the asset.
  81240. */
  81241. validate: boolean;
  81242. /**
  81243. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81244. */
  81245. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81246. private _onValidatedObserver;
  81247. /**
  81248. * Callback raised after a loader extension is created.
  81249. */
  81250. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81251. private _loader;
  81252. private _progressCallback?;
  81253. private _requests;
  81254. private static magicBase64Encoded;
  81255. /**
  81256. * Name of the loader ("gltf")
  81257. */
  81258. name: string;
  81259. /** @hidden */
  81260. extensions: ISceneLoaderPluginExtensions;
  81261. /**
  81262. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81263. */
  81264. dispose(): void;
  81265. /** @hidden */
  81266. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81267. /** @hidden */
  81268. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81269. /** @hidden */
  81270. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81271. meshes: AbstractMesh[];
  81272. particleSystems: IParticleSystem[];
  81273. skeletons: Skeleton[];
  81274. animationGroups: AnimationGroup[];
  81275. }>;
  81276. /** @hidden */
  81277. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81278. /** @hidden */
  81279. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81280. /** @hidden */
  81281. canDirectLoad(data: string): boolean;
  81282. /** @hidden */
  81283. directLoad(scene: Scene, data: string): Promise<any>;
  81284. /**
  81285. * The callback that allows custom handling of the root url based on the response url.
  81286. * @param rootUrl the original root url
  81287. * @param responseURL the response url if available
  81288. * @returns the new root url
  81289. */
  81290. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81291. /** @hidden */
  81292. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81293. /**
  81294. * The loader state or null if the loader is not active.
  81295. */
  81296. get loaderState(): Nullable<GLTFLoaderState>;
  81297. /**
  81298. * Returns a promise that resolves when the asset is completely loaded.
  81299. * @returns a promise that resolves when the asset is completely loaded.
  81300. */
  81301. whenCompleteAsync(): Promise<void>;
  81302. /** @hidden */
  81303. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81304. /** @hidden */
  81305. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81306. private _onProgress;
  81307. private _validate;
  81308. private _getLoader;
  81309. private _parseJson;
  81310. private _unpackBinaryAsync;
  81311. private _unpackBinaryV1Async;
  81312. private _unpackBinaryV2Async;
  81313. private static _parseVersion;
  81314. private static _compareVersion;
  81315. private static readonly _logSpaces;
  81316. private _logIndentLevel;
  81317. private _loggingEnabled;
  81318. /** @hidden */
  81319. _log: (message: string) => void;
  81320. /** @hidden */
  81321. _logOpen(message: string): void;
  81322. /** @hidden */
  81323. _logClose(): void;
  81324. private _logEnabled;
  81325. private _logDisabled;
  81326. private _capturePerformanceCounters;
  81327. /** @hidden */
  81328. _startPerformanceCounter: (counterName: string) => void;
  81329. /** @hidden */
  81330. _endPerformanceCounter: (counterName: string) => void;
  81331. private _startPerformanceCounterEnabled;
  81332. private _startPerformanceCounterDisabled;
  81333. private _endPerformanceCounterEnabled;
  81334. private _endPerformanceCounterDisabled;
  81335. }
  81336. }
  81337. declare module BABYLON.GLTF1 {
  81338. /**
  81339. * Enums
  81340. * @hidden
  81341. */
  81342. export enum EComponentType {
  81343. BYTE = 5120,
  81344. UNSIGNED_BYTE = 5121,
  81345. SHORT = 5122,
  81346. UNSIGNED_SHORT = 5123,
  81347. FLOAT = 5126
  81348. }
  81349. /** @hidden */
  81350. export enum EShaderType {
  81351. FRAGMENT = 35632,
  81352. VERTEX = 35633
  81353. }
  81354. /** @hidden */
  81355. export enum EParameterType {
  81356. BYTE = 5120,
  81357. UNSIGNED_BYTE = 5121,
  81358. SHORT = 5122,
  81359. UNSIGNED_SHORT = 5123,
  81360. INT = 5124,
  81361. UNSIGNED_INT = 5125,
  81362. FLOAT = 5126,
  81363. FLOAT_VEC2 = 35664,
  81364. FLOAT_VEC3 = 35665,
  81365. FLOAT_VEC4 = 35666,
  81366. INT_VEC2 = 35667,
  81367. INT_VEC3 = 35668,
  81368. INT_VEC4 = 35669,
  81369. BOOL = 35670,
  81370. BOOL_VEC2 = 35671,
  81371. BOOL_VEC3 = 35672,
  81372. BOOL_VEC4 = 35673,
  81373. FLOAT_MAT2 = 35674,
  81374. FLOAT_MAT3 = 35675,
  81375. FLOAT_MAT4 = 35676,
  81376. SAMPLER_2D = 35678
  81377. }
  81378. /** @hidden */
  81379. export enum ETextureWrapMode {
  81380. CLAMP_TO_EDGE = 33071,
  81381. MIRRORED_REPEAT = 33648,
  81382. REPEAT = 10497
  81383. }
  81384. /** @hidden */
  81385. export enum ETextureFilterType {
  81386. NEAREST = 9728,
  81387. LINEAR = 9728,
  81388. NEAREST_MIPMAP_NEAREST = 9984,
  81389. LINEAR_MIPMAP_NEAREST = 9985,
  81390. NEAREST_MIPMAP_LINEAR = 9986,
  81391. LINEAR_MIPMAP_LINEAR = 9987
  81392. }
  81393. /** @hidden */
  81394. export enum ETextureFormat {
  81395. ALPHA = 6406,
  81396. RGB = 6407,
  81397. RGBA = 6408,
  81398. LUMINANCE = 6409,
  81399. LUMINANCE_ALPHA = 6410
  81400. }
  81401. /** @hidden */
  81402. export enum ECullingType {
  81403. FRONT = 1028,
  81404. BACK = 1029,
  81405. FRONT_AND_BACK = 1032
  81406. }
  81407. /** @hidden */
  81408. export enum EBlendingFunction {
  81409. ZERO = 0,
  81410. ONE = 1,
  81411. SRC_COLOR = 768,
  81412. ONE_MINUS_SRC_COLOR = 769,
  81413. DST_COLOR = 774,
  81414. ONE_MINUS_DST_COLOR = 775,
  81415. SRC_ALPHA = 770,
  81416. ONE_MINUS_SRC_ALPHA = 771,
  81417. DST_ALPHA = 772,
  81418. ONE_MINUS_DST_ALPHA = 773,
  81419. CONSTANT_COLOR = 32769,
  81420. ONE_MINUS_CONSTANT_COLOR = 32770,
  81421. CONSTANT_ALPHA = 32771,
  81422. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81423. SRC_ALPHA_SATURATE = 776
  81424. }
  81425. /** @hidden */
  81426. export interface IGLTFProperty {
  81427. extensions?: {
  81428. [key: string]: any;
  81429. };
  81430. extras?: Object;
  81431. }
  81432. /** @hidden */
  81433. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81434. name?: string;
  81435. }
  81436. /** @hidden */
  81437. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81438. bufferView: string;
  81439. byteOffset: number;
  81440. byteStride: number;
  81441. count: number;
  81442. type: string;
  81443. componentType: EComponentType;
  81444. max?: number[];
  81445. min?: number[];
  81446. name?: string;
  81447. }
  81448. /** @hidden */
  81449. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81450. buffer: string;
  81451. byteOffset: number;
  81452. byteLength: number;
  81453. byteStride: number;
  81454. target?: number;
  81455. }
  81456. /** @hidden */
  81457. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81458. uri: string;
  81459. byteLength?: number;
  81460. type?: string;
  81461. }
  81462. /** @hidden */
  81463. export interface IGLTFShader extends IGLTFChildRootProperty {
  81464. uri: string;
  81465. type: EShaderType;
  81466. }
  81467. /** @hidden */
  81468. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81469. attributes: string[];
  81470. fragmentShader: string;
  81471. vertexShader: string;
  81472. }
  81473. /** @hidden */
  81474. export interface IGLTFTechniqueParameter {
  81475. type: number;
  81476. count?: number;
  81477. semantic?: string;
  81478. node?: string;
  81479. value?: number | boolean | string | Array<any>;
  81480. source?: string;
  81481. babylonValue?: any;
  81482. }
  81483. /** @hidden */
  81484. export interface IGLTFTechniqueCommonProfile {
  81485. lightingModel: string;
  81486. texcoordBindings: Object;
  81487. parameters?: Array<any>;
  81488. }
  81489. /** @hidden */
  81490. export interface IGLTFTechniqueStatesFunctions {
  81491. blendColor?: number[];
  81492. blendEquationSeparate?: number[];
  81493. blendFuncSeparate?: number[];
  81494. colorMask: boolean[];
  81495. cullFace: number[];
  81496. }
  81497. /** @hidden */
  81498. export interface IGLTFTechniqueStates {
  81499. enable: number[];
  81500. functions: IGLTFTechniqueStatesFunctions;
  81501. }
  81502. /** @hidden */
  81503. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81504. parameters: {
  81505. [key: string]: IGLTFTechniqueParameter;
  81506. };
  81507. program: string;
  81508. attributes: {
  81509. [key: string]: string;
  81510. };
  81511. uniforms: {
  81512. [key: string]: string;
  81513. };
  81514. states: IGLTFTechniqueStates;
  81515. }
  81516. /** @hidden */
  81517. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81518. technique?: string;
  81519. values: string[];
  81520. }
  81521. /** @hidden */
  81522. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81523. attributes: {
  81524. [key: string]: string;
  81525. };
  81526. indices: string;
  81527. material: string;
  81528. mode?: number;
  81529. }
  81530. /** @hidden */
  81531. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81532. primitives: IGLTFMeshPrimitive[];
  81533. }
  81534. /** @hidden */
  81535. export interface IGLTFImage extends IGLTFChildRootProperty {
  81536. uri: string;
  81537. }
  81538. /** @hidden */
  81539. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81540. magFilter?: number;
  81541. minFilter?: number;
  81542. wrapS?: number;
  81543. wrapT?: number;
  81544. }
  81545. /** @hidden */
  81546. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81547. sampler: string;
  81548. source: string;
  81549. format?: ETextureFormat;
  81550. internalFormat?: ETextureFormat;
  81551. target?: number;
  81552. type?: number;
  81553. babylonTexture?: Texture;
  81554. }
  81555. /** @hidden */
  81556. export interface IGLTFAmbienLight {
  81557. color?: number[];
  81558. }
  81559. /** @hidden */
  81560. export interface IGLTFDirectionalLight {
  81561. color?: number[];
  81562. }
  81563. /** @hidden */
  81564. export interface IGLTFPointLight {
  81565. color?: number[];
  81566. constantAttenuation?: number;
  81567. linearAttenuation?: number;
  81568. quadraticAttenuation?: number;
  81569. }
  81570. /** @hidden */
  81571. export interface IGLTFSpotLight {
  81572. color?: number[];
  81573. constantAttenuation?: number;
  81574. fallOfAngle?: number;
  81575. fallOffExponent?: number;
  81576. linearAttenuation?: number;
  81577. quadraticAttenuation?: number;
  81578. }
  81579. /** @hidden */
  81580. export interface IGLTFLight extends IGLTFChildRootProperty {
  81581. type: string;
  81582. }
  81583. /** @hidden */
  81584. export interface IGLTFCameraOrthographic {
  81585. xmag: number;
  81586. ymag: number;
  81587. zfar: number;
  81588. znear: number;
  81589. }
  81590. /** @hidden */
  81591. export interface IGLTFCameraPerspective {
  81592. aspectRatio: number;
  81593. yfov: number;
  81594. zfar: number;
  81595. znear: number;
  81596. }
  81597. /** @hidden */
  81598. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81599. type: string;
  81600. }
  81601. /** @hidden */
  81602. export interface IGLTFAnimationChannelTarget {
  81603. id: string;
  81604. path: string;
  81605. }
  81606. /** @hidden */
  81607. export interface IGLTFAnimationChannel {
  81608. sampler: string;
  81609. target: IGLTFAnimationChannelTarget;
  81610. }
  81611. /** @hidden */
  81612. export interface IGLTFAnimationSampler {
  81613. input: string;
  81614. output: string;
  81615. interpolation?: string;
  81616. }
  81617. /** @hidden */
  81618. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81619. channels?: IGLTFAnimationChannel[];
  81620. parameters?: {
  81621. [key: string]: string;
  81622. };
  81623. samplers?: {
  81624. [key: string]: IGLTFAnimationSampler;
  81625. };
  81626. }
  81627. /** @hidden */
  81628. export interface IGLTFNodeInstanceSkin {
  81629. skeletons: string[];
  81630. skin: string;
  81631. meshes: string[];
  81632. }
  81633. /** @hidden */
  81634. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81635. bindShapeMatrix: number[];
  81636. inverseBindMatrices: string;
  81637. jointNames: string[];
  81638. babylonSkeleton?: Skeleton;
  81639. }
  81640. /** @hidden */
  81641. export interface IGLTFNode extends IGLTFChildRootProperty {
  81642. camera?: string;
  81643. children: string[];
  81644. skin?: string;
  81645. jointName?: string;
  81646. light?: string;
  81647. matrix: number[];
  81648. mesh?: string;
  81649. meshes?: string[];
  81650. rotation?: number[];
  81651. scale?: number[];
  81652. translation?: number[];
  81653. babylonNode?: Node;
  81654. }
  81655. /** @hidden */
  81656. export interface IGLTFScene extends IGLTFChildRootProperty {
  81657. nodes: string[];
  81658. }
  81659. /** @hidden */
  81660. export interface IGLTFRuntime {
  81661. extensions: {
  81662. [key: string]: any;
  81663. };
  81664. accessors: {
  81665. [key: string]: IGLTFAccessor;
  81666. };
  81667. buffers: {
  81668. [key: string]: IGLTFBuffer;
  81669. };
  81670. bufferViews: {
  81671. [key: string]: IGLTFBufferView;
  81672. };
  81673. meshes: {
  81674. [key: string]: IGLTFMesh;
  81675. };
  81676. lights: {
  81677. [key: string]: IGLTFLight;
  81678. };
  81679. cameras: {
  81680. [key: string]: IGLTFCamera;
  81681. };
  81682. nodes: {
  81683. [key: string]: IGLTFNode;
  81684. };
  81685. images: {
  81686. [key: string]: IGLTFImage;
  81687. };
  81688. textures: {
  81689. [key: string]: IGLTFTexture;
  81690. };
  81691. shaders: {
  81692. [key: string]: IGLTFShader;
  81693. };
  81694. programs: {
  81695. [key: string]: IGLTFProgram;
  81696. };
  81697. samplers: {
  81698. [key: string]: IGLTFSampler;
  81699. };
  81700. techniques: {
  81701. [key: string]: IGLTFTechnique;
  81702. };
  81703. materials: {
  81704. [key: string]: IGLTFMaterial;
  81705. };
  81706. animations: {
  81707. [key: string]: IGLTFAnimation;
  81708. };
  81709. skins: {
  81710. [key: string]: IGLTFSkins;
  81711. };
  81712. currentScene?: Object;
  81713. scenes: {
  81714. [key: string]: IGLTFScene;
  81715. };
  81716. extensionsUsed: string[];
  81717. extensionsRequired?: string[];
  81718. buffersCount: number;
  81719. shaderscount: number;
  81720. scene: Scene;
  81721. rootUrl: string;
  81722. loadedBufferCount: number;
  81723. loadedBufferViews: {
  81724. [name: string]: ArrayBufferView;
  81725. };
  81726. loadedShaderCount: number;
  81727. importOnlyMeshes: boolean;
  81728. importMeshesNames?: string[];
  81729. dummyNodes: Node[];
  81730. forAssetContainer: boolean;
  81731. }
  81732. /** @hidden */
  81733. export interface INodeToRoot {
  81734. bone: Bone;
  81735. node: IGLTFNode;
  81736. id: string;
  81737. }
  81738. /** @hidden */
  81739. export interface IJointNode {
  81740. node: IGLTFNode;
  81741. id: string;
  81742. }
  81743. }
  81744. declare module BABYLON.GLTF1 {
  81745. /**
  81746. * Utils functions for GLTF
  81747. * @hidden
  81748. */
  81749. export class GLTFUtils {
  81750. /**
  81751. * Sets the given "parameter" matrix
  81752. * @param scene: the Scene object
  81753. * @param source: the source node where to pick the matrix
  81754. * @param parameter: the GLTF technique parameter
  81755. * @param uniformName: the name of the shader's uniform
  81756. * @param shaderMaterial: the shader material
  81757. */
  81758. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81759. /**
  81760. * Sets the given "parameter" matrix
  81761. * @param shaderMaterial: the shader material
  81762. * @param uniform: the name of the shader's uniform
  81763. * @param value: the value of the uniform
  81764. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81765. */
  81766. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81767. /**
  81768. * Returns the wrap mode of the texture
  81769. * @param mode: the mode value
  81770. */
  81771. static GetWrapMode(mode: number): number;
  81772. /**
  81773. * Returns the byte stride giving an accessor
  81774. * @param accessor: the GLTF accessor objet
  81775. */
  81776. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81777. /**
  81778. * Returns the texture filter mode giving a mode value
  81779. * @param mode: the filter mode value
  81780. */
  81781. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81782. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81783. /**
  81784. * Returns a buffer from its accessor
  81785. * @param gltfRuntime: the GLTF runtime
  81786. * @param accessor: the GLTF accessor
  81787. */
  81788. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81789. /**
  81790. * Decodes a buffer view into a string
  81791. * @param view: the buffer view
  81792. */
  81793. static DecodeBufferToText(view: ArrayBufferView): string;
  81794. /**
  81795. * Returns the default material of gltf. Related to
  81796. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81797. * @param scene: the Babylon.js scene
  81798. */
  81799. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81800. private static _DefaultMaterial;
  81801. }
  81802. }
  81803. declare module BABYLON.GLTF1 {
  81804. /**
  81805. * Implementation of the base glTF spec
  81806. * @hidden
  81807. */
  81808. export class GLTFLoaderBase {
  81809. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81810. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81811. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81812. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81813. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81814. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81815. }
  81816. /**
  81817. * glTF V1 Loader
  81818. * @hidden
  81819. */
  81820. export class GLTFLoader implements IGLTFLoader {
  81821. static Extensions: {
  81822. [name: string]: GLTFLoaderExtension;
  81823. };
  81824. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81825. state: Nullable<GLTFLoaderState>;
  81826. dispose(): void;
  81827. private _importMeshAsync;
  81828. /**
  81829. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81830. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81831. * @param scene the scene the meshes should be added to
  81832. * @param forAssetContainer defines if the entities must be stored in the scene
  81833. * @param data gltf data containing information of the meshes in a loaded file
  81834. * @param rootUrl root url to load from
  81835. * @param onProgress event that fires when loading progress has occured
  81836. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81837. */
  81838. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81839. private _loadAsync;
  81840. /**
  81841. * Imports all objects from a loaded gltf file and adds them to the scene
  81842. * @param scene the scene the objects should be added to
  81843. * @param data gltf data containing information of the meshes in a loaded file
  81844. * @param rootUrl root url to load from
  81845. * @param onProgress event that fires when loading progress has occured
  81846. * @returns a promise which completes when objects have been loaded to the scene
  81847. */
  81848. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81849. private _loadShadersAsync;
  81850. private _loadBuffersAsync;
  81851. private _createNodes;
  81852. }
  81853. /** @hidden */
  81854. export abstract class GLTFLoaderExtension {
  81855. private _name;
  81856. constructor(name: string);
  81857. get name(): string;
  81858. /**
  81859. * Defines an override for loading the runtime
  81860. * Return true to stop further extensions from loading the runtime
  81861. */
  81862. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81863. /**
  81864. * Defines an onverride for creating gltf runtime
  81865. * Return true to stop further extensions from creating the runtime
  81866. */
  81867. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81868. /**
  81869. * Defines an override for loading buffers
  81870. * Return true to stop further extensions from loading this buffer
  81871. */
  81872. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81873. /**
  81874. * Defines an override for loading texture buffers
  81875. * Return true to stop further extensions from loading this texture data
  81876. */
  81877. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81878. /**
  81879. * Defines an override for creating textures
  81880. * Return true to stop further extensions from loading this texture
  81881. */
  81882. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81883. /**
  81884. * Defines an override for loading shader strings
  81885. * Return true to stop further extensions from loading this shader data
  81886. */
  81887. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81888. /**
  81889. * Defines an override for loading materials
  81890. * Return true to stop further extensions from loading this material
  81891. */
  81892. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81893. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81894. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81895. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81896. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81897. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81898. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81899. private static LoadTextureBufferAsync;
  81900. private static CreateTextureAsync;
  81901. private static ApplyExtensions;
  81902. }
  81903. }
  81904. declare module BABYLON.GLTF1 {
  81905. /** @hidden */
  81906. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81907. private _bin;
  81908. constructor();
  81909. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81910. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81911. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81912. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81913. }
  81914. }
  81915. declare module BABYLON.GLTF1 {
  81916. /** @hidden */
  81917. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81918. constructor();
  81919. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81920. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81921. private _loadTexture;
  81922. }
  81923. }
  81924. declare module BABYLON.GLTF2.Loader {
  81925. /**
  81926. * Loader interface with an index field.
  81927. */
  81928. export interface IArrayItem {
  81929. /**
  81930. * The index of this item in the array.
  81931. */
  81932. index: number;
  81933. }
  81934. /**
  81935. * Loader interface with additional members.
  81936. */
  81937. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81938. /** @hidden */
  81939. _data?: Promise<ArrayBufferView>;
  81940. /** @hidden */
  81941. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81942. }
  81943. /**
  81944. * Loader interface with additional members.
  81945. */
  81946. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81947. }
  81948. /** @hidden */
  81949. export interface _IAnimationSamplerData {
  81950. input: Float32Array;
  81951. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81952. output: Float32Array;
  81953. }
  81954. /**
  81955. * Loader interface with additional members.
  81956. */
  81957. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81958. /** @hidden */
  81959. _data?: Promise<_IAnimationSamplerData>;
  81960. }
  81961. /**
  81962. * Loader interface with additional members.
  81963. */
  81964. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81965. channels: IAnimationChannel[];
  81966. samplers: IAnimationSampler[];
  81967. /** @hidden */
  81968. _babylonAnimationGroup?: AnimationGroup;
  81969. }
  81970. /**
  81971. * Loader interface with additional members.
  81972. */
  81973. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81974. /** @hidden */
  81975. _data?: Promise<ArrayBufferView>;
  81976. }
  81977. /**
  81978. * Loader interface with additional members.
  81979. */
  81980. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81981. /** @hidden */
  81982. _data?: Promise<ArrayBufferView>;
  81983. /** @hidden */
  81984. _babylonBuffer?: Promise<Buffer>;
  81985. }
  81986. /**
  81987. * Loader interface with additional members.
  81988. */
  81989. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81990. }
  81991. /**
  81992. * Loader interface with additional members.
  81993. */
  81994. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81995. /** @hidden */
  81996. _data?: Promise<ArrayBufferView>;
  81997. }
  81998. /**
  81999. * Loader interface with additional members.
  82000. */
  82001. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82002. }
  82003. /**
  82004. * Loader interface with additional members.
  82005. */
  82006. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82007. }
  82008. /**
  82009. * Loader interface with additional members.
  82010. */
  82011. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82012. baseColorTexture?: ITextureInfo;
  82013. metallicRoughnessTexture?: ITextureInfo;
  82014. }
  82015. /**
  82016. * Loader interface with additional members.
  82017. */
  82018. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82019. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82020. normalTexture?: IMaterialNormalTextureInfo;
  82021. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82022. emissiveTexture?: ITextureInfo;
  82023. /** @hidden */
  82024. _data?: {
  82025. [babylonDrawMode: number]: {
  82026. babylonMaterial: Material;
  82027. babylonMeshes: AbstractMesh[];
  82028. promise: Promise<void>;
  82029. };
  82030. };
  82031. }
  82032. /**
  82033. * Loader interface with additional members.
  82034. */
  82035. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82036. primitives: IMeshPrimitive[];
  82037. }
  82038. /**
  82039. * Loader interface with additional members.
  82040. */
  82041. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82042. /** @hidden */
  82043. _instanceData?: {
  82044. babylonSourceMesh: Mesh;
  82045. promise: Promise<any>;
  82046. };
  82047. }
  82048. /**
  82049. * Loader interface with additional members.
  82050. */
  82051. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82052. /**
  82053. * The parent glTF node.
  82054. */
  82055. parent?: INode;
  82056. /** @hidden */
  82057. _babylonTransformNode?: TransformNode;
  82058. /** @hidden */
  82059. _primitiveBabylonMeshes?: AbstractMesh[];
  82060. /** @hidden */
  82061. _babylonBones?: Bone[];
  82062. /** @hidden */
  82063. _numMorphTargets?: number;
  82064. }
  82065. /** @hidden */
  82066. export interface _ISamplerData {
  82067. noMipMaps: boolean;
  82068. samplingMode: number;
  82069. wrapU: number;
  82070. wrapV: number;
  82071. }
  82072. /**
  82073. * Loader interface with additional members.
  82074. */
  82075. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82076. /** @hidden */
  82077. _data?: _ISamplerData;
  82078. }
  82079. /**
  82080. * Loader interface with additional members.
  82081. */
  82082. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82083. }
  82084. /**
  82085. * Loader interface with additional members.
  82086. */
  82087. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82088. /** @hidden */
  82089. _data?: {
  82090. babylonSkeleton: Skeleton;
  82091. promise: Promise<void>;
  82092. };
  82093. }
  82094. /**
  82095. * Loader interface with additional members.
  82096. */
  82097. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82098. }
  82099. /**
  82100. * Loader interface with additional members.
  82101. */
  82102. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82103. }
  82104. /**
  82105. * Loader interface with additional members.
  82106. */
  82107. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82108. accessors?: IAccessor[];
  82109. animations?: IAnimation[];
  82110. buffers?: IBuffer[];
  82111. bufferViews?: IBufferView[];
  82112. cameras?: ICamera[];
  82113. images?: IImage[];
  82114. materials?: IMaterial[];
  82115. meshes?: IMesh[];
  82116. nodes?: INode[];
  82117. samplers?: ISampler[];
  82118. scenes?: IScene[];
  82119. skins?: ISkin[];
  82120. textures?: ITexture[];
  82121. }
  82122. }
  82123. declare module BABYLON.GLTF2 {
  82124. /**
  82125. * Interface for a glTF loader extension.
  82126. */
  82127. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82128. /**
  82129. * Called after the loader state changes to LOADING.
  82130. */
  82131. onLoading?(): void;
  82132. /**
  82133. * Called after the loader state changes to READY.
  82134. */
  82135. onReady?(): void;
  82136. /**
  82137. * Define this method to modify the default behavior when loading scenes.
  82138. * @param context The context when loading the asset
  82139. * @param scene The glTF scene property
  82140. * @returns A promise that resolves when the load is complete or null if not handled
  82141. */
  82142. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82143. /**
  82144. * Define this method to modify the default behavior when loading nodes.
  82145. * @param context The context when loading the asset
  82146. * @param node The glTF node property
  82147. * @param assign A function called synchronously after parsing the glTF properties
  82148. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82149. */
  82150. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82151. /**
  82152. * Define this method to modify the default behavior when loading cameras.
  82153. * @param context The context when loading the asset
  82154. * @param camera The glTF camera property
  82155. * @param assign A function called synchronously after parsing the glTF properties
  82156. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82157. */
  82158. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82159. /**
  82160. * @hidden
  82161. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82162. * @param context The context when loading the asset
  82163. * @param primitive The glTF mesh primitive property
  82164. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82165. */
  82166. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82167. /**
  82168. * @hidden
  82169. * Define this method to modify the default behavior when loading data for mesh primitives.
  82170. * @param context The context when loading the asset
  82171. * @param name The mesh name when loading the asset
  82172. * @param node The glTF node when loading the asset
  82173. * @param mesh The glTF mesh when loading the asset
  82174. * @param primitive The glTF mesh primitive property
  82175. * @param assign A function called synchronously after parsing the glTF properties
  82176. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82177. */
  82178. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82179. /**
  82180. * @hidden
  82181. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82182. * @param context The context when loading the asset
  82183. * @param material The glTF material property
  82184. * @param assign A function called synchronously after parsing the glTF properties
  82185. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82186. */
  82187. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82188. /**
  82189. * Define this method to modify the default behavior when creating materials.
  82190. * @param context The context when loading the asset
  82191. * @param material The glTF material property
  82192. * @param babylonDrawMode The draw mode for the Babylon material
  82193. * @returns The Babylon material or null if not handled
  82194. */
  82195. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82196. /**
  82197. * Define this method to modify the default behavior when loading material properties.
  82198. * @param context The context when loading the asset
  82199. * @param material The glTF material property
  82200. * @param babylonMaterial The Babylon material
  82201. * @returns A promise that resolves when the load is complete or null if not handled
  82202. */
  82203. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82204. /**
  82205. * Define this method to modify the default behavior when loading texture infos.
  82206. * @param context The context when loading the asset
  82207. * @param textureInfo The glTF texture info property
  82208. * @param assign A function called synchronously after parsing the glTF properties
  82209. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82210. */
  82211. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82212. /**
  82213. * @hidden
  82214. * Define this method to modify the default behavior when loading textures.
  82215. * @param context The context when loading the asset
  82216. * @param texture The glTF texture property
  82217. * @param assign A function called synchronously after parsing the glTF properties
  82218. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82219. */
  82220. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82221. /**
  82222. * Define this method to modify the default behavior when loading animations.
  82223. * @param context The context when loading the asset
  82224. * @param animation The glTF animation property
  82225. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82226. */
  82227. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82228. /**
  82229. * @hidden
  82230. * Define this method to modify the default behavior when loading skins.
  82231. * @param context The context when loading the asset
  82232. * @param node The glTF node property
  82233. * @param skin The glTF skin property
  82234. * @returns A promise that resolves when the load is complete or null if not handled
  82235. */
  82236. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82237. /**
  82238. * @hidden
  82239. * Define this method to modify the default behavior when loading uris.
  82240. * @param context The context when loading the asset
  82241. * @param property The glTF property associated with the uri
  82242. * @param uri The uri to load
  82243. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82244. */
  82245. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82246. /**
  82247. * Define this method to modify the default behavior when loading buffer views.
  82248. * @param context The context when loading the asset
  82249. * @param bufferView The glTF buffer view property
  82250. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82251. */
  82252. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82253. /**
  82254. * Define this method to modify the default behavior when loading buffers.
  82255. * @param context The context when loading the asset
  82256. * @param buffer The glTF buffer property
  82257. * @param byteOffset The byte offset to load
  82258. * @param byteLength The byte length to load
  82259. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82260. */
  82261. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82262. }
  82263. }
  82264. declare module BABYLON.GLTF2 {
  82265. /**
  82266. * Helper class for working with arrays when loading the glTF asset
  82267. */
  82268. export class ArrayItem {
  82269. /**
  82270. * Gets an item from the given array.
  82271. * @param context The context when loading the asset
  82272. * @param array The array to get the item from
  82273. * @param index The index to the array
  82274. * @returns The array item
  82275. */
  82276. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82277. /**
  82278. * Assign an `index` field to each item of the given array.
  82279. * @param array The array of items
  82280. */
  82281. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82282. }
  82283. /**
  82284. * The glTF 2.0 loader
  82285. */
  82286. export class GLTFLoader implements IGLTFLoader {
  82287. /** @hidden */
  82288. _completePromises: Promise<any>[];
  82289. /** @hidden */
  82290. _forAssetContainer: boolean;
  82291. /** Storage */
  82292. _babylonLights: Light[];
  82293. /** @hidden */
  82294. _disableInstancedMesh: number;
  82295. private _disposed;
  82296. private _parent;
  82297. private _state;
  82298. private _extensions;
  82299. private _rootUrl;
  82300. private _fileName;
  82301. private _uniqueRootUrl;
  82302. private _gltf;
  82303. private _bin;
  82304. private _babylonScene;
  82305. private _rootBabylonMesh;
  82306. private _defaultBabylonMaterialData;
  82307. private static _RegisteredExtensions;
  82308. /**
  82309. * The default glTF sampler.
  82310. */
  82311. static readonly DefaultSampler: ISampler;
  82312. /**
  82313. * Registers a loader extension.
  82314. * @param name The name of the loader extension.
  82315. * @param factory The factory function that creates the loader extension.
  82316. */
  82317. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82318. /**
  82319. * Unregisters a loader extension.
  82320. * @param name The name of the loader extension.
  82321. * @returns A boolean indicating whether the extension has been unregistered
  82322. */
  82323. static UnregisterExtension(name: string): boolean;
  82324. /**
  82325. * The loader state.
  82326. */
  82327. get state(): Nullable<GLTFLoaderState>;
  82328. /**
  82329. * The object that represents the glTF JSON.
  82330. */
  82331. get gltf(): IGLTF;
  82332. /**
  82333. * The BIN chunk of a binary glTF.
  82334. */
  82335. get bin(): Nullable<IDataBuffer>;
  82336. /**
  82337. * The parent file loader.
  82338. */
  82339. get parent(): GLTFFileLoader;
  82340. /**
  82341. * The Babylon scene when loading the asset.
  82342. */
  82343. get babylonScene(): Scene;
  82344. /**
  82345. * The root Babylon mesh when loading the asset.
  82346. */
  82347. get rootBabylonMesh(): Mesh;
  82348. /** @hidden */
  82349. constructor(parent: GLTFFileLoader);
  82350. /** @hidden */
  82351. dispose(): void;
  82352. /** @hidden */
  82353. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82354. /** @hidden */
  82355. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82356. private _loadAsync;
  82357. private _loadData;
  82358. private _setupData;
  82359. private _loadExtensions;
  82360. private _checkExtensions;
  82361. private _setState;
  82362. private _createRootNode;
  82363. /**
  82364. * Loads a glTF scene.
  82365. * @param context The context when loading the asset
  82366. * @param scene The glTF scene property
  82367. * @returns A promise that resolves when the load is complete
  82368. */
  82369. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82370. private _forEachPrimitive;
  82371. private _getMeshes;
  82372. private _getTransformNodes;
  82373. private _getSkeletons;
  82374. private _getAnimationGroups;
  82375. private _startAnimations;
  82376. /**
  82377. * Loads a glTF node.
  82378. * @param context The context when loading the asset
  82379. * @param node The glTF node property
  82380. * @param assign A function called synchronously after parsing the glTF properties
  82381. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82382. */
  82383. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82384. private _loadMeshAsync;
  82385. /**
  82386. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82387. * @param context The context when loading the asset
  82388. * @param name The mesh name when loading the asset
  82389. * @param node The glTF node when loading the asset
  82390. * @param mesh The glTF mesh when loading the asset
  82391. * @param primitive The glTF mesh primitive property
  82392. * @param assign A function called synchronously after parsing the glTF properties
  82393. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82394. */
  82395. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82396. private _loadVertexDataAsync;
  82397. private _createMorphTargets;
  82398. private _loadMorphTargetsAsync;
  82399. private _loadMorphTargetVertexDataAsync;
  82400. private static _LoadTransform;
  82401. private _loadSkinAsync;
  82402. private _loadBones;
  82403. private _loadBone;
  82404. private _loadSkinInverseBindMatricesDataAsync;
  82405. private _updateBoneMatrices;
  82406. private _getNodeMatrix;
  82407. /**
  82408. * Loads a glTF camera.
  82409. * @param context The context when loading the asset
  82410. * @param camera The glTF camera property
  82411. * @param assign A function called synchronously after parsing the glTF properties
  82412. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82413. */
  82414. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82415. private _loadAnimationsAsync;
  82416. /**
  82417. * Loads a glTF animation.
  82418. * @param context The context when loading the asset
  82419. * @param animation The glTF animation property
  82420. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82421. */
  82422. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82423. /**
  82424. * @hidden Loads a glTF animation channel.
  82425. * @param context The context when loading the asset
  82426. * @param animationContext The context of the animation when loading the asset
  82427. * @param animation The glTF animation property
  82428. * @param channel The glTF animation channel property
  82429. * @param babylonAnimationGroup The babylon animation group property
  82430. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82431. * @returns A void promise when the channel load is complete
  82432. */
  82433. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82434. private _loadAnimationSamplerAsync;
  82435. private _loadBufferAsync;
  82436. /**
  82437. * Loads a glTF buffer view.
  82438. * @param context The context when loading the asset
  82439. * @param bufferView The glTF buffer view property
  82440. * @returns A promise that resolves with the loaded data when the load is complete
  82441. */
  82442. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82443. private _loadAccessorAsync;
  82444. /** @hidden */
  82445. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82446. private _loadIndicesAccessorAsync;
  82447. private _loadVertexBufferViewAsync;
  82448. private _loadVertexAccessorAsync;
  82449. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82450. /** @hidden */
  82451. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82452. private _createDefaultMaterial;
  82453. /**
  82454. * Creates a Babylon material from a glTF material.
  82455. * @param context The context when loading the asset
  82456. * @param material The glTF material property
  82457. * @param babylonDrawMode The draw mode for the Babylon material
  82458. * @returns The Babylon material
  82459. */
  82460. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82461. /**
  82462. * Loads properties from a glTF material into a Babylon material.
  82463. * @param context The context when loading the asset
  82464. * @param material The glTF material property
  82465. * @param babylonMaterial The Babylon material
  82466. * @returns A promise that resolves when the load is complete
  82467. */
  82468. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82469. /**
  82470. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82471. * @param context The context when loading the asset
  82472. * @param material The glTF material property
  82473. * @param babylonMaterial The Babylon material
  82474. * @returns A promise that resolves when the load is complete
  82475. */
  82476. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82477. /**
  82478. * Loads the alpha properties from a glTF material into a Babylon material.
  82479. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82480. * @param context The context when loading the asset
  82481. * @param material The glTF material property
  82482. * @param babylonMaterial The Babylon material
  82483. */
  82484. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82485. /**
  82486. * Loads a glTF texture info.
  82487. * @param context The context when loading the asset
  82488. * @param textureInfo The glTF texture info property
  82489. * @param assign A function called synchronously after parsing the glTF properties
  82490. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82491. */
  82492. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82493. /** @hidden */
  82494. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82495. /** @hidden */
  82496. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82497. private _loadSampler;
  82498. /**
  82499. * Loads a glTF image.
  82500. * @param context The context when loading the asset
  82501. * @param image The glTF image property
  82502. * @returns A promise that resolves with the loaded data when the load is complete
  82503. */
  82504. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82505. /**
  82506. * Loads a glTF uri.
  82507. * @param context The context when loading the asset
  82508. * @param property The glTF property associated with the uri
  82509. * @param uri The base64 or relative uri
  82510. * @returns A promise that resolves with the loaded data when the load is complete
  82511. */
  82512. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82513. /**
  82514. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82515. * @param babylonObject the Babylon object with metadata
  82516. * @param pointer the JSON pointer
  82517. */
  82518. static AddPointerMetadata(babylonObject: {
  82519. metadata: any;
  82520. }, pointer: string): void;
  82521. private static _GetTextureWrapMode;
  82522. private static _GetTextureSamplingMode;
  82523. private static _GetTypedArrayConstructor;
  82524. private static _GetTypedArray;
  82525. private static _GetNumComponents;
  82526. private static _ValidateUri;
  82527. /** @hidden */
  82528. static _GetDrawMode(context: string, mode: number | undefined): number;
  82529. private _compileMaterialsAsync;
  82530. private _compileShadowGeneratorsAsync;
  82531. private _forEachExtensions;
  82532. private _applyExtensions;
  82533. private _extensionsOnLoading;
  82534. private _extensionsOnReady;
  82535. private _extensionsLoadSceneAsync;
  82536. private _extensionsLoadNodeAsync;
  82537. private _extensionsLoadCameraAsync;
  82538. private _extensionsLoadVertexDataAsync;
  82539. private _extensionsLoadMeshPrimitiveAsync;
  82540. private _extensionsLoadMaterialAsync;
  82541. private _extensionsCreateMaterial;
  82542. private _extensionsLoadMaterialPropertiesAsync;
  82543. private _extensionsLoadTextureInfoAsync;
  82544. private _extensionsLoadTextureAsync;
  82545. private _extensionsLoadAnimationAsync;
  82546. private _extensionsLoadSkinAsync;
  82547. private _extensionsLoadUriAsync;
  82548. private _extensionsLoadBufferViewAsync;
  82549. private _extensionsLoadBufferAsync;
  82550. /**
  82551. * Helper method called by a loader extension to load an glTF extension.
  82552. * @param context The context when loading the asset
  82553. * @param property The glTF property to load the extension from
  82554. * @param extensionName The name of the extension to load
  82555. * @param actionAsync The action to run
  82556. * @returns The promise returned by actionAsync or null if the extension does not exist
  82557. */
  82558. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82559. /**
  82560. * Helper method called by a loader extension to load a glTF extra.
  82561. * @param context The context when loading the asset
  82562. * @param property The glTF property to load the extra from
  82563. * @param extensionName The name of the extension to load
  82564. * @param actionAsync The action to run
  82565. * @returns The promise returned by actionAsync or null if the extra does not exist
  82566. */
  82567. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82568. /**
  82569. * Checks for presence of an extension.
  82570. * @param name The name of the extension to check
  82571. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82572. */
  82573. isExtensionUsed(name: string): boolean;
  82574. /**
  82575. * Increments the indentation level and logs a message.
  82576. * @param message The message to log
  82577. */
  82578. logOpen(message: string): void;
  82579. /**
  82580. * Decrements the indentation level.
  82581. */
  82582. logClose(): void;
  82583. /**
  82584. * Logs a message
  82585. * @param message The message to log
  82586. */
  82587. log(message: string): void;
  82588. /**
  82589. * Starts a performance counter.
  82590. * @param counterName The name of the performance counter
  82591. */
  82592. startPerformanceCounter(counterName: string): void;
  82593. /**
  82594. * Ends a performance counter.
  82595. * @param counterName The name of the performance counter
  82596. */
  82597. endPerformanceCounter(counterName: string): void;
  82598. }
  82599. }
  82600. declare module BABYLON.GLTF2.Loader.Extensions {
  82601. /** @hidden */
  82602. interface IEXTLightsImageBased_LightImageBased {
  82603. _babylonTexture?: BaseTexture;
  82604. _loaded?: Promise<void>;
  82605. }
  82606. /**
  82607. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82608. */
  82609. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82610. /**
  82611. * The name of this extension.
  82612. */
  82613. readonly name: string;
  82614. /**
  82615. * Defines whether this extension is enabled.
  82616. */
  82617. enabled: boolean;
  82618. private _loader;
  82619. private _lights?;
  82620. /** @hidden */
  82621. constructor(loader: GLTFLoader);
  82622. /** @hidden */
  82623. dispose(): void;
  82624. /** @hidden */
  82625. onLoading(): void;
  82626. /** @hidden */
  82627. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82628. private _loadLightAsync;
  82629. }
  82630. }
  82631. declare module BABYLON.GLTF2.Loader.Extensions {
  82632. /**
  82633. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82634. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82635. * !!! Experimental Extension Subject to Changes !!!
  82636. */
  82637. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82638. /**
  82639. * The name of this extension.
  82640. */
  82641. readonly name: string;
  82642. /**
  82643. * Defines whether this extension is enabled.
  82644. */
  82645. enabled: boolean;
  82646. private _loader;
  82647. /** @hidden */
  82648. constructor(loader: GLTFLoader);
  82649. /** @hidden */
  82650. dispose(): void;
  82651. /** @hidden */
  82652. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82653. }
  82654. }
  82655. declare module BABYLON.GLTF2.Loader.Extensions {
  82656. /**
  82657. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82658. */
  82659. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82660. /** The name of this extension. */
  82661. readonly name: string;
  82662. /** Defines whether this extension is enabled. */
  82663. enabled: boolean;
  82664. private _loader;
  82665. /** @hidden */
  82666. constructor(loader: GLTFLoader);
  82667. /** @hidden */
  82668. dispose(): void;
  82669. /** @hidden */
  82670. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82671. }
  82672. }
  82673. declare module BABYLON.GLTF2.Loader.Extensions {
  82674. /**
  82675. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82676. */
  82677. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82678. /**
  82679. * The name of this extension.
  82680. */
  82681. readonly name: string;
  82682. /**
  82683. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82684. */
  82685. dracoCompression?: DracoCompression;
  82686. /**
  82687. * Defines whether this extension is enabled.
  82688. */
  82689. enabled: boolean;
  82690. private _loader;
  82691. /** @hidden */
  82692. constructor(loader: GLTFLoader);
  82693. /** @hidden */
  82694. dispose(): void;
  82695. /** @hidden */
  82696. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82697. }
  82698. }
  82699. declare module BABYLON.GLTF2.Loader.Extensions {
  82700. /**
  82701. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82702. */
  82703. export class KHR_lights implements IGLTFLoaderExtension {
  82704. /**
  82705. * The name of this extension.
  82706. */
  82707. readonly name: string;
  82708. /**
  82709. * Defines whether this extension is enabled.
  82710. */
  82711. enabled: boolean;
  82712. private _loader;
  82713. private _lights?;
  82714. /** @hidden */
  82715. constructor(loader: GLTFLoader);
  82716. /** @hidden */
  82717. dispose(): void;
  82718. /** @hidden */
  82719. onLoading(): void;
  82720. /** @hidden */
  82721. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82722. }
  82723. }
  82724. declare module BABYLON.GLTF2.Loader.Extensions {
  82725. /**
  82726. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82727. */
  82728. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82729. /**
  82730. * The name of this extension.
  82731. */
  82732. readonly name: string;
  82733. /**
  82734. * Defines whether this extension is enabled.
  82735. */
  82736. enabled: boolean;
  82737. /**
  82738. * Defines a number that determines the order the extensions are applied.
  82739. */
  82740. order: number;
  82741. private _loader;
  82742. /** @hidden */
  82743. constructor(loader: GLTFLoader);
  82744. /** @hidden */
  82745. dispose(): void;
  82746. /** @hidden */
  82747. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82748. private _loadSpecularGlossinessPropertiesAsync;
  82749. }
  82750. }
  82751. declare module BABYLON.GLTF2.Loader.Extensions {
  82752. /**
  82753. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82754. */
  82755. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82756. /**
  82757. * The name of this extension.
  82758. */
  82759. readonly name: string;
  82760. /**
  82761. * Defines whether this extension is enabled.
  82762. */
  82763. enabled: boolean;
  82764. /**
  82765. * Defines a number that determines the order the extensions are applied.
  82766. */
  82767. order: number;
  82768. private _loader;
  82769. /** @hidden */
  82770. constructor(loader: GLTFLoader);
  82771. /** @hidden */
  82772. dispose(): void;
  82773. /** @hidden */
  82774. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82775. private _loadUnlitPropertiesAsync;
  82776. }
  82777. }
  82778. declare module BABYLON.GLTF2.Loader.Extensions {
  82779. /**
  82780. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82781. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82782. * !!! Experimental Extension Subject to Changes !!!
  82783. */
  82784. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82785. /**
  82786. * The name of this extension.
  82787. */
  82788. readonly name: string;
  82789. /**
  82790. * Defines whether this extension is enabled.
  82791. */
  82792. enabled: boolean;
  82793. /**
  82794. * Defines a number that determines the order the extensions are applied.
  82795. */
  82796. order: number;
  82797. private _loader;
  82798. /** @hidden */
  82799. constructor(loader: GLTFLoader);
  82800. /** @hidden */
  82801. dispose(): void;
  82802. /** @hidden */
  82803. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82804. private _loadClearCoatPropertiesAsync;
  82805. }
  82806. }
  82807. declare module BABYLON.GLTF2.Loader.Extensions {
  82808. /**
  82809. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82810. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82811. * !!! Experimental Extension Subject to Changes !!!
  82812. */
  82813. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82814. /**
  82815. * The name of this extension.
  82816. */
  82817. readonly name: string;
  82818. /**
  82819. * Defines whether this extension is enabled.
  82820. */
  82821. enabled: boolean;
  82822. /**
  82823. * Defines a number that determines the order the extensions are applied.
  82824. */
  82825. order: number;
  82826. private _loader;
  82827. /** @hidden */
  82828. constructor(loader: GLTFLoader);
  82829. /** @hidden */
  82830. dispose(): void;
  82831. /** @hidden */
  82832. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82833. private _loadSheenPropertiesAsync;
  82834. }
  82835. }
  82836. declare module BABYLON.GLTF2.Loader.Extensions {
  82837. /**
  82838. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82839. * !!! Experimental Extension Subject to Changes !!!
  82840. */
  82841. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82842. /**
  82843. * The name of this extension.
  82844. */
  82845. readonly name: string;
  82846. /**
  82847. * Defines whether this extension is enabled.
  82848. */
  82849. enabled: boolean;
  82850. /**
  82851. * Defines a number that determines the order the extensions are applied.
  82852. */
  82853. order: number;
  82854. private _loader;
  82855. /** @hidden */
  82856. constructor(loader: GLTFLoader);
  82857. /** @hidden */
  82858. dispose(): void;
  82859. /** @hidden */
  82860. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82861. private _loadSpecularPropertiesAsync;
  82862. }
  82863. }
  82864. declare module BABYLON.GLTF2.Loader.Extensions {
  82865. /**
  82866. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82867. * !!! Experimental Extension Subject to Changes !!!
  82868. */
  82869. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82870. /**
  82871. * Default ior Value from the spec.
  82872. */
  82873. private static readonly _DEFAULT_IOR;
  82874. /**
  82875. * The name of this extension.
  82876. */
  82877. readonly name: string;
  82878. /**
  82879. * Defines whether this extension is enabled.
  82880. */
  82881. enabled: boolean;
  82882. /**
  82883. * Defines a number that determines the order the extensions are applied.
  82884. */
  82885. order: number;
  82886. private _loader;
  82887. /** @hidden */
  82888. constructor(loader: GLTFLoader);
  82889. /** @hidden */
  82890. dispose(): void;
  82891. /** @hidden */
  82892. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82893. private _loadIorPropertiesAsync;
  82894. }
  82895. }
  82896. declare module BABYLON.GLTF2.Loader.Extensions {
  82897. /**
  82898. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82899. * !!! Experimental Extension Subject to Changes !!!
  82900. */
  82901. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82902. /**
  82903. * The name of this extension.
  82904. */
  82905. readonly name: string;
  82906. /**
  82907. * Defines whether this extension is enabled.
  82908. */
  82909. enabled: boolean;
  82910. private _loader;
  82911. private _variants?;
  82912. /** @hidden */
  82913. constructor(loader: GLTFLoader);
  82914. /** @hidden */
  82915. dispose(): void;
  82916. /**
  82917. * Gets the list of available variant names for this asset.
  82918. * @param rootMesh The glTF root mesh
  82919. * @returns the list of all the variant names for this model
  82920. */
  82921. static GetAvailableVariants(rootMesh: Mesh): string[];
  82922. /**
  82923. * Gets the list of available variant names for this asset.
  82924. * @param rootMesh The glTF root mesh
  82925. * @returns the list of all the variant names for this model
  82926. */
  82927. getAvailableVariants(rootMesh: Mesh): string[];
  82928. /**
  82929. * Select a variant given a variant name or a list of variant names.
  82930. * @param rootMesh The glTF root mesh
  82931. * @param variantName The variant name(s) to select.
  82932. */
  82933. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82934. /**
  82935. * Select a variant given a variant name or a list of variant names.
  82936. * @param rootMesh The glTF root mesh
  82937. * @param variantName The variant name(s) to select.
  82938. */
  82939. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82940. /**
  82941. * Reset back to the original before selecting a variant.
  82942. * @param rootMesh The glTF root mesh
  82943. */
  82944. static Reset(rootMesh: Mesh): void;
  82945. /**
  82946. * Reset back to the original before selecting a variant.
  82947. * @param rootMesh The glTF root mesh
  82948. */
  82949. reset(rootMesh: Mesh): void;
  82950. /**
  82951. * Gets the last selected variant name(s) or null if original.
  82952. * @param rootMesh The glTF root mesh
  82953. * @returns The selected variant name(s).
  82954. */
  82955. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82956. /**
  82957. * Gets the last selected variant name(s) or null if original.
  82958. * @param rootMesh The glTF root mesh
  82959. * @returns The selected variant name(s).
  82960. */
  82961. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82962. private static _GetExtensionMetadata;
  82963. /** @hidden */
  82964. onLoading(): void;
  82965. /** @hidden */
  82966. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82967. }
  82968. }
  82969. declare module BABYLON.GLTF2.Loader.Extensions {
  82970. /**
  82971. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82972. * !!! Experimental Extension Subject to Changes !!!
  82973. */
  82974. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82975. /**
  82976. * The name of this extension.
  82977. */
  82978. readonly name: string;
  82979. /**
  82980. * Defines whether this extension is enabled.
  82981. */
  82982. enabled: boolean;
  82983. /**
  82984. * Defines a number that determines the order the extensions are applied.
  82985. */
  82986. order: number;
  82987. private _loader;
  82988. /** @hidden */
  82989. constructor(loader: GLTFLoader);
  82990. /** @hidden */
  82991. dispose(): void;
  82992. /** @hidden */
  82993. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82994. private _loadTransparentPropertiesAsync;
  82995. }
  82996. }
  82997. declare module BABYLON.GLTF2.Loader.Extensions {
  82998. /**
  82999. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83000. */
  83001. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83002. /**
  83003. * The name of this extension.
  83004. */
  83005. readonly name: string;
  83006. /**
  83007. * Defines whether this extension is enabled.
  83008. */
  83009. enabled: boolean;
  83010. /** @hidden */
  83011. constructor(loader: GLTFLoader);
  83012. /** @hidden */
  83013. dispose(): void;
  83014. }
  83015. }
  83016. declare module BABYLON.GLTF2.Loader.Extensions {
  83017. /**
  83018. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83019. * !!! Experimental Extension Subject to Changes !!!
  83020. */
  83021. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83022. /** The name of this extension. */
  83023. readonly name: string;
  83024. /** Defines whether this extension is enabled. */
  83025. enabled: boolean;
  83026. private _loader;
  83027. /** @hidden */
  83028. constructor(loader: GLTFLoader);
  83029. /** @hidden */
  83030. dispose(): void;
  83031. /** @hidden */
  83032. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83033. }
  83034. }
  83035. declare module BABYLON.GLTF2.Loader.Extensions {
  83036. /**
  83037. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83038. */
  83039. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83040. /**
  83041. * The name of this extension.
  83042. */
  83043. readonly name: string;
  83044. /**
  83045. * Defines whether this extension is enabled.
  83046. */
  83047. enabled: boolean;
  83048. private _loader;
  83049. /** @hidden */
  83050. constructor(loader: GLTFLoader);
  83051. /** @hidden */
  83052. dispose(): void;
  83053. /** @hidden */
  83054. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83055. }
  83056. }
  83057. declare module BABYLON.GLTF2.Loader.Extensions {
  83058. /**
  83059. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83060. * !!! Experimental Extension Subject to Changes !!!
  83061. */
  83062. export class KHR_xmp implements IGLTFLoaderExtension {
  83063. /**
  83064. * The name of this extension.
  83065. */
  83066. readonly name: string;
  83067. /**
  83068. * Defines whether this extension is enabled.
  83069. */
  83070. enabled: boolean;
  83071. /**
  83072. * Defines a number that determines the order the extensions are applied.
  83073. */
  83074. order: number;
  83075. private _loader;
  83076. /** @hidden */
  83077. constructor(loader: GLTFLoader);
  83078. /** @hidden */
  83079. dispose(): void;
  83080. /**
  83081. * Called after the loader state changes to LOADING.
  83082. */
  83083. onLoading(): void;
  83084. }
  83085. }
  83086. declare module BABYLON.GLTF2.Loader.Extensions {
  83087. /**
  83088. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83089. */
  83090. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83091. /**
  83092. * The name of this extension.
  83093. */
  83094. readonly name: string;
  83095. /**
  83096. * Defines whether this extension is enabled.
  83097. */
  83098. enabled: boolean;
  83099. private _loader;
  83100. private _clips;
  83101. private _emitters;
  83102. /** @hidden */
  83103. constructor(loader: GLTFLoader);
  83104. /** @hidden */
  83105. dispose(): void;
  83106. /** @hidden */
  83107. onLoading(): void;
  83108. /** @hidden */
  83109. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83110. /** @hidden */
  83111. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83112. /** @hidden */
  83113. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83114. private _loadClipAsync;
  83115. private _loadEmitterAsync;
  83116. private _getEventAction;
  83117. private _loadAnimationEventAsync;
  83118. }
  83119. }
  83120. declare module BABYLON.GLTF2.Loader.Extensions {
  83121. /**
  83122. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83123. */
  83124. export class MSFT_lod implements IGLTFLoaderExtension {
  83125. /**
  83126. * The name of this extension.
  83127. */
  83128. readonly name: string;
  83129. /**
  83130. * Defines whether this extension is enabled.
  83131. */
  83132. enabled: boolean;
  83133. /**
  83134. * Defines a number that determines the order the extensions are applied.
  83135. */
  83136. order: number;
  83137. /**
  83138. * Maximum number of LODs to load, starting from the lowest LOD.
  83139. */
  83140. maxLODsToLoad: number;
  83141. /**
  83142. * Observable raised when all node LODs of one level are loaded.
  83143. * The event data is the index of the loaded LOD starting from zero.
  83144. * Dispose the loader to cancel the loading of the next level of LODs.
  83145. */
  83146. onNodeLODsLoadedObservable: Observable<number>;
  83147. /**
  83148. * Observable raised when all material LODs of one level are loaded.
  83149. * The event data is the index of the loaded LOD starting from zero.
  83150. * Dispose the loader to cancel the loading of the next level of LODs.
  83151. */
  83152. onMaterialLODsLoadedObservable: Observable<number>;
  83153. private _loader;
  83154. private _bufferLODs;
  83155. private _nodeIndexLOD;
  83156. private _nodeSignalLODs;
  83157. private _nodePromiseLODs;
  83158. private _nodeBufferLODs;
  83159. private _materialIndexLOD;
  83160. private _materialSignalLODs;
  83161. private _materialPromiseLODs;
  83162. private _materialBufferLODs;
  83163. /** @hidden */
  83164. constructor(loader: GLTFLoader);
  83165. /** @hidden */
  83166. dispose(): void;
  83167. /** @hidden */
  83168. onReady(): void;
  83169. /** @hidden */
  83170. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83171. /** @hidden */
  83172. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83173. /** @hidden */
  83174. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83175. /** @hidden */
  83176. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83177. /** @hidden */
  83178. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83179. private _loadBufferLOD;
  83180. /**
  83181. * Gets an array of LOD properties from lowest to highest.
  83182. */
  83183. private _getLODs;
  83184. private _disposeTransformNode;
  83185. private _disposeMaterials;
  83186. }
  83187. }
  83188. declare module BABYLON.GLTF2.Loader.Extensions {
  83189. /** @hidden */
  83190. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83191. readonly name: string;
  83192. enabled: boolean;
  83193. private _loader;
  83194. constructor(loader: GLTFLoader);
  83195. dispose(): void;
  83196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83197. }
  83198. }
  83199. declare module BABYLON.GLTF2.Loader.Extensions {
  83200. /** @hidden */
  83201. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83202. readonly name: string;
  83203. enabled: boolean;
  83204. private _loader;
  83205. constructor(loader: GLTFLoader);
  83206. dispose(): void;
  83207. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83208. }
  83209. }
  83210. declare module BABYLON.GLTF2.Loader.Extensions {
  83211. /**
  83212. * Store glTF extras (if present) in BJS objects' metadata
  83213. */
  83214. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83215. /**
  83216. * The name of this extension.
  83217. */
  83218. readonly name: string;
  83219. /**
  83220. * Defines whether this extension is enabled.
  83221. */
  83222. enabled: boolean;
  83223. private _loader;
  83224. private _assignExtras;
  83225. /** @hidden */
  83226. constructor(loader: GLTFLoader);
  83227. /** @hidden */
  83228. dispose(): void;
  83229. /** @hidden */
  83230. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83231. /** @hidden */
  83232. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83233. /** @hidden */
  83234. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83235. }
  83236. }
  83237. declare module BABYLON {
  83238. /**
  83239. * Class reading and parsing the MTL file bundled with the obj file.
  83240. */
  83241. export class MTLFileLoader {
  83242. /**
  83243. * Invert Y-Axis of referenced textures on load
  83244. */
  83245. static INVERT_TEXTURE_Y: boolean;
  83246. /**
  83247. * All material loaded from the mtl will be set here
  83248. */
  83249. materials: StandardMaterial[];
  83250. /**
  83251. * This function will read the mtl file and create each material described inside
  83252. * This function could be improve by adding :
  83253. * -some component missing (Ni, Tf...)
  83254. * -including the specific options available
  83255. *
  83256. * @param scene defines the scene the material will be created in
  83257. * @param data defines the mtl data to parse
  83258. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83259. * @param forAssetContainer defines if the material should be registered in the scene
  83260. */
  83261. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83262. /**
  83263. * Gets the texture for the material.
  83264. *
  83265. * If the material is imported from input file,
  83266. * We sanitize the url to ensure it takes the textre from aside the material.
  83267. *
  83268. * @param rootUrl The root url to load from
  83269. * @param value The value stored in the mtl
  83270. * @return The Texture
  83271. */
  83272. private static _getTexture;
  83273. }
  83274. }
  83275. declare module BABYLON {
  83276. /**
  83277. * Options for loading OBJ/MTL files
  83278. */
  83279. type MeshLoadOptions = {
  83280. /**
  83281. * Defines if UVs are optimized by default during load.
  83282. */
  83283. OptimizeWithUV: boolean;
  83284. /**
  83285. * Defines custom scaling of UV coordinates of loaded meshes.
  83286. */
  83287. UVScaling: Vector2;
  83288. /**
  83289. * Invert model on y-axis (does a model scaling inversion)
  83290. */
  83291. InvertY: boolean;
  83292. /**
  83293. * Invert Y-Axis of referenced textures on load
  83294. */
  83295. InvertTextureY: boolean;
  83296. /**
  83297. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83298. */
  83299. ImportVertexColors: boolean;
  83300. /**
  83301. * Compute the normals for the model, even if normals are present in the file.
  83302. */
  83303. ComputeNormals: boolean;
  83304. /**
  83305. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83306. */
  83307. SkipMaterials: boolean;
  83308. /**
  83309. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83310. */
  83311. MaterialLoadingFailsSilently: boolean;
  83312. };
  83313. /**
  83314. * OBJ file type loader.
  83315. * This is a babylon scene loader plugin.
  83316. */
  83317. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83318. /**
  83319. * Defines if UVs are optimized by default during load.
  83320. */
  83321. static OPTIMIZE_WITH_UV: boolean;
  83322. /**
  83323. * Invert model on y-axis (does a model scaling inversion)
  83324. */
  83325. static INVERT_Y: boolean;
  83326. /**
  83327. * Invert Y-Axis of referenced textures on load
  83328. */
  83329. static get INVERT_TEXTURE_Y(): boolean;
  83330. static set INVERT_TEXTURE_Y(value: boolean);
  83331. /**
  83332. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83333. */
  83334. static IMPORT_VERTEX_COLORS: boolean;
  83335. /**
  83336. * Compute the normals for the model, even if normals are present in the file.
  83337. */
  83338. static COMPUTE_NORMALS: boolean;
  83339. /**
  83340. * Defines custom scaling of UV coordinates of loaded meshes.
  83341. */
  83342. static UV_SCALING: Vector2;
  83343. /**
  83344. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83345. */
  83346. static SKIP_MATERIALS: boolean;
  83347. /**
  83348. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83349. *
  83350. * Defaults to true for backwards compatibility.
  83351. */
  83352. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83353. /**
  83354. * Defines the name of the plugin.
  83355. */
  83356. name: string;
  83357. /**
  83358. * Defines the extension the plugin is able to load.
  83359. */
  83360. extensions: string;
  83361. /** @hidden */
  83362. obj: RegExp;
  83363. /** @hidden */
  83364. group: RegExp;
  83365. /** @hidden */
  83366. mtllib: RegExp;
  83367. /** @hidden */
  83368. usemtl: RegExp;
  83369. /** @hidden */
  83370. smooth: RegExp;
  83371. /** @hidden */
  83372. vertexPattern: RegExp;
  83373. /** @hidden */
  83374. normalPattern: RegExp;
  83375. /** @hidden */
  83376. uvPattern: RegExp;
  83377. /** @hidden */
  83378. facePattern1: RegExp;
  83379. /** @hidden */
  83380. facePattern2: RegExp;
  83381. /** @hidden */
  83382. facePattern3: RegExp;
  83383. /** @hidden */
  83384. facePattern4: RegExp;
  83385. /** @hidden */
  83386. facePattern5: RegExp;
  83387. private _forAssetContainer;
  83388. private _meshLoadOptions;
  83389. /**
  83390. * Creates loader for .OBJ files
  83391. *
  83392. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83393. */
  83394. constructor(meshLoadOptions?: MeshLoadOptions);
  83395. private static get currentMeshLoadOptions();
  83396. /**
  83397. * Calls synchronously the MTL file attached to this obj.
  83398. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83399. * Without this function materials are not displayed in the first frame (but displayed after).
  83400. * In consequence it is impossible to get material information in your HTML file
  83401. *
  83402. * @param url The URL of the MTL file
  83403. * @param rootUrl
  83404. * @param onSuccess Callback function to be called when the MTL file is loaded
  83405. * @private
  83406. */
  83407. private _loadMTL;
  83408. /**
  83409. * Instantiates a OBJ file loader plugin.
  83410. * @returns the created plugin
  83411. */
  83412. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83413. /**
  83414. * If the data string can be loaded directly.
  83415. *
  83416. * @param data string containing the file data
  83417. * @returns if the data can be loaded directly
  83418. */
  83419. canDirectLoad(data: string): boolean;
  83420. /**
  83421. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83422. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83423. * @param scene the scene the meshes should be added to
  83424. * @param data the OBJ data to load
  83425. * @param rootUrl root url to load from
  83426. * @param onProgress event that fires when loading progress has occured
  83427. * @param fileName Defines the name of the file to load
  83428. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83429. */
  83430. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83431. meshes: AbstractMesh[];
  83432. particleSystems: IParticleSystem[];
  83433. skeletons: Skeleton[];
  83434. animationGroups: AnimationGroup[];
  83435. }>;
  83436. /**
  83437. * Imports all objects from the loaded OBJ data and adds them to the scene
  83438. * @param scene the scene the objects should be added to
  83439. * @param data the OBJ data to load
  83440. * @param rootUrl root url to load from
  83441. * @param onProgress event that fires when loading progress has occured
  83442. * @param fileName Defines the name of the file to load
  83443. * @returns a promise which completes when objects have been loaded to the scene
  83444. */
  83445. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83446. /**
  83447. * Load into an asset container.
  83448. * @param scene The scene to load into
  83449. * @param data The data to import
  83450. * @param rootUrl The root url for scene and resources
  83451. * @param onProgress The callback when the load progresses
  83452. * @param fileName Defines the name of the file to load
  83453. * @returns The loaded asset container
  83454. */
  83455. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83456. /**
  83457. * Read the OBJ file and create an Array of meshes.
  83458. * Each mesh contains all information given by the OBJ and the MTL file.
  83459. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83460. *
  83461. * @param meshesNames
  83462. * @param scene Scene The scene where are displayed the data
  83463. * @param data String The content of the obj file
  83464. * @param rootUrl String The path to the folder
  83465. * @returns Array<AbstractMesh>
  83466. * @private
  83467. */
  83468. private _parseSolid;
  83469. }
  83470. }
  83471. declare module BABYLON {
  83472. /**
  83473. * STL file type loader.
  83474. * This is a babylon scene loader plugin.
  83475. */
  83476. export class STLFileLoader implements ISceneLoaderPlugin {
  83477. /** @hidden */
  83478. solidPattern: RegExp;
  83479. /** @hidden */
  83480. facetsPattern: RegExp;
  83481. /** @hidden */
  83482. normalPattern: RegExp;
  83483. /** @hidden */
  83484. vertexPattern: RegExp;
  83485. /**
  83486. * Defines the name of the plugin.
  83487. */
  83488. name: string;
  83489. /**
  83490. * Defines the extensions the stl loader is able to load.
  83491. * force data to come in as an ArrayBuffer
  83492. * we'll convert to string if it looks like it's an ASCII .stl
  83493. */
  83494. extensions: ISceneLoaderPluginExtensions;
  83495. /**
  83496. * Import meshes into a scene.
  83497. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83498. * @param scene The scene to import into
  83499. * @param data The data to import
  83500. * @param rootUrl The root url for scene and resources
  83501. * @param meshes The meshes array to import into
  83502. * @param particleSystems The particle systems array to import into
  83503. * @param skeletons The skeletons array to import into
  83504. * @param onError The callback when import fails
  83505. * @returns True if successful or false otherwise
  83506. */
  83507. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83508. /**
  83509. * Load into a scene.
  83510. * @param scene The scene to load into
  83511. * @param data The data to import
  83512. * @param rootUrl The root url for scene and resources
  83513. * @param onError The callback when import fails
  83514. * @returns true if successful or false otherwise
  83515. */
  83516. load(scene: Scene, data: any, rootUrl: string): boolean;
  83517. /**
  83518. * Load into an asset container.
  83519. * @param scene The scene to load into
  83520. * @param data The data to import
  83521. * @param rootUrl The root url for scene and resources
  83522. * @param onError The callback when import fails
  83523. * @returns The loaded asset container
  83524. */
  83525. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83526. private _isBinary;
  83527. private _parseBinary;
  83528. private _parseASCII;
  83529. }
  83530. }
  83531. declare module BABYLON {
  83532. /**
  83533. * Class for generating OBJ data from a Babylon scene.
  83534. */
  83535. export class OBJExport {
  83536. /**
  83537. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83538. * @param mesh defines the list of meshes to serialize
  83539. * @param materials defines if materials should be exported
  83540. * @param matlibname defines the name of the associated mtl file
  83541. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83542. * @returns the OBJ content
  83543. */
  83544. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83545. /**
  83546. * Exports the material(s) of a mesh in .MTL file format (text)
  83547. * @param mesh defines the mesh to extract the material from
  83548. * @returns the mtl content
  83549. */
  83550. static MTL(mesh: Mesh): string;
  83551. }
  83552. }
  83553. declare module BABYLON {
  83554. /** @hidden */
  83555. export var __IGLTFExporterExtension: number;
  83556. /**
  83557. * Interface for extending the exporter
  83558. * @hidden
  83559. */
  83560. export interface IGLTFExporterExtension {
  83561. /**
  83562. * The name of this extension
  83563. */
  83564. readonly name: string;
  83565. /**
  83566. * Defines whether this extension is enabled
  83567. */
  83568. enabled: boolean;
  83569. /**
  83570. * Defines whether this extension is required
  83571. */
  83572. required: boolean;
  83573. }
  83574. }
  83575. declare module BABYLON.GLTF2.Exporter {
  83576. /** @hidden */
  83577. export var __IGLTFExporterExtensionV2: number;
  83578. /**
  83579. * Interface for a glTF exporter extension
  83580. * @hidden
  83581. */
  83582. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83583. /**
  83584. * Define this method to modify the default behavior before exporting a texture
  83585. * @param context The context when loading the asset
  83586. * @param babylonTexture The Babylon.js texture
  83587. * @param mimeType The mime-type of the generated image
  83588. * @returns A promise that resolves with the exported texture
  83589. */
  83590. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83591. /**
  83592. * Define this method to get notified when a texture info is created
  83593. * @param context The context when loading the asset
  83594. * @param textureInfo The glTF texture info
  83595. * @param babylonTexture The Babylon.js texture
  83596. */
  83597. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83598. /**
  83599. * Define this method to modify the default behavior when exporting texture info
  83600. * @param context The context when loading the asset
  83601. * @param meshPrimitive glTF mesh primitive
  83602. * @param babylonSubMesh Babylon submesh
  83603. * @param binaryWriter glTF serializer binary writer instance
  83604. * @returns nullable IMeshPrimitive promise
  83605. */
  83606. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83607. /**
  83608. * Define this method to modify the default behavior when exporting a node
  83609. * @param context The context when exporting the node
  83610. * @param node glTF node
  83611. * @param babylonNode BabylonJS node
  83612. * @returns nullable INode promise
  83613. */
  83614. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83615. [key: number]: number;
  83616. }): Promise<Nullable<INode>>;
  83617. /**
  83618. * Define this method to modify the default behavior when exporting a material
  83619. * @param material glTF material
  83620. * @param babylonMaterial BabylonJS material
  83621. * @returns nullable IMaterial promise
  83622. */
  83623. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83624. /**
  83625. * Define this method to return additional textures to export from a material
  83626. * @param material glTF material
  83627. * @param babylonMaterial BabylonJS material
  83628. * @returns List of textures
  83629. */
  83630. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83631. /** Gets a boolean indicating that this extension was used */
  83632. wasUsed: boolean;
  83633. /** Gets a boolean indicating that this extension is required for the file to work */
  83634. required: boolean;
  83635. /**
  83636. * Called after the exporter state changes to EXPORTING
  83637. */
  83638. onExporting?(): void;
  83639. }
  83640. }
  83641. declare module BABYLON.GLTF2.Exporter {
  83642. /**
  83643. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83644. * @hidden
  83645. */
  83646. export class _GLTFMaterialExporter {
  83647. /**
  83648. * Represents the dielectric specular values for R, G and B
  83649. */
  83650. private static readonly _DielectricSpecular;
  83651. /**
  83652. * Allows the maximum specular power to be defined for material calculations
  83653. */
  83654. private static readonly _MaxSpecularPower;
  83655. /**
  83656. * Mapping to store textures
  83657. */
  83658. private _textureMap;
  83659. /**
  83660. * Numeric tolerance value
  83661. */
  83662. private static readonly _Epsilon;
  83663. /**
  83664. * Reference to the glTF Exporter
  83665. */
  83666. private _exporter;
  83667. constructor(exporter: _Exporter);
  83668. /**
  83669. * Specifies if two colors are approximately equal in value
  83670. * @param color1 first color to compare to
  83671. * @param color2 second color to compare to
  83672. * @param epsilon threshold value
  83673. */
  83674. private static FuzzyEquals;
  83675. /**
  83676. * Gets the materials from a Babylon scene and converts them to glTF materials
  83677. * @param scene babylonjs scene
  83678. * @param mimeType texture mime type
  83679. * @param images array of images
  83680. * @param textures array of textures
  83681. * @param materials array of materials
  83682. * @param imageData mapping of texture names to base64 textures
  83683. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83684. */
  83685. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83686. /**
  83687. * Makes a copy of the glTF material without the texture parameters
  83688. * @param originalMaterial original glTF material
  83689. * @returns glTF material without texture parameters
  83690. */
  83691. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83692. /**
  83693. * Specifies if the material has any texture parameters present
  83694. * @param material glTF Material
  83695. * @returns boolean specifying if texture parameters are present
  83696. */
  83697. _hasTexturesPresent(material: IMaterial): boolean;
  83698. /**
  83699. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83700. * @param babylonStandardMaterial
  83701. * @returns glTF Metallic Roughness Material representation
  83702. */
  83703. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83704. /**
  83705. * Computes the metallic factor
  83706. * @param diffuse diffused value
  83707. * @param specular specular value
  83708. * @param oneMinusSpecularStrength one minus the specular strength
  83709. * @returns metallic value
  83710. */
  83711. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83712. /**
  83713. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83714. * @param glTFMaterial glTF material
  83715. * @param babylonMaterial Babylon material
  83716. */
  83717. private static _SetAlphaMode;
  83718. /**
  83719. * Converts a Babylon Standard Material to a glTF Material
  83720. * @param babylonStandardMaterial BJS Standard Material
  83721. * @param mimeType mime type to use for the textures
  83722. * @param images array of glTF image interfaces
  83723. * @param textures array of glTF texture interfaces
  83724. * @param materials array of glTF material interfaces
  83725. * @param imageData map of image file name to data
  83726. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83727. */
  83728. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83729. private _finishMaterial;
  83730. /**
  83731. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83732. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83733. * @param mimeType mime type to use for the textures
  83734. * @param images array of glTF image interfaces
  83735. * @param textures array of glTF texture interfaces
  83736. * @param materials array of glTF material interfaces
  83737. * @param imageData map of image file name to data
  83738. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83739. */
  83740. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83741. /**
  83742. * Converts an image typed array buffer to a base64 image
  83743. * @param buffer typed array buffer
  83744. * @param width width of the image
  83745. * @param height height of the image
  83746. * @param mimeType mimetype of the image
  83747. * @returns base64 image string
  83748. */
  83749. private _createBase64FromCanvasAsync;
  83750. /**
  83751. * Generates a white texture based on the specified width and height
  83752. * @param width width of the texture in pixels
  83753. * @param height height of the texture in pixels
  83754. * @param scene babylonjs scene
  83755. * @returns white texture
  83756. */
  83757. private _createWhiteTexture;
  83758. /**
  83759. * 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
  83760. * @param texture1 first texture to resize
  83761. * @param texture2 second texture to resize
  83762. * @param scene babylonjs scene
  83763. * @returns resized textures or null
  83764. */
  83765. private _resizeTexturesToSameDimensions;
  83766. /**
  83767. * Converts an array of pixels to a Float32Array
  83768. * Throws an error if the pixel format is not supported
  83769. * @param pixels - array buffer containing pixel values
  83770. * @returns Float32 of pixels
  83771. */
  83772. private _convertPixelArrayToFloat32;
  83773. /**
  83774. * Convert Specular Glossiness Textures to Metallic Roughness
  83775. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83776. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83777. * @param diffuseTexture texture used to store diffuse information
  83778. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83779. * @param factors specular glossiness material factors
  83780. * @param mimeType the mime type to use for the texture
  83781. * @returns pbr metallic roughness interface or null
  83782. */
  83783. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83784. /**
  83785. * Converts specular glossiness material properties to metallic roughness
  83786. * @param specularGlossiness interface with specular glossiness material properties
  83787. * @returns interface with metallic roughness material properties
  83788. */
  83789. private _convertSpecularGlossinessToMetallicRoughness;
  83790. /**
  83791. * Calculates the surface reflectance, independent of lighting conditions
  83792. * @param color Color source to calculate brightness from
  83793. * @returns number representing the perceived brightness, or zero if color is undefined
  83794. */
  83795. private _getPerceivedBrightness;
  83796. /**
  83797. * Returns the maximum color component value
  83798. * @param color
  83799. * @returns maximum color component value, or zero if color is null or undefined
  83800. */
  83801. private _getMaxComponent;
  83802. /**
  83803. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83804. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83805. * @param mimeType mime type to use for the textures
  83806. * @param images array of glTF image interfaces
  83807. * @param textures array of glTF texture interfaces
  83808. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83809. * @param imageData map of image file name to data
  83810. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83811. * @returns glTF PBR Metallic Roughness factors
  83812. */
  83813. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83814. private _getGLTFTextureSampler;
  83815. private _getGLTFTextureWrapMode;
  83816. private _getGLTFTextureWrapModesSampler;
  83817. /**
  83818. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83819. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83820. * @param mimeType mime type to use for the textures
  83821. * @param images array of glTF image interfaces
  83822. * @param textures array of glTF texture interfaces
  83823. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83824. * @param imageData map of image file name to data
  83825. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83826. * @returns glTF PBR Metallic Roughness factors
  83827. */
  83828. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83829. /**
  83830. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83831. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83832. * @param mimeType mime type to use for the textures
  83833. * @param images array of glTF image interfaces
  83834. * @param textures array of glTF texture interfaces
  83835. * @param materials array of glTF material interfaces
  83836. * @param imageData map of image file name to data
  83837. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83838. */
  83839. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83840. private setMetallicRoughnessPbrMaterial;
  83841. private getPixelsFromTexture;
  83842. /**
  83843. * Extracts a texture from a Babylon texture into file data and glTF data
  83844. * @param babylonTexture Babylon texture to extract
  83845. * @param mimeType Mime Type of the babylonTexture
  83846. * @return glTF texture info, or null if the texture format is not supported
  83847. */
  83848. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83849. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83850. /**
  83851. * Builds a texture from base64 string
  83852. * @param base64Texture base64 texture string
  83853. * @param baseTextureName Name to use for the texture
  83854. * @param mimeType image mime type for the texture
  83855. * @param images array of images
  83856. * @param textures array of textures
  83857. * @param imageData map of image data
  83858. * @returns glTF texture info, or null if the texture format is not supported
  83859. */
  83860. private _getTextureInfoFromBase64;
  83861. }
  83862. }
  83863. declare module BABYLON {
  83864. /**
  83865. * Class for holding and downloading glTF file data
  83866. */
  83867. export class GLTFData {
  83868. /**
  83869. * Object which contains the file name as the key and its data as the value
  83870. */
  83871. glTFFiles: {
  83872. [fileName: string]: string | Blob;
  83873. };
  83874. /**
  83875. * Initializes the glTF file object
  83876. */
  83877. constructor();
  83878. /**
  83879. * Downloads the glTF data as files based on their names and data
  83880. */
  83881. downloadFiles(): void;
  83882. }
  83883. }
  83884. declare module BABYLON {
  83885. /**
  83886. * Holds a collection of exporter options and parameters
  83887. */
  83888. export interface IExportOptions {
  83889. /**
  83890. * Function which indicates whether a babylon node should be exported or not
  83891. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83892. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83893. */
  83894. shouldExportNode?(node: Node): boolean;
  83895. /**
  83896. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83897. * @param metadata source metadata to read from
  83898. * @returns the data to store to glTF node extras
  83899. */
  83900. metadataSelector?(metadata: any): any;
  83901. /**
  83902. * The sample rate to bake animation curves
  83903. */
  83904. animationSampleRate?: number;
  83905. /**
  83906. * Begin serialization without waiting for the scene to be ready
  83907. */
  83908. exportWithoutWaitingForScene?: boolean;
  83909. /**
  83910. * Indicates if coordinate system swapping root nodes should be included in export
  83911. */
  83912. includeCoordinateSystemConversionNodes?: boolean;
  83913. }
  83914. /**
  83915. * Class for generating glTF data from a Babylon scene.
  83916. */
  83917. export class GLTF2Export {
  83918. /**
  83919. * Exports the geometry of the scene to .gltf file format asynchronously
  83920. * @param scene Babylon scene with scene hierarchy information
  83921. * @param filePrefix File prefix to use when generating the glTF file
  83922. * @param options Exporter options
  83923. * @returns Returns an object with a .gltf file and associates texture names
  83924. * as keys and their data and paths as values
  83925. */
  83926. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83927. private static _PreExportAsync;
  83928. private static _PostExportAsync;
  83929. /**
  83930. * Exports the geometry of the scene to .glb file format asychronously
  83931. * @param scene Babylon scene with scene hierarchy information
  83932. * @param filePrefix File prefix to use when generating glb file
  83933. * @param options Exporter options
  83934. * @returns Returns an object with a .glb filename as key and data as value
  83935. */
  83936. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83937. }
  83938. }
  83939. declare module BABYLON.GLTF2.Exporter {
  83940. /**
  83941. * @hidden
  83942. */
  83943. export class _GLTFUtilities {
  83944. /**
  83945. * Creates a buffer view based on the supplied arguments
  83946. * @param bufferIndex index value of the specified buffer
  83947. * @param byteOffset byte offset value
  83948. * @param byteLength byte length of the bufferView
  83949. * @param byteStride byte distance between conequential elements
  83950. * @param name name of the buffer view
  83951. * @returns bufferView for glTF
  83952. */
  83953. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83954. /**
  83955. * Creates an accessor based on the supplied arguments
  83956. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83957. * @param name The name of the accessor
  83958. * @param type The type of the accessor
  83959. * @param componentType The datatype of components in the attribute
  83960. * @param count The number of attributes referenced by this accessor
  83961. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83962. * @param min Minimum value of each component in this attribute
  83963. * @param max Maximum value of each component in this attribute
  83964. * @returns accessor for glTF
  83965. */
  83966. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83967. /**
  83968. * Calculates the minimum and maximum values of an array of position floats
  83969. * @param positions Positions array of a mesh
  83970. * @param vertexStart Starting vertex offset to calculate min and max values
  83971. * @param vertexCount Number of vertices to check for min and max values
  83972. * @returns min number array and max number array
  83973. */
  83974. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83975. min: number[];
  83976. max: number[];
  83977. };
  83978. /**
  83979. * Converts a new right-handed Vector3
  83980. * @param vector vector3 array
  83981. * @returns right-handed Vector3
  83982. */
  83983. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83984. /**
  83985. * Converts a Vector3 to right-handed
  83986. * @param vector Vector3 to convert to right-handed
  83987. */
  83988. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83989. /**
  83990. * Converts a three element number array to right-handed
  83991. * @param vector number array to convert to right-handed
  83992. */
  83993. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83994. /**
  83995. * Converts a new right-handed Vector3
  83996. * @param vector vector3 array
  83997. * @returns right-handed Vector3
  83998. */
  83999. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84000. /**
  84001. * Converts a Vector3 to right-handed
  84002. * @param vector Vector3 to convert to right-handed
  84003. */
  84004. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84005. /**
  84006. * Converts a three element number array to right-handed
  84007. * @param vector number array to convert to right-handed
  84008. */
  84009. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84010. /**
  84011. * Converts a Vector4 to right-handed
  84012. * @param vector Vector4 to convert to right-handed
  84013. */
  84014. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84015. /**
  84016. * Converts a Vector4 to right-handed
  84017. * @param vector Vector4 to convert to right-handed
  84018. */
  84019. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84020. /**
  84021. * Converts a Quaternion to right-handed
  84022. * @param quaternion Source quaternion to convert to right-handed
  84023. */
  84024. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84025. /**
  84026. * Converts a Quaternion to right-handed
  84027. * @param quaternion Source quaternion to convert to right-handed
  84028. */
  84029. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84030. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84031. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84032. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84033. }
  84034. }
  84035. declare module BABYLON.GLTF2.Exporter {
  84036. /**
  84037. * Converts Babylon Scene into glTF 2.0.
  84038. * @hidden
  84039. */
  84040. export class _Exporter {
  84041. /**
  84042. * Stores the glTF to export
  84043. */
  84044. _glTF: IGLTF;
  84045. /**
  84046. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84047. */
  84048. _bufferViews: IBufferView[];
  84049. /**
  84050. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84051. */
  84052. _accessors: IAccessor[];
  84053. /**
  84054. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84055. */
  84056. _nodes: INode[];
  84057. /**
  84058. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84059. */
  84060. private _scenes;
  84061. /**
  84062. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84063. */
  84064. private _meshes;
  84065. /**
  84066. * Stores all the generated material information, which represents the appearance of each primitive
  84067. */
  84068. _materials: IMaterial[];
  84069. _materialMap: {
  84070. [materialID: number]: number;
  84071. };
  84072. /**
  84073. * Stores all the generated texture information, which is referenced by glTF materials
  84074. */
  84075. _textures: ITexture[];
  84076. /**
  84077. * Stores all the generated image information, which is referenced by glTF textures
  84078. */
  84079. _images: IImage[];
  84080. /**
  84081. * Stores all the texture samplers
  84082. */
  84083. _samplers: ISampler[];
  84084. /**
  84085. * Stores all the generated glTF skins
  84086. */
  84087. _skins: ISkin[];
  84088. /**
  84089. * Stores all the generated animation samplers, which is referenced by glTF animations
  84090. */
  84091. /**
  84092. * Stores the animations for glTF models
  84093. */
  84094. private _animations;
  84095. /**
  84096. * Stores the total amount of bytes stored in the glTF buffer
  84097. */
  84098. private _totalByteLength;
  84099. /**
  84100. * Stores a reference to the Babylon scene containing the source geometry and material information
  84101. */
  84102. _babylonScene: Scene;
  84103. /**
  84104. * Stores a map of the image data, where the key is the file name and the value
  84105. * is the image data
  84106. */
  84107. _imageData: {
  84108. [fileName: string]: {
  84109. data: Uint8Array;
  84110. mimeType: ImageMimeType;
  84111. };
  84112. };
  84113. protected _orderedImageData: Array<{
  84114. data: Uint8Array;
  84115. mimeType: ImageMimeType;
  84116. }>;
  84117. /**
  84118. * Stores a map of the unique id of a node to its index in the node array
  84119. */
  84120. _nodeMap: {
  84121. [key: number]: number;
  84122. };
  84123. /**
  84124. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84125. */
  84126. _convertToRightHandedSystem: boolean;
  84127. /**
  84128. * Specifies if a Babylon node should be converted to right-handed on export
  84129. */
  84130. _convertToRightHandedSystemMap: {
  84131. [nodeId: number]: boolean;
  84132. };
  84133. _includeCoordinateSystemConversionNodes: boolean;
  84134. /**
  84135. * Baked animation sample rate
  84136. */
  84137. private _animationSampleRate;
  84138. private _options;
  84139. private _localEngine;
  84140. _glTFMaterialExporter: _GLTFMaterialExporter;
  84141. private _extensions;
  84142. private static _ExtensionNames;
  84143. private static _ExtensionFactories;
  84144. private _applyExtension;
  84145. private _applyExtensions;
  84146. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84147. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84148. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84149. [key: number]: number;
  84150. }): Promise<Nullable<INode>>;
  84151. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84152. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84153. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84154. private _forEachExtensions;
  84155. private _extensionsOnExporting;
  84156. /**
  84157. * Load glTF serializer extensions
  84158. */
  84159. private _loadExtensions;
  84160. /**
  84161. * Creates a glTF Exporter instance, which can accept optional exporter options
  84162. * @param babylonScene Babylon scene object
  84163. * @param options Options to modify the behavior of the exporter
  84164. */
  84165. constructor(babylonScene: Scene, options?: IExportOptions);
  84166. dispose(): void;
  84167. /**
  84168. * Registers a glTF exporter extension
  84169. * @param name Name of the extension to export
  84170. * @param factory The factory function that creates the exporter extension
  84171. */
  84172. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84173. /**
  84174. * Un-registers an exporter extension
  84175. * @param name The name fo the exporter extension
  84176. * @returns A boolean indicating whether the extension has been un-registered
  84177. */
  84178. static UnregisterExtension(name: string): boolean;
  84179. /**
  84180. * Lazy load a local engine
  84181. */
  84182. _getLocalEngine(): Engine;
  84183. private reorderIndicesBasedOnPrimitiveMode;
  84184. /**
  84185. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84186. * clock-wise during export to glTF
  84187. * @param submesh BabylonJS submesh
  84188. * @param primitiveMode Primitive mode of the mesh
  84189. * @param sideOrientation the winding order of the submesh
  84190. * @param vertexBufferKind The type of vertex attribute
  84191. * @param meshAttributeArray The vertex attribute data
  84192. * @param byteOffset The offset to the binary data
  84193. * @param binaryWriter The binary data for the glTF file
  84194. * @param convertToRightHandedSystem Converts the values to right-handed
  84195. */
  84196. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84197. /**
  84198. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84199. * clock-wise during export to glTF
  84200. * @param submesh BabylonJS submesh
  84201. * @param primitiveMode Primitive mode of the mesh
  84202. * @param sideOrientation the winding order of the submesh
  84203. * @param vertexBufferKind The type of vertex attribute
  84204. * @param meshAttributeArray The vertex attribute data
  84205. * @param byteOffset The offset to the binary data
  84206. * @param binaryWriter The binary data for the glTF file
  84207. * @param convertToRightHandedSystem Converts the values to right-handed
  84208. */
  84209. private reorderTriangleFillMode;
  84210. /**
  84211. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84212. * clock-wise during export to glTF
  84213. * @param submesh BabylonJS submesh
  84214. * @param primitiveMode Primitive mode of the mesh
  84215. * @param sideOrientation the winding order of the submesh
  84216. * @param vertexBufferKind The type of vertex attribute
  84217. * @param meshAttributeArray The vertex attribute data
  84218. * @param byteOffset The offset to the binary data
  84219. * @param binaryWriter The binary data for the glTF file
  84220. * @param convertToRightHandedSystem Converts the values to right-handed
  84221. */
  84222. private reorderTriangleStripDrawMode;
  84223. /**
  84224. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84225. * clock-wise during export to glTF
  84226. * @param submesh BabylonJS submesh
  84227. * @param primitiveMode Primitive mode of the mesh
  84228. * @param sideOrientation the winding order of the submesh
  84229. * @param vertexBufferKind The type of vertex attribute
  84230. * @param meshAttributeArray The vertex attribute data
  84231. * @param byteOffset The offset to the binary data
  84232. * @param binaryWriter The binary data for the glTF file
  84233. * @param convertToRightHandedSystem Converts the values to right-handed
  84234. */
  84235. private reorderTriangleFanMode;
  84236. /**
  84237. * Writes the vertex attribute data to binary
  84238. * @param vertices The vertices to write to the binary writer
  84239. * @param byteOffset The offset into the binary writer to overwrite binary data
  84240. * @param vertexAttributeKind The vertex attribute type
  84241. * @param meshAttributeArray The vertex attribute data
  84242. * @param binaryWriter The writer containing the binary data
  84243. * @param convertToRightHandedSystem Converts the values to right-handed
  84244. */
  84245. private writeVertexAttributeData;
  84246. /**
  84247. * Writes mesh attribute data to a data buffer
  84248. * Returns the bytelength of the data
  84249. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84250. * @param meshAttributeArray Array containing the attribute data
  84251. * @param byteStride Specifies the space between data
  84252. * @param binaryWriter The buffer to write the binary data to
  84253. * @param convertToRightHandedSystem Converts the values to right-handed
  84254. */
  84255. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84256. /**
  84257. * Writes mesh attribute data to a data buffer
  84258. * Returns the bytelength of the data
  84259. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84260. * @param meshAttributeArray Array containing the attribute data
  84261. * @param byteStride Specifies the space between data
  84262. * @param binaryWriter The buffer to write the binary data to
  84263. * @param convertToRightHandedSystem Converts the values to right-handed
  84264. */
  84265. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84266. /**
  84267. * Generates glTF json data
  84268. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84269. * @param glTFPrefix Text to use when prefixing a glTF file
  84270. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84271. * @returns json data as string
  84272. */
  84273. private generateJSON;
  84274. /**
  84275. * Generates data for .gltf and .bin files based on the glTF prefix string
  84276. * @param glTFPrefix Text to use when prefixing a glTF file
  84277. * @param dispose Dispose the exporter
  84278. * @returns GLTFData with glTF file data
  84279. */
  84280. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84281. /**
  84282. * Creates a binary buffer for glTF
  84283. * @returns array buffer for binary data
  84284. */
  84285. private _generateBinaryAsync;
  84286. /**
  84287. * Pads the number to a multiple of 4
  84288. * @param num number to pad
  84289. * @returns padded number
  84290. */
  84291. private _getPadding;
  84292. /**
  84293. * @hidden
  84294. */
  84295. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84296. /**
  84297. * Sets the TRS for each node
  84298. * @param node glTF Node for storing the transformation data
  84299. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84300. * @param convertToRightHandedSystem Converts the values to right-handed
  84301. */
  84302. private setNodeTransformation;
  84303. private getVertexBufferFromMesh;
  84304. /**
  84305. * Creates a bufferview based on the vertices type for the Babylon mesh
  84306. * @param kind Indicates the type of vertices data
  84307. * @param componentType Indicates the numerical type used to store the data
  84308. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84309. * @param binaryWriter The buffer to write the bufferview data to
  84310. * @param convertToRightHandedSystem Converts the values to right-handed
  84311. */
  84312. private createBufferViewKind;
  84313. /**
  84314. * Creates a bufferview based on the vertices type for the Babylon mesh
  84315. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84316. * @param babylonMorphTarget the morph target to be exported
  84317. * @param binaryWriter The buffer to write the bufferview data to
  84318. * @param convertToRightHandedSystem Converts the values to right-handed
  84319. */
  84320. private setMorphTargetAttributes;
  84321. /**
  84322. * The primitive mode of the Babylon mesh
  84323. * @param babylonMesh The BabylonJS mesh
  84324. */
  84325. private getMeshPrimitiveMode;
  84326. /**
  84327. * Sets the primitive mode of the glTF mesh primitive
  84328. * @param meshPrimitive glTF mesh primitive
  84329. * @param primitiveMode The primitive mode
  84330. */
  84331. private setPrimitiveMode;
  84332. /**
  84333. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84334. * @param meshPrimitive glTF mesh primitive
  84335. * @param attributeKind vertex attribute
  84336. * @returns boolean specifying if uv coordinates are present
  84337. */
  84338. private setAttributeKind;
  84339. /**
  84340. * Sets data for the primitive attributes of each submesh
  84341. * @param mesh glTF Mesh object to store the primitive attribute information
  84342. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84343. * @param binaryWriter Buffer to write the attribute data to
  84344. * @param convertToRightHandedSystem Converts the values to right-handed
  84345. */
  84346. private setPrimitiveAttributesAsync;
  84347. /**
  84348. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84349. * @param node The node to check
  84350. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84351. */
  84352. private isBabylonCoordinateSystemConvertingNode;
  84353. /**
  84354. * Creates a glTF scene based on the array of meshes
  84355. * Returns the the total byte offset
  84356. * @param babylonScene Babylon scene to get the mesh data from
  84357. * @param binaryWriter Buffer to write binary data to
  84358. */
  84359. private createSceneAsync;
  84360. /**
  84361. * Creates a mapping of Node unique id to node index and handles animations
  84362. * @param babylonScene Babylon Scene
  84363. * @param nodes Babylon transform nodes
  84364. * @param binaryWriter Buffer to write binary data to
  84365. * @returns Node mapping of unique id to index
  84366. */
  84367. private createNodeMapAndAnimationsAsync;
  84368. /**
  84369. * Creates a glTF node from a Babylon mesh
  84370. * @param babylonMesh Source Babylon mesh
  84371. * @param binaryWriter Buffer for storing geometry data
  84372. * @param convertToRightHandedSystem Converts the values to right-handed
  84373. * @param nodeMap Node mapping of unique id to glTF node index
  84374. * @returns glTF node
  84375. */
  84376. private createNodeAsync;
  84377. /**
  84378. * Creates a glTF skin from a Babylon skeleton
  84379. * @param babylonScene Babylon Scene
  84380. * @param nodes Babylon transform nodes
  84381. * @param binaryWriter Buffer to write binary data to
  84382. * @returns Node mapping of unique id to index
  84383. */
  84384. private createSkinsAsync;
  84385. }
  84386. /**
  84387. * @hidden
  84388. *
  84389. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84390. */
  84391. export class _BinaryWriter {
  84392. /**
  84393. * Array buffer which stores all binary data
  84394. */
  84395. private _arrayBuffer;
  84396. /**
  84397. * View of the array buffer
  84398. */
  84399. private _dataView;
  84400. /**
  84401. * byte offset of data in array buffer
  84402. */
  84403. private _byteOffset;
  84404. /**
  84405. * Initialize binary writer with an initial byte length
  84406. * @param byteLength Initial byte length of the array buffer
  84407. */
  84408. constructor(byteLength: number);
  84409. /**
  84410. * Resize the array buffer to the specified byte length
  84411. * @param byteLength
  84412. */
  84413. private resizeBuffer;
  84414. /**
  84415. * Get an array buffer with the length of the byte offset
  84416. * @returns ArrayBuffer resized to the byte offset
  84417. */
  84418. getArrayBuffer(): ArrayBuffer;
  84419. /**
  84420. * Get the byte offset of the array buffer
  84421. * @returns byte offset
  84422. */
  84423. getByteOffset(): number;
  84424. /**
  84425. * Stores an UInt8 in the array buffer
  84426. * @param entry
  84427. * @param byteOffset If defined, specifies where to set the value as an offset.
  84428. */
  84429. setUInt8(entry: number, byteOffset?: number): void;
  84430. /**
  84431. * Stores an UInt16 in the array buffer
  84432. * @param entry
  84433. * @param byteOffset If defined, specifies where to set the value as an offset.
  84434. */
  84435. setUInt16(entry: number, byteOffset?: number): void;
  84436. /**
  84437. * Gets an UInt32 in the array buffer
  84438. * @param entry
  84439. * @param byteOffset If defined, specifies where to set the value as an offset.
  84440. */
  84441. getUInt32(byteOffset: number): number;
  84442. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84443. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84444. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84445. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84446. /**
  84447. * Stores a Float32 in the array buffer
  84448. * @param entry
  84449. */
  84450. setFloat32(entry: number, byteOffset?: number): void;
  84451. /**
  84452. * Stores an UInt32 in the array buffer
  84453. * @param entry
  84454. * @param byteOffset If defined, specifies where to set the value as an offset.
  84455. */
  84456. setUInt32(entry: number, byteOffset?: number): void;
  84457. }
  84458. }
  84459. declare module BABYLON.GLTF2.Exporter {
  84460. /**
  84461. * @hidden
  84462. * Interface to store animation data.
  84463. */
  84464. export interface _IAnimationData {
  84465. /**
  84466. * Keyframe data.
  84467. */
  84468. inputs: number[];
  84469. /**
  84470. * Value data.
  84471. */
  84472. outputs: number[][];
  84473. /**
  84474. * Animation interpolation data.
  84475. */
  84476. samplerInterpolation: AnimationSamplerInterpolation;
  84477. /**
  84478. * Minimum keyframe value.
  84479. */
  84480. inputsMin: number;
  84481. /**
  84482. * Maximum keyframe value.
  84483. */
  84484. inputsMax: number;
  84485. }
  84486. /**
  84487. * @hidden
  84488. */
  84489. export interface _IAnimationInfo {
  84490. /**
  84491. * The target channel for the animation
  84492. */
  84493. animationChannelTargetPath: AnimationChannelTargetPath;
  84494. /**
  84495. * The glTF accessor type for the data.
  84496. */
  84497. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84498. /**
  84499. * Specifies if quaternions should be used.
  84500. */
  84501. useQuaternion: boolean;
  84502. }
  84503. /**
  84504. * @hidden
  84505. * Utility class for generating glTF animation data from BabylonJS.
  84506. */
  84507. export class _GLTFAnimation {
  84508. /**
  84509. * @ignore
  84510. *
  84511. * Creates glTF channel animation from BabylonJS animation.
  84512. * @param babylonTransformNode - BabylonJS mesh.
  84513. * @param animation - animation.
  84514. * @param animationChannelTargetPath - The target animation channel.
  84515. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84516. * @param useQuaternion - Specifies if quaternions are used.
  84517. * @returns nullable IAnimationData
  84518. */
  84519. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84520. private static _DeduceAnimationInfo;
  84521. /**
  84522. * @ignore
  84523. * Create node animations from the transform node animations
  84524. * @param babylonNode
  84525. * @param runtimeGLTFAnimation
  84526. * @param idleGLTFAnimations
  84527. * @param nodeMap
  84528. * @param nodes
  84529. * @param binaryWriter
  84530. * @param bufferViews
  84531. * @param accessors
  84532. * @param convertToRightHandedSystem
  84533. * @param animationSampleRate
  84534. */
  84535. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84536. [key: number]: number;
  84537. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84538. /**
  84539. * @ignore
  84540. * Create individual morph animations from the mesh's morph target animation tracks
  84541. * @param babylonNode
  84542. * @param runtimeGLTFAnimation
  84543. * @param idleGLTFAnimations
  84544. * @param nodeMap
  84545. * @param nodes
  84546. * @param binaryWriter
  84547. * @param bufferViews
  84548. * @param accessors
  84549. * @param convertToRightHandedSystem
  84550. * @param animationSampleRate
  84551. */
  84552. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84553. [key: number]: number;
  84554. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84555. /**
  84556. * @ignore
  84557. * Create node and morph animations from the animation groups
  84558. * @param babylonScene
  84559. * @param glTFAnimations
  84560. * @param nodeMap
  84561. * @param nodes
  84562. * @param binaryWriter
  84563. * @param bufferViews
  84564. * @param accessors
  84565. * @param convertToRightHandedSystemMap
  84566. * @param animationSampleRate
  84567. */
  84568. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84569. [key: number]: number;
  84570. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84571. [nodeId: number]: boolean;
  84572. }, animationSampleRate: number): void;
  84573. private static AddAnimation;
  84574. /**
  84575. * Create a baked animation
  84576. * @param babylonTransformNode BabylonJS mesh
  84577. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84578. * @param animationChannelTargetPath animation target channel
  84579. * @param minFrame minimum animation frame
  84580. * @param maxFrame maximum animation frame
  84581. * @param fps frames per second of the animation
  84582. * @param inputs input key frames of the animation
  84583. * @param outputs output key frame data of the animation
  84584. * @param convertToRightHandedSystem converts the values to right-handed
  84585. * @param useQuaternion specifies if quaternions should be used
  84586. */
  84587. private static _CreateBakedAnimation;
  84588. private static _ConvertFactorToVector3OrQuaternion;
  84589. private static _SetInterpolatedValue;
  84590. /**
  84591. * Creates linear animation from the animation key frames
  84592. * @param babylonTransformNode BabylonJS mesh
  84593. * @param animation BabylonJS animation
  84594. * @param animationChannelTargetPath The target animation channel
  84595. * @param frameDelta The difference between the last and first frame of the animation
  84596. * @param inputs Array to store the key frame times
  84597. * @param outputs Array to store the key frame data
  84598. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84599. * @param useQuaternion Specifies if quaternions are used in the animation
  84600. */
  84601. private static _CreateLinearOrStepAnimation;
  84602. /**
  84603. * Creates cubic spline animation from the animation key frames
  84604. * @param babylonTransformNode BabylonJS mesh
  84605. * @param animation BabylonJS animation
  84606. * @param animationChannelTargetPath The target animation channel
  84607. * @param frameDelta The difference between the last and first frame of the animation
  84608. * @param inputs Array to store the key frame times
  84609. * @param outputs Array to store the key frame data
  84610. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84611. * @param useQuaternion Specifies if quaternions are used in the animation
  84612. */
  84613. private static _CreateCubicSplineAnimation;
  84614. private static _GetBasePositionRotationOrScale;
  84615. /**
  84616. * Adds a key frame value
  84617. * @param keyFrame
  84618. * @param animation
  84619. * @param outputs
  84620. * @param animationChannelTargetPath
  84621. * @param basePositionRotationOrScale
  84622. * @param convertToRightHandedSystem
  84623. * @param useQuaternion
  84624. */
  84625. private static _AddKeyframeValue;
  84626. /**
  84627. * Determine the interpolation based on the key frames
  84628. * @param keyFrames
  84629. * @param animationChannelTargetPath
  84630. * @param useQuaternion
  84631. */
  84632. private static _DeduceInterpolation;
  84633. /**
  84634. * Adds an input tangent or output tangent to the output data
  84635. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84636. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84637. * @param outputs The animation data by keyframe
  84638. * @param animationChannelTargetPath The target animation channel
  84639. * @param interpolation The interpolation type
  84640. * @param keyFrame The key frame with the animation data
  84641. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84642. * @param useQuaternion Specifies if quaternions are used
  84643. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84644. */
  84645. private static AddSplineTangent;
  84646. /**
  84647. * Get the minimum and maximum key frames' frame values
  84648. * @param keyFrames animation key frames
  84649. * @returns the minimum and maximum key frame value
  84650. */
  84651. private static calculateMinMaxKeyFrames;
  84652. }
  84653. }
  84654. declare module BABYLON.GLTF2.Exporter {
  84655. /** @hidden */
  84656. export var textureTransformPixelShader: {
  84657. name: string;
  84658. shader: string;
  84659. };
  84660. }
  84661. declare module BABYLON.GLTF2.Exporter.Extensions {
  84662. /**
  84663. * @hidden
  84664. */
  84665. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84666. private _recordedTextures;
  84667. /** Name of this extension */
  84668. readonly name: string;
  84669. /** Defines whether this extension is enabled */
  84670. enabled: boolean;
  84671. /** Defines whether this extension is required */
  84672. required: boolean;
  84673. /** Reference to the glTF exporter */
  84674. private _wasUsed;
  84675. constructor(exporter: _Exporter);
  84676. dispose(): void;
  84677. /** @hidden */
  84678. get wasUsed(): boolean;
  84679. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84680. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84681. /**
  84682. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84683. * @param babylonTexture
  84684. * @param offset
  84685. * @param rotation
  84686. * @param scale
  84687. * @param scene
  84688. */
  84689. private _textureTransformTextureAsync;
  84690. }
  84691. }
  84692. declare module BABYLON.GLTF2.Exporter.Extensions {
  84693. /**
  84694. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84695. */
  84696. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84697. /** The name of this extension. */
  84698. readonly name: string;
  84699. /** Defines whether this extension is enabled. */
  84700. enabled: boolean;
  84701. /** Defines whether this extension is required */
  84702. required: boolean;
  84703. /** Reference to the glTF exporter */
  84704. private _exporter;
  84705. private _lights;
  84706. /** @hidden */
  84707. constructor(exporter: _Exporter);
  84708. /** @hidden */
  84709. dispose(): void;
  84710. /** @hidden */
  84711. get wasUsed(): boolean;
  84712. /** @hidden */
  84713. onExporting(): void;
  84714. /**
  84715. * Define this method to modify the default behavior when exporting a node
  84716. * @param context The context when exporting the node
  84717. * @param node glTF node
  84718. * @param babylonNode BabylonJS node
  84719. * @param nodeMap Node mapping of unique id to glTF node index
  84720. * @returns nullable INode promise
  84721. */
  84722. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84723. [key: number]: number;
  84724. }): Promise<Nullable<INode>>;
  84725. }
  84726. }
  84727. declare module BABYLON.GLTF2.Exporter.Extensions {
  84728. /**
  84729. * @hidden
  84730. */
  84731. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84732. /** Name of this extension */
  84733. readonly name: string;
  84734. /** Defines whether this extension is enabled */
  84735. enabled: boolean;
  84736. /** Defines whether this extension is required */
  84737. required: boolean;
  84738. /** Reference to the glTF exporter */
  84739. private _textureInfos;
  84740. private _exportedTextures;
  84741. private _wasUsed;
  84742. constructor(exporter: _Exporter);
  84743. dispose(): void;
  84744. /** @hidden */
  84745. get wasUsed(): boolean;
  84746. private _getTextureIndex;
  84747. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84748. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84749. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84750. }
  84751. }
  84752. declare module BABYLON.GLTF2.Exporter.Extensions {
  84753. /**
  84754. * @hidden
  84755. */
  84756. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84757. /** Name of this extension */
  84758. readonly name: string;
  84759. /** Defines whether this extension is enabled */
  84760. enabled: boolean;
  84761. /** Defines whether this extension is required */
  84762. required: boolean;
  84763. private _wasUsed;
  84764. constructor(exporter: _Exporter);
  84765. /** @hidden */
  84766. get wasUsed(): boolean;
  84767. dispose(): void;
  84768. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84769. }
  84770. }
  84771. declare module BABYLON {
  84772. /**
  84773. * Class for generating STL data from a Babylon scene.
  84774. */
  84775. export class STLExport {
  84776. /**
  84777. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84778. * @param meshes list defines the mesh to serialize
  84779. * @param download triggers the automatic download of the file.
  84780. * @param fileName changes the downloads fileName.
  84781. * @param binary changes the STL to a binary type.
  84782. * @param isLittleEndian toggle for binary type exporter.
  84783. * @returns the STL as UTF8 string
  84784. */
  84785. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84786. }
  84787. }
  84788. declare module "babylonjs-gltf2interface" {
  84789. export = BABYLON.GLTF2;
  84790. }
  84791. /**
  84792. * Module for glTF 2.0 Interface
  84793. */
  84794. declare module BABYLON.GLTF2 {
  84795. /**
  84796. * The datatype of the components in the attribute
  84797. */
  84798. const enum AccessorComponentType {
  84799. /**
  84800. * Byte
  84801. */
  84802. BYTE = 5120,
  84803. /**
  84804. * Unsigned Byte
  84805. */
  84806. UNSIGNED_BYTE = 5121,
  84807. /**
  84808. * Short
  84809. */
  84810. SHORT = 5122,
  84811. /**
  84812. * Unsigned Short
  84813. */
  84814. UNSIGNED_SHORT = 5123,
  84815. /**
  84816. * Unsigned Int
  84817. */
  84818. UNSIGNED_INT = 5125,
  84819. /**
  84820. * Float
  84821. */
  84822. FLOAT = 5126,
  84823. }
  84824. /**
  84825. * Specifies if the attirbute is a scalar, vector, or matrix
  84826. */
  84827. const enum AccessorType {
  84828. /**
  84829. * Scalar
  84830. */
  84831. SCALAR = "SCALAR",
  84832. /**
  84833. * Vector2
  84834. */
  84835. VEC2 = "VEC2",
  84836. /**
  84837. * Vector3
  84838. */
  84839. VEC3 = "VEC3",
  84840. /**
  84841. * Vector4
  84842. */
  84843. VEC4 = "VEC4",
  84844. /**
  84845. * Matrix2x2
  84846. */
  84847. MAT2 = "MAT2",
  84848. /**
  84849. * Matrix3x3
  84850. */
  84851. MAT3 = "MAT3",
  84852. /**
  84853. * Matrix4x4
  84854. */
  84855. MAT4 = "MAT4",
  84856. }
  84857. /**
  84858. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84859. */
  84860. const enum AnimationChannelTargetPath {
  84861. /**
  84862. * Translation
  84863. */
  84864. TRANSLATION = "translation",
  84865. /**
  84866. * Rotation
  84867. */
  84868. ROTATION = "rotation",
  84869. /**
  84870. * Scale
  84871. */
  84872. SCALE = "scale",
  84873. /**
  84874. * Weights
  84875. */
  84876. WEIGHTS = "weights",
  84877. }
  84878. /**
  84879. * Interpolation algorithm
  84880. */
  84881. const enum AnimationSamplerInterpolation {
  84882. /**
  84883. * The animated values are linearly interpolated between keyframes
  84884. */
  84885. LINEAR = "LINEAR",
  84886. /**
  84887. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84888. */
  84889. STEP = "STEP",
  84890. /**
  84891. * The animation's interpolation is computed using a cubic spline with specified tangents
  84892. */
  84893. CUBICSPLINE = "CUBICSPLINE",
  84894. }
  84895. /**
  84896. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84897. */
  84898. const enum CameraType {
  84899. /**
  84900. * A perspective camera containing properties to create a perspective projection matrix
  84901. */
  84902. PERSPECTIVE = "perspective",
  84903. /**
  84904. * An orthographic camera containing properties to create an orthographic projection matrix
  84905. */
  84906. ORTHOGRAPHIC = "orthographic",
  84907. }
  84908. /**
  84909. * The mime-type of the image
  84910. */
  84911. const enum ImageMimeType {
  84912. /**
  84913. * JPEG Mime-type
  84914. */
  84915. JPEG = "image/jpeg",
  84916. /**
  84917. * PNG Mime-type
  84918. */
  84919. PNG = "image/png",
  84920. }
  84921. /**
  84922. * The alpha rendering mode of the material
  84923. */
  84924. const enum MaterialAlphaMode {
  84925. /**
  84926. * The alpha value is ignored and the rendered output is fully opaque
  84927. */
  84928. OPAQUE = "OPAQUE",
  84929. /**
  84930. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84931. */
  84932. MASK = "MASK",
  84933. /**
  84934. * 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)
  84935. */
  84936. BLEND = "BLEND",
  84937. }
  84938. /**
  84939. * The type of the primitives to render
  84940. */
  84941. const enum MeshPrimitiveMode {
  84942. /**
  84943. * Points
  84944. */
  84945. POINTS = 0,
  84946. /**
  84947. * Lines
  84948. */
  84949. LINES = 1,
  84950. /**
  84951. * Line Loop
  84952. */
  84953. LINE_LOOP = 2,
  84954. /**
  84955. * Line Strip
  84956. */
  84957. LINE_STRIP = 3,
  84958. /**
  84959. * Triangles
  84960. */
  84961. TRIANGLES = 4,
  84962. /**
  84963. * Triangle Strip
  84964. */
  84965. TRIANGLE_STRIP = 5,
  84966. /**
  84967. * Triangle Fan
  84968. */
  84969. TRIANGLE_FAN = 6,
  84970. }
  84971. /**
  84972. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84973. */
  84974. const enum TextureMagFilter {
  84975. /**
  84976. * Nearest
  84977. */
  84978. NEAREST = 9728,
  84979. /**
  84980. * Linear
  84981. */
  84982. LINEAR = 9729,
  84983. }
  84984. /**
  84985. * Minification filter. All valid values correspond to WebGL enums
  84986. */
  84987. const enum TextureMinFilter {
  84988. /**
  84989. * Nearest
  84990. */
  84991. NEAREST = 9728,
  84992. /**
  84993. * Linear
  84994. */
  84995. LINEAR = 9729,
  84996. /**
  84997. * Nearest Mip-Map Nearest
  84998. */
  84999. NEAREST_MIPMAP_NEAREST = 9984,
  85000. /**
  85001. * Linear Mipmap Nearest
  85002. */
  85003. LINEAR_MIPMAP_NEAREST = 9985,
  85004. /**
  85005. * Nearest Mipmap Linear
  85006. */
  85007. NEAREST_MIPMAP_LINEAR = 9986,
  85008. /**
  85009. * Linear Mipmap Linear
  85010. */
  85011. LINEAR_MIPMAP_LINEAR = 9987,
  85012. }
  85013. /**
  85014. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85015. */
  85016. const enum TextureWrapMode {
  85017. /**
  85018. * Clamp to Edge
  85019. */
  85020. CLAMP_TO_EDGE = 33071,
  85021. /**
  85022. * Mirrored Repeat
  85023. */
  85024. MIRRORED_REPEAT = 33648,
  85025. /**
  85026. * Repeat
  85027. */
  85028. REPEAT = 10497,
  85029. }
  85030. /**
  85031. * glTF Property
  85032. */
  85033. interface IProperty {
  85034. /**
  85035. * Dictionary object with extension-specific objects
  85036. */
  85037. extensions?: {
  85038. [key: string]: any;
  85039. };
  85040. /**
  85041. * Application-Specific data
  85042. */
  85043. extras?: any;
  85044. }
  85045. /**
  85046. * glTF Child of Root Property
  85047. */
  85048. interface IChildRootProperty extends IProperty {
  85049. /**
  85050. * The user-defined name of this object
  85051. */
  85052. name?: string;
  85053. }
  85054. /**
  85055. * Indices of those attributes that deviate from their initialization value
  85056. */
  85057. interface IAccessorSparseIndices extends IProperty {
  85058. /**
  85059. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85060. */
  85061. bufferView: number;
  85062. /**
  85063. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85064. */
  85065. byteOffset?: number;
  85066. /**
  85067. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85068. */
  85069. componentType: AccessorComponentType;
  85070. }
  85071. /**
  85072. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85073. */
  85074. interface IAccessorSparseValues extends IProperty {
  85075. /**
  85076. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85077. */
  85078. bufferView: number;
  85079. /**
  85080. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85081. */
  85082. byteOffset?: number;
  85083. }
  85084. /**
  85085. * Sparse storage of attributes that deviate from their initialization value
  85086. */
  85087. interface IAccessorSparse extends IProperty {
  85088. /**
  85089. * The number of attributes encoded in this sparse accessor
  85090. */
  85091. count: number;
  85092. /**
  85093. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85094. */
  85095. indices: IAccessorSparseIndices;
  85096. /**
  85097. * 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
  85098. */
  85099. values: IAccessorSparseValues;
  85100. }
  85101. /**
  85102. * 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
  85103. */
  85104. interface IAccessor extends IChildRootProperty {
  85105. /**
  85106. * The index of the bufferview
  85107. */
  85108. bufferView?: number;
  85109. /**
  85110. * The offset relative to the start of the bufferView in bytes
  85111. */
  85112. byteOffset?: number;
  85113. /**
  85114. * The datatype of components in the attribute
  85115. */
  85116. componentType: AccessorComponentType;
  85117. /**
  85118. * Specifies whether integer data values should be normalized
  85119. */
  85120. normalized?: boolean;
  85121. /**
  85122. * The number of attributes referenced by this accessor
  85123. */
  85124. count: number;
  85125. /**
  85126. * Specifies if the attribute is a scalar, vector, or matrix
  85127. */
  85128. type: AccessorType;
  85129. /**
  85130. * Maximum value of each component in this attribute
  85131. */
  85132. max?: number[];
  85133. /**
  85134. * Minimum value of each component in this attribute
  85135. */
  85136. min?: number[];
  85137. /**
  85138. * Sparse storage of attributes that deviate from their initialization value
  85139. */
  85140. sparse?: IAccessorSparse;
  85141. }
  85142. /**
  85143. * Targets an animation's sampler at a node's property
  85144. */
  85145. interface IAnimationChannel extends IProperty {
  85146. /**
  85147. * The index of a sampler in this animation used to compute the value for the target
  85148. */
  85149. sampler: number;
  85150. /**
  85151. * The index of the node and TRS property to target
  85152. */
  85153. target: IAnimationChannelTarget;
  85154. }
  85155. /**
  85156. * The index of the node and TRS property that an animation channel targets
  85157. */
  85158. interface IAnimationChannelTarget extends IProperty {
  85159. /**
  85160. * The index of the node to target
  85161. */
  85162. node: number;
  85163. /**
  85164. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85165. */
  85166. path: AnimationChannelTargetPath;
  85167. }
  85168. /**
  85169. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85170. */
  85171. interface IAnimationSampler extends IProperty {
  85172. /**
  85173. * The index of an accessor containing keyframe input values, e.g., time
  85174. */
  85175. input: number;
  85176. /**
  85177. * Interpolation algorithm
  85178. */
  85179. interpolation?: AnimationSamplerInterpolation;
  85180. /**
  85181. * The index of an accessor, containing keyframe output values
  85182. */
  85183. output: number;
  85184. }
  85185. /**
  85186. * A keyframe animation
  85187. */
  85188. interface IAnimation extends IChildRootProperty {
  85189. /**
  85190. * An array of channels, each of which targets an animation's sampler at a node's property
  85191. */
  85192. channels: IAnimationChannel[];
  85193. /**
  85194. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85195. */
  85196. samplers: IAnimationSampler[];
  85197. }
  85198. /**
  85199. * Metadata about the glTF asset
  85200. */
  85201. interface IAsset extends IChildRootProperty {
  85202. /**
  85203. * A copyright message suitable for display to credit the content creator
  85204. */
  85205. copyright?: string;
  85206. /**
  85207. * Tool that generated this glTF model. Useful for debugging
  85208. */
  85209. generator?: string;
  85210. /**
  85211. * The glTF version that this asset targets
  85212. */
  85213. version: string;
  85214. /**
  85215. * The minimum glTF version that this asset targets
  85216. */
  85217. minVersion?: string;
  85218. }
  85219. /**
  85220. * A buffer points to binary geometry, animation, or skins
  85221. */
  85222. interface IBuffer extends IChildRootProperty {
  85223. /**
  85224. * 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
  85225. */
  85226. uri?: string;
  85227. /**
  85228. * The length of the buffer in bytes
  85229. */
  85230. byteLength: number;
  85231. }
  85232. /**
  85233. * A view into a buffer generally representing a subset of the buffer
  85234. */
  85235. interface IBufferView extends IChildRootProperty {
  85236. /**
  85237. * The index of the buffer
  85238. */
  85239. buffer: number;
  85240. /**
  85241. * The offset into the buffer in bytes
  85242. */
  85243. byteOffset?: number;
  85244. /**
  85245. * The lenth of the bufferView in bytes
  85246. */
  85247. byteLength: number;
  85248. /**
  85249. * The stride, in bytes
  85250. */
  85251. byteStride?: number;
  85252. }
  85253. /**
  85254. * An orthographic camera containing properties to create an orthographic projection matrix
  85255. */
  85256. interface ICameraOrthographic extends IProperty {
  85257. /**
  85258. * The floating-point horizontal magnification of the view. Must not be zero
  85259. */
  85260. xmag: number;
  85261. /**
  85262. * The floating-point vertical magnification of the view. Must not be zero
  85263. */
  85264. ymag: number;
  85265. /**
  85266. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85267. */
  85268. zfar: number;
  85269. /**
  85270. * The floating-point distance to the near clipping plane
  85271. */
  85272. znear: number;
  85273. }
  85274. /**
  85275. * A perspective camera containing properties to create a perspective projection matrix
  85276. */
  85277. interface ICameraPerspective extends IProperty {
  85278. /**
  85279. * The floating-point aspect ratio of the field of view
  85280. */
  85281. aspectRatio?: number;
  85282. /**
  85283. * The floating-point vertical field of view in radians
  85284. */
  85285. yfov: number;
  85286. /**
  85287. * The floating-point distance to the far clipping plane
  85288. */
  85289. zfar?: number;
  85290. /**
  85291. * The floating-point distance to the near clipping plane
  85292. */
  85293. znear: number;
  85294. }
  85295. /**
  85296. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85297. */
  85298. interface ICamera extends IChildRootProperty {
  85299. /**
  85300. * An orthographic camera containing properties to create an orthographic projection matrix
  85301. */
  85302. orthographic?: ICameraOrthographic;
  85303. /**
  85304. * A perspective camera containing properties to create a perspective projection matrix
  85305. */
  85306. perspective?: ICameraPerspective;
  85307. /**
  85308. * Specifies if the camera uses a perspective or orthographic projection
  85309. */
  85310. type: CameraType;
  85311. }
  85312. /**
  85313. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85314. */
  85315. interface IImage extends IChildRootProperty {
  85316. /**
  85317. * 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
  85318. */
  85319. uri?: string;
  85320. /**
  85321. * The image's MIME type
  85322. */
  85323. mimeType?: ImageMimeType;
  85324. /**
  85325. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85326. */
  85327. bufferView?: number;
  85328. }
  85329. /**
  85330. * Material Normal Texture Info
  85331. */
  85332. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85333. /**
  85334. * The scalar multiplier applied to each normal vector of the normal texture
  85335. */
  85336. scale?: number;
  85337. }
  85338. /**
  85339. * Material Occlusion Texture Info
  85340. */
  85341. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85342. /**
  85343. * A scalar multiplier controlling the amount of occlusion applied
  85344. */
  85345. strength?: number;
  85346. }
  85347. /**
  85348. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85349. */
  85350. interface IMaterialPbrMetallicRoughness {
  85351. /**
  85352. * The material's base color factor
  85353. */
  85354. baseColorFactor?: number[];
  85355. /**
  85356. * The base color texture
  85357. */
  85358. baseColorTexture?: ITextureInfo;
  85359. /**
  85360. * The metalness of the material
  85361. */
  85362. metallicFactor?: number;
  85363. /**
  85364. * The roughness of the material
  85365. */
  85366. roughnessFactor?: number;
  85367. /**
  85368. * The metallic-roughness texture
  85369. */
  85370. metallicRoughnessTexture?: ITextureInfo;
  85371. }
  85372. /**
  85373. * The material appearance of a primitive
  85374. */
  85375. interface IMaterial extends IChildRootProperty {
  85376. /**
  85377. * 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
  85378. */
  85379. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85380. /**
  85381. * The normal map texture
  85382. */
  85383. normalTexture?: IMaterialNormalTextureInfo;
  85384. /**
  85385. * The occlusion map texture
  85386. */
  85387. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85388. /**
  85389. * The emissive map texture
  85390. */
  85391. emissiveTexture?: ITextureInfo;
  85392. /**
  85393. * 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
  85394. */
  85395. emissiveFactor?: number[];
  85396. /**
  85397. * The alpha rendering mode of the material
  85398. */
  85399. alphaMode?: MaterialAlphaMode;
  85400. /**
  85401. * The alpha cutoff value of the material
  85402. */
  85403. alphaCutoff?: number;
  85404. /**
  85405. * Specifies whether the material is double sided
  85406. */
  85407. doubleSided?: boolean;
  85408. }
  85409. /**
  85410. * Geometry to be rendered with the given material
  85411. */
  85412. interface IMeshPrimitive extends IProperty {
  85413. /**
  85414. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85415. */
  85416. attributes: {
  85417. [name: string]: number;
  85418. };
  85419. /**
  85420. * The index of the accessor that contains the indices
  85421. */
  85422. indices?: number;
  85423. /**
  85424. * The index of the material to apply to this primitive when rendering
  85425. */
  85426. material?: number;
  85427. /**
  85428. * The type of primitives to render. All valid values correspond to WebGL enums
  85429. */
  85430. mode?: MeshPrimitiveMode;
  85431. /**
  85432. * 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
  85433. */
  85434. targets?: {
  85435. [name: string]: number;
  85436. }[];
  85437. }
  85438. /**
  85439. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85440. */
  85441. interface IMesh extends IChildRootProperty {
  85442. /**
  85443. * An array of primitives, each defining geometry to be rendered with a material
  85444. */
  85445. primitives: IMeshPrimitive[];
  85446. /**
  85447. * Array of weights to be applied to the Morph Targets
  85448. */
  85449. weights?: number[];
  85450. }
  85451. /**
  85452. * A node in the node hierarchy
  85453. */
  85454. interface INode extends IChildRootProperty {
  85455. /**
  85456. * The index of the camera referenced by this node
  85457. */
  85458. camera?: number;
  85459. /**
  85460. * The indices of this node's children
  85461. */
  85462. children?: number[];
  85463. /**
  85464. * The index of the skin referenced by this node
  85465. */
  85466. skin?: number;
  85467. /**
  85468. * A floating-point 4x4 transformation matrix stored in column-major order
  85469. */
  85470. matrix?: number[];
  85471. /**
  85472. * The index of the mesh in this node
  85473. */
  85474. mesh?: number;
  85475. /**
  85476. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85477. */
  85478. rotation?: number[];
  85479. /**
  85480. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85481. */
  85482. scale?: number[];
  85483. /**
  85484. * The node's translation along the x, y, and z axes
  85485. */
  85486. translation?: number[];
  85487. /**
  85488. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85489. */
  85490. weights?: number[];
  85491. }
  85492. /**
  85493. * Texture sampler properties for filtering and wrapping modes
  85494. */
  85495. interface ISampler extends IChildRootProperty {
  85496. /**
  85497. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85498. */
  85499. magFilter?: TextureMagFilter;
  85500. /**
  85501. * Minification filter. All valid values correspond to WebGL enums
  85502. */
  85503. minFilter?: TextureMinFilter;
  85504. /**
  85505. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85506. */
  85507. wrapS?: TextureWrapMode;
  85508. /**
  85509. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85510. */
  85511. wrapT?: TextureWrapMode;
  85512. }
  85513. /**
  85514. * The root nodes of a scene
  85515. */
  85516. interface IScene extends IChildRootProperty {
  85517. /**
  85518. * The indices of each root node
  85519. */
  85520. nodes: number[];
  85521. }
  85522. /**
  85523. * Joints and matrices defining a skin
  85524. */
  85525. interface ISkin extends IChildRootProperty {
  85526. /**
  85527. * 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
  85528. */
  85529. inverseBindMatrices?: number;
  85530. /**
  85531. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85532. */
  85533. skeleton?: number;
  85534. /**
  85535. * 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)
  85536. */
  85537. joints: number[];
  85538. }
  85539. /**
  85540. * A texture and its sampler
  85541. */
  85542. interface ITexture extends IChildRootProperty {
  85543. /**
  85544. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85545. */
  85546. sampler?: number;
  85547. /**
  85548. * The index of the image used by this texture
  85549. */
  85550. source: number;
  85551. }
  85552. /**
  85553. * Reference to a texture
  85554. */
  85555. interface ITextureInfo extends IProperty {
  85556. /**
  85557. * The index of the texture
  85558. */
  85559. index: number;
  85560. /**
  85561. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85562. */
  85563. texCoord?: number;
  85564. }
  85565. /**
  85566. * The root object for a glTF asset
  85567. */
  85568. interface IGLTF extends IProperty {
  85569. /**
  85570. * An array of accessors. An accessor is a typed view into a bufferView
  85571. */
  85572. accessors?: IAccessor[];
  85573. /**
  85574. * An array of keyframe animations
  85575. */
  85576. animations?: IAnimation[];
  85577. /**
  85578. * Metadata about the glTF asset
  85579. */
  85580. asset: IAsset;
  85581. /**
  85582. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85583. */
  85584. buffers?: IBuffer[];
  85585. /**
  85586. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85587. */
  85588. bufferViews?: IBufferView[];
  85589. /**
  85590. * An array of cameras
  85591. */
  85592. cameras?: ICamera[];
  85593. /**
  85594. * Names of glTF extensions used somewhere in this asset
  85595. */
  85596. extensionsUsed?: string[];
  85597. /**
  85598. * Names of glTF extensions required to properly load this asset
  85599. */
  85600. extensionsRequired?: string[];
  85601. /**
  85602. * An array of images. An image defines data used to create a texture
  85603. */
  85604. images?: IImage[];
  85605. /**
  85606. * An array of materials. A material defines the appearance of a primitive
  85607. */
  85608. materials?: IMaterial[];
  85609. /**
  85610. * An array of meshes. A mesh is a set of primitives to be rendered
  85611. */
  85612. meshes?: IMesh[];
  85613. /**
  85614. * An array of nodes
  85615. */
  85616. nodes?: INode[];
  85617. /**
  85618. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85619. */
  85620. samplers?: ISampler[];
  85621. /**
  85622. * The index of the default scene
  85623. */
  85624. scene?: number;
  85625. /**
  85626. * An array of scenes
  85627. */
  85628. scenes?: IScene[];
  85629. /**
  85630. * An array of skins. A skin is defined by joints and matrices
  85631. */
  85632. skins?: ISkin[];
  85633. /**
  85634. * An array of textures
  85635. */
  85636. textures?: ITexture[];
  85637. }
  85638. /**
  85639. * The glTF validation results
  85640. * @ignore
  85641. */
  85642. interface IGLTFValidationResults {
  85643. info: {
  85644. generator: string;
  85645. hasAnimations: boolean;
  85646. hasDefaultScene: boolean;
  85647. hasMaterials: boolean;
  85648. hasMorphTargets: boolean;
  85649. hasSkins: boolean;
  85650. hasTextures: boolean;
  85651. maxAttributesUsed: number;
  85652. primitivesCount: number
  85653. };
  85654. issues: {
  85655. messages: Array<string>;
  85656. numErrors: number;
  85657. numHints: number;
  85658. numInfos: number;
  85659. numWarnings: number;
  85660. truncated: boolean
  85661. };
  85662. mimeType: string;
  85663. uri: string;
  85664. validatedAt: string;
  85665. validatorVersion: string;
  85666. }
  85667. /**
  85668. * The glTF validation options
  85669. */
  85670. interface IGLTFValidationOptions {
  85671. /** Uri to use */
  85672. uri?: string;
  85673. /** Function used to load external resources */
  85674. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85675. /** Boolean indicating that we need to validate accessor data */
  85676. validateAccessorData?: boolean;
  85677. /** max number of issues allowed */
  85678. maxIssues?: number;
  85679. /** Ignored issues */
  85680. ignoredIssues?: Array<string>;
  85681. /** Value to override severy settings */
  85682. severityOverrides?: Object;
  85683. }
  85684. /**
  85685. * The glTF validator object
  85686. * @ignore
  85687. */
  85688. interface IGLTFValidator {
  85689. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85690. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85691. }
  85692. /**
  85693. * Interfaces from the EXT_lights_image_based extension
  85694. */
  85695. /** @hidden */
  85696. interface IEXTLightsImageBased_LightReferenceImageBased {
  85697. light: number;
  85698. }
  85699. /** @hidden */
  85700. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85701. intensity: number;
  85702. rotation: number[];
  85703. specularImageSize: number;
  85704. specularImages: number[][];
  85705. irradianceCoefficients: number[][];
  85706. }
  85707. /** @hidden */
  85708. interface IEXTLightsImageBased {
  85709. lights: IEXTLightsImageBased_LightImageBased[];
  85710. }
  85711. /**
  85712. * Interfaces from the EXT_mesh_gpu_instancing extension
  85713. * !!! Experimental Extension Subject to Changes !!!
  85714. */
  85715. /** @hidden */
  85716. interface IEXTMeshGpuInstancing {
  85717. mesh?: number;
  85718. attributes: { [name: string]: number };
  85719. }
  85720. /**
  85721. * Interfaces from the KHR_draco_mesh_compression extension
  85722. */
  85723. /** @hidden */
  85724. interface IKHRDracoMeshCompression {
  85725. bufferView: number;
  85726. attributes: { [name: string]: number };
  85727. }
  85728. /**
  85729. * Interfaces from the KHR_lights_punctual extension
  85730. */
  85731. /** @hidden */
  85732. const enum IKHRLightsPunctual_LightType {
  85733. DIRECTIONAL = "directional",
  85734. POINT = "point",
  85735. SPOT = "spot"
  85736. }
  85737. /** @hidden */
  85738. interface IKHRLightsPunctual_LightReference {
  85739. light: number;
  85740. }
  85741. /** @hidden */
  85742. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85743. type: IKHRLightsPunctual_LightType;
  85744. color?: number[];
  85745. intensity?: number;
  85746. range?: number;
  85747. spot?: {
  85748. innerConeAngle?: number;
  85749. outerConeAngle?: number;
  85750. };
  85751. }
  85752. /** @hidden */
  85753. interface IKHRLightsPunctual {
  85754. lights: IKHRLightsPunctual_Light[];
  85755. }
  85756. /**
  85757. * Interfaces from the KHR_materials_clearcoat extension
  85758. * !!! Experimental Extension Subject to Changes !!!
  85759. */
  85760. /** @hidden */
  85761. interface IKHRMaterialsClearcoat {
  85762. clearcoatFactor: number;
  85763. clearcoatTexture: ITextureInfo;
  85764. clearcoatRoughnessFactor: number;
  85765. clearcoatRoughnessTexture: ITextureInfo;
  85766. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85767. }
  85768. /**
  85769. * Interfaces from the KHR_materials_ior extension
  85770. * !!! Experimental Extension Subject to Changes !!!
  85771. */
  85772. /** @hidden */
  85773. interface IKHRMaterialsIor {
  85774. ior: number;
  85775. }
  85776. /**
  85777. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85778. */
  85779. /** @hidden */
  85780. interface IKHRMaterialsPbrSpecularGlossiness {
  85781. diffuseFactor: number[];
  85782. diffuseTexture: ITextureInfo;
  85783. specularFactor: number[];
  85784. glossinessFactor: number;
  85785. specularGlossinessTexture: ITextureInfo;
  85786. }
  85787. /**
  85788. * Interfaces from the KHR_materials_sheen extension
  85789. * !!! Experimental Extension Subject to Changes !!!
  85790. */
  85791. /** @hidden */
  85792. interface IKHRMaterialsSheen {
  85793. sheenColorFactor?: number[];
  85794. sheenTexture?: ITextureInfo;
  85795. sheenRoughnessFactor?: number;
  85796. }
  85797. /**
  85798. * Interfaces from the KHR_materials_specular extension
  85799. * !!! Experimental Extension Subject to Changes !!!
  85800. */
  85801. /** @hidden */
  85802. interface IKHRMaterialsSpecular {
  85803. specularFactor: number;
  85804. specularColorFactor: number[];
  85805. specularTexture: ITextureInfo;
  85806. }
  85807. /**
  85808. * Interfaces from the KHR_materials_transmission extension
  85809. * !!! Experimental Extension Subject to Changes !!!
  85810. */
  85811. /** @hidden */
  85812. interface IKHRMaterialsTransmission {
  85813. transmissionFactor?: number;
  85814. transmissionTexture?: ITextureInfo;
  85815. }
  85816. /**
  85817. * Interfaces from the KHR_materials_variants extension
  85818. * !!! Experimental Extension Subject to Changes !!!
  85819. */
  85820. /** @hidden */
  85821. interface IKHRMaterialVariants_Mapping extends IProperty {
  85822. mappings: Array<{
  85823. variants: number[];
  85824. material: number;
  85825. }>;
  85826. }
  85827. /** @hidden */
  85828. interface IKHRMaterialVariants_Variant extends IProperty {
  85829. name: string;
  85830. }
  85831. /** @hidden */
  85832. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85833. variants: Array<IKHRMaterialVariants_Variant>;
  85834. }
  85835. /**
  85836. * Interfaces from the KHR_texture_basisu extension
  85837. * !!! Experimental Extension Subject to Changes !!!
  85838. */
  85839. /** @hidden */
  85840. interface IKHRTextureBasisU {
  85841. source: number;
  85842. }
  85843. /**
  85844. * Interfaces from the EXT_texture_webp extension
  85845. */
  85846. /** @hidden */
  85847. interface IEXTTextureWebP {
  85848. source: number;
  85849. }
  85850. /**
  85851. * Interfaces from the KHR_texture_transform extension
  85852. */
  85853. /** @hidden */
  85854. interface IKHRTextureTransform {
  85855. offset?: number[];
  85856. rotation?: number;
  85857. scale?: number[];
  85858. texCoord?: number;
  85859. }
  85860. /**
  85861. * Interfaces from the KHR_xmp extension
  85862. * !!! Experimental Extension Subject to Changes !!!
  85863. */
  85864. /** @hidden */
  85865. interface IKHRXmp_Data {
  85866. [key: string]: unknown;
  85867. }
  85868. /** @hidden */
  85869. interface IKHRXmp_Gltf {
  85870. packets: IKHRXmp_Data[];
  85871. }
  85872. /** @hidden */
  85873. interface IKHRXmp_Node {
  85874. packet: number;
  85875. }
  85876. /**
  85877. * Interfaces from the MSFT_audio_emitter extension
  85878. */
  85879. /** @hidden */
  85880. interface IMSFTAudioEmitter_ClipReference {
  85881. clip: number;
  85882. weight?: number;
  85883. }
  85884. /** @hidden */
  85885. interface IMSFTAudioEmitter_EmittersReference {
  85886. emitters: number[];
  85887. }
  85888. /** @hidden */
  85889. const enum IMSFTAudioEmitter_DistanceModel {
  85890. linear = "linear",
  85891. inverse = "inverse",
  85892. exponential = "exponential",
  85893. }
  85894. /** @hidden */
  85895. interface IMSFTAudioEmitter_Emitter {
  85896. name?: string;
  85897. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85898. refDistance?: number;
  85899. maxDistance?: number;
  85900. rolloffFactor?: number;
  85901. innerAngle?: number;
  85902. outerAngle?: number;
  85903. loop?: boolean;
  85904. volume?: number;
  85905. clips: IMSFTAudioEmitter_ClipReference[];
  85906. }
  85907. /** @hidden */
  85908. const enum IMSFTAudioEmitter_AudioMimeType {
  85909. WAV = "audio/wav",
  85910. }
  85911. /** @hidden */
  85912. interface IMSFTAudioEmitter_Clip extends IProperty {
  85913. uri?: string;
  85914. bufferView?: number;
  85915. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85916. }
  85917. /** @hidden */
  85918. const enum IMSFTAudioEmitter_AnimationEventAction {
  85919. play = "play",
  85920. pause = "pause",
  85921. stop = "stop",
  85922. }
  85923. /** @hidden */
  85924. interface IMSFTAudioEmitter_AnimationEvent {
  85925. action: IMSFTAudioEmitter_AnimationEventAction;
  85926. emitter: number;
  85927. time: number;
  85928. startOffset?: number;
  85929. }
  85930. /**
  85931. * Interfaces from the MSFT_lod extension
  85932. */
  85933. /** @hidden */
  85934. interface IMSFTLOD {
  85935. ids: number[];
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /** @hidden */
  85940. export var cellPixelShader: {
  85941. name: string;
  85942. shader: string;
  85943. };
  85944. }
  85945. declare module BABYLON {
  85946. /** @hidden */
  85947. export var cellVertexShader: {
  85948. name: string;
  85949. shader: string;
  85950. };
  85951. }
  85952. declare module BABYLON {
  85953. export class CellMaterial extends BABYLON.PushMaterial {
  85954. private _diffuseTexture;
  85955. diffuseTexture: BABYLON.BaseTexture;
  85956. diffuseColor: BABYLON.Color3;
  85957. _computeHighLevel: boolean;
  85958. computeHighLevel: boolean;
  85959. private _disableLighting;
  85960. disableLighting: boolean;
  85961. private _maxSimultaneousLights;
  85962. maxSimultaneousLights: number;
  85963. constructor(name: string, scene: BABYLON.Scene);
  85964. needAlphaBlending(): boolean;
  85965. needAlphaTesting(): boolean;
  85966. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85967. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85968. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85969. getAnimatables(): BABYLON.IAnimatable[];
  85970. getActiveTextures(): BABYLON.BaseTexture[];
  85971. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85972. dispose(forceDisposeEffect?: boolean): void;
  85973. getClassName(): string;
  85974. clone(name: string): CellMaterial;
  85975. serialize(): any;
  85976. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85977. }
  85978. }
  85979. declare module BABYLON {
  85980. export class CustomShaderStructure {
  85981. FragmentStore: string;
  85982. VertexStore: string;
  85983. constructor();
  85984. }
  85985. export class ShaderSpecialParts {
  85986. constructor();
  85987. Fragment_Begin: string;
  85988. Fragment_Definitions: string;
  85989. Fragment_MainBegin: string;
  85990. Fragment_Custom_Diffuse: string;
  85991. Fragment_Before_Lights: string;
  85992. Fragment_Before_Fog: string;
  85993. Fragment_Custom_Alpha: string;
  85994. Fragment_Before_FragColor: string;
  85995. Vertex_Begin: string;
  85996. Vertex_Definitions: string;
  85997. Vertex_MainBegin: string;
  85998. Vertex_Before_PositionUpdated: string;
  85999. Vertex_Before_NormalUpdated: string;
  86000. Vertex_After_WorldPosComputed: string;
  86001. Vertex_MainEnd: string;
  86002. }
  86003. export class CustomMaterial extends BABYLON.StandardMaterial {
  86004. static ShaderIndexer: number;
  86005. CustomParts: ShaderSpecialParts;
  86006. _isCreatedShader: boolean;
  86007. _createdShaderName: string;
  86008. _customUniform: string[];
  86009. _newUniforms: string[];
  86010. _newUniformInstances: {
  86011. [name: string]: any;
  86012. };
  86013. _newSamplerInstances: {
  86014. [name: string]: BABYLON.Texture;
  86015. };
  86016. _customAttributes: string[];
  86017. FragmentShader: string;
  86018. VertexShader: string;
  86019. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86020. ReviewUniform(name: string, arr: string[]): string[];
  86021. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86022. constructor(name: string, scene: BABYLON.Scene);
  86023. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86024. AddAttribute(name: string): CustomMaterial;
  86025. Fragment_Begin(shaderPart: string): CustomMaterial;
  86026. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86027. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86028. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86029. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86030. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86031. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86032. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86033. Vertex_Begin(shaderPart: string): CustomMaterial;
  86034. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86035. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86036. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86037. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86038. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86039. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86040. }
  86041. }
  86042. declare module BABYLON {
  86043. export class ShaderAlebdoParts {
  86044. constructor();
  86045. Fragment_Begin: string;
  86046. Fragment_Definitions: string;
  86047. Fragment_MainBegin: string;
  86048. Fragment_Custom_Albedo: string;
  86049. Fragment_Before_Lights: string;
  86050. Fragment_Custom_MetallicRoughness: string;
  86051. Fragment_Custom_MicroSurface: string;
  86052. Fragment_Before_Fog: string;
  86053. Fragment_Custom_Alpha: string;
  86054. Fragment_Before_FragColor: string;
  86055. Vertex_Begin: string;
  86056. Vertex_Definitions: string;
  86057. Vertex_MainBegin: string;
  86058. Vertex_Before_PositionUpdated: string;
  86059. Vertex_Before_NormalUpdated: string;
  86060. Vertex_After_WorldPosComputed: string;
  86061. Vertex_MainEnd: string;
  86062. }
  86063. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86064. static ShaderIndexer: number;
  86065. CustomParts: ShaderAlebdoParts;
  86066. _isCreatedShader: boolean;
  86067. _createdShaderName: string;
  86068. _customUniform: string[];
  86069. _newUniforms: string[];
  86070. _newUniformInstances: {
  86071. [name: string]: any;
  86072. };
  86073. _newSamplerInstances: {
  86074. [name: string]: BABYLON.Texture;
  86075. };
  86076. _customAttributes: string[];
  86077. FragmentShader: string;
  86078. VertexShader: string;
  86079. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86080. ReviewUniform(name: string, arr: string[]): string[];
  86081. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86082. constructor(name: string, scene: BABYLON.Scene);
  86083. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86084. AddAttribute(name: string): PBRCustomMaterial;
  86085. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86086. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86087. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86088. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86089. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86090. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86091. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86092. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86093. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86094. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86095. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86096. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86097. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86098. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86099. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86100. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86101. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86102. }
  86103. }
  86104. declare module BABYLON {
  86105. /** @hidden */
  86106. export var firePixelShader: {
  86107. name: string;
  86108. shader: string;
  86109. };
  86110. }
  86111. declare module BABYLON {
  86112. /** @hidden */
  86113. export var fireVertexShader: {
  86114. name: string;
  86115. shader: string;
  86116. };
  86117. }
  86118. declare module BABYLON {
  86119. export class FireMaterial extends BABYLON.PushMaterial {
  86120. private _diffuseTexture;
  86121. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86122. private _distortionTexture;
  86123. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86124. private _opacityTexture;
  86125. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86126. diffuseColor: BABYLON.Color3;
  86127. speed: number;
  86128. private _scaledDiffuse;
  86129. private _lastTime;
  86130. constructor(name: string, scene: BABYLON.Scene);
  86131. needAlphaBlending(): boolean;
  86132. needAlphaTesting(): boolean;
  86133. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86134. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86135. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86136. getAnimatables(): BABYLON.IAnimatable[];
  86137. getActiveTextures(): BABYLON.BaseTexture[];
  86138. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86139. getClassName(): string;
  86140. dispose(forceDisposeEffect?: boolean): void;
  86141. clone(name: string): FireMaterial;
  86142. serialize(): any;
  86143. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86144. }
  86145. }
  86146. declare module BABYLON {
  86147. /** @hidden */
  86148. export var furPixelShader: {
  86149. name: string;
  86150. shader: string;
  86151. };
  86152. }
  86153. declare module BABYLON {
  86154. /** @hidden */
  86155. export var furVertexShader: {
  86156. name: string;
  86157. shader: string;
  86158. };
  86159. }
  86160. declare module BABYLON {
  86161. export class FurMaterial extends BABYLON.PushMaterial {
  86162. private _diffuseTexture;
  86163. diffuseTexture: BABYLON.BaseTexture;
  86164. private _heightTexture;
  86165. heightTexture: BABYLON.BaseTexture;
  86166. diffuseColor: BABYLON.Color3;
  86167. furLength: number;
  86168. furAngle: number;
  86169. furColor: BABYLON.Color3;
  86170. furOffset: number;
  86171. furSpacing: number;
  86172. furGravity: BABYLON.Vector3;
  86173. furSpeed: number;
  86174. furDensity: number;
  86175. furOcclusion: number;
  86176. furTexture: BABYLON.DynamicTexture;
  86177. private _disableLighting;
  86178. disableLighting: boolean;
  86179. private _maxSimultaneousLights;
  86180. maxSimultaneousLights: number;
  86181. highLevelFur: boolean;
  86182. _meshes: BABYLON.AbstractMesh[];
  86183. private _furTime;
  86184. constructor(name: string, scene: BABYLON.Scene);
  86185. get furTime(): number;
  86186. set furTime(furTime: number);
  86187. needAlphaBlending(): boolean;
  86188. needAlphaTesting(): boolean;
  86189. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86190. updateFur(): void;
  86191. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86192. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86193. getAnimatables(): BABYLON.IAnimatable[];
  86194. getActiveTextures(): BABYLON.BaseTexture[];
  86195. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86196. dispose(forceDisposeEffect?: boolean): void;
  86197. clone(name: string): FurMaterial;
  86198. serialize(): any;
  86199. getClassName(): string;
  86200. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86201. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86202. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86203. }
  86204. }
  86205. declare module BABYLON {
  86206. /** @hidden */
  86207. export var gradientPixelShader: {
  86208. name: string;
  86209. shader: string;
  86210. };
  86211. }
  86212. declare module BABYLON {
  86213. /** @hidden */
  86214. export var gradientVertexShader: {
  86215. name: string;
  86216. shader: string;
  86217. };
  86218. }
  86219. declare module BABYLON {
  86220. export class GradientMaterial extends BABYLON.PushMaterial {
  86221. private _maxSimultaneousLights;
  86222. maxSimultaneousLights: number;
  86223. topColor: BABYLON.Color3;
  86224. topColorAlpha: number;
  86225. bottomColor: BABYLON.Color3;
  86226. bottomColorAlpha: number;
  86227. offset: number;
  86228. scale: number;
  86229. smoothness: number;
  86230. private _disableLighting;
  86231. disableLighting: boolean;
  86232. constructor(name: string, scene: BABYLON.Scene);
  86233. needAlphaBlending(): boolean;
  86234. needAlphaTesting(): boolean;
  86235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86238. getAnimatables(): BABYLON.IAnimatable[];
  86239. dispose(forceDisposeEffect?: boolean): void;
  86240. clone(name: string): GradientMaterial;
  86241. serialize(): any;
  86242. getClassName(): string;
  86243. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86244. }
  86245. }
  86246. declare module BABYLON {
  86247. /** @hidden */
  86248. export var gridPixelShader: {
  86249. name: string;
  86250. shader: string;
  86251. };
  86252. }
  86253. declare module BABYLON {
  86254. /** @hidden */
  86255. export var gridVertexShader: {
  86256. name: string;
  86257. shader: string;
  86258. };
  86259. }
  86260. declare module BABYLON {
  86261. /**
  86262. * The grid materials allows you to wrap any shape with a grid.
  86263. * Colors are customizable.
  86264. */
  86265. export class GridMaterial extends BABYLON.PushMaterial {
  86266. /**
  86267. * Main color of the grid (e.g. between lines)
  86268. */
  86269. mainColor: BABYLON.Color3;
  86270. /**
  86271. * Color of the grid lines.
  86272. */
  86273. lineColor: BABYLON.Color3;
  86274. /**
  86275. * The scale of the grid compared to unit.
  86276. */
  86277. gridRatio: number;
  86278. /**
  86279. * Allows setting an offset for the grid lines.
  86280. */
  86281. gridOffset: BABYLON.Vector3;
  86282. /**
  86283. * The frequency of thicker lines.
  86284. */
  86285. majorUnitFrequency: number;
  86286. /**
  86287. * The visibility of minor units in the grid.
  86288. */
  86289. minorUnitVisibility: number;
  86290. /**
  86291. * The grid opacity outside of the lines.
  86292. */
  86293. opacity: number;
  86294. /**
  86295. * Determine RBG output is premultiplied by alpha value.
  86296. */
  86297. preMultiplyAlpha: boolean;
  86298. private _opacityTexture;
  86299. opacityTexture: BABYLON.BaseTexture;
  86300. private _gridControl;
  86301. /**
  86302. * constructor
  86303. * @param name The name given to the material in order to identify it afterwards.
  86304. * @param scene The scene the material is used in.
  86305. */
  86306. constructor(name: string, scene: BABYLON.Scene);
  86307. /**
  86308. * Returns wehter or not the grid requires alpha blending.
  86309. */
  86310. needAlphaBlending(): boolean;
  86311. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86314. /**
  86315. * Dispose the material and its associated resources.
  86316. * @param forceDisposeEffect will also dispose the used effect when true
  86317. */
  86318. dispose(forceDisposeEffect?: boolean): void;
  86319. clone(name: string): GridMaterial;
  86320. serialize(): any;
  86321. getClassName(): string;
  86322. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86323. }
  86324. }
  86325. declare module BABYLON {
  86326. /** @hidden */
  86327. export var lavaPixelShader: {
  86328. name: string;
  86329. shader: string;
  86330. };
  86331. }
  86332. declare module BABYLON {
  86333. /** @hidden */
  86334. export var lavaVertexShader: {
  86335. name: string;
  86336. shader: string;
  86337. };
  86338. }
  86339. declare module BABYLON {
  86340. export class LavaMaterial extends BABYLON.PushMaterial {
  86341. private _diffuseTexture;
  86342. diffuseTexture: BABYLON.BaseTexture;
  86343. noiseTexture: BABYLON.BaseTexture;
  86344. fogColor: BABYLON.Color3;
  86345. speed: number;
  86346. movingSpeed: number;
  86347. lowFrequencySpeed: number;
  86348. fogDensity: number;
  86349. private _lastTime;
  86350. diffuseColor: BABYLON.Color3;
  86351. private _disableLighting;
  86352. disableLighting: boolean;
  86353. private _unlit;
  86354. unlit: boolean;
  86355. private _maxSimultaneousLights;
  86356. maxSimultaneousLights: number;
  86357. private _scaledDiffuse;
  86358. constructor(name: string, scene: BABYLON.Scene);
  86359. needAlphaBlending(): boolean;
  86360. needAlphaTesting(): boolean;
  86361. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86362. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86363. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86364. getAnimatables(): BABYLON.IAnimatable[];
  86365. getActiveTextures(): BABYLON.BaseTexture[];
  86366. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86367. dispose(forceDisposeEffect?: boolean): void;
  86368. clone(name: string): LavaMaterial;
  86369. serialize(): any;
  86370. getClassName(): string;
  86371. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86372. }
  86373. }
  86374. declare module BABYLON {
  86375. /** @hidden */
  86376. export var mixPixelShader: {
  86377. name: string;
  86378. shader: string;
  86379. };
  86380. }
  86381. declare module BABYLON {
  86382. /** @hidden */
  86383. export var mixVertexShader: {
  86384. name: string;
  86385. shader: string;
  86386. };
  86387. }
  86388. declare module BABYLON {
  86389. export class MixMaterial extends BABYLON.PushMaterial {
  86390. /**
  86391. * Mix textures
  86392. */
  86393. private _mixTexture1;
  86394. mixTexture1: BABYLON.BaseTexture;
  86395. private _mixTexture2;
  86396. mixTexture2: BABYLON.BaseTexture;
  86397. /**
  86398. * Diffuse textures
  86399. */
  86400. private _diffuseTexture1;
  86401. diffuseTexture1: BABYLON.Texture;
  86402. private _diffuseTexture2;
  86403. diffuseTexture2: BABYLON.Texture;
  86404. private _diffuseTexture3;
  86405. diffuseTexture3: BABYLON.Texture;
  86406. private _diffuseTexture4;
  86407. diffuseTexture4: BABYLON.Texture;
  86408. private _diffuseTexture5;
  86409. diffuseTexture5: BABYLON.Texture;
  86410. private _diffuseTexture6;
  86411. diffuseTexture6: BABYLON.Texture;
  86412. private _diffuseTexture7;
  86413. diffuseTexture7: BABYLON.Texture;
  86414. private _diffuseTexture8;
  86415. diffuseTexture8: BABYLON.Texture;
  86416. /**
  86417. * Uniforms
  86418. */
  86419. diffuseColor: BABYLON.Color3;
  86420. specularColor: BABYLON.Color3;
  86421. specularPower: number;
  86422. private _disableLighting;
  86423. disableLighting: boolean;
  86424. private _maxSimultaneousLights;
  86425. maxSimultaneousLights: number;
  86426. constructor(name: string, scene: BABYLON.Scene);
  86427. needAlphaBlending(): boolean;
  86428. needAlphaTesting(): boolean;
  86429. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86430. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86431. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86432. getAnimatables(): BABYLON.IAnimatable[];
  86433. getActiveTextures(): BABYLON.BaseTexture[];
  86434. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86435. dispose(forceDisposeEffect?: boolean): void;
  86436. clone(name: string): MixMaterial;
  86437. serialize(): any;
  86438. getClassName(): string;
  86439. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86440. }
  86441. }
  86442. declare module BABYLON {
  86443. /** @hidden */
  86444. export var normalPixelShader: {
  86445. name: string;
  86446. shader: string;
  86447. };
  86448. }
  86449. declare module BABYLON {
  86450. /** @hidden */
  86451. export var normalVertexShader: {
  86452. name: string;
  86453. shader: string;
  86454. };
  86455. }
  86456. declare module BABYLON {
  86457. export class NormalMaterial extends BABYLON.PushMaterial {
  86458. private _diffuseTexture;
  86459. diffuseTexture: BABYLON.BaseTexture;
  86460. diffuseColor: BABYLON.Color3;
  86461. private _disableLighting;
  86462. disableLighting: boolean;
  86463. private _maxSimultaneousLights;
  86464. maxSimultaneousLights: number;
  86465. constructor(name: string, scene: BABYLON.Scene);
  86466. needAlphaBlending(): boolean;
  86467. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86468. needAlphaTesting(): boolean;
  86469. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86470. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86471. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86472. getAnimatables(): BABYLON.IAnimatable[];
  86473. getActiveTextures(): BABYLON.BaseTexture[];
  86474. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86475. dispose(forceDisposeEffect?: boolean): void;
  86476. clone(name: string): NormalMaterial;
  86477. serialize(): any;
  86478. getClassName(): string;
  86479. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86480. }
  86481. }
  86482. declare module BABYLON {
  86483. /** @hidden */
  86484. export var shadowOnlyPixelShader: {
  86485. name: string;
  86486. shader: string;
  86487. };
  86488. }
  86489. declare module BABYLON {
  86490. /** @hidden */
  86491. export var shadowOnlyVertexShader: {
  86492. name: string;
  86493. shader: string;
  86494. };
  86495. }
  86496. declare module BABYLON {
  86497. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86498. private _activeLight;
  86499. private _needAlphaBlending;
  86500. constructor(name: string, scene: BABYLON.Scene);
  86501. shadowColor: BABYLON.Color3;
  86502. needAlphaBlending(): boolean;
  86503. needAlphaTesting(): boolean;
  86504. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86505. get activeLight(): BABYLON.IShadowLight;
  86506. set activeLight(light: BABYLON.IShadowLight);
  86507. private _getFirstShadowLightForMesh;
  86508. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86509. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86510. clone(name: string): ShadowOnlyMaterial;
  86511. serialize(): any;
  86512. getClassName(): string;
  86513. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86514. }
  86515. }
  86516. declare module BABYLON {
  86517. /** @hidden */
  86518. export var simplePixelShader: {
  86519. name: string;
  86520. shader: string;
  86521. };
  86522. }
  86523. declare module BABYLON {
  86524. /** @hidden */
  86525. export var simpleVertexShader: {
  86526. name: string;
  86527. shader: string;
  86528. };
  86529. }
  86530. declare module BABYLON {
  86531. export class SimpleMaterial extends BABYLON.PushMaterial {
  86532. private _diffuseTexture;
  86533. diffuseTexture: BABYLON.BaseTexture;
  86534. diffuseColor: BABYLON.Color3;
  86535. private _disableLighting;
  86536. disableLighting: boolean;
  86537. private _maxSimultaneousLights;
  86538. maxSimultaneousLights: number;
  86539. constructor(name: string, scene: BABYLON.Scene);
  86540. needAlphaBlending(): boolean;
  86541. needAlphaTesting(): boolean;
  86542. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86543. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86544. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86545. getAnimatables(): BABYLON.IAnimatable[];
  86546. getActiveTextures(): BABYLON.BaseTexture[];
  86547. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86548. dispose(forceDisposeEffect?: boolean): void;
  86549. clone(name: string): SimpleMaterial;
  86550. serialize(): any;
  86551. getClassName(): string;
  86552. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86553. }
  86554. }
  86555. declare module BABYLON {
  86556. /** @hidden */
  86557. export var skyPixelShader: {
  86558. name: string;
  86559. shader: string;
  86560. };
  86561. }
  86562. declare module BABYLON {
  86563. /** @hidden */
  86564. export var skyVertexShader: {
  86565. name: string;
  86566. shader: string;
  86567. };
  86568. }
  86569. declare module BABYLON {
  86570. /**
  86571. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86572. * @see https://doc.babylonjs.com/extensions/sky
  86573. */
  86574. export class SkyMaterial extends BABYLON.PushMaterial {
  86575. /**
  86576. * Defines the overall luminance of sky in interval ]0, 1[.
  86577. */
  86578. luminance: number;
  86579. /**
  86580. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86581. */
  86582. turbidity: number;
  86583. /**
  86584. * Defines the sky appearance (light intensity).
  86585. */
  86586. rayleigh: number;
  86587. /**
  86588. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86589. */
  86590. mieCoefficient: number;
  86591. /**
  86592. * Defines the amount of haze particles following the Mie scattering theory.
  86593. */
  86594. mieDirectionalG: number;
  86595. /**
  86596. * Defines the distance of the sun according to the active scene camera.
  86597. */
  86598. distance: number;
  86599. /**
  86600. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86601. * "inclined".
  86602. */
  86603. inclination: number;
  86604. /**
  86605. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86606. * an object direction and a reference direction.
  86607. */
  86608. azimuth: number;
  86609. /**
  86610. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86611. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86612. */
  86613. sunPosition: BABYLON.Vector3;
  86614. /**
  86615. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86616. * .sunPosition property.
  86617. */
  86618. useSunPosition: boolean;
  86619. /**
  86620. * Defines an offset vector used to get a horizon offset.
  86621. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86622. */
  86623. cameraOffset: BABYLON.Vector3;
  86624. private _cameraPosition;
  86625. /**
  86626. * Instantiates a new sky material.
  86627. * This material allows to create dynamic and texture free
  86628. * effects for skyboxes by taking care of the atmosphere state.
  86629. * @see https://doc.babylonjs.com/extensions/sky
  86630. * @param name Define the name of the material in the scene
  86631. * @param scene Define the scene the material belong to
  86632. */
  86633. constructor(name: string, scene: BABYLON.Scene);
  86634. /**
  86635. * Specifies if the material will require alpha blending
  86636. * @returns a boolean specifying if alpha blending is needed
  86637. */
  86638. needAlphaBlending(): boolean;
  86639. /**
  86640. * Specifies if this material should be rendered in alpha test mode
  86641. * @returns false as the sky material doesn't need alpha testing.
  86642. */
  86643. needAlphaTesting(): boolean;
  86644. /**
  86645. * Get the texture used for alpha test purpose.
  86646. * @returns null as the sky material has no texture.
  86647. */
  86648. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86649. /**
  86650. * Get if the submesh is ready to be used and all its information available.
  86651. * Child classes can use it to update shaders
  86652. * @param mesh defines the mesh to check
  86653. * @param subMesh defines which submesh to check
  86654. * @param useInstances specifies that instances should be used
  86655. * @returns a boolean indicating that the submesh is ready or not
  86656. */
  86657. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86658. /**
  86659. * Binds the submesh to this material by preparing the effect and shader to draw
  86660. * @param world defines the world transformation matrix
  86661. * @param mesh defines the mesh containing the submesh
  86662. * @param subMesh defines the submesh to bind the material to
  86663. */
  86664. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86665. /**
  86666. * Get the list of animatables in the material.
  86667. * @returns the list of animatables object used in the material
  86668. */
  86669. getAnimatables(): BABYLON.IAnimatable[];
  86670. /**
  86671. * Disposes the material
  86672. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86673. */
  86674. dispose(forceDisposeEffect?: boolean): void;
  86675. /**
  86676. * Makes a duplicate of the material, and gives it a new name
  86677. * @param name defines the new name for the duplicated material
  86678. * @returns the cloned material
  86679. */
  86680. clone(name: string): SkyMaterial;
  86681. /**
  86682. * Serializes this material in a JSON representation
  86683. * @returns the serialized material object
  86684. */
  86685. serialize(): any;
  86686. /**
  86687. * Gets the current class name of the material e.g. "SkyMaterial"
  86688. * Mainly use in serialization.
  86689. * @returns the class name
  86690. */
  86691. getClassName(): string;
  86692. /**
  86693. * Creates a sky material from parsed material data
  86694. * @param source defines the JSON representation of the material
  86695. * @param scene defines the hosting scene
  86696. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86697. * @returns a new sky material
  86698. */
  86699. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86700. }
  86701. }
  86702. declare module BABYLON {
  86703. /** @hidden */
  86704. export var terrainPixelShader: {
  86705. name: string;
  86706. shader: string;
  86707. };
  86708. }
  86709. declare module BABYLON {
  86710. /** @hidden */
  86711. export var terrainVertexShader: {
  86712. name: string;
  86713. shader: string;
  86714. };
  86715. }
  86716. declare module BABYLON {
  86717. export class TerrainMaterial extends BABYLON.PushMaterial {
  86718. private _mixTexture;
  86719. mixTexture: BABYLON.BaseTexture;
  86720. private _diffuseTexture1;
  86721. diffuseTexture1: BABYLON.Texture;
  86722. private _diffuseTexture2;
  86723. diffuseTexture2: BABYLON.Texture;
  86724. private _diffuseTexture3;
  86725. diffuseTexture3: BABYLON.Texture;
  86726. private _bumpTexture1;
  86727. bumpTexture1: BABYLON.Texture;
  86728. private _bumpTexture2;
  86729. bumpTexture2: BABYLON.Texture;
  86730. private _bumpTexture3;
  86731. bumpTexture3: BABYLON.Texture;
  86732. diffuseColor: BABYLON.Color3;
  86733. specularColor: BABYLON.Color3;
  86734. specularPower: number;
  86735. private _disableLighting;
  86736. disableLighting: boolean;
  86737. private _maxSimultaneousLights;
  86738. maxSimultaneousLights: number;
  86739. constructor(name: string, scene: BABYLON.Scene);
  86740. needAlphaBlending(): boolean;
  86741. needAlphaTesting(): boolean;
  86742. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86743. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86744. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86745. getAnimatables(): BABYLON.IAnimatable[];
  86746. getActiveTextures(): BABYLON.BaseTexture[];
  86747. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86748. dispose(forceDisposeEffect?: boolean): void;
  86749. clone(name: string): TerrainMaterial;
  86750. serialize(): any;
  86751. getClassName(): string;
  86752. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86753. }
  86754. }
  86755. declare module BABYLON {
  86756. /** @hidden */
  86757. export var triplanarPixelShader: {
  86758. name: string;
  86759. shader: string;
  86760. };
  86761. }
  86762. declare module BABYLON {
  86763. /** @hidden */
  86764. export var triplanarVertexShader: {
  86765. name: string;
  86766. shader: string;
  86767. };
  86768. }
  86769. declare module BABYLON {
  86770. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86771. mixTexture: BABYLON.BaseTexture;
  86772. private _diffuseTextureX;
  86773. diffuseTextureX: BABYLON.BaseTexture;
  86774. private _diffuseTextureY;
  86775. diffuseTextureY: BABYLON.BaseTexture;
  86776. private _diffuseTextureZ;
  86777. diffuseTextureZ: BABYLON.BaseTexture;
  86778. private _normalTextureX;
  86779. normalTextureX: BABYLON.BaseTexture;
  86780. private _normalTextureY;
  86781. normalTextureY: BABYLON.BaseTexture;
  86782. private _normalTextureZ;
  86783. normalTextureZ: BABYLON.BaseTexture;
  86784. tileSize: number;
  86785. diffuseColor: BABYLON.Color3;
  86786. specularColor: BABYLON.Color3;
  86787. specularPower: number;
  86788. private _disableLighting;
  86789. disableLighting: boolean;
  86790. private _maxSimultaneousLights;
  86791. maxSimultaneousLights: number;
  86792. constructor(name: string, scene: BABYLON.Scene);
  86793. needAlphaBlending(): boolean;
  86794. needAlphaTesting(): boolean;
  86795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86798. getAnimatables(): BABYLON.IAnimatable[];
  86799. getActiveTextures(): BABYLON.BaseTexture[];
  86800. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86801. dispose(forceDisposeEffect?: boolean): void;
  86802. clone(name: string): TriPlanarMaterial;
  86803. serialize(): any;
  86804. getClassName(): string;
  86805. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86806. }
  86807. }
  86808. declare module BABYLON {
  86809. /** @hidden */
  86810. export var waterPixelShader: {
  86811. name: string;
  86812. shader: string;
  86813. };
  86814. }
  86815. declare module BABYLON {
  86816. /** @hidden */
  86817. export var waterVertexShader: {
  86818. name: string;
  86819. shader: string;
  86820. };
  86821. }
  86822. declare module BABYLON {
  86823. export class WaterMaterial extends BABYLON.PushMaterial {
  86824. renderTargetSize: BABYLON.Vector2;
  86825. private _bumpTexture;
  86826. bumpTexture: BABYLON.BaseTexture;
  86827. diffuseColor: BABYLON.Color3;
  86828. specularColor: BABYLON.Color3;
  86829. specularPower: number;
  86830. private _disableLighting;
  86831. disableLighting: boolean;
  86832. private _maxSimultaneousLights;
  86833. maxSimultaneousLights: number;
  86834. /**
  86835. * @param {number}: Represents the wind force
  86836. */
  86837. windForce: number;
  86838. /**
  86839. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86840. */
  86841. windDirection: BABYLON.Vector2;
  86842. /**
  86843. * @param {number}: Wave height, represents the height of the waves
  86844. */
  86845. waveHeight: number;
  86846. /**
  86847. * @param {number}: Bump height, represents the bump height related to the bump map
  86848. */
  86849. bumpHeight: number;
  86850. /**
  86851. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86852. */
  86853. private _bumpSuperimpose;
  86854. bumpSuperimpose: boolean;
  86855. /**
  86856. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86857. */
  86858. private _fresnelSeparate;
  86859. fresnelSeparate: boolean;
  86860. /**
  86861. * @param {boolean}: bump Waves modify the reflection.
  86862. */
  86863. private _bumpAffectsReflection;
  86864. bumpAffectsReflection: boolean;
  86865. /**
  86866. * @param {number}: The water color blended with the refraction (near)
  86867. */
  86868. waterColor: BABYLON.Color3;
  86869. /**
  86870. * @param {number}: The blend factor related to the water color
  86871. */
  86872. colorBlendFactor: number;
  86873. /**
  86874. * @param {number}: The water color blended with the reflection (far)
  86875. */
  86876. waterColor2: BABYLON.Color3;
  86877. /**
  86878. * @param {number}: The blend factor related to the water color (reflection, far)
  86879. */
  86880. colorBlendFactor2: number;
  86881. /**
  86882. * @param {number}: Represents the maximum length of a wave
  86883. */
  86884. waveLength: number;
  86885. /**
  86886. * @param {number}: Defines the waves speed
  86887. */
  86888. waveSpeed: number;
  86889. /**
  86890. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86891. * will avoid calculating useless pixels in the pixel shader of the water material.
  86892. */
  86893. disableClipPlane: boolean;
  86894. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86895. private _mesh;
  86896. private _refractionRTT;
  86897. private _reflectionRTT;
  86898. private _reflectionTransform;
  86899. private _lastTime;
  86900. private _lastDeltaTime;
  86901. private _useLogarithmicDepth;
  86902. private _waitingRenderList;
  86903. private _imageProcessingConfiguration;
  86904. private _imageProcessingObserver;
  86905. /**
  86906. * Gets a boolean indicating that current material needs to register RTT
  86907. */
  86908. get hasRenderTargetTextures(): boolean;
  86909. /**
  86910. * Constructor
  86911. */
  86912. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86913. get useLogarithmicDepth(): boolean;
  86914. set useLogarithmicDepth(value: boolean);
  86915. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86916. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86917. addToRenderList(node: any): void;
  86918. enableRenderTargets(enable: boolean): void;
  86919. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86920. get renderTargetsEnabled(): boolean;
  86921. needAlphaBlending(): boolean;
  86922. needAlphaTesting(): boolean;
  86923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86924. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86925. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86926. private _createRenderTargets;
  86927. getAnimatables(): BABYLON.IAnimatable[];
  86928. getActiveTextures(): BABYLON.BaseTexture[];
  86929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86930. dispose(forceDisposeEffect?: boolean): void;
  86931. clone(name: string): WaterMaterial;
  86932. serialize(): any;
  86933. getClassName(): string;
  86934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86935. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86936. }
  86937. }
  86938. declare module BABYLON {
  86939. /** @hidden */
  86940. export var asciiartPixelShader: {
  86941. name: string;
  86942. shader: string;
  86943. };
  86944. }
  86945. declare module BABYLON {
  86946. /**
  86947. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86948. *
  86949. * It basically takes care rendering the font front the given font size to a texture.
  86950. * This is used later on in the postprocess.
  86951. */
  86952. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86953. private _font;
  86954. private _text;
  86955. private _charSize;
  86956. /**
  86957. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86958. */
  86959. get charSize(): number;
  86960. /**
  86961. * Create a new instance of the Ascii Art FontTexture class
  86962. * @param name the name of the texture
  86963. * @param font the font to use, use the W3C CSS notation
  86964. * @param text the caracter set to use in the rendering.
  86965. * @param scene the scene that owns the texture
  86966. */
  86967. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86968. /**
  86969. * Gets the max char width of a font.
  86970. * @param font the font to use, use the W3C CSS notation
  86971. * @return the max char width
  86972. */
  86973. private getFontWidth;
  86974. /**
  86975. * Gets the max char height of a font.
  86976. * @param font the font to use, use the W3C CSS notation
  86977. * @return the max char height
  86978. */
  86979. private getFontHeight;
  86980. /**
  86981. * Clones the current AsciiArtTexture.
  86982. * @return the clone of the texture.
  86983. */
  86984. clone(): AsciiArtFontTexture;
  86985. /**
  86986. * Parses a json object representing the texture and returns an instance of it.
  86987. * @param source the source JSON representation
  86988. * @param scene the scene to create the texture for
  86989. * @return the parsed texture
  86990. */
  86991. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86992. }
  86993. /**
  86994. * Option available in the Ascii Art Post Process.
  86995. */
  86996. export interface IAsciiArtPostProcessOptions {
  86997. /**
  86998. * The font to use following the w3c font definition.
  86999. */
  87000. font?: string;
  87001. /**
  87002. * The character set to use in the postprocess.
  87003. */
  87004. characterSet?: string;
  87005. /**
  87006. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87007. * This number is defined between 0 and 1;
  87008. */
  87009. mixToTile?: number;
  87010. /**
  87011. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87012. * This number is defined between 0 and 1;
  87013. */
  87014. mixToNormal?: number;
  87015. }
  87016. /**
  87017. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87018. *
  87019. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87020. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87021. */
  87022. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87023. /**
  87024. * The font texture used to render the char in the post process.
  87025. */
  87026. private _asciiArtFontTexture;
  87027. /**
  87028. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87029. * This number is defined between 0 and 1;
  87030. */
  87031. mixToTile: number;
  87032. /**
  87033. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87034. * This number is defined between 0 and 1;
  87035. */
  87036. mixToNormal: number;
  87037. /**
  87038. * Instantiates a new Ascii Art Post Process.
  87039. * @param name the name to give to the postprocess
  87040. * @camera the camera to apply the post process to.
  87041. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87042. */
  87043. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87044. }
  87045. }
  87046. declare module BABYLON {
  87047. /** @hidden */
  87048. export var digitalrainPixelShader: {
  87049. name: string;
  87050. shader: string;
  87051. };
  87052. }
  87053. declare module BABYLON {
  87054. /**
  87055. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87056. *
  87057. * It basically takes care rendering the font front the given font size to a texture.
  87058. * This is used later on in the postprocess.
  87059. */
  87060. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87061. private _font;
  87062. private _text;
  87063. private _charSize;
  87064. /**
  87065. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87066. */
  87067. get charSize(): number;
  87068. /**
  87069. * Create a new instance of the Digital Rain FontTexture class
  87070. * @param name the name of the texture
  87071. * @param font the font to use, use the W3C CSS notation
  87072. * @param text the caracter set to use in the rendering.
  87073. * @param scene the scene that owns the texture
  87074. */
  87075. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87076. /**
  87077. * Gets the max char width of a font.
  87078. * @param font the font to use, use the W3C CSS notation
  87079. * @return the max char width
  87080. */
  87081. private getFontWidth;
  87082. /**
  87083. * Gets the max char height of a font.
  87084. * @param font the font to use, use the W3C CSS notation
  87085. * @return the max char height
  87086. */
  87087. private getFontHeight;
  87088. /**
  87089. * Clones the current DigitalRainFontTexture.
  87090. * @return the clone of the texture.
  87091. */
  87092. clone(): DigitalRainFontTexture;
  87093. /**
  87094. * Parses a json object representing the texture and returns an instance of it.
  87095. * @param source the source JSON representation
  87096. * @param scene the scene to create the texture for
  87097. * @return the parsed texture
  87098. */
  87099. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87100. }
  87101. /**
  87102. * Option available in the Digital Rain Post Process.
  87103. */
  87104. export interface IDigitalRainPostProcessOptions {
  87105. /**
  87106. * The font to use following the w3c font definition.
  87107. */
  87108. font?: string;
  87109. /**
  87110. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87111. * This number is defined between 0 and 1;
  87112. */
  87113. mixToTile?: number;
  87114. /**
  87115. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87116. * This number is defined between 0 and 1;
  87117. */
  87118. mixToNormal?: number;
  87119. }
  87120. /**
  87121. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87122. *
  87123. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87124. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87125. */
  87126. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87127. /**
  87128. * The font texture used to render the char in the post process.
  87129. */
  87130. private _digitalRainFontTexture;
  87131. /**
  87132. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87133. * This number is defined between 0 and 1;
  87134. */
  87135. mixToTile: number;
  87136. /**
  87137. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87138. * This number is defined between 0 and 1;
  87139. */
  87140. mixToNormal: number;
  87141. /**
  87142. * Instantiates a new Digital Rain Post Process.
  87143. * @param name the name to give to the postprocess
  87144. * @camera the camera to apply the post process to.
  87145. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87146. */
  87147. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87148. }
  87149. }
  87150. declare module BABYLON {
  87151. /** @hidden */
  87152. export var brickProceduralTexturePixelShader: {
  87153. name: string;
  87154. shader: string;
  87155. };
  87156. }
  87157. declare module BABYLON {
  87158. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87159. private _numberOfBricksHeight;
  87160. private _numberOfBricksWidth;
  87161. private _jointColor;
  87162. private _brickColor;
  87163. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87164. updateShaderUniforms(): void;
  87165. get numberOfBricksHeight(): number;
  87166. set numberOfBricksHeight(value: number);
  87167. get numberOfBricksWidth(): number;
  87168. set numberOfBricksWidth(value: number);
  87169. get jointColor(): BABYLON.Color3;
  87170. set jointColor(value: BABYLON.Color3);
  87171. get brickColor(): BABYLON.Color3;
  87172. set brickColor(value: BABYLON.Color3);
  87173. /**
  87174. * Serializes this brick procedural texture
  87175. * @returns a serialized brick procedural texture object
  87176. */
  87177. serialize(): any;
  87178. /**
  87179. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87180. * @param parsedTexture defines parsed texture data
  87181. * @param scene defines the current scene
  87182. * @param rootUrl defines the root URL containing brick procedural texture information
  87183. * @returns a parsed Brick Procedural BABYLON.Texture
  87184. */
  87185. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87186. }
  87187. }
  87188. declare module BABYLON {
  87189. /** @hidden */
  87190. export var cloudProceduralTexturePixelShader: {
  87191. name: string;
  87192. shader: string;
  87193. };
  87194. }
  87195. declare module BABYLON {
  87196. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87197. private _skyColor;
  87198. private _cloudColor;
  87199. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87200. updateShaderUniforms(): void;
  87201. get skyColor(): BABYLON.Color4;
  87202. set skyColor(value: BABYLON.Color4);
  87203. get cloudColor(): BABYLON.Color4;
  87204. set cloudColor(value: BABYLON.Color4);
  87205. /**
  87206. * Serializes this cloud procedural texture
  87207. * @returns a serialized cloud procedural texture object
  87208. */
  87209. serialize(): any;
  87210. /**
  87211. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87212. * @param parsedTexture defines parsed texture data
  87213. * @param scene defines the current scene
  87214. * @param rootUrl defines the root URL containing cloud procedural texture information
  87215. * @returns a parsed Cloud Procedural BABYLON.Texture
  87216. */
  87217. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /** @hidden */
  87222. export var fireProceduralTexturePixelShader: {
  87223. name: string;
  87224. shader: string;
  87225. };
  87226. }
  87227. declare module BABYLON {
  87228. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87229. private _time;
  87230. private _speed;
  87231. private _autoGenerateTime;
  87232. private _fireColors;
  87233. private _alphaThreshold;
  87234. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87235. updateShaderUniforms(): void;
  87236. render(useCameraPostProcess?: boolean): void;
  87237. static get PurpleFireColors(): BABYLON.Color3[];
  87238. static get GreenFireColors(): BABYLON.Color3[];
  87239. static get RedFireColors(): BABYLON.Color3[];
  87240. static get BlueFireColors(): BABYLON.Color3[];
  87241. get autoGenerateTime(): boolean;
  87242. set autoGenerateTime(value: boolean);
  87243. get fireColors(): BABYLON.Color3[];
  87244. set fireColors(value: BABYLON.Color3[]);
  87245. get time(): number;
  87246. set time(value: number);
  87247. get speed(): BABYLON.Vector2;
  87248. set speed(value: BABYLON.Vector2);
  87249. get alphaThreshold(): number;
  87250. set alphaThreshold(value: number);
  87251. /**
  87252. * Serializes this fire procedural texture
  87253. * @returns a serialized fire procedural texture object
  87254. */
  87255. serialize(): any;
  87256. /**
  87257. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87258. * @param parsedTexture defines parsed texture data
  87259. * @param scene defines the current scene
  87260. * @param rootUrl defines the root URL containing fire procedural texture information
  87261. * @returns a parsed Fire Procedural BABYLON.Texture
  87262. */
  87263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87264. }
  87265. }
  87266. declare module BABYLON {
  87267. /** @hidden */
  87268. export var grassProceduralTexturePixelShader: {
  87269. name: string;
  87270. shader: string;
  87271. };
  87272. }
  87273. declare module BABYLON {
  87274. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87275. private _grassColors;
  87276. private _groundColor;
  87277. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87278. updateShaderUniforms(): void;
  87279. get grassColors(): BABYLON.Color3[];
  87280. set grassColors(value: BABYLON.Color3[]);
  87281. get groundColor(): BABYLON.Color3;
  87282. set groundColor(value: BABYLON.Color3);
  87283. /**
  87284. * Serializes this grass procedural texture
  87285. * @returns a serialized grass procedural texture object
  87286. */
  87287. serialize(): any;
  87288. /**
  87289. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87290. * @param parsedTexture defines parsed texture data
  87291. * @param scene defines the current scene
  87292. * @param rootUrl defines the root URL containing grass procedural texture information
  87293. * @returns a parsed Grass Procedural BABYLON.Texture
  87294. */
  87295. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87296. }
  87297. }
  87298. declare module BABYLON {
  87299. /** @hidden */
  87300. export var marbleProceduralTexturePixelShader: {
  87301. name: string;
  87302. shader: string;
  87303. };
  87304. }
  87305. declare module BABYLON {
  87306. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87307. private _numberOfTilesHeight;
  87308. private _numberOfTilesWidth;
  87309. private _amplitude;
  87310. private _jointColor;
  87311. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87312. updateShaderUniforms(): void;
  87313. get numberOfTilesHeight(): number;
  87314. set numberOfTilesHeight(value: number);
  87315. get amplitude(): number;
  87316. set amplitude(value: number);
  87317. get numberOfTilesWidth(): number;
  87318. set numberOfTilesWidth(value: number);
  87319. get jointColor(): BABYLON.Color3;
  87320. set jointColor(value: BABYLON.Color3);
  87321. /**
  87322. * Serializes this marble procedural texture
  87323. * @returns a serialized marble procedural texture object
  87324. */
  87325. serialize(): any;
  87326. /**
  87327. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87328. * @param parsedTexture defines parsed texture data
  87329. * @param scene defines the current scene
  87330. * @param rootUrl defines the root URL containing marble procedural texture information
  87331. * @returns a parsed Marble Procedural BABYLON.Texture
  87332. */
  87333. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87334. }
  87335. }
  87336. declare module BABYLON {
  87337. /** @hidden */
  87338. export var normalMapProceduralTexturePixelShader: {
  87339. name: string;
  87340. shader: string;
  87341. };
  87342. }
  87343. declare module BABYLON {
  87344. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87345. private _baseTexture;
  87346. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87347. updateShaderUniforms(): void;
  87348. render(useCameraPostProcess?: boolean): void;
  87349. resize(size: any, generateMipMaps: any): void;
  87350. get baseTexture(): BABYLON.Texture;
  87351. set baseTexture(texture: BABYLON.Texture);
  87352. /**
  87353. * Serializes this normal map procedural texture
  87354. * @returns a serialized normal map procedural texture object
  87355. */
  87356. serialize(): any;
  87357. /**
  87358. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87359. * @param parsedTexture defines parsed texture data
  87360. * @param scene defines the current scene
  87361. * @param rootUrl defines the root URL containing normal map procedural texture information
  87362. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87363. */
  87364. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87365. }
  87366. }
  87367. declare module BABYLON {
  87368. /** @hidden */
  87369. export var perlinNoiseProceduralTexturePixelShader: {
  87370. name: string;
  87371. shader: string;
  87372. };
  87373. }
  87374. declare module BABYLON {
  87375. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87376. time: number;
  87377. timeScale: number;
  87378. translationSpeed: number;
  87379. private _currentTranslation;
  87380. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87381. updateShaderUniforms(): void;
  87382. render(useCameraPostProcess?: boolean): void;
  87383. resize(size: any, generateMipMaps: any): void;
  87384. /**
  87385. * Serializes this perlin noise procedural texture
  87386. * @returns a serialized perlin noise procedural texture object
  87387. */
  87388. serialize(): any;
  87389. /**
  87390. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87391. * @param parsedTexture defines parsed texture data
  87392. * @param scene defines the current scene
  87393. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87394. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87395. */
  87396. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87397. }
  87398. }
  87399. declare module BABYLON {
  87400. /** @hidden */
  87401. export var roadProceduralTexturePixelShader: {
  87402. name: string;
  87403. shader: string;
  87404. };
  87405. }
  87406. declare module BABYLON {
  87407. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87408. private _roadColor;
  87409. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87410. updateShaderUniforms(): void;
  87411. get roadColor(): BABYLON.Color3;
  87412. set roadColor(value: BABYLON.Color3);
  87413. /**
  87414. * Serializes this road procedural texture
  87415. * @returns a serialized road procedural texture object
  87416. */
  87417. serialize(): any;
  87418. /**
  87419. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87420. * @param parsedTexture defines parsed texture data
  87421. * @param scene defines the current scene
  87422. * @param rootUrl defines the root URL containing road procedural texture information
  87423. * @returns a parsed Road Procedural BABYLON.Texture
  87424. */
  87425. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87426. }
  87427. }
  87428. declare module BABYLON {
  87429. /** @hidden */
  87430. export var starfieldProceduralTexturePixelShader: {
  87431. name: string;
  87432. shader: string;
  87433. };
  87434. }
  87435. declare module BABYLON {
  87436. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87437. private _time;
  87438. private _alpha;
  87439. private _beta;
  87440. private _zoom;
  87441. private _formuparam;
  87442. private _stepsize;
  87443. private _tile;
  87444. private _brightness;
  87445. private _darkmatter;
  87446. private _distfading;
  87447. private _saturation;
  87448. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87449. updateShaderUniforms(): void;
  87450. get time(): number;
  87451. set time(value: number);
  87452. get alpha(): number;
  87453. set alpha(value: number);
  87454. get beta(): number;
  87455. set beta(value: number);
  87456. get formuparam(): number;
  87457. set formuparam(value: number);
  87458. get stepsize(): number;
  87459. set stepsize(value: number);
  87460. get zoom(): number;
  87461. set zoom(value: number);
  87462. get tile(): number;
  87463. set tile(value: number);
  87464. get brightness(): number;
  87465. set brightness(value: number);
  87466. get darkmatter(): number;
  87467. set darkmatter(value: number);
  87468. get distfading(): number;
  87469. set distfading(value: number);
  87470. get saturation(): number;
  87471. set saturation(value: number);
  87472. /**
  87473. * Serializes this starfield procedural texture
  87474. * @returns a serialized starfield procedural texture object
  87475. */
  87476. serialize(): any;
  87477. /**
  87478. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87479. * @param parsedTexture defines parsed texture data
  87480. * @param scene defines the current scene
  87481. * @param rootUrl defines the root URL containing startfield procedural texture information
  87482. * @returns a parsed Starfield Procedural BABYLON.Texture
  87483. */
  87484. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87485. }
  87486. }
  87487. declare module BABYLON {
  87488. /** @hidden */
  87489. export var woodProceduralTexturePixelShader: {
  87490. name: string;
  87491. shader: string;
  87492. };
  87493. }
  87494. declare module BABYLON {
  87495. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87496. private _ampScale;
  87497. private _woodColor;
  87498. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87499. updateShaderUniforms(): void;
  87500. get ampScale(): number;
  87501. set ampScale(value: number);
  87502. get woodColor(): BABYLON.Color3;
  87503. set woodColor(value: BABYLON.Color3);
  87504. /**
  87505. * Serializes this wood procedural texture
  87506. * @returns a serialized wood procedural texture object
  87507. */
  87508. serialize(): any;
  87509. /**
  87510. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87511. * @param parsedTexture defines parsed texture data
  87512. * @param scene defines the current scene
  87513. * @param rootUrl defines the root URL containing wood procedural texture information
  87514. * @returns a parsed Wood Procedural BABYLON.Texture
  87515. */
  87516. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87517. }
  87518. }