documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * 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".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  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. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal 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. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): 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. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set 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. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set 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. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * 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"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * 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"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "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. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "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. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * 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)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * 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
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. 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;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. 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;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, 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 left 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 LookAtLH(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 left 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 LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * 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.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * 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)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @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
  5160. * @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
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param element Defines the element the controls should be listened from
  6411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6412. */
  6413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6414. /**
  6415. * Detach the current controls from the specified dom element.
  6416. * @param element Defines the element to stop listening the inputs from
  6417. */
  6418. detachControl(element: Nullable<HTMLElement>): void;
  6419. /**
  6420. * Update the current camera state depending on the inputs that have been used this frame.
  6421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6422. */
  6423. checkInputs?: () => void;
  6424. }
  6425. /**
  6426. * Represents a map of input types to input instance or input index to input instance.
  6427. */
  6428. export interface CameraInputsMap<TCamera extends Camera> {
  6429. /**
  6430. * Accessor to the input by input type.
  6431. */
  6432. [name: string]: ICameraInput<TCamera>;
  6433. /**
  6434. * Accessor to the input by input index.
  6435. */
  6436. [idx: number]: ICameraInput<TCamera>;
  6437. }
  6438. /**
  6439. * This represents the input manager used within a camera.
  6440. * It helps dealing with all the different kind of input attached to a camera.
  6441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6442. */
  6443. export class CameraInputsManager<TCamera extends Camera> {
  6444. /**
  6445. * Defines the list of inputs attahed to the camera.
  6446. */
  6447. attached: CameraInputsMap<TCamera>;
  6448. /**
  6449. * Defines the dom element the camera is collecting inputs from.
  6450. * This is null if the controls have not been attached.
  6451. */
  6452. attachedElement: Nullable<HTMLElement>;
  6453. /**
  6454. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6455. */
  6456. noPreventDefault: boolean;
  6457. /**
  6458. * Defined the camera the input manager belongs to.
  6459. */
  6460. camera: TCamera;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs: () => void;
  6466. /**
  6467. * Instantiate a new Camera Input Manager.
  6468. * @param camera Defines the camera the input manager blongs to
  6469. */
  6470. constructor(camera: TCamera);
  6471. /**
  6472. * Add an input method to a camera
  6473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6474. * @param input camera input method
  6475. */
  6476. add(input: ICameraInput<TCamera>): void;
  6477. /**
  6478. * Remove a specific input method from a camera
  6479. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6480. * @param inputToRemove camera input method
  6481. */
  6482. remove(inputToRemove: ICameraInput<TCamera>): void;
  6483. /**
  6484. * Remove a specific input type from a camera
  6485. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6486. * @param inputType the type of the input to remove
  6487. */
  6488. removeByType(inputType: string): void;
  6489. private _addCheckInputs;
  6490. /**
  6491. * Attach the input controls to the currently attached dom element to listen the events from.
  6492. * @param input Defines the input to attach
  6493. */
  6494. attachInput(input: ICameraInput<TCamera>): void;
  6495. /**
  6496. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6497. * @param element Defines the dom element to collect the events from
  6498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6499. */
  6500. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6501. /**
  6502. * Detach the current manager inputs controls from a specific dom element.
  6503. * @param element Defines the dom element to collect the events from
  6504. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6505. */
  6506. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6507. /**
  6508. * Rebuild the dynamic inputCheck function from the current list of
  6509. * defined inputs in the manager.
  6510. */
  6511. rebuildInputCheck(): void;
  6512. /**
  6513. * Remove all attached input methods from a camera
  6514. */
  6515. clear(): void;
  6516. /**
  6517. * Serialize the current input manager attached to a camera.
  6518. * This ensures than once parsed,
  6519. * the input associated to the camera will be identical to the current ones
  6520. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6521. */
  6522. serialize(serializedCamera: any): void;
  6523. /**
  6524. * Parses an input manager serialized JSON to restore the previous list of inputs
  6525. * and states associated to a camera.
  6526. * @param parsedCamera Defines the JSON to parse
  6527. */
  6528. parse(parsedCamera: any): void;
  6529. }
  6530. }
  6531. declare module BABYLON {
  6532. /**
  6533. * Class used to store data that will be store in GPU memory
  6534. */
  6535. export class Buffer {
  6536. private _engine;
  6537. private _buffer;
  6538. /** @hidden */
  6539. _data: Nullable<DataArray>;
  6540. private _updatable;
  6541. private _instanced;
  6542. private _divisor;
  6543. /**
  6544. * Gets the byte stride.
  6545. */
  6546. readonly byteStride: number;
  6547. /**
  6548. * Constructor
  6549. * @param engine the engine
  6550. * @param data the data to use for this buffer
  6551. * @param updatable whether the data is updatable
  6552. * @param stride the stride (optional)
  6553. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param useBytes set to true if the stride in in bytes (optional)
  6556. * @param divisor sets an optional divisor for instances (1 by default)
  6557. */
  6558. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6559. /**
  6560. * Create a new VertexBuffer based on the current buffer
  6561. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6562. * @param offset defines offset in the buffer (0 by default)
  6563. * @param size defines the size in floats of attributes (position is 3 for instance)
  6564. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6565. * @param instanced defines if the vertex buffer contains indexed data
  6566. * @param useBytes defines if the offset and stride are in bytes *
  6567. * @param divisor sets an optional divisor for instances (1 by default)
  6568. * @returns the new vertex buffer
  6569. */
  6570. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6571. /**
  6572. * Gets a boolean indicating if the Buffer is updatable?
  6573. * @returns true if the buffer is updatable
  6574. */
  6575. isUpdatable(): boolean;
  6576. /**
  6577. * Gets current buffer's data
  6578. * @returns a DataArray or null
  6579. */
  6580. getData(): Nullable<DataArray>;
  6581. /**
  6582. * Gets underlying native buffer
  6583. * @returns underlying native buffer
  6584. */
  6585. getBuffer(): Nullable<DataBuffer>;
  6586. /**
  6587. * Gets the stride in float32 units (i.e. byte stride / 4).
  6588. * May not be an integer if the byte stride is not divisible by 4.
  6589. * @returns the stride in float32 units
  6590. * @deprecated Please use byteStride instead.
  6591. */
  6592. getStrideSize(): number;
  6593. /**
  6594. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6595. * @param data defines the data to store
  6596. */
  6597. create(data?: Nullable<DataArray>): void;
  6598. /** @hidden */
  6599. _rebuild(): void;
  6600. /**
  6601. * Update current buffer data
  6602. * @param data defines the data to store
  6603. */
  6604. update(data: DataArray): void;
  6605. /**
  6606. * Updates the data directly.
  6607. * @param data the new data
  6608. * @param offset the new offset
  6609. * @param vertexCount the vertex count (optional)
  6610. * @param useBytes set to true if the offset is in bytes
  6611. */
  6612. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6613. /**
  6614. * Release all resources
  6615. */
  6616. dispose(): void;
  6617. }
  6618. /**
  6619. * Specialized buffer used to store vertex data
  6620. */
  6621. export class VertexBuffer {
  6622. /** @hidden */
  6623. _buffer: Buffer;
  6624. private _kind;
  6625. private _size;
  6626. private _ownsBuffer;
  6627. private _instanced;
  6628. private _instanceDivisor;
  6629. /**
  6630. * The byte type.
  6631. */
  6632. static readonly BYTE: number;
  6633. /**
  6634. * The unsigned byte type.
  6635. */
  6636. static readonly UNSIGNED_BYTE: number;
  6637. /**
  6638. * The short type.
  6639. */
  6640. static readonly SHORT: number;
  6641. /**
  6642. * The unsigned short type.
  6643. */
  6644. static readonly UNSIGNED_SHORT: number;
  6645. /**
  6646. * The integer type.
  6647. */
  6648. static readonly INT: number;
  6649. /**
  6650. * The unsigned integer type.
  6651. */
  6652. static readonly UNSIGNED_INT: number;
  6653. /**
  6654. * The float type.
  6655. */
  6656. static readonly FLOAT: number;
  6657. /**
  6658. * Gets or sets the instance divisor when in instanced mode
  6659. */
  6660. get instanceDivisor(): number;
  6661. set instanceDivisor(value: number);
  6662. /**
  6663. * Gets the byte stride.
  6664. */
  6665. readonly byteStride: number;
  6666. /**
  6667. * Gets the byte offset.
  6668. */
  6669. readonly byteOffset: number;
  6670. /**
  6671. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6672. */
  6673. readonly normalized: boolean;
  6674. /**
  6675. * Gets the data type of each component in the array.
  6676. */
  6677. readonly type: number;
  6678. /**
  6679. * Constructor
  6680. * @param engine the engine
  6681. * @param data the data to use for this vertex buffer
  6682. * @param kind the vertex buffer kind
  6683. * @param updatable whether the data is updatable
  6684. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6685. * @param stride the stride (optional)
  6686. * @param instanced whether the buffer is instanced (optional)
  6687. * @param offset the offset of the data (optional)
  6688. * @param size the number of components (optional)
  6689. * @param type the type of the component (optional)
  6690. * @param normalized whether the data contains normalized data (optional)
  6691. * @param useBytes set to true if stride and offset are in bytes (optional)
  6692. * @param divisor defines the instance divisor to use (1 by default)
  6693. */
  6694. 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);
  6695. /** @hidden */
  6696. _rebuild(): void;
  6697. /**
  6698. * Returns the kind of the VertexBuffer (string)
  6699. * @returns a string
  6700. */
  6701. getKind(): string;
  6702. /**
  6703. * Gets a boolean indicating if the VertexBuffer is updatable?
  6704. * @returns true if the buffer is updatable
  6705. */
  6706. isUpdatable(): boolean;
  6707. /**
  6708. * Gets current buffer's data
  6709. * @returns a DataArray or null
  6710. */
  6711. getData(): Nullable<DataArray>;
  6712. /**
  6713. * Gets underlying native buffer
  6714. * @returns underlying native buffer
  6715. */
  6716. getBuffer(): Nullable<DataBuffer>;
  6717. /**
  6718. * Gets the stride in float32 units (i.e. byte stride / 4).
  6719. * May not be an integer if the byte stride is not divisible by 4.
  6720. * @returns the stride in float32 units
  6721. * @deprecated Please use byteStride instead.
  6722. */
  6723. getStrideSize(): number;
  6724. /**
  6725. * Returns the offset as a multiple of the type byte length.
  6726. * @returns the offset in bytes
  6727. * @deprecated Please use byteOffset instead.
  6728. */
  6729. getOffset(): number;
  6730. /**
  6731. * Returns the number of components per vertex attribute (integer)
  6732. * @returns the size in float
  6733. */
  6734. getSize(): number;
  6735. /**
  6736. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6737. * @returns true if this buffer is instanced
  6738. */
  6739. getIsInstanced(): boolean;
  6740. /**
  6741. * Returns the instancing divisor, zero for non-instanced (integer).
  6742. * @returns a number
  6743. */
  6744. getInstanceDivisor(): number;
  6745. /**
  6746. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6747. * @param data defines the data to store
  6748. */
  6749. create(data?: DataArray): void;
  6750. /**
  6751. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6752. * This function will create a new buffer if the current one is not updatable
  6753. * @param data defines the data to store
  6754. */
  6755. update(data: DataArray): void;
  6756. /**
  6757. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6758. * Returns the directly updated WebGLBuffer.
  6759. * @param data the new data
  6760. * @param offset the new offset
  6761. * @param useBytes set to true if the offset is in bytes
  6762. */
  6763. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6764. /**
  6765. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6766. */
  6767. dispose(): void;
  6768. /**
  6769. * Enumerates each value of this vertex buffer as numbers.
  6770. * @param count the number of values to enumerate
  6771. * @param callback the callback function called for each value
  6772. */
  6773. forEach(count: number, callback: (value: number, index: number) => void): void;
  6774. /**
  6775. * Positions
  6776. */
  6777. static readonly PositionKind: string;
  6778. /**
  6779. * Normals
  6780. */
  6781. static readonly NormalKind: string;
  6782. /**
  6783. * Tangents
  6784. */
  6785. static readonly TangentKind: string;
  6786. /**
  6787. * Texture coordinates
  6788. */
  6789. static readonly UVKind: string;
  6790. /**
  6791. * Texture coordinates 2
  6792. */
  6793. static readonly UV2Kind: string;
  6794. /**
  6795. * Texture coordinates 3
  6796. */
  6797. static readonly UV3Kind: string;
  6798. /**
  6799. * Texture coordinates 4
  6800. */
  6801. static readonly UV4Kind: string;
  6802. /**
  6803. * Texture coordinates 5
  6804. */
  6805. static readonly UV5Kind: string;
  6806. /**
  6807. * Texture coordinates 6
  6808. */
  6809. static readonly UV6Kind: string;
  6810. /**
  6811. * Colors
  6812. */
  6813. static readonly ColorKind: string;
  6814. /**
  6815. * Matrix indices (for bones)
  6816. */
  6817. static readonly MatricesIndicesKind: string;
  6818. /**
  6819. * Matrix weights (for bones)
  6820. */
  6821. static readonly MatricesWeightsKind: string;
  6822. /**
  6823. * Additional matrix indices (for bones)
  6824. */
  6825. static readonly MatricesIndicesExtraKind: string;
  6826. /**
  6827. * Additional matrix weights (for bones)
  6828. */
  6829. static readonly MatricesWeightsExtraKind: string;
  6830. /**
  6831. * Deduces the stride given a kind.
  6832. * @param kind The kind string to deduce
  6833. * @returns The deduced stride
  6834. */
  6835. static DeduceStride(kind: string): number;
  6836. /**
  6837. * Gets the byte length of the given type.
  6838. * @param type the type
  6839. * @returns the number of bytes
  6840. */
  6841. static GetTypeByteLength(type: number): number;
  6842. /**
  6843. * Enumerates each value of the given parameters as numbers.
  6844. * @param data the data to enumerate
  6845. * @param byteOffset the byte offset of the data
  6846. * @param byteStride the byte stride of the data
  6847. * @param componentCount the number of components per element
  6848. * @param componentType the type of the component
  6849. * @param count the number of values to enumerate
  6850. * @param normalized whether the data is normalized
  6851. * @param callback the callback function called for each value
  6852. */
  6853. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6854. private static _GetFloatValue;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * The options Interface for creating a Capsule Mesh
  6860. */
  6861. export interface ICreateCapsuleOptions {
  6862. /** The Orientation of the capsule. Default : Vector3.Up() */
  6863. orientation?: Vector3;
  6864. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6865. subdivisions: number;
  6866. /** Number of cylindrical segments on the capsule. */
  6867. tessellation: number;
  6868. /** Height or Length of the capsule. */
  6869. height: number;
  6870. /** Radius of the capsule. */
  6871. radius: number;
  6872. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6873. capSubdivisions: number;
  6874. /** Overwrite for the top radius. */
  6875. radiusTop?: number;
  6876. /** Overwrite for the bottom radius. */
  6877. radiusBottom?: number;
  6878. /** Overwrite for the top capSubdivisions. */
  6879. topCapSubdivisions?: number;
  6880. /** Overwrite for the bottom capSubdivisions. */
  6881. bottomCapSubdivisions?: number;
  6882. }
  6883. /**
  6884. * Class containing static functions to help procedurally build meshes
  6885. */
  6886. export class CapsuleBuilder {
  6887. /**
  6888. * Creates a capsule or a pill mesh
  6889. * @param name defines the name of the mesh
  6890. * @param options The constructors options.
  6891. * @param scene The scene the mesh is scoped to.
  6892. * @returns Capsule Mesh
  6893. */
  6894. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6895. }
  6896. }
  6897. declare module BABYLON {
  6898. /**
  6899. * @hidden
  6900. */
  6901. export class IntersectionInfo {
  6902. bu: Nullable<number>;
  6903. bv: Nullable<number>;
  6904. distance: number;
  6905. faceId: number;
  6906. subMeshId: number;
  6907. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6908. }
  6909. }
  6910. declare module BABYLON {
  6911. /**
  6912. * Class used to store bounding sphere information
  6913. */
  6914. export class BoundingSphere {
  6915. /**
  6916. * Gets the center of the bounding sphere in local space
  6917. */
  6918. readonly center: Vector3;
  6919. /**
  6920. * Radius of the bounding sphere in local space
  6921. */
  6922. radius: number;
  6923. /**
  6924. * Gets the center of the bounding sphere in world space
  6925. */
  6926. readonly centerWorld: Vector3;
  6927. /**
  6928. * Radius of the bounding sphere in world space
  6929. */
  6930. radiusWorld: number;
  6931. /**
  6932. * Gets the minimum vector in local space
  6933. */
  6934. readonly minimum: Vector3;
  6935. /**
  6936. * Gets the maximum vector in local space
  6937. */
  6938. readonly maximum: Vector3;
  6939. private _worldMatrix;
  6940. private static readonly TmpVector3;
  6941. /**
  6942. * Creates a new bounding sphere
  6943. * @param min defines the minimum vector (in local space)
  6944. * @param max defines the maximum vector (in local space)
  6945. * @param worldMatrix defines the new world matrix
  6946. */
  6947. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6948. /**
  6949. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6950. * @param min defines the new minimum vector (in local space)
  6951. * @param max defines the new maximum vector (in local space)
  6952. * @param worldMatrix defines the new world matrix
  6953. */
  6954. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6955. /**
  6956. * Scale the current bounding sphere by applying a scale factor
  6957. * @param factor defines the scale factor to apply
  6958. * @returns the current bounding box
  6959. */
  6960. scale(factor: number): BoundingSphere;
  6961. /**
  6962. * Gets the world matrix of the bounding box
  6963. * @returns a matrix
  6964. */
  6965. getWorldMatrix(): DeepImmutable<Matrix>;
  6966. /** @hidden */
  6967. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6968. /**
  6969. * Tests if the bounding sphere is intersecting the frustum planes
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @returns true if there is an intersection
  6972. */
  6973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. /**
  6975. * Tests if the bounding sphere center is in between the frustum planes.
  6976. * Used for optimistic fast inclusion.
  6977. * @param frustumPlanes defines the frustum planes to test
  6978. * @returns true if the sphere center is in between the frustum planes
  6979. */
  6980. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6981. /**
  6982. * Tests if a point is inside the bounding sphere
  6983. * @param point defines the point to test
  6984. * @returns true if the point is inside the bounding sphere
  6985. */
  6986. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6987. /**
  6988. * Checks if two sphere intersct
  6989. * @param sphere0 sphere 0
  6990. * @param sphere1 sphere 1
  6991. * @returns true if the speres intersect
  6992. */
  6993. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6994. }
  6995. }
  6996. declare module BABYLON {
  6997. /**
  6998. * Class used to store bounding box information
  6999. */
  7000. export class BoundingBox implements ICullable {
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in local space
  7003. */
  7004. readonly vectors: Vector3[];
  7005. /**
  7006. * Gets the center of the bounding box in local space
  7007. */
  7008. readonly center: Vector3;
  7009. /**
  7010. * Gets the center of the bounding box in world space
  7011. */
  7012. readonly centerWorld: Vector3;
  7013. /**
  7014. * Gets the extend size in local space
  7015. */
  7016. readonly extendSize: Vector3;
  7017. /**
  7018. * Gets the extend size in world space
  7019. */
  7020. readonly extendSizeWorld: Vector3;
  7021. /**
  7022. * Gets the OBB (object bounding box) directions
  7023. */
  7024. readonly directions: Vector3[];
  7025. /**
  7026. * Gets the 8 vectors representing the bounding box in world space
  7027. */
  7028. readonly vectorsWorld: Vector3[];
  7029. /**
  7030. * Gets the minimum vector in world space
  7031. */
  7032. readonly minimumWorld: Vector3;
  7033. /**
  7034. * Gets the maximum vector in world space
  7035. */
  7036. readonly maximumWorld: Vector3;
  7037. /**
  7038. * Gets the minimum vector in local space
  7039. */
  7040. readonly minimum: Vector3;
  7041. /**
  7042. * Gets the maximum vector in local space
  7043. */
  7044. readonly maximum: Vector3;
  7045. private _worldMatrix;
  7046. private static readonly TmpVector3;
  7047. /**
  7048. * @hidden
  7049. */
  7050. _tag: number;
  7051. /**
  7052. * Creates a new bounding box
  7053. * @param min defines the minimum vector (in local space)
  7054. * @param max defines the maximum vector (in local space)
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * Scale the current bounding box by applying a scale factor
  7067. * @param factor defines the scale factor to apply
  7068. * @returns the current bounding box
  7069. */
  7070. scale(factor: number): BoundingBox;
  7071. /**
  7072. * Gets the world matrix of the bounding box
  7073. * @returns a matrix
  7074. */
  7075. getWorldMatrix(): DeepImmutable<Matrix>;
  7076. /** @hidden */
  7077. _update(world: DeepImmutable<Matrix>): void;
  7078. /**
  7079. * Tests if the bounding box is intersecting the frustum planes
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @returns true if there is an intersection
  7082. */
  7083. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if the bounding box is entirely inside the frustum planes
  7086. * @param frustumPlanes defines the frustum planes to test
  7087. * @returns true if there is an inclusion
  7088. */
  7089. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7090. /**
  7091. * Tests if a point is inside the bounding box
  7092. * @param point defines the point to test
  7093. * @returns true if the point is inside the bounding box
  7094. */
  7095. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7096. /**
  7097. * Tests if the bounding box intersects with a bounding sphere
  7098. * @param sphere defines the sphere to test
  7099. * @returns true if there is an intersection
  7100. */
  7101. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7102. /**
  7103. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7104. * @param min defines the min vector to use
  7105. * @param max defines the max vector to use
  7106. * @returns true if there is an intersection
  7107. */
  7108. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7109. /**
  7110. * Tests if two bounding boxes are intersections
  7111. * @param box0 defines the first box to test
  7112. * @param box1 defines the second box to test
  7113. * @returns true if there is an intersection
  7114. */
  7115. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7116. /**
  7117. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7118. * @param minPoint defines the minimum vector of the bounding box
  7119. * @param maxPoint defines the maximum vector of the bounding box
  7120. * @param sphereCenter defines the sphere center
  7121. * @param sphereRadius defines the sphere radius
  7122. * @returns true if there is an intersection
  7123. */
  7124. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7125. /**
  7126. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7127. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7128. * @param frustumPlanes defines the frustum planes to test
  7129. * @return true if there is an inclusion
  7130. */
  7131. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7132. /**
  7133. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @return true if there is an intersection
  7137. */
  7138. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class Collider {
  7144. /** Define if a collision was found */
  7145. collisionFound: boolean;
  7146. /**
  7147. * Define last intersection point in local space
  7148. */
  7149. intersectionPoint: Vector3;
  7150. /**
  7151. * Define last collided mesh
  7152. */
  7153. collidedMesh: Nullable<AbstractMesh>;
  7154. private _collisionPoint;
  7155. private _planeIntersectionPoint;
  7156. private _tempVector;
  7157. private _tempVector2;
  7158. private _tempVector3;
  7159. private _tempVector4;
  7160. private _edge;
  7161. private _baseToVertex;
  7162. private _destinationPoint;
  7163. private _slidePlaneNormal;
  7164. private _displacementVector;
  7165. /** @hidden */
  7166. _radius: Vector3;
  7167. /** @hidden */
  7168. _retry: number;
  7169. private _velocity;
  7170. private _basePoint;
  7171. private _epsilon;
  7172. /** @hidden */
  7173. _velocityWorldLength: number;
  7174. /** @hidden */
  7175. _basePointWorld: Vector3;
  7176. private _velocityWorld;
  7177. private _normalizedVelocity;
  7178. /** @hidden */
  7179. _initialVelocity: Vector3;
  7180. /** @hidden */
  7181. _initialPosition: Vector3;
  7182. private _nearestDistance;
  7183. private _collisionMask;
  7184. get collisionMask(): number;
  7185. set collisionMask(mask: number);
  7186. /**
  7187. * Gets the plane normal used to compute the sliding response (in local space)
  7188. */
  7189. get slidePlaneNormal(): Vector3;
  7190. /** @hidden */
  7191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7192. /** @hidden */
  7193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7194. /** @hidden */
  7195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7196. /** @hidden */
  7197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7200. /** @hidden */
  7201. _getResponse(pos: Vector3, vel: Vector3): void;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Interface for cullable objects
  7207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7208. */
  7209. export interface ICullable {
  7210. /**
  7211. * Checks if the object or part of the object is in the frustum
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isInFrustum(frustumPlanes: Plane[]): boolean;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7223. }
  7224. /**
  7225. * Info for a bounding data of a mesh
  7226. */
  7227. export class BoundingInfo implements ICullable {
  7228. /**
  7229. * Bounding box for the mesh
  7230. */
  7231. readonly boundingBox: BoundingBox;
  7232. /**
  7233. * Bounding sphere for the mesh
  7234. */
  7235. readonly boundingSphere: BoundingSphere;
  7236. private _isLocked;
  7237. private static readonly TmpVector3;
  7238. /**
  7239. * Constructs bounding info
  7240. * @param minimum min vector of the bounding box/sphere
  7241. * @param maximum max vector of the bounding box/sphere
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7245. /**
  7246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7247. * @param min defines the new minimum vector (in local space)
  7248. * @param max defines the new maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * min vector of the bounding box/sphere
  7254. */
  7255. get minimum(): Vector3;
  7256. /**
  7257. * max vector of the bounding box/sphere
  7258. */
  7259. get maximum(): Vector3;
  7260. /**
  7261. * If the info is locked and won't be updated to avoid perf overhead
  7262. */
  7263. get isLocked(): boolean;
  7264. set isLocked(value: boolean);
  7265. /**
  7266. * Updates the bounding sphere and box
  7267. * @param world world matrix to be used to update
  7268. */
  7269. update(world: DeepImmutable<Matrix>): void;
  7270. /**
  7271. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7272. * @param center New center of the bounding info
  7273. * @param extend New extend of the bounding info
  7274. * @returns the current bounding info
  7275. */
  7276. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7277. /**
  7278. * Scale the current bounding info by applying a scale factor
  7279. * @param factor defines the scale factor to apply
  7280. * @returns the current bounding info
  7281. */
  7282. scale(factor: number): BoundingInfo;
  7283. /**
  7284. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7285. * @param frustumPlanes defines the frustum to test
  7286. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7287. * @returns true if the bounding info is in the frustum planes
  7288. */
  7289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7290. /**
  7291. * Gets the world distance between the min and max points of the bounding box
  7292. */
  7293. get diagonalLength(): number;
  7294. /**
  7295. * Checks if a cullable object (mesh...) is in the camera frustum
  7296. * Unlike isInFrustum this cheks the full bounding box
  7297. * @param frustumPlanes Camera near/planes
  7298. * @returns true if the object is in frustum otherwise false
  7299. */
  7300. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7301. /** @hidden */
  7302. _checkCollision(collider: Collider): boolean;
  7303. /**
  7304. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7305. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7306. * @param point the point to check intersection with
  7307. * @returns if the point intersects
  7308. */
  7309. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7310. /**
  7311. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7313. * @param boundingInfo the bounding info to check intersection with
  7314. * @param precise if the intersection should be done using OBB
  7315. * @returns if the bounding info intersects
  7316. */
  7317. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Extracts minimum and maximum values from a list of indexed positions
  7323. * @param positions defines the positions to use
  7324. * @param indices defines the indices to the positions
  7325. * @param indexStart defines the start index
  7326. * @param indexCount defines the end index
  7327. * @param bias defines bias value to add to the result
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. /**
  7335. * Extracts minimum and maximum values from a list of positions
  7336. * @param positions defines the positions to use
  7337. * @param start defines the start index in the positions array
  7338. * @param count defines the number of positions to handle
  7339. * @param bias defines bias value to add to the result
  7340. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7341. * @return minimum and maximum values
  7342. */
  7343. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7344. minimum: Vector3;
  7345. maximum: Vector3;
  7346. };
  7347. }
  7348. declare module BABYLON {
  7349. /** @hidden */
  7350. export class WebGLDataBuffer extends DataBuffer {
  7351. private _buffer;
  7352. constructor(resource: WebGLBuffer);
  7353. get underlyingResource(): any;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. /** @hidden */
  7358. export class WebGLPipelineContext implements IPipelineContext {
  7359. engine: ThinEngine;
  7360. program: Nullable<WebGLProgram>;
  7361. context?: WebGLRenderingContext;
  7362. vertexShader?: WebGLShader;
  7363. fragmentShader?: WebGLShader;
  7364. isParallelCompiled: boolean;
  7365. onCompiled?: () => void;
  7366. transformFeedback?: WebGLTransformFeedback | null;
  7367. vertexCompilationError: Nullable<string>;
  7368. fragmentCompilationError: Nullable<string>;
  7369. programLinkError: Nullable<string>;
  7370. programValidationError: Nullable<string>;
  7371. get isAsync(): boolean;
  7372. get isReady(): boolean;
  7373. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7374. _getVertexShaderCode(): string | null;
  7375. _getFragmentShaderCode(): string | null;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. interface ThinEngine {
  7380. /**
  7381. * Create an uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Create a dynamic uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param elements defines the content of the uniform buffer
  7391. * @returns the webGL uniform buffer
  7392. */
  7393. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7394. /**
  7395. * Update an existing uniform buffer
  7396. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7397. * @param uniformBuffer defines the target uniform buffer
  7398. * @param elements defines the content to update
  7399. * @param offset defines the offset in the uniform buffer where update should start
  7400. * @param count defines the size of the data to update
  7401. */
  7402. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7403. /**
  7404. * Bind an uniform buffer to the current webGL context
  7405. * @param buffer defines the buffer to bind
  7406. */
  7407. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7408. /**
  7409. * Bind a buffer to the current webGL context at a given location
  7410. * @param buffer defines the buffer to bind
  7411. * @param location defines the index where to bind the buffer
  7412. */
  7413. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7414. /**
  7415. * Bind a specific block at a given index in a specific shader program
  7416. * @param pipelineContext defines the pipeline context to use
  7417. * @param blockName defines the block name
  7418. * @param index defines the index where to bind the block
  7419. */
  7420. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7421. }
  7422. }
  7423. declare module BABYLON {
  7424. /**
  7425. * Uniform buffer objects.
  7426. *
  7427. * Handles blocks of uniform on the GPU.
  7428. *
  7429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7430. *
  7431. * For more information, please refer to :
  7432. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7433. */
  7434. export class UniformBuffer {
  7435. private _engine;
  7436. private _buffer;
  7437. private _data;
  7438. private _bufferData;
  7439. private _dynamic?;
  7440. private _uniformLocations;
  7441. private _uniformSizes;
  7442. private _uniformLocationPointer;
  7443. private _needSync;
  7444. private _noUBO;
  7445. private _currentEffect;
  7446. /** @hidden */
  7447. _alreadyBound: boolean;
  7448. private static _MAX_UNIFORM_SIZE;
  7449. private static _tempBuffer;
  7450. /**
  7451. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7456. /**
  7457. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7462. /**
  7463. * Lambda to Update a single 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. updateFloat: (name: string, x: number) => void;
  7468. /**
  7469. * Lambda to Update a vec2 of float 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. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7474. /**
  7475. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7480. /**
  7481. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7486. /**
  7487. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7492. /**
  7493. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7498. /**
  7499. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7500. * This is dynamic to allow compat with webgl 1 and 2.
  7501. * You will need to pass the name of the uniform as well as the value.
  7502. */
  7503. updateVector4: (name: string, vector: Vector4) => void;
  7504. /**
  7505. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7506. * This is dynamic to allow compat with webgl 1 and 2.
  7507. * You will need to pass the name of the uniform as well as the value.
  7508. */
  7509. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7510. /**
  7511. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7512. * This is dynamic to allow compat with webgl 1 and 2.
  7513. * You will need to pass the name of the uniform as well as the value.
  7514. */
  7515. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7516. /**
  7517. * Instantiates a new Uniform buffer objects.
  7518. *
  7519. * Handles blocks of uniform on the GPU.
  7520. *
  7521. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7522. *
  7523. * For more information, please refer to :
  7524. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7525. * @param engine Define the engine the buffer is associated with
  7526. * @param data Define the data contained in the buffer
  7527. * @param dynamic Define if the buffer is updatable
  7528. */
  7529. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7530. /**
  7531. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7532. * or just falling back on setUniformXXX calls.
  7533. */
  7534. get useUbo(): boolean;
  7535. /**
  7536. * Indicates if the WebGL underlying uniform buffer is in sync
  7537. * with the javascript cache data.
  7538. */
  7539. get isSync(): boolean;
  7540. /**
  7541. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7542. * Also, a dynamic UniformBuffer will disable cache verification and always
  7543. * update the underlying WebGL uniform buffer to the GPU.
  7544. * @returns if Dynamic, otherwise false
  7545. */
  7546. isDynamic(): boolean;
  7547. /**
  7548. * The data cache on JS side.
  7549. * @returns the underlying data as a float array
  7550. */
  7551. getData(): Float32Array;
  7552. /**
  7553. * The underlying WebGL Uniform buffer.
  7554. * @returns the webgl buffer
  7555. */
  7556. getBuffer(): Nullable<DataBuffer>;
  7557. /**
  7558. * std140 layout specifies how to align data within an UBO structure.
  7559. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7560. * for specs.
  7561. */
  7562. private _fillAlignment;
  7563. /**
  7564. * Adds an uniform in the buffer.
  7565. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7566. * for the layout to be correct !
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param size Data size, or data directly.
  7569. */
  7570. addUniform(name: string, size: number | number[]): void;
  7571. /**
  7572. * Adds a Matrix 4x4 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. * @param mat A 4x4 matrix.
  7575. */
  7576. addMatrix(name: string, mat: Matrix): void;
  7577. /**
  7578. * Adds a vec2 to the uniform buffer.
  7579. * @param name Name of the uniform, as used in the uniform block in the shader.
  7580. * @param x Define the x component value of the vec2
  7581. * @param y Define the y component value of the vec2
  7582. */
  7583. addFloat2(name: string, x: number, y: number): void;
  7584. /**
  7585. * Adds a vec3 to the uniform buffer.
  7586. * @param name Name of the uniform, as used in the uniform block in the shader.
  7587. * @param x Define the x component value of the vec3
  7588. * @param y Define the y component value of the vec3
  7589. * @param z Define the z component value of the vec3
  7590. */
  7591. addFloat3(name: string, x: number, y: number, z: number): void;
  7592. /**
  7593. * Adds a vec3 to the uniform buffer.
  7594. * @param name Name of the uniform, as used in the uniform block in the shader.
  7595. * @param color Define the vec3 from a Color
  7596. */
  7597. addColor3(name: string, color: Color3): void;
  7598. /**
  7599. * Adds a vec4 to the uniform buffer.
  7600. * @param name Name of the uniform, as used in the uniform block in the shader.
  7601. * @param color Define the rgb components from a Color
  7602. * @param alpha Define the a component of the vec4
  7603. */
  7604. addColor4(name: string, color: Color3, alpha: number): void;
  7605. /**
  7606. * Adds a vec3 to the uniform buffer.
  7607. * @param name Name of the uniform, as used in the uniform block in the shader.
  7608. * @param vector Define the vec3 components from a Vector
  7609. */
  7610. addVector3(name: string, vector: Vector3): void;
  7611. /**
  7612. * Adds a Matrix 3x3 to the uniform buffer.
  7613. * @param name Name of the uniform, as used in the uniform block in the shader.
  7614. */
  7615. addMatrix3x3(name: string): void;
  7616. /**
  7617. * Adds a Matrix 2x2 to the uniform buffer.
  7618. * @param name Name of the uniform, as used in the uniform block in the shader.
  7619. */
  7620. addMatrix2x2(name: string): void;
  7621. /**
  7622. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7623. */
  7624. create(): void;
  7625. /** @hidden */
  7626. _rebuild(): void;
  7627. /**
  7628. * Updates the WebGL Uniform Buffer on the GPU.
  7629. * If the `dynamic` flag is set to true, no cache comparison is done.
  7630. * Otherwise, the buffer will be updated only if the cache differs.
  7631. */
  7632. update(): void;
  7633. /**
  7634. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7635. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7636. * @param data Define the flattened data
  7637. * @param size Define the size of the data.
  7638. */
  7639. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7640. private _valueCache;
  7641. private _cacheMatrix;
  7642. private _updateMatrix3x3ForUniform;
  7643. private _updateMatrix3x3ForEffect;
  7644. private _updateMatrix2x2ForEffect;
  7645. private _updateMatrix2x2ForUniform;
  7646. private _updateFloatForEffect;
  7647. private _updateFloatForUniform;
  7648. private _updateFloat2ForEffect;
  7649. private _updateFloat2ForUniform;
  7650. private _updateFloat3ForEffect;
  7651. private _updateFloat3ForUniform;
  7652. private _updateFloat4ForEffect;
  7653. private _updateFloat4ForUniform;
  7654. private _updateMatrixForEffect;
  7655. private _updateMatrixForUniform;
  7656. private _updateVector3ForEffect;
  7657. private _updateVector3ForUniform;
  7658. private _updateVector4ForEffect;
  7659. private _updateVector4ForUniform;
  7660. private _updateColor3ForEffect;
  7661. private _updateColor3ForUniform;
  7662. private _updateColor4ForEffect;
  7663. private _updateColor4ForUniform;
  7664. /**
  7665. * Sets a sampler uniform on the effect.
  7666. * @param name Define the name of the sampler.
  7667. * @param texture Define the texture to set in the sampler
  7668. */
  7669. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7670. /**
  7671. * Directly updates the value of the uniform in the cache AND on the GPU.
  7672. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7673. * @param data Define the flattened data
  7674. */
  7675. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7676. /**
  7677. * Binds this uniform buffer to an effect.
  7678. * @param effect Define the effect to bind the buffer to
  7679. * @param name Name of the uniform block in the shader.
  7680. */
  7681. bindToEffect(effect: Effect, name: string): void;
  7682. /**
  7683. * Disposes the uniform buffer.
  7684. */
  7685. dispose(): void;
  7686. }
  7687. }
  7688. declare module BABYLON {
  7689. /**
  7690. * Enum that determines the text-wrapping mode to use.
  7691. */
  7692. export enum InspectableType {
  7693. /**
  7694. * Checkbox for booleans
  7695. */
  7696. Checkbox = 0,
  7697. /**
  7698. * Sliders for numbers
  7699. */
  7700. Slider = 1,
  7701. /**
  7702. * Vector3
  7703. */
  7704. Vector3 = 2,
  7705. /**
  7706. * Quaternions
  7707. */
  7708. Quaternion = 3,
  7709. /**
  7710. * Color3
  7711. */
  7712. Color3 = 4,
  7713. /**
  7714. * String
  7715. */
  7716. String = 5
  7717. }
  7718. /**
  7719. * Interface used to define custom inspectable properties.
  7720. * This interface is used by the inspector to display custom property grids
  7721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7722. */
  7723. export interface IInspectable {
  7724. /**
  7725. * Gets the label to display
  7726. */
  7727. label: string;
  7728. /**
  7729. * Gets the name of the property to edit
  7730. */
  7731. propertyName: string;
  7732. /**
  7733. * Gets the type of the editor to use
  7734. */
  7735. type: InspectableType;
  7736. /**
  7737. * Gets the minimum value of the property when using in "slider" mode
  7738. */
  7739. min?: number;
  7740. /**
  7741. * Gets the maximum value of the property when using in "slider" mode
  7742. */
  7743. max?: number;
  7744. /**
  7745. * Gets the setp to use when using in "slider" mode
  7746. */
  7747. step?: number;
  7748. }
  7749. }
  7750. declare module BABYLON {
  7751. /**
  7752. * Class used to provide helper for timing
  7753. */
  7754. export class TimingTools {
  7755. /**
  7756. * Polyfill for setImmediate
  7757. * @param action defines the action to execute after the current execution block
  7758. */
  7759. static SetImmediate(action: () => void): void;
  7760. }
  7761. }
  7762. declare module BABYLON {
  7763. /**
  7764. * Class used to enable instatition of objects by class name
  7765. */
  7766. export class InstantiationTools {
  7767. /**
  7768. * Use this object to register external classes like custom textures or material
  7769. * to allow the laoders to instantiate them
  7770. */
  7771. static RegisteredExternalClasses: {
  7772. [key: string]: Object;
  7773. };
  7774. /**
  7775. * Tries to instantiate a new object from a given class name
  7776. * @param className defines the class name to instantiate
  7777. * @returns the new object or null if the system was not able to do the instantiation
  7778. */
  7779. static Instantiate(className: string): any;
  7780. }
  7781. }
  7782. declare module BABYLON {
  7783. /**
  7784. * Define options used to create a depth texture
  7785. */
  7786. export class DepthTextureCreationOptions {
  7787. /** Specifies whether or not a stencil should be allocated in the texture */
  7788. generateStencil?: boolean;
  7789. /** Specifies whether or not bilinear filtering is enable on the texture */
  7790. bilinearFiltering?: boolean;
  7791. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7792. comparisonFunction?: number;
  7793. /** Specifies if the created texture is a cube texture */
  7794. isCube?: boolean;
  7795. }
  7796. }
  7797. declare module BABYLON {
  7798. interface ThinEngine {
  7799. /**
  7800. * Creates a depth stencil cube texture.
  7801. * This is only available in WebGL 2.
  7802. * @param size The size of face edge in the cube texture.
  7803. * @param options The options defining the cube texture.
  7804. * @returns The cube texture
  7805. */
  7806. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7807. /**
  7808. * Creates a cube texture
  7809. * @param rootUrl defines the url where the files to load is located
  7810. * @param scene defines the current scene
  7811. * @param files defines the list of files to load (1 per face)
  7812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7813. * @param onLoad defines an optional callback raised when the texture is loaded
  7814. * @param onError defines an optional callback raised if there is an issue to load the texture
  7815. * @param format defines the format of the data
  7816. * @param forcedExtension defines the extension to use to pick the right loader
  7817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7820. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7821. * @param loaderOptions options to be passed to the loader
  7822. * @returns the cube texture as an InternalTexture
  7823. */
  7824. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7825. /**
  7826. * Creates a cube texture
  7827. * @param rootUrl defines the url where the files to load is located
  7828. * @param scene defines the current scene
  7829. * @param files defines the list of files to load (1 per face)
  7830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7831. * @param onLoad defines an optional callback raised when the texture is loaded
  7832. * @param onError defines an optional callback raised if there is an issue to load the texture
  7833. * @param format defines the format of the data
  7834. * @param forcedExtension defines the extension to use to pick the right loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. 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;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7851. * @returns the cube texture as an InternalTexture
  7852. */
  7853. 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;
  7854. /** @hidden */
  7855. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7856. /** @hidden */
  7857. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7858. /** @hidden */
  7859. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7860. /** @hidden */
  7861. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7862. /**
  7863. * @hidden
  7864. */
  7865. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7866. }
  7867. }
  7868. declare module BABYLON {
  7869. /**
  7870. * Class for creating a cube texture
  7871. */
  7872. export class CubeTexture extends BaseTexture {
  7873. private _delayedOnLoad;
  7874. /**
  7875. * Observable triggered once the texture has been loaded.
  7876. */
  7877. onLoadObservable: Observable<CubeTexture>;
  7878. /**
  7879. * The url of the texture
  7880. */
  7881. url: string;
  7882. /**
  7883. * Gets or sets the center of the bounding box associated with the cube texture.
  7884. * It must define where the camera used to render the texture was set
  7885. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7886. */
  7887. boundingBoxPosition: Vector3;
  7888. private _boundingBoxSize;
  7889. /**
  7890. * Gets or sets the size of the bounding box associated with the cube texture
  7891. * When defined, the cubemap will switch to local mode
  7892. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7893. * @example https://www.babylonjs-playground.com/#RNASML
  7894. */
  7895. set boundingBoxSize(value: Vector3);
  7896. /**
  7897. * Returns the bounding box size
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. get boundingBoxSize(): Vector3;
  7901. protected _rotationY: number;
  7902. /**
  7903. * Sets texture matrix rotation angle around Y axis in radians.
  7904. */
  7905. set rotationY(value: number);
  7906. /**
  7907. * Gets texture matrix rotation angle around Y axis radians.
  7908. */
  7909. get rotationY(): number;
  7910. /**
  7911. * Are mip maps generated for this texture or not.
  7912. */
  7913. get noMipmap(): boolean;
  7914. private _noMipmap;
  7915. private _files;
  7916. protected _forcedExtension: Nullable<string>;
  7917. private _extensions;
  7918. private _textureMatrix;
  7919. private _format;
  7920. private _createPolynomials;
  7921. private _loaderOptions;
  7922. /**
  7923. * Creates a cube texture from an array of image urls
  7924. * @param files defines an array of image urls
  7925. * @param scene defines the hosting scene
  7926. * @param noMipmap specifies if mip maps are not used
  7927. * @returns a cube texture
  7928. */
  7929. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7930. /**
  7931. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7932. * @param url defines the url of the prefiltered texture
  7933. * @param scene defines the scene the texture is attached to
  7934. * @param forcedExtension defines the extension of the file if different from the url
  7935. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7936. * @return the prefiltered texture
  7937. */
  7938. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7939. /**
  7940. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7941. * as prefiltered data.
  7942. * @param rootUrl defines the url of the texture or the root name of the six images
  7943. * @param null defines the scene or engine the texture is attached to
  7944. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7945. * @param noMipmap defines if mipmaps should be created or not
  7946. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7947. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7948. * @param onError defines a callback triggered in case of error during load
  7949. * @param format defines the internal format to use for the texture once loaded
  7950. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7951. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7952. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7955. * @param loaderOptions options to be passed to the loader
  7956. * @return the cube texture
  7957. */
  7958. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7959. /**
  7960. * Get the current class name of the texture useful for serialization or dynamic coding.
  7961. * @returns "CubeTexture"
  7962. */
  7963. getClassName(): string;
  7964. /**
  7965. * Update the url (and optional buffer) of this texture if url was null during construction.
  7966. * @param url the url of the texture
  7967. * @param forcedExtension defines the extension to use
  7968. * @param onLoad callback called when the texture is loaded (defaults to null)
  7969. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7970. */
  7971. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7972. /**
  7973. * Delays loading of the cube texture
  7974. * @param forcedExtension defines the extension to use
  7975. */
  7976. delayLoad(forcedExtension?: string): void;
  7977. /**
  7978. * Returns the reflection texture matrix
  7979. * @returns the reflection texture matrix
  7980. */
  7981. getReflectionTextureMatrix(): Matrix;
  7982. /**
  7983. * Sets the reflection texture matrix
  7984. * @param value Reflection texture matrix
  7985. */
  7986. setReflectionTextureMatrix(value: Matrix): void;
  7987. /**
  7988. * Parses text to create a cube texture
  7989. * @param parsedTexture define the serialized text to read from
  7990. * @param scene defines the hosting scene
  7991. * @param rootUrl defines the root url of the cube texture
  7992. * @returns a cube texture
  7993. */
  7994. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7995. /**
  7996. * Makes a clone, or deep copy, of the cube texture
  7997. * @returns a new cube texture
  7998. */
  7999. clone(): CubeTexture;
  8000. }
  8001. }
  8002. declare module BABYLON {
  8003. /**
  8004. * Manages the defines for the Material
  8005. */
  8006. export class MaterialDefines {
  8007. /** @hidden */
  8008. protected _keys: string[];
  8009. private _isDirty;
  8010. /** @hidden */
  8011. _renderId: number;
  8012. /** @hidden */
  8013. _areLightsDirty: boolean;
  8014. /** @hidden */
  8015. _areLightsDisposed: boolean;
  8016. /** @hidden */
  8017. _areAttributesDirty: boolean;
  8018. /** @hidden */
  8019. _areTexturesDirty: boolean;
  8020. /** @hidden */
  8021. _areFresnelDirty: boolean;
  8022. /** @hidden */
  8023. _areMiscDirty: boolean;
  8024. /** @hidden */
  8025. _arePrePassDirty: boolean;
  8026. /** @hidden */
  8027. _areImageProcessingDirty: boolean;
  8028. /** @hidden */
  8029. _normals: boolean;
  8030. /** @hidden */
  8031. _uvs: boolean;
  8032. /** @hidden */
  8033. _needNormals: boolean;
  8034. /** @hidden */
  8035. _needUVs: boolean;
  8036. [id: string]: any;
  8037. /**
  8038. * Specifies if the material needs to be re-calculated
  8039. */
  8040. get isDirty(): boolean;
  8041. /**
  8042. * Marks the material to indicate that it has been re-calculated
  8043. */
  8044. markAsProcessed(): void;
  8045. /**
  8046. * Marks the material to indicate that it needs to be re-calculated
  8047. */
  8048. markAsUnprocessed(): void;
  8049. /**
  8050. * Marks the material to indicate all of its defines need to be re-calculated
  8051. */
  8052. markAllAsDirty(): void;
  8053. /**
  8054. * Marks the material to indicate that image processing needs to be re-calculated
  8055. */
  8056. markAsImageProcessingDirty(): void;
  8057. /**
  8058. * Marks the material to indicate the lights need to be re-calculated
  8059. * @param disposed Defines whether the light is dirty due to dispose or not
  8060. */
  8061. markAsLightDirty(disposed?: boolean): void;
  8062. /**
  8063. * Marks the attribute state as changed
  8064. */
  8065. markAsAttributesDirty(): void;
  8066. /**
  8067. * Marks the texture state as changed
  8068. */
  8069. markAsTexturesDirty(): void;
  8070. /**
  8071. * Marks the fresnel state as changed
  8072. */
  8073. markAsFresnelDirty(): void;
  8074. /**
  8075. * Marks the misc state as changed
  8076. */
  8077. markAsMiscDirty(): void;
  8078. /**
  8079. * Marks the prepass state as changed
  8080. */
  8081. markAsPrePassDirty(): void;
  8082. /**
  8083. * Rebuilds the material defines
  8084. */
  8085. rebuild(): void;
  8086. /**
  8087. * Specifies if two material defines are equal
  8088. * @param other - A material define instance to compare to
  8089. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8090. */
  8091. isEqual(other: MaterialDefines): boolean;
  8092. /**
  8093. * Clones this instance's defines to another instance
  8094. * @param other - material defines to clone values to
  8095. */
  8096. cloneTo(other: MaterialDefines): void;
  8097. /**
  8098. * Resets the material define values
  8099. */
  8100. reset(): void;
  8101. /**
  8102. * Converts the material define values to a string
  8103. * @returns - String of material define information
  8104. */
  8105. toString(): string;
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. /**
  8110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8112. * 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;
  8113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8114. */
  8115. export class ColorCurves {
  8116. private _dirty;
  8117. private _tempColor;
  8118. private _globalCurve;
  8119. private _highlightsCurve;
  8120. private _midtonesCurve;
  8121. private _shadowsCurve;
  8122. private _positiveCurve;
  8123. private _negativeCurve;
  8124. private _globalHue;
  8125. private _globalDensity;
  8126. private _globalSaturation;
  8127. private _globalExposure;
  8128. /**
  8129. * Gets the global Hue value.
  8130. * 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).
  8131. */
  8132. get globalHue(): number;
  8133. /**
  8134. * Sets the global Hue value.
  8135. * 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).
  8136. */
  8137. set globalHue(value: number);
  8138. /**
  8139. * Gets the global Density value.
  8140. * 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.
  8141. * Values less than zero provide a filter of opposite hue.
  8142. */
  8143. get globalDensity(): number;
  8144. /**
  8145. * Sets the global Density value.
  8146. * 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.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. set globalDensity(value: number);
  8150. /**
  8151. * Gets the global Saturation value.
  8152. * 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.
  8153. */
  8154. get globalSaturation(): number;
  8155. /**
  8156. * Sets the global Saturation value.
  8157. * 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.
  8158. */
  8159. set globalSaturation(value: number);
  8160. /**
  8161. * Gets the global Exposure value.
  8162. * 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.
  8163. */
  8164. get globalExposure(): number;
  8165. /**
  8166. * Sets the global Exposure value.
  8167. * 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.
  8168. */
  8169. set globalExposure(value: number);
  8170. private _highlightsHue;
  8171. private _highlightsDensity;
  8172. private _highlightsSaturation;
  8173. private _highlightsExposure;
  8174. /**
  8175. * Gets the highlights Hue value.
  8176. * 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).
  8177. */
  8178. get highlightsHue(): number;
  8179. /**
  8180. * Sets the highlights Hue value.
  8181. * 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).
  8182. */
  8183. set highlightsHue(value: number);
  8184. /**
  8185. * Gets the highlights Density value.
  8186. * 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.
  8187. * Values less than zero provide a filter of opposite hue.
  8188. */
  8189. get highlightsDensity(): number;
  8190. /**
  8191. * Sets the highlights Density value.
  8192. * 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.
  8193. * Values less than zero provide a filter of opposite hue.
  8194. */
  8195. set highlightsDensity(value: number);
  8196. /**
  8197. * Gets the highlights Saturation value.
  8198. * 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.
  8199. */
  8200. get highlightsSaturation(): number;
  8201. /**
  8202. * Sets the highlights Saturation value.
  8203. * 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.
  8204. */
  8205. set highlightsSaturation(value: number);
  8206. /**
  8207. * Gets the highlights Exposure value.
  8208. * 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.
  8209. */
  8210. get highlightsExposure(): number;
  8211. /**
  8212. * Sets the highlights Exposure value.
  8213. * 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.
  8214. */
  8215. set highlightsExposure(value: number);
  8216. private _midtonesHue;
  8217. private _midtonesDensity;
  8218. private _midtonesSaturation;
  8219. private _midtonesExposure;
  8220. /**
  8221. * Gets the midtones Hue value.
  8222. * 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).
  8223. */
  8224. get midtonesHue(): number;
  8225. /**
  8226. * Sets the midtones Hue value.
  8227. * 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).
  8228. */
  8229. set midtonesHue(value: number);
  8230. /**
  8231. * Gets the midtones Density value.
  8232. * 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.
  8233. * Values less than zero provide a filter of opposite hue.
  8234. */
  8235. get midtonesDensity(): number;
  8236. /**
  8237. * Sets the midtones Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. set midtonesDensity(value: number);
  8242. /**
  8243. * Gets the midtones Saturation value.
  8244. * 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.
  8245. */
  8246. get midtonesSaturation(): number;
  8247. /**
  8248. * Sets the midtones Saturation value.
  8249. * 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.
  8250. */
  8251. set midtonesSaturation(value: number);
  8252. /**
  8253. * Gets the midtones Exposure value.
  8254. * 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.
  8255. */
  8256. get midtonesExposure(): number;
  8257. /**
  8258. * Sets the midtones Exposure value.
  8259. * 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.
  8260. */
  8261. set midtonesExposure(value: number);
  8262. private _shadowsHue;
  8263. private _shadowsDensity;
  8264. private _shadowsSaturation;
  8265. private _shadowsExposure;
  8266. /**
  8267. * Gets the shadows Hue value.
  8268. * 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).
  8269. */
  8270. get shadowsHue(): number;
  8271. /**
  8272. * Sets the shadows Hue value.
  8273. * 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).
  8274. */
  8275. set shadowsHue(value: number);
  8276. /**
  8277. * Gets the shadows Density value.
  8278. * 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.
  8279. * Values less than zero provide a filter of opposite hue.
  8280. */
  8281. get shadowsDensity(): number;
  8282. /**
  8283. * Sets the shadows Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. set shadowsDensity(value: number);
  8288. /**
  8289. * Gets the shadows Saturation value.
  8290. * 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.
  8291. */
  8292. get shadowsSaturation(): number;
  8293. /**
  8294. * Sets the shadows Saturation value.
  8295. * 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.
  8296. */
  8297. set shadowsSaturation(value: number);
  8298. /**
  8299. * Gets the shadows Exposure value.
  8300. * 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.
  8301. */
  8302. get shadowsExposure(): number;
  8303. /**
  8304. * Sets the shadows Exposure value.
  8305. * 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.
  8306. */
  8307. set shadowsExposure(value: number);
  8308. /**
  8309. * Returns the class name
  8310. * @returns The class name
  8311. */
  8312. getClassName(): string;
  8313. /**
  8314. * Binds the color curves to the shader.
  8315. * @param colorCurves The color curve to bind
  8316. * @param effect The effect to bind to
  8317. * @param positiveUniform The positive uniform shader parameter
  8318. * @param neutralUniform The neutral uniform shader parameter
  8319. * @param negativeUniform The negative uniform shader parameter
  8320. */
  8321. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8322. /**
  8323. * Prepare the list of uniforms associated with the ColorCurves effects.
  8324. * @param uniformsList The list of uniforms used in the effect
  8325. */
  8326. static PrepareUniforms(uniformsList: string[]): void;
  8327. /**
  8328. * Returns color grading data based on a hue, density, saturation and exposure value.
  8329. * @param filterHue The hue of the color filter.
  8330. * @param filterDensity The density of the color filter.
  8331. * @param saturation The saturation.
  8332. * @param exposure The exposure.
  8333. * @param result The result data container.
  8334. */
  8335. private getColorGradingDataToRef;
  8336. /**
  8337. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8338. * @param value The input slider value in range [-100,100].
  8339. * @returns Adjusted value.
  8340. */
  8341. private static applyColorGradingSliderNonlinear;
  8342. /**
  8343. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8344. * @param hue The hue (H) input.
  8345. * @param saturation The saturation (S) input.
  8346. * @param brightness The brightness (B) input.
  8347. * @result An RGBA color represented as Vector4.
  8348. */
  8349. private static fromHSBToRef;
  8350. /**
  8351. * Returns a value clamped between min and max
  8352. * @param value The value to clamp
  8353. * @param min The minimum of value
  8354. * @param max The maximum of value
  8355. * @returns The clamped value.
  8356. */
  8357. private static clamp;
  8358. /**
  8359. * Clones the current color curve instance.
  8360. * @return The cloned curves
  8361. */
  8362. clone(): ColorCurves;
  8363. /**
  8364. * Serializes the current color curve instance to a json representation.
  8365. * @return a JSON representation
  8366. */
  8367. serialize(): any;
  8368. /**
  8369. * Parses the color curve from a json representation.
  8370. * @param source the JSON source to parse
  8371. * @return The parsed curves
  8372. */
  8373. static Parse(source: any): ColorCurves;
  8374. }
  8375. }
  8376. declare module BABYLON {
  8377. /**
  8378. * Interface to follow in your material defines to integrate easily the
  8379. * Image proccessing functions.
  8380. * @hidden
  8381. */
  8382. export interface IImageProcessingConfigurationDefines {
  8383. IMAGEPROCESSING: boolean;
  8384. VIGNETTE: boolean;
  8385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8386. VIGNETTEBLENDMODEOPAQUE: boolean;
  8387. TONEMAPPING: boolean;
  8388. TONEMAPPING_ACES: boolean;
  8389. CONTRAST: boolean;
  8390. EXPOSURE: boolean;
  8391. COLORCURVES: boolean;
  8392. COLORGRADING: boolean;
  8393. COLORGRADING3D: boolean;
  8394. SAMPLER3DGREENDEPTH: boolean;
  8395. SAMPLER3DBGRMAP: boolean;
  8396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8397. }
  8398. /**
  8399. * @hidden
  8400. */
  8401. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8402. IMAGEPROCESSING: boolean;
  8403. VIGNETTE: boolean;
  8404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8405. VIGNETTEBLENDMODEOPAQUE: boolean;
  8406. TONEMAPPING: boolean;
  8407. TONEMAPPING_ACES: boolean;
  8408. CONTRAST: boolean;
  8409. COLORCURVES: boolean;
  8410. COLORGRADING: boolean;
  8411. COLORGRADING3D: boolean;
  8412. SAMPLER3DGREENDEPTH: boolean;
  8413. SAMPLER3DBGRMAP: boolean;
  8414. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8415. EXPOSURE: boolean;
  8416. constructor();
  8417. }
  8418. /**
  8419. * This groups together the common properties used for image processing either in direct forward pass
  8420. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8421. * or not.
  8422. */
  8423. export class ImageProcessingConfiguration {
  8424. /**
  8425. * Default tone mapping applied in BabylonJS.
  8426. */
  8427. static readonly TONEMAPPING_STANDARD: number;
  8428. /**
  8429. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8430. * to other engines rendering to increase portability.
  8431. */
  8432. static readonly TONEMAPPING_ACES: number;
  8433. /**
  8434. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8435. */
  8436. colorCurves: Nullable<ColorCurves>;
  8437. private _colorCurvesEnabled;
  8438. /**
  8439. * Gets wether the color curves effect is enabled.
  8440. */
  8441. get colorCurvesEnabled(): boolean;
  8442. /**
  8443. * Sets wether the color curves effect is enabled.
  8444. */
  8445. set colorCurvesEnabled(value: boolean);
  8446. private _colorGradingTexture;
  8447. /**
  8448. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8449. */
  8450. get colorGradingTexture(): Nullable<BaseTexture>;
  8451. /**
  8452. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8453. */
  8454. set colorGradingTexture(value: Nullable<BaseTexture>);
  8455. private _colorGradingEnabled;
  8456. /**
  8457. * Gets wether the color grading effect is enabled.
  8458. */
  8459. get colorGradingEnabled(): boolean;
  8460. /**
  8461. * Sets wether the color grading effect is enabled.
  8462. */
  8463. set colorGradingEnabled(value: boolean);
  8464. private _colorGradingWithGreenDepth;
  8465. /**
  8466. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8467. */
  8468. get colorGradingWithGreenDepth(): boolean;
  8469. /**
  8470. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8471. */
  8472. set colorGradingWithGreenDepth(value: boolean);
  8473. private _colorGradingBGR;
  8474. /**
  8475. * Gets wether the color grading texture contains BGR values.
  8476. */
  8477. get colorGradingBGR(): boolean;
  8478. /**
  8479. * Sets wether the color grading texture contains BGR values.
  8480. */
  8481. set colorGradingBGR(value: boolean);
  8482. /** @hidden */
  8483. _exposure: number;
  8484. /**
  8485. * Gets the Exposure used in the effect.
  8486. */
  8487. get exposure(): number;
  8488. /**
  8489. * Sets the Exposure used in the effect.
  8490. */
  8491. set exposure(value: number);
  8492. private _toneMappingEnabled;
  8493. /**
  8494. * Gets wether the tone mapping effect is enabled.
  8495. */
  8496. get toneMappingEnabled(): boolean;
  8497. /**
  8498. * Sets wether the tone mapping effect is enabled.
  8499. */
  8500. set toneMappingEnabled(value: boolean);
  8501. private _toneMappingType;
  8502. /**
  8503. * Gets the type of tone mapping effect.
  8504. */
  8505. get toneMappingType(): number;
  8506. /**
  8507. * Sets the type of tone mapping effect used in BabylonJS.
  8508. */
  8509. set toneMappingType(value: number);
  8510. protected _contrast: number;
  8511. /**
  8512. * Gets the contrast used in the effect.
  8513. */
  8514. get contrast(): number;
  8515. /**
  8516. * Sets the contrast used in the effect.
  8517. */
  8518. set contrast(value: number);
  8519. /**
  8520. * Vignette stretch size.
  8521. */
  8522. vignetteStretch: number;
  8523. /**
  8524. * Vignette centre X Offset.
  8525. */
  8526. vignetteCentreX: number;
  8527. /**
  8528. * Vignette centre Y Offset.
  8529. */
  8530. vignetteCentreY: number;
  8531. /**
  8532. * Vignette weight or intensity of the vignette effect.
  8533. */
  8534. vignetteWeight: number;
  8535. /**
  8536. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8537. * if vignetteEnabled is set to true.
  8538. */
  8539. vignetteColor: Color4;
  8540. /**
  8541. * Camera field of view used by the Vignette effect.
  8542. */
  8543. vignetteCameraFov: number;
  8544. private _vignetteBlendMode;
  8545. /**
  8546. * Gets the vignette blend mode allowing different kind of effect.
  8547. */
  8548. get vignetteBlendMode(): number;
  8549. /**
  8550. * Sets the vignette blend mode allowing different kind of effect.
  8551. */
  8552. set vignetteBlendMode(value: number);
  8553. private _vignetteEnabled;
  8554. /**
  8555. * Gets wether the vignette effect is enabled.
  8556. */
  8557. get vignetteEnabled(): boolean;
  8558. /**
  8559. * Sets wether the vignette effect is enabled.
  8560. */
  8561. set vignetteEnabled(value: boolean);
  8562. private _applyByPostProcess;
  8563. /**
  8564. * Gets wether the image processing is applied through a post process or not.
  8565. */
  8566. get applyByPostProcess(): boolean;
  8567. /**
  8568. * Sets wether the image processing is applied through a post process or not.
  8569. */
  8570. set applyByPostProcess(value: boolean);
  8571. private _isEnabled;
  8572. /**
  8573. * Gets wether the image processing is enabled or not.
  8574. */
  8575. get isEnabled(): boolean;
  8576. /**
  8577. * Sets wether the image processing is enabled or not.
  8578. */
  8579. set isEnabled(value: boolean);
  8580. /**
  8581. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8582. */
  8583. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8584. /**
  8585. * Method called each time the image processing information changes requires to recompile the effect.
  8586. */
  8587. protected _updateParameters(): void;
  8588. /**
  8589. * Gets the current class name.
  8590. * @return "ImageProcessingConfiguration"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Prepare the list of uniforms associated with the Image Processing effects.
  8595. * @param uniforms The list of uniforms used in the effect
  8596. * @param defines the list of defines currently in use
  8597. */
  8598. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8599. /**
  8600. * Prepare the list of samplers associated with the Image Processing effects.
  8601. * @param samplersList The list of uniforms used in the effect
  8602. * @param defines the list of defines currently in use
  8603. */
  8604. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8605. /**
  8606. * Prepare the list of defines associated to the shader.
  8607. * @param defines the list of defines to complete
  8608. * @param forPostProcess Define if we are currently in post process mode or not
  8609. */
  8610. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8611. /**
  8612. * Returns true if all the image processing information are ready.
  8613. * @returns True if ready, otherwise, false
  8614. */
  8615. isReady(): boolean;
  8616. /**
  8617. * Binds the image processing to the shader.
  8618. * @param effect The effect to bind to
  8619. * @param overrideAspectRatio Override the aspect ratio of the effect
  8620. */
  8621. bind(effect: Effect, overrideAspectRatio?: number): void;
  8622. /**
  8623. * Clones the current image processing instance.
  8624. * @return The cloned image processing
  8625. */
  8626. clone(): ImageProcessingConfiguration;
  8627. /**
  8628. * Serializes the current image processing instance to a json representation.
  8629. * @return a JSON representation
  8630. */
  8631. serialize(): any;
  8632. /**
  8633. * Parses the image processing from a json representation.
  8634. * @param source the JSON source to parse
  8635. * @return The parsed image processing
  8636. */
  8637. static Parse(source: any): ImageProcessingConfiguration;
  8638. private static _VIGNETTEMODE_MULTIPLY;
  8639. private static _VIGNETTEMODE_OPAQUE;
  8640. /**
  8641. * Used to apply the vignette as a mix with the pixel color.
  8642. */
  8643. static get VIGNETTEMODE_MULTIPLY(): number;
  8644. /**
  8645. * Used to apply the vignette as a replacement of the pixel color.
  8646. */
  8647. static get VIGNETTEMODE_OPAQUE(): number;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /** @hidden */
  8652. export var postprocessVertexShader: {
  8653. name: string;
  8654. shader: string;
  8655. };
  8656. }
  8657. declare module BABYLON {
  8658. /**
  8659. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8660. */
  8661. export type RenderTargetTextureSize = number | {
  8662. width: number;
  8663. height: number;
  8664. layers?: number;
  8665. };
  8666. interface ThinEngine {
  8667. /**
  8668. * Creates a new render target texture
  8669. * @param size defines the size of the texture
  8670. * @param options defines the options used to create the texture
  8671. * @returns a new render target texture stored in an InternalTexture
  8672. */
  8673. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8674. /**
  8675. * Creates a depth stencil texture.
  8676. * This is only available in WebGL 2 or with the depth texture extension available.
  8677. * @param size The size of face edge in the texture.
  8678. * @param options The options defining the texture.
  8679. * @returns The texture
  8680. */
  8681. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8682. /** @hidden */
  8683. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * Defines the kind of connection point for node based material
  8689. */
  8690. export enum NodeMaterialBlockConnectionPointTypes {
  8691. /** Float */
  8692. Float = 1,
  8693. /** Int */
  8694. Int = 2,
  8695. /** Vector2 */
  8696. Vector2 = 4,
  8697. /** Vector3 */
  8698. Vector3 = 8,
  8699. /** Vector4 */
  8700. Vector4 = 16,
  8701. /** Color3 */
  8702. Color3 = 32,
  8703. /** Color4 */
  8704. Color4 = 64,
  8705. /** Matrix */
  8706. Matrix = 128,
  8707. /** Custom object */
  8708. Object = 256,
  8709. /** Detect type based on connection */
  8710. AutoDetect = 1024,
  8711. /** Output type that will be defined by input type */
  8712. BasedOnInput = 2048
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum used to define the target of a block
  8718. */
  8719. export enum NodeMaterialBlockTargets {
  8720. /** Vertex shader */
  8721. Vertex = 1,
  8722. /** Fragment shader */
  8723. Fragment = 2,
  8724. /** Neutral */
  8725. Neutral = 4,
  8726. /** Vertex and Fragment */
  8727. VertexAndFragment = 3
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8733. */
  8734. export enum NodeMaterialBlockConnectionPointMode {
  8735. /** Value is an uniform */
  8736. Uniform = 0,
  8737. /** Value is a mesh attribute */
  8738. Attribute = 1,
  8739. /** Value is a varying between vertex and fragment shaders */
  8740. Varying = 2,
  8741. /** Mode is undefined */
  8742. Undefined = 3
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. /**
  8747. * Enum used to define system values e.g. values automatically provided by the system
  8748. */
  8749. export enum NodeMaterialSystemValues {
  8750. /** World */
  8751. World = 1,
  8752. /** View */
  8753. View = 2,
  8754. /** Projection */
  8755. Projection = 3,
  8756. /** ViewProjection */
  8757. ViewProjection = 4,
  8758. /** WorldView */
  8759. WorldView = 5,
  8760. /** WorldViewProjection */
  8761. WorldViewProjection = 6,
  8762. /** CameraPosition */
  8763. CameraPosition = 7,
  8764. /** Fog Color */
  8765. FogColor = 8,
  8766. /** Delta time */
  8767. DeltaTime = 9
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /** Defines supported spaces */
  8772. export enum Space {
  8773. /** Local (object) space */
  8774. LOCAL = 0,
  8775. /** World space */
  8776. WORLD = 1,
  8777. /** Bone space */
  8778. BONE = 2
  8779. }
  8780. /** Defines the 3 main axes */
  8781. export class Axis {
  8782. /** X axis */
  8783. static X: Vector3;
  8784. /** Y axis */
  8785. static Y: Vector3;
  8786. /** Z axis */
  8787. static Z: Vector3;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Represents a camera frustum
  8793. */
  8794. export class Frustum {
  8795. /**
  8796. * Gets the planes representing the frustum
  8797. * @param transform matrix to be applied to the returned planes
  8798. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8799. */
  8800. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8801. /**
  8802. * Gets the near frustum plane transformed by the transform matrix
  8803. * @param transform transformation matrix to be applied to the resulting frustum plane
  8804. * @param frustumPlane the resuling frustum plane
  8805. */
  8806. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8807. /**
  8808. * Gets the far frustum plane transformed by the transform matrix
  8809. * @param transform transformation matrix to be applied to the resulting frustum plane
  8810. * @param frustumPlane the resuling frustum plane
  8811. */
  8812. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8813. /**
  8814. * Gets the left frustum plane transformed by the transform matrix
  8815. * @param transform transformation matrix to be applied to the resulting frustum plane
  8816. * @param frustumPlane the resuling frustum plane
  8817. */
  8818. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8819. /**
  8820. * Gets the right frustum plane transformed by the transform matrix
  8821. * @param transform transformation matrix to be applied to the resulting frustum plane
  8822. * @param frustumPlane the resuling frustum plane
  8823. */
  8824. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8825. /**
  8826. * Gets the top frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the bottom frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8839. * @param transform transformation matrix to be applied to the resulting frustum planes
  8840. * @param frustumPlanes the resuling frustum planes
  8841. */
  8842. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Interface for the size containing width and height
  8848. */
  8849. export interface ISize {
  8850. /**
  8851. * Width
  8852. */
  8853. width: number;
  8854. /**
  8855. * Heighht
  8856. */
  8857. height: number;
  8858. }
  8859. /**
  8860. * Size containing widht and height
  8861. */
  8862. export class Size implements ISize {
  8863. /**
  8864. * Width
  8865. */
  8866. width: number;
  8867. /**
  8868. * Height
  8869. */
  8870. height: number;
  8871. /**
  8872. * Creates a Size object from the given width and height (floats).
  8873. * @param width width of the new size
  8874. * @param height height of the new size
  8875. */
  8876. constructor(width: number, height: number);
  8877. /**
  8878. * Returns a string with the Size width and height
  8879. * @returns a string with the Size width and height
  8880. */
  8881. toString(): string;
  8882. /**
  8883. * "Size"
  8884. * @returns the string "Size"
  8885. */
  8886. getClassName(): string;
  8887. /**
  8888. * Returns the Size hash code.
  8889. * @returns a hash code for a unique width and height
  8890. */
  8891. getHashCode(): number;
  8892. /**
  8893. * Updates the current size from the given one.
  8894. * @param src the given size
  8895. */
  8896. copyFrom(src: Size): void;
  8897. /**
  8898. * Updates in place the current Size from the given floats.
  8899. * @param width width of the new size
  8900. * @param height height of the new size
  8901. * @returns the updated Size.
  8902. */
  8903. copyFromFloats(width: number, height: number): Size;
  8904. /**
  8905. * Updates in place the current Size from the given floats.
  8906. * @param width width to set
  8907. * @param height height to set
  8908. * @returns the updated Size.
  8909. */
  8910. set(width: number, height: number): Size;
  8911. /**
  8912. * Multiplies the width and height by numbers
  8913. * @param w factor to multiple the width by
  8914. * @param h factor to multiple the height by
  8915. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8916. */
  8917. multiplyByFloats(w: number, h: number): Size;
  8918. /**
  8919. * Clones the size
  8920. * @returns a new Size copied from the given one.
  8921. */
  8922. clone(): Size;
  8923. /**
  8924. * True if the current Size and the given one width and height are strictly equal.
  8925. * @param other the other size to compare against
  8926. * @returns True if the current Size and the given one width and height are strictly equal.
  8927. */
  8928. equals(other: Size): boolean;
  8929. /**
  8930. * The surface of the Size : width * height (float).
  8931. */
  8932. get surface(): number;
  8933. /**
  8934. * Create a new size of zero
  8935. * @returns a new Size set to (0.0, 0.0)
  8936. */
  8937. static Zero(): Size;
  8938. /**
  8939. * Sums the width and height of two sizes
  8940. * @param otherSize size to add to this size
  8941. * @returns a new Size set as the addition result of the current Size and the given one.
  8942. */
  8943. add(otherSize: Size): Size;
  8944. /**
  8945. * Subtracts the width and height of two
  8946. * @param otherSize size to subtract to this size
  8947. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8948. */
  8949. subtract(otherSize: Size): Size;
  8950. /**
  8951. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8952. * @param start starting size to lerp between
  8953. * @param end end size to lerp between
  8954. * @param amount amount to lerp between the start and end values
  8955. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8956. */
  8957. static Lerp(start: Size, end: Size, amount: number): Size;
  8958. }
  8959. }
  8960. declare module BABYLON {
  8961. /**
  8962. * Contains position and normal vectors for a vertex
  8963. */
  8964. export class PositionNormalVertex {
  8965. /** the position of the vertex (defaut: 0,0,0) */
  8966. position: Vector3;
  8967. /** the normal of the vertex (defaut: 0,1,0) */
  8968. normal: Vector3;
  8969. /**
  8970. * Creates a PositionNormalVertex
  8971. * @param position the position of the vertex (defaut: 0,0,0)
  8972. * @param normal the normal of the vertex (defaut: 0,1,0)
  8973. */
  8974. constructor(
  8975. /** the position of the vertex (defaut: 0,0,0) */
  8976. position?: Vector3,
  8977. /** the normal of the vertex (defaut: 0,1,0) */
  8978. normal?: Vector3);
  8979. /**
  8980. * Clones the PositionNormalVertex
  8981. * @returns the cloned PositionNormalVertex
  8982. */
  8983. clone(): PositionNormalVertex;
  8984. }
  8985. /**
  8986. * Contains position, normal and uv vectors for a vertex
  8987. */
  8988. export class PositionNormalTextureVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /** the uv of the vertex (default: 0,0) */
  8994. uv: Vector2;
  8995. /**
  8996. * Creates a PositionNormalTextureVertex
  8997. * @param position the position of the vertex (defaut: 0,0,0)
  8998. * @param normal the normal of the vertex (defaut: 0,1,0)
  8999. * @param uv the uv of the vertex (default: 0,0)
  9000. */
  9001. constructor(
  9002. /** the position of the vertex (defaut: 0,0,0) */
  9003. position?: Vector3,
  9004. /** the normal of the vertex (defaut: 0,1,0) */
  9005. normal?: Vector3,
  9006. /** the uv of the vertex (default: 0,0) */
  9007. uv?: Vector2);
  9008. /**
  9009. * Clones the PositionNormalTextureVertex
  9010. * @returns the cloned PositionNormalTextureVertex
  9011. */
  9012. clone(): PositionNormalTextureVertex;
  9013. }
  9014. }
  9015. declare module BABYLON {
  9016. /**
  9017. * Enum defining the type of animations supported by InputBlock
  9018. */
  9019. export enum AnimatedInputBlockTypes {
  9020. /** No animation */
  9021. None = 0,
  9022. /** Time based animation. Will only work for floats */
  9023. Time = 1
  9024. }
  9025. }
  9026. declare module BABYLON {
  9027. /**
  9028. * Interface describing all the common properties and methods a shadow light needs to implement.
  9029. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9030. * as well as binding the different shadow properties to the effects.
  9031. */
  9032. export interface IShadowLight extends Light {
  9033. /**
  9034. * The light id in the scene (used in scene.findLighById for instance)
  9035. */
  9036. id: string;
  9037. /**
  9038. * The position the shdow will be casted from.
  9039. */
  9040. position: Vector3;
  9041. /**
  9042. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9043. */
  9044. direction: Vector3;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. /**
  9054. * The friendly name of the light in the scene.
  9055. */
  9056. name: string;
  9057. /**
  9058. * Defines the shadow projection clipping minimum z value.
  9059. */
  9060. shadowMinZ: number;
  9061. /**
  9062. * Defines the shadow projection clipping maximum z value.
  9063. */
  9064. shadowMaxZ: number;
  9065. /**
  9066. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9067. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9068. */
  9069. computeTransformedInformation(): boolean;
  9070. /**
  9071. * Gets the scene the light belongs to.
  9072. * @returns The scene
  9073. */
  9074. getScene(): Scene;
  9075. /**
  9076. * Callback defining a custom Projection Matrix Builder.
  9077. * This can be used to override the default projection matrix computation.
  9078. */
  9079. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9080. /**
  9081. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9082. * @param matrix The materix to updated with the projection information
  9083. * @param viewMatrix The transform matrix of the light
  9084. * @param renderList The list of mesh to render in the map
  9085. * @returns The current light
  9086. */
  9087. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9088. /**
  9089. * Gets the current depth scale used in ESM.
  9090. * @returns The scale
  9091. */
  9092. getDepthScale(): number;
  9093. /**
  9094. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9095. * @returns true if a cube texture needs to be use
  9096. */
  9097. needCube(): boolean;
  9098. /**
  9099. * Detects if the projection matrix requires to be recomputed this frame.
  9100. * @returns true if it requires to be recomputed otherwise, false.
  9101. */
  9102. needProjectionMatrixCompute(): boolean;
  9103. /**
  9104. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9105. */
  9106. forceProjectionMatrixCompute(): void;
  9107. /**
  9108. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9109. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9110. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9111. */
  9112. getShadowDirection(faceIndex?: number): Vector3;
  9113. /**
  9114. * Gets the minZ used for shadow according to both the scene and the light.
  9115. * @param activeCamera The camera we are returning the min for
  9116. * @returns the depth min z
  9117. */
  9118. getDepthMinZ(activeCamera: Camera): number;
  9119. /**
  9120. * Gets the maxZ used for shadow according to both the scene and the light.
  9121. * @param activeCamera The camera we are returning the max for
  9122. * @returns the depth max z
  9123. */
  9124. getDepthMaxZ(activeCamera: Camera): number;
  9125. }
  9126. /**
  9127. * Base implementation IShadowLight
  9128. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9129. */
  9130. export abstract class ShadowLight extends Light implements IShadowLight {
  9131. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9132. protected _position: Vector3;
  9133. protected _setPosition(value: Vector3): void;
  9134. /**
  9135. * Sets the position the shadow will be casted from. Also use as the light position for both
  9136. * point and spot lights.
  9137. */
  9138. get position(): Vector3;
  9139. /**
  9140. * Sets the position the shadow will be casted from. Also use as the light position for both
  9141. * point and spot lights.
  9142. */
  9143. set position(value: Vector3);
  9144. protected _direction: Vector3;
  9145. protected _setDirection(value: Vector3): void;
  9146. /**
  9147. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9148. * Also use as the light direction on spot and directional lights.
  9149. */
  9150. get direction(): Vector3;
  9151. /**
  9152. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9153. * Also use as the light direction on spot and directional lights.
  9154. */
  9155. set direction(value: Vector3);
  9156. protected _shadowMinZ: number;
  9157. /**
  9158. * Gets the shadow projection clipping minimum z value.
  9159. */
  9160. get shadowMinZ(): number;
  9161. /**
  9162. * Sets the shadow projection clipping minimum z value.
  9163. */
  9164. set shadowMinZ(value: number);
  9165. protected _shadowMaxZ: number;
  9166. /**
  9167. * Sets the shadow projection clipping maximum z value.
  9168. */
  9169. get shadowMaxZ(): number;
  9170. /**
  9171. * Gets the shadow projection clipping maximum z value.
  9172. */
  9173. set shadowMaxZ(value: number);
  9174. /**
  9175. * Callback defining a custom Projection Matrix Builder.
  9176. * This can be used to override the default projection matrix computation.
  9177. */
  9178. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9179. /**
  9180. * The transformed position. Position of the light in world space taking parenting in account.
  9181. */
  9182. transformedPosition: Vector3;
  9183. /**
  9184. * The transformed direction. Direction of the light in world space taking parenting in account.
  9185. */
  9186. transformedDirection: Vector3;
  9187. private _needProjectionMatrixCompute;
  9188. /**
  9189. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9190. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9191. */
  9192. computeTransformedInformation(): boolean;
  9193. /**
  9194. * Return the depth scale used for the shadow map.
  9195. * @returns the depth scale.
  9196. */
  9197. getDepthScale(): number;
  9198. /**
  9199. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9202. */
  9203. getShadowDirection(faceIndex?: number): Vector3;
  9204. /**
  9205. * Returns the ShadowLight absolute position in the World.
  9206. * @returns the position vector in world space
  9207. */
  9208. getAbsolutePosition(): Vector3;
  9209. /**
  9210. * Sets the ShadowLight direction toward the passed target.
  9211. * @param target The point to target in local space
  9212. * @returns the updated ShadowLight direction
  9213. */
  9214. setDirectionToTarget(target: Vector3): Vector3;
  9215. /**
  9216. * Returns the light rotation in euler definition.
  9217. * @returns the x y z rotation in local space.
  9218. */
  9219. getRotation(): Vector3;
  9220. /**
  9221. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9222. * @returns true if a cube texture needs to be use
  9223. */
  9224. needCube(): boolean;
  9225. /**
  9226. * Detects if the projection matrix requires to be recomputed this frame.
  9227. * @returns true if it requires to be recomputed otherwise, false.
  9228. */
  9229. needProjectionMatrixCompute(): boolean;
  9230. /**
  9231. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9232. */
  9233. forceProjectionMatrixCompute(): void;
  9234. /** @hidden */
  9235. _initCache(): void;
  9236. /** @hidden */
  9237. _isSynchronized(): boolean;
  9238. /**
  9239. * Computes the world matrix of the node
  9240. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9241. * @returns the world matrix
  9242. */
  9243. computeWorldMatrix(force?: boolean): Matrix;
  9244. /**
  9245. * Gets the minZ used for shadow according to both the scene and the light.
  9246. * @param activeCamera The camera we are returning the min for
  9247. * @returns the depth min z
  9248. */
  9249. getDepthMinZ(activeCamera: Camera): number;
  9250. /**
  9251. * Gets the maxZ used for shadow according to both the scene and the light.
  9252. * @param activeCamera The camera we are returning the max for
  9253. * @returns the depth max z
  9254. */
  9255. getDepthMaxZ(activeCamera: Camera): number;
  9256. /**
  9257. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9258. * @param matrix The materix to updated with the projection information
  9259. * @param viewMatrix The transform matrix of the light
  9260. * @param renderList The list of mesh to render in the map
  9261. * @returns The current light
  9262. */
  9263. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9264. }
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var packingFunctions: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var bayerDitherFunctions: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var shadowMapFragmentDeclaration: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var clipPlaneFragmentDeclaration: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var clipPlaneFragment: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var shadowMapFragment: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var shadowMapPixelShader: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var bonesDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var morphTargetsVertexGlobalDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var morphTargetsVertexDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var instancesDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var helperFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var shadowMapVertexDeclaration: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var clipPlaneVertexDeclaration: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var morphTargetsVertex: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var instancesVertex: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var bonesVertex: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var shadowMapVertexNormalBias: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var shadowMapVertexMetric: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var clipPlaneVertex: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /** @hidden */
  9408. export var shadowMapVertexShader: {
  9409. name: string;
  9410. shader: string;
  9411. };
  9412. }
  9413. declare module BABYLON {
  9414. /** @hidden */
  9415. export var depthBoxBlurPixelShader: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module BABYLON {
  9421. /** @hidden */
  9422. export var shadowMapFragmentSoftTransparentShadow: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module BABYLON {
  9428. /**
  9429. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9430. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9431. */
  9432. export class EffectFallbacks implements IEffectFallbacks {
  9433. private _defines;
  9434. private _currentRank;
  9435. private _maxRank;
  9436. private _mesh;
  9437. /**
  9438. * Removes the fallback from the bound mesh.
  9439. */
  9440. unBindMesh(): void;
  9441. /**
  9442. * Adds a fallback on the specified property.
  9443. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9444. * @param define The name of the define in the shader
  9445. */
  9446. addFallback(rank: number, define: string): void;
  9447. /**
  9448. * Sets the mesh to use CPU skinning when needing to fallback.
  9449. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9450. * @param mesh The mesh to use the fallbacks.
  9451. */
  9452. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9453. /**
  9454. * Checks to see if more fallbacks are still availible.
  9455. */
  9456. get hasMoreFallbacks(): boolean;
  9457. /**
  9458. * Removes the defines that should be removed when falling back.
  9459. * @param currentDefines defines the current define statements for the shader.
  9460. * @param effect defines the current effect we try to compile
  9461. * @returns The resulting defines with defines of the current rank removed.
  9462. */
  9463. reduce(currentDefines: string, effect: Effect): string;
  9464. }
  9465. }
  9466. declare module BABYLON {
  9467. /**
  9468. * Interface used to define Action
  9469. */
  9470. export interface IAction {
  9471. /**
  9472. * Trigger for the action
  9473. */
  9474. trigger: number;
  9475. /** Options of the trigger */
  9476. triggerOptions: any;
  9477. /**
  9478. * Gets the trigger parameters
  9479. * @returns the trigger parameters
  9480. */
  9481. getTriggerParameter(): any;
  9482. /**
  9483. * Internal only - executes current action event
  9484. * @hidden
  9485. */
  9486. _executeCurrent(evt?: ActionEvent): void;
  9487. /**
  9488. * Serialize placeholder for child classes
  9489. * @param parent of child
  9490. * @returns the serialized object
  9491. */
  9492. serialize(parent: any): any;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. _prepare(): void;
  9498. /**
  9499. * Internal only - manager for action
  9500. * @hidden
  9501. */
  9502. _actionManager: Nullable<AbstractActionManager>;
  9503. /**
  9504. * Adds action to chain of actions, may be a DoNothingAction
  9505. * @param action defines the next action to execute
  9506. * @returns The action passed in
  9507. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9508. */
  9509. then(action: IAction): IAction;
  9510. }
  9511. /**
  9512. * The action to be carried out following a trigger
  9513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9514. */
  9515. export class Action implements IAction {
  9516. /** the trigger, with or without parameters, for the action */
  9517. triggerOptions: any;
  9518. /**
  9519. * Trigger for the action
  9520. */
  9521. trigger: number;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: ActionManager;
  9527. private _nextActiveAction;
  9528. private _child;
  9529. private _condition?;
  9530. private _triggerParameter;
  9531. /**
  9532. * An event triggered prior to action being executed.
  9533. */
  9534. onBeforeExecuteObservable: Observable<Action>;
  9535. /**
  9536. * Creates a new Action
  9537. * @param triggerOptions the trigger, with or without parameters, for the action
  9538. * @param condition an optional determinant of action
  9539. */
  9540. constructor(
  9541. /** the trigger, with or without parameters, for the action */
  9542. triggerOptions: any, condition?: Condition);
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. _prepare(): void;
  9548. /**
  9549. * Gets the trigger parameters
  9550. * @returns the trigger parameters
  9551. */
  9552. getTriggerParameter(): any;
  9553. /**
  9554. * Internal only - executes current action event
  9555. * @hidden
  9556. */
  9557. _executeCurrent(evt?: ActionEvent): void;
  9558. /**
  9559. * Execute placeholder for child classes
  9560. * @param evt optional action event
  9561. */
  9562. execute(evt?: ActionEvent): void;
  9563. /**
  9564. * Skips to next active action
  9565. */
  9566. skipToNextActiveAction(): void;
  9567. /**
  9568. * Adds action to chain of actions, may be a DoNothingAction
  9569. * @param action defines the next action to execute
  9570. * @returns The action passed in
  9571. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9572. */
  9573. then(action: Action): Action;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. _getProperty(propertyPath: string): string;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. _getEffectiveTarget(target: any, propertyPath: string): any;
  9584. /**
  9585. * Serialize placeholder for child classes
  9586. * @param parent of child
  9587. * @returns the serialized object
  9588. */
  9589. serialize(parent: any): any;
  9590. /**
  9591. * Internal only called by serialize
  9592. * @hidden
  9593. */
  9594. protected _serialize(serializedAction: any, parent?: any): any;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. static _SerializeValueAsString: (value: any) => string;
  9600. /**
  9601. * Internal only
  9602. * @hidden
  9603. */
  9604. static _GetTargetProperty: (target: Scene | Node) => {
  9605. name: string;
  9606. targetType: string;
  9607. value: string;
  9608. };
  9609. }
  9610. }
  9611. declare module BABYLON {
  9612. /**
  9613. * A Condition applied to an Action
  9614. */
  9615. export class Condition {
  9616. /**
  9617. * Internal only - manager for action
  9618. * @hidden
  9619. */
  9620. _actionManager: ActionManager;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. _evaluationId: number;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. _currentResult: boolean;
  9631. /**
  9632. * Creates a new Condition
  9633. * @param actionManager the manager of the action the condition is applied to
  9634. */
  9635. constructor(actionManager: ActionManager);
  9636. /**
  9637. * Check if the current condition is valid
  9638. * @returns a boolean
  9639. */
  9640. isValid(): boolean;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. _getProperty(propertyPath: string): string;
  9646. /**
  9647. * Internal only
  9648. * @hidden
  9649. */
  9650. _getEffectiveTarget(target: any, propertyPath: string): any;
  9651. /**
  9652. * Serialize placeholder for child classes
  9653. * @returns the serialized object
  9654. */
  9655. serialize(): any;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. protected _serialize(serializedCondition: any): any;
  9661. }
  9662. /**
  9663. * Defines specific conditional operators as extensions of Condition
  9664. */
  9665. export class ValueCondition extends Condition {
  9666. /** path to specify the property of the target the conditional operator uses */
  9667. propertyPath: string;
  9668. /** the value compared by the conditional operator against the current value of the property */
  9669. value: any;
  9670. /** the conditional operator, default ValueCondition.IsEqual */
  9671. operator: number;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsEqual;
  9677. /**
  9678. * Internal only
  9679. * @hidden
  9680. */
  9681. private static _IsDifferent;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private static _IsGreater;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. private static _IsLesser;
  9692. /**
  9693. * returns the number for IsEqual
  9694. */
  9695. static get IsEqual(): number;
  9696. /**
  9697. * Returns the number for IsDifferent
  9698. */
  9699. static get IsDifferent(): number;
  9700. /**
  9701. * Returns the number for IsGreater
  9702. */
  9703. static get IsGreater(): number;
  9704. /**
  9705. * Returns the number for IsLesser
  9706. */
  9707. static get IsLesser(): number;
  9708. /**
  9709. * Internal only The action manager for the condition
  9710. * @hidden
  9711. */
  9712. _actionManager: ActionManager;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. private _target;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. private _effectiveTarget;
  9723. /**
  9724. * Internal only
  9725. * @hidden
  9726. */
  9727. private _property;
  9728. /**
  9729. * Creates a new ValueCondition
  9730. * @param actionManager manager for the action the condition applies to
  9731. * @param target for the action
  9732. * @param propertyPath path to specify the property of the target the conditional operator uses
  9733. * @param value the value compared by the conditional operator against the current value of the property
  9734. * @param operator the conditional operator, default ValueCondition.IsEqual
  9735. */
  9736. constructor(actionManager: ActionManager, target: any,
  9737. /** path to specify the property of the target the conditional operator uses */
  9738. propertyPath: string,
  9739. /** the value compared by the conditional operator against the current value of the property */
  9740. value: any,
  9741. /** the conditional operator, default ValueCondition.IsEqual */
  9742. operator?: number);
  9743. /**
  9744. * Compares the given value with the property value for the specified conditional operator
  9745. * @returns the result of the comparison
  9746. */
  9747. isValid(): boolean;
  9748. /**
  9749. * Serialize the ValueCondition into a JSON compatible object
  9750. * @returns serialization object
  9751. */
  9752. serialize(): any;
  9753. /**
  9754. * Gets the name of the conditional operator for the ValueCondition
  9755. * @param operator the conditional operator
  9756. * @returns the name
  9757. */
  9758. static GetOperatorName(operator: number): string;
  9759. }
  9760. /**
  9761. * Defines a predicate condition as an extension of Condition
  9762. */
  9763. export class PredicateCondition extends Condition {
  9764. /** defines the predicate function used to validate the condition */
  9765. predicate: () => boolean;
  9766. /**
  9767. * Internal only - manager for action
  9768. * @hidden
  9769. */
  9770. _actionManager: ActionManager;
  9771. /**
  9772. * Creates a new PredicateCondition
  9773. * @param actionManager manager for the action the condition applies to
  9774. * @param predicate defines the predicate function used to validate the condition
  9775. */
  9776. constructor(actionManager: ActionManager,
  9777. /** defines the predicate function used to validate the condition */
  9778. predicate: () => boolean);
  9779. /**
  9780. * @returns the validity of the predicate condition
  9781. */
  9782. isValid(): boolean;
  9783. }
  9784. /**
  9785. * Defines a state condition as an extension of Condition
  9786. */
  9787. export class StateCondition extends Condition {
  9788. /** Value to compare with target state */
  9789. value: string;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private _target;
  9800. /**
  9801. * Creates a new StateCondition
  9802. * @param actionManager manager for the action the condition applies to
  9803. * @param target of the condition
  9804. * @param value to compare with target state
  9805. */
  9806. constructor(actionManager: ActionManager, target: any,
  9807. /** Value to compare with target state */
  9808. value: string);
  9809. /**
  9810. * Gets a boolean indicating if the current condition is met
  9811. * @returns the validity of the state
  9812. */
  9813. isValid(): boolean;
  9814. /**
  9815. * Serialize the StateCondition into a JSON compatible object
  9816. * @returns serialization object
  9817. */
  9818. serialize(): any;
  9819. }
  9820. }
  9821. declare module BABYLON {
  9822. /**
  9823. * This defines an action responsible to toggle a boolean once triggered.
  9824. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9825. */
  9826. export class SwitchBooleanAction extends Action {
  9827. /**
  9828. * The path to the boolean property in the target object
  9829. */
  9830. propertyPath: string;
  9831. private _target;
  9832. private _effectiveTarget;
  9833. private _property;
  9834. /**
  9835. * Instantiate the action
  9836. * @param triggerOptions defines the trigger options
  9837. * @param target defines the object containing the boolean
  9838. * @param propertyPath defines the path to the boolean property in the target object
  9839. * @param condition defines the trigger related conditions
  9840. */
  9841. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9842. /** @hidden */
  9843. _prepare(): void;
  9844. /**
  9845. * Execute the action toggle the boolean value.
  9846. */
  9847. execute(): void;
  9848. /**
  9849. * Serializes the actions and its related information.
  9850. * @param parent defines the object to serialize in
  9851. * @returns the serialized object
  9852. */
  9853. serialize(parent: any): any;
  9854. }
  9855. /**
  9856. * This defines an action responsible to set a the state field of the target
  9857. * to a desired value once triggered.
  9858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9859. */
  9860. export class SetStateAction extends Action {
  9861. /**
  9862. * The value to store in the state field.
  9863. */
  9864. value: string;
  9865. private _target;
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param target defines the object containing the state property
  9870. * @param value defines the value to store in the state field
  9871. * @param condition defines the trigger related conditions
  9872. */
  9873. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9874. /**
  9875. * Execute the action and store the value on the target state property.
  9876. */
  9877. execute(): void;
  9878. /**
  9879. * Serializes the actions and its related information.
  9880. * @param parent defines the object to serialize in
  9881. * @returns the serialized object
  9882. */
  9883. serialize(parent: any): any;
  9884. }
  9885. /**
  9886. * This defines an action responsible to set a property of the target
  9887. * to a desired value once triggered.
  9888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9889. */
  9890. export class SetValueAction extends Action {
  9891. /**
  9892. * The path of the property to set in the target.
  9893. */
  9894. propertyPath: string;
  9895. /**
  9896. * The value to set in the property
  9897. */
  9898. value: any;
  9899. private _target;
  9900. private _effectiveTarget;
  9901. private _property;
  9902. /**
  9903. * Instantiate the action
  9904. * @param triggerOptions defines the trigger options
  9905. * @param target defines the object containing the property
  9906. * @param propertyPath defines the path of the property to set in the target
  9907. * @param value defines the value to set in the property
  9908. * @param condition defines the trigger related conditions
  9909. */
  9910. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9911. /** @hidden */
  9912. _prepare(): void;
  9913. /**
  9914. * Execute the action and set the targetted property to the desired value.
  9915. */
  9916. execute(): void;
  9917. /**
  9918. * Serializes the actions and its related information.
  9919. * @param parent defines the object to serialize in
  9920. * @returns the serialized object
  9921. */
  9922. serialize(parent: any): any;
  9923. }
  9924. /**
  9925. * This defines an action responsible to increment the target value
  9926. * to a desired value once triggered.
  9927. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9928. */
  9929. export class IncrementValueAction extends Action {
  9930. /**
  9931. * The path of the property to increment in the target.
  9932. */
  9933. propertyPath: string;
  9934. /**
  9935. * The value we should increment the property by.
  9936. */
  9937. value: any;
  9938. private _target;
  9939. private _effectiveTarget;
  9940. private _property;
  9941. /**
  9942. * Instantiate the action
  9943. * @param triggerOptions defines the trigger options
  9944. * @param target defines the object containing the property
  9945. * @param propertyPath defines the path of the property to increment in the target
  9946. * @param value defines the value value we should increment the property by
  9947. * @param condition defines the trigger related conditions
  9948. */
  9949. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9950. /** @hidden */
  9951. _prepare(): void;
  9952. /**
  9953. * Execute the action and increment the target of the value amount.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to start an animation once triggered.
  9965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class PlayAnimationAction extends Action {
  9968. /**
  9969. * Where the animation should start (animation frame)
  9970. */
  9971. from: number;
  9972. /**
  9973. * Where the animation should stop (animation frame)
  9974. */
  9975. to: number;
  9976. /**
  9977. * Define if the animation should loop or stop after the first play.
  9978. */
  9979. loop?: boolean;
  9980. private _target;
  9981. /**
  9982. * Instantiate the action
  9983. * @param triggerOptions defines the trigger options
  9984. * @param target defines the target animation or animation name
  9985. * @param from defines from where the animation should start (animation frame)
  9986. * @param end defines where the animation should stop (animation frame)
  9987. * @param loop defines if the animation should loop or stop after the first play
  9988. * @param condition defines the trigger related conditions
  9989. */
  9990. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9991. /** @hidden */
  9992. _prepare(): void;
  9993. /**
  9994. * Execute the action and play the animation.
  9995. */
  9996. execute(): void;
  9997. /**
  9998. * Serializes the actions and its related information.
  9999. * @param parent defines the object to serialize in
  10000. * @returns the serialized object
  10001. */
  10002. serialize(parent: any): any;
  10003. }
  10004. /**
  10005. * This defines an action responsible to stop an animation once triggered.
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10007. */
  10008. export class StopAnimationAction extends Action {
  10009. private _target;
  10010. /**
  10011. * Instantiate the action
  10012. * @param triggerOptions defines the trigger options
  10013. * @param target defines the target animation or animation name
  10014. * @param condition defines the trigger related conditions
  10015. */
  10016. constructor(triggerOptions: any, target: any, condition?: Condition);
  10017. /** @hidden */
  10018. _prepare(): void;
  10019. /**
  10020. * Execute the action and stop the animation.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible that does nothing once triggered.
  10032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10033. */
  10034. export class DoNothingAction extends Action {
  10035. /**
  10036. * Instantiate the action
  10037. * @param triggerOptions defines the trigger options
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions?: any, condition?: Condition);
  10041. /**
  10042. * Execute the action and do nothing.
  10043. */
  10044. execute(): void;
  10045. /**
  10046. * Serializes the actions and its related information.
  10047. * @param parent defines the object to serialize in
  10048. * @returns the serialized object
  10049. */
  10050. serialize(parent: any): any;
  10051. }
  10052. /**
  10053. * This defines an action responsible to trigger several actions once triggered.
  10054. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10055. */
  10056. export class CombineAction extends Action {
  10057. /**
  10058. * The list of aggregated animations to run.
  10059. */
  10060. children: Action[];
  10061. /**
  10062. * Instantiate the action
  10063. * @param triggerOptions defines the trigger options
  10064. * @param children defines the list of aggregated animations to run
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10068. /** @hidden */
  10069. _prepare(): void;
  10070. /**
  10071. * Execute the action and executes all the aggregated actions.
  10072. */
  10073. execute(evt: ActionEvent): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. /**
  10082. * This defines an action responsible to run code (external event) once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class ExecuteCodeAction extends Action {
  10086. /**
  10087. * The callback function to run.
  10088. */
  10089. func: (evt: ActionEvent) => void;
  10090. /**
  10091. * Instantiate the action
  10092. * @param triggerOptions defines the trigger options
  10093. * @param func defines the callback function to run
  10094. * @param condition defines the trigger related conditions
  10095. */
  10096. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10097. /**
  10098. * Execute the action and run the attached code.
  10099. */
  10100. execute(evt: ActionEvent): void;
  10101. }
  10102. /**
  10103. * This defines an action responsible to set the parent property of the target once triggered.
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10105. */
  10106. export class SetParentAction extends Action {
  10107. private _parent;
  10108. private _target;
  10109. /**
  10110. * Instantiate the action
  10111. * @param triggerOptions defines the trigger options
  10112. * @param target defines the target containing the parent property
  10113. * @param parent defines from where the animation should start (animation frame)
  10114. * @param condition defines the trigger related conditions
  10115. */
  10116. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10117. /** @hidden */
  10118. _prepare(): void;
  10119. /**
  10120. * Execute the action and set the parent property.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. }
  10131. declare module BABYLON {
  10132. /**
  10133. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10134. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10136. */
  10137. export class ActionManager extends AbstractActionManager {
  10138. /**
  10139. * Nothing
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly NothingTrigger: number;
  10143. /**
  10144. * On pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnPickTrigger: number;
  10148. /**
  10149. * On left pick
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnLeftPickTrigger: number;
  10153. /**
  10154. * On right pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnRightPickTrigger: number;
  10158. /**
  10159. * On center pick
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnCenterPickTrigger: number;
  10163. /**
  10164. * On pick down
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPickDownTrigger: number;
  10168. /**
  10169. * On double pick
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnDoublePickTrigger: number;
  10173. /**
  10174. * On pick up
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPickUpTrigger: number;
  10178. /**
  10179. * On pick out.
  10180. * This trigger will only be raised if you also declared a OnPickDown
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickOutTrigger: number;
  10184. /**
  10185. * On long press
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnLongPressTrigger: number;
  10189. /**
  10190. * On pointer over
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPointerOverTrigger: number;
  10194. /**
  10195. * On pointer out
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnPointerOutTrigger: number;
  10199. /**
  10200. * On every frame
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnEveryFrameTrigger: number;
  10204. /**
  10205. * On intersection enter
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnIntersectionEnterTrigger: number;
  10209. /**
  10210. * On intersection exit
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10212. */
  10213. static readonly OnIntersectionExitTrigger: number;
  10214. /**
  10215. * On key down
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10217. */
  10218. static readonly OnKeyDownTrigger: number;
  10219. /**
  10220. * On key up
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly OnKeyUpTrigger: number;
  10224. private _scene;
  10225. /**
  10226. * Creates a new action manager
  10227. * @param scene defines the hosting scene
  10228. */
  10229. constructor(scene: Scene);
  10230. /**
  10231. * Releases all associated resources
  10232. */
  10233. dispose(): void;
  10234. /**
  10235. * Gets hosting scene
  10236. * @returns the hosting scene
  10237. */
  10238. getScene(): Scene;
  10239. /**
  10240. * Does this action manager handles actions of any of the given triggers
  10241. * @param triggers defines the triggers to be tested
  10242. * @return a boolean indicating whether one (or more) of the triggers is handled
  10243. */
  10244. hasSpecificTriggers(triggers: number[]): boolean;
  10245. /**
  10246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10247. * speed.
  10248. * @param triggerA defines the trigger to be tested
  10249. * @param triggerB defines the trigger to be tested
  10250. * @return a boolean indicating whether one (or more) of the triggers is handled
  10251. */
  10252. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10253. /**
  10254. * Does this action manager handles actions of a given trigger
  10255. * @param trigger defines the trigger to be tested
  10256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10257. * @return whether the trigger is handled
  10258. */
  10259. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10260. /**
  10261. * Does this action manager has pointer triggers
  10262. */
  10263. get hasPointerTriggers(): boolean;
  10264. /**
  10265. * Does this action manager has pick triggers
  10266. */
  10267. get hasPickTriggers(): boolean;
  10268. /**
  10269. * Registers an action to this action manager
  10270. * @param action defines the action to be registered
  10271. * @return the action amended (prepared) after registration
  10272. */
  10273. registerAction(action: IAction): Nullable<IAction>;
  10274. /**
  10275. * Unregisters an action to this action manager
  10276. * @param action defines the action to be unregistered
  10277. * @return a boolean indicating whether the action has been unregistered
  10278. */
  10279. unregisterAction(action: IAction): Boolean;
  10280. /**
  10281. * Process a specific trigger
  10282. * @param trigger defines the trigger to process
  10283. * @param evt defines the event details to be processed
  10284. */
  10285. processTrigger(trigger: number, evt?: IActionEvent): void;
  10286. /** @hidden */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /** @hidden */
  10289. _getProperty(propertyPath: string): string;
  10290. /**
  10291. * Serialize this manager to a JSON object
  10292. * @param name defines the property name to store this manager
  10293. * @returns a JSON representation of this manager
  10294. */
  10295. serialize(name: string): any;
  10296. /**
  10297. * Creates a new ActionManager from a JSON data
  10298. * @param parsedActions defines the JSON data to read from
  10299. * @param object defines the hosting mesh
  10300. * @param scene defines the hosting scene
  10301. */
  10302. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10303. /**
  10304. * Get a trigger name by index
  10305. * @param trigger defines the trigger index
  10306. * @returns a trigger name
  10307. */
  10308. static GetTriggerName(trigger: number): string;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Class used to represent a sprite
  10314. * @see https://doc.babylonjs.com/babylon101/sprites
  10315. */
  10316. export class Sprite implements IAnimatable {
  10317. /** defines the name */
  10318. name: string;
  10319. /** Gets or sets the current world position */
  10320. position: Vector3;
  10321. /** Gets or sets the main color */
  10322. color: Color4;
  10323. /** Gets or sets the width */
  10324. width: number;
  10325. /** Gets or sets the height */
  10326. height: number;
  10327. /** Gets or sets rotation angle */
  10328. angle: number;
  10329. /** Gets or sets the cell index in the sprite sheet */
  10330. cellIndex: number;
  10331. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10332. cellRef: string;
  10333. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10334. invertU: boolean;
  10335. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10336. invertV: boolean;
  10337. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10338. disposeWhenFinishedAnimating: boolean;
  10339. /** Gets the list of attached animations */
  10340. animations: Nullable<Array<Animation>>;
  10341. /** Gets or sets a boolean indicating if the sprite can be picked */
  10342. isPickable: boolean;
  10343. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10344. useAlphaForPicking: boolean;
  10345. /** @hidden */
  10346. _xOffset: number;
  10347. /** @hidden */
  10348. _yOffset: number;
  10349. /** @hidden */
  10350. _xSize: number;
  10351. /** @hidden */
  10352. _ySize: number;
  10353. /**
  10354. * Gets or sets the associated action manager
  10355. */
  10356. actionManager: Nullable<ActionManager>;
  10357. /**
  10358. * An event triggered when the control has been disposed
  10359. */
  10360. onDisposeObservable: Observable<Sprite>;
  10361. private _animationStarted;
  10362. private _loopAnimation;
  10363. private _fromIndex;
  10364. private _toIndex;
  10365. private _delay;
  10366. private _direction;
  10367. private _manager;
  10368. private _time;
  10369. private _onAnimationEnd;
  10370. /**
  10371. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10372. */
  10373. isVisible: boolean;
  10374. /**
  10375. * Gets or sets the sprite size
  10376. */
  10377. get size(): number;
  10378. set size(value: number);
  10379. /**
  10380. * Returns a boolean indicating if the animation is started
  10381. */
  10382. get animationStarted(): boolean;
  10383. /**
  10384. * Gets or sets the unique id of the sprite
  10385. */
  10386. uniqueId: number;
  10387. /**
  10388. * Gets the manager of this sprite
  10389. */
  10390. get manager(): ISpriteManager;
  10391. /**
  10392. * Creates a new Sprite
  10393. * @param name defines the name
  10394. * @param manager defines the manager
  10395. */
  10396. constructor(
  10397. /** defines the name */
  10398. name: string, manager: ISpriteManager);
  10399. /**
  10400. * Returns the string "Sprite"
  10401. * @returns "Sprite"
  10402. */
  10403. getClassName(): string;
  10404. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10405. get fromIndex(): number;
  10406. set fromIndex(value: number);
  10407. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10408. get toIndex(): number;
  10409. set toIndex(value: number);
  10410. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10411. get loopAnimation(): boolean;
  10412. set loopAnimation(value: boolean);
  10413. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10414. get delay(): number;
  10415. set delay(value: number);
  10416. /**
  10417. * Starts an animation
  10418. * @param from defines the initial key
  10419. * @param to defines the end key
  10420. * @param loop defines if the animation must loop
  10421. * @param delay defines the start delay (in ms)
  10422. * @param onAnimationEnd defines a callback to call when animation ends
  10423. */
  10424. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10425. /** Stops current animation (if any) */
  10426. stopAnimation(): void;
  10427. /** @hidden */
  10428. _animate(deltaTime: number): void;
  10429. /** Release associated resources */
  10430. dispose(): void;
  10431. /**
  10432. * Serializes the sprite to a JSON object
  10433. * @returns the JSON object
  10434. */
  10435. serialize(): any;
  10436. /**
  10437. * Parses a JSON object to create a new sprite
  10438. * @param parsedSprite The JSON object to parse
  10439. * @param manager defines the hosting manager
  10440. * @returns the new sprite
  10441. */
  10442. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10443. }
  10444. }
  10445. declare module BABYLON {
  10446. /**
  10447. * Information about the result of picking within a scene
  10448. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10449. */
  10450. export class PickingInfo {
  10451. /** @hidden */
  10452. _pickingUnavailable: boolean;
  10453. /**
  10454. * If the pick collided with an object
  10455. */
  10456. hit: boolean;
  10457. /**
  10458. * Distance away where the pick collided
  10459. */
  10460. distance: number;
  10461. /**
  10462. * The location of pick collision
  10463. */
  10464. pickedPoint: Nullable<Vector3>;
  10465. /**
  10466. * The mesh corresponding the the pick collision
  10467. */
  10468. pickedMesh: Nullable<AbstractMesh>;
  10469. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10470. bu: number;
  10471. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10472. bv: number;
  10473. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10474. faceId: number;
  10475. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10476. subMeshFaceId: number;
  10477. /** Id of the the submesh that was picked */
  10478. subMeshId: number;
  10479. /** If a sprite was picked, this will be the sprite the pick collided with */
  10480. pickedSprite: Nullable<Sprite>;
  10481. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10482. thinInstanceIndex: number;
  10483. /**
  10484. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10485. */
  10486. originMesh: Nullable<AbstractMesh>;
  10487. /**
  10488. * The ray that was used to perform the picking.
  10489. */
  10490. ray: Nullable<Ray>;
  10491. /**
  10492. * Gets the normal correspodning to the face the pick collided with
  10493. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10494. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10495. * @returns The normal correspodning to the face the pick collided with
  10496. */
  10497. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10498. /**
  10499. * Gets the texture coordinates of where the pick occured
  10500. * @returns the vector containing the coordnates of the texture
  10501. */
  10502. getTextureCoordinates(): Nullable<Vector2>;
  10503. }
  10504. }
  10505. declare module BABYLON {
  10506. /**
  10507. * Class representing a ray with position and direction
  10508. */
  10509. export class Ray {
  10510. /** origin point */
  10511. origin: Vector3;
  10512. /** direction */
  10513. direction: Vector3;
  10514. /** length of the ray */
  10515. length: number;
  10516. private static readonly _TmpVector3;
  10517. private _tmpRay;
  10518. /**
  10519. * Creates a new ray
  10520. * @param origin origin point
  10521. * @param direction direction
  10522. * @param length length of the ray
  10523. */
  10524. constructor(
  10525. /** origin point */
  10526. origin: Vector3,
  10527. /** direction */
  10528. direction: Vector3,
  10529. /** length of the ray */
  10530. length?: number);
  10531. /**
  10532. * Checks if the ray intersects a box
  10533. * This does not account for the ray lenght by design to improve perfs.
  10534. * @param minimum bound of the box
  10535. * @param maximum bound of the box
  10536. * @param intersectionTreshold extra extend to be added to the box in all direction
  10537. * @returns if the box was hit
  10538. */
  10539. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10540. /**
  10541. * Checks if the ray intersects a box
  10542. * This does not account for the ray lenght by design to improve perfs.
  10543. * @param box the bounding box to check
  10544. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10545. * @returns if the box was hit
  10546. */
  10547. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10548. /**
  10549. * If the ray hits a sphere
  10550. * @param sphere the bounding sphere to check
  10551. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10552. * @returns true if it hits the sphere
  10553. */
  10554. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10555. /**
  10556. * If the ray hits a triange
  10557. * @param vertex0 triangle vertex
  10558. * @param vertex1 triangle vertex
  10559. * @param vertex2 triangle vertex
  10560. * @returns intersection information if hit
  10561. */
  10562. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10563. /**
  10564. * Checks if ray intersects a plane
  10565. * @param plane the plane to check
  10566. * @returns the distance away it was hit
  10567. */
  10568. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10569. /**
  10570. * Calculate the intercept of a ray on a given axis
  10571. * @param axis to check 'x' | 'y' | 'z'
  10572. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10573. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10574. */
  10575. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10576. /**
  10577. * Checks if ray intersects a mesh
  10578. * @param mesh the mesh to check
  10579. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10580. * @returns picking info of the intersecton
  10581. */
  10582. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10583. /**
  10584. * Checks if ray intersects a mesh
  10585. * @param meshes the meshes to check
  10586. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10587. * @param results array to store result in
  10588. * @returns Array of picking infos
  10589. */
  10590. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10591. private _comparePickingInfo;
  10592. private static smallnum;
  10593. private static rayl;
  10594. /**
  10595. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10596. * @param sega the first point of the segment to test the intersection against
  10597. * @param segb the second point of the segment to test the intersection against
  10598. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10599. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10600. */
  10601. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10602. /**
  10603. * Update the ray from viewport position
  10604. * @param x position
  10605. * @param y y position
  10606. * @param viewportWidth viewport width
  10607. * @param viewportHeight viewport height
  10608. * @param world world matrix
  10609. * @param view view matrix
  10610. * @param projection projection matrix
  10611. * @returns this ray updated
  10612. */
  10613. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10614. /**
  10615. * Creates a ray with origin and direction of 0,0,0
  10616. * @returns the new ray
  10617. */
  10618. static Zero(): Ray;
  10619. /**
  10620. * Creates a new ray from screen space and viewport
  10621. * @param x position
  10622. * @param y y position
  10623. * @param viewportWidth viewport width
  10624. * @param viewportHeight viewport height
  10625. * @param world world matrix
  10626. * @param view view matrix
  10627. * @param projection projection matrix
  10628. * @returns new ray
  10629. */
  10630. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10631. /**
  10632. * 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
  10633. * transformed to the given world matrix.
  10634. * @param origin The origin point
  10635. * @param end The end point
  10636. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10637. * @returns the new ray
  10638. */
  10639. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10640. /**
  10641. * Transforms a ray by a matrix
  10642. * @param ray ray to transform
  10643. * @param matrix matrix to apply
  10644. * @returns the resulting new ray
  10645. */
  10646. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10647. /**
  10648. * Transforms a ray by a matrix
  10649. * @param ray ray to transform
  10650. * @param matrix matrix to apply
  10651. * @param result ray to store result in
  10652. */
  10653. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10654. /**
  10655. * Unproject a ray from screen space to object space
  10656. * @param sourceX defines the screen space x coordinate to use
  10657. * @param sourceY defines the screen space y coordinate to use
  10658. * @param viewportWidth defines the current width of the viewport
  10659. * @param viewportHeight defines the current height of the viewport
  10660. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10661. * @param view defines the view matrix to use
  10662. * @param projection defines the projection matrix to use
  10663. */
  10664. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10665. }
  10666. /**
  10667. * Type used to define predicate used to select faces when a mesh intersection is detected
  10668. */
  10669. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10670. interface Scene {
  10671. /** @hidden */
  10672. _tempPickingRay: Nullable<Ray>;
  10673. /** @hidden */
  10674. _cachedRayForTransform: Ray;
  10675. /** @hidden */
  10676. _pickWithRayInverseMatrix: Matrix;
  10677. /** @hidden */
  10678. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10679. /** @hidden */
  10680. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10681. /** @hidden */
  10682. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. /**
  10687. * Groups all the scene component constants in one place to ease maintenance.
  10688. * @hidden
  10689. */
  10690. export class SceneComponentConstants {
  10691. static readonly NAME_EFFECTLAYER: string;
  10692. static readonly NAME_LAYER: string;
  10693. static readonly NAME_LENSFLARESYSTEM: string;
  10694. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10695. static readonly NAME_PARTICLESYSTEM: string;
  10696. static readonly NAME_GAMEPAD: string;
  10697. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10698. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10699. static readonly NAME_PREPASSRENDERER: string;
  10700. static readonly NAME_DEPTHRENDERER: string;
  10701. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10702. static readonly NAME_SPRITE: string;
  10703. static readonly NAME_SUBSURFACE: string;
  10704. static readonly NAME_OUTLINERENDERER: string;
  10705. static readonly NAME_PROCEDURALTEXTURE: string;
  10706. static readonly NAME_SHADOWGENERATOR: string;
  10707. static readonly NAME_OCTREE: string;
  10708. static readonly NAME_PHYSICSENGINE: string;
  10709. static readonly NAME_AUDIO: string;
  10710. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10711. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10712. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10713. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10714. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10715. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10716. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10717. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10718. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10719. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10720. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10721. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10722. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10723. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10724. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10725. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10726. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10727. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10728. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10729. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10730. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10731. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10732. static readonly STEP_AFTERRENDER_AUDIO: number;
  10733. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10734. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10735. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10736. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10737. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10738. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10739. static readonly STEP_POINTERMOVE_SPRITE: number;
  10740. static readonly STEP_POINTERDOWN_SPRITE: number;
  10741. static readonly STEP_POINTERUP_SPRITE: number;
  10742. }
  10743. /**
  10744. * This represents a scene component.
  10745. *
  10746. * This is used to decouple the dependency the scene is having on the different workloads like
  10747. * layers, post processes...
  10748. */
  10749. export interface ISceneComponent {
  10750. /**
  10751. * The name of the component. Each component must have a unique name.
  10752. */
  10753. name: string;
  10754. /**
  10755. * The scene the component belongs to.
  10756. */
  10757. scene: Scene;
  10758. /**
  10759. * Register the component to one instance of a scene.
  10760. */
  10761. register(): void;
  10762. /**
  10763. * Rebuilds the elements related to this component in case of
  10764. * context lost for instance.
  10765. */
  10766. rebuild(): void;
  10767. /**
  10768. * Disposes the component and the associated ressources.
  10769. */
  10770. dispose(): void;
  10771. }
  10772. /**
  10773. * This represents a SERIALIZABLE scene component.
  10774. *
  10775. * This extends Scene Component to add Serialization methods on top.
  10776. */
  10777. export interface ISceneSerializableComponent extends ISceneComponent {
  10778. /**
  10779. * Adds all the elements from the container to the scene
  10780. * @param container the container holding the elements
  10781. */
  10782. addFromContainer(container: AbstractScene): void;
  10783. /**
  10784. * Removes all the elements in the container from the scene
  10785. * @param container contains the elements to remove
  10786. * @param dispose if the removed element should be disposed (default: false)
  10787. */
  10788. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10789. /**
  10790. * Serializes the component data to the specified json object
  10791. * @param serializationObject The object to serialize to
  10792. */
  10793. serialize(serializationObject: any): void;
  10794. }
  10795. /**
  10796. * Strong typing of a Mesh related stage step action
  10797. */
  10798. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10799. /**
  10800. * Strong typing of a Evaluate Sub Mesh related stage step action
  10801. */
  10802. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10803. /**
  10804. * Strong typing of a pre active Mesh related stage step action
  10805. */
  10806. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10807. /**
  10808. * Strong typing of a Camera related stage step action
  10809. */
  10810. export type CameraStageAction = (camera: Camera) => void;
  10811. /**
  10812. * Strong typing of a Camera Frame buffer related stage step action
  10813. */
  10814. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10815. /**
  10816. * Strong typing of a Render Target related stage step action
  10817. */
  10818. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10819. /**
  10820. * Strong typing of a RenderingGroup related stage step action
  10821. */
  10822. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10823. /**
  10824. * Strong typing of a Mesh Render related stage step action
  10825. */
  10826. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10827. /**
  10828. * Strong typing of a simple stage step action
  10829. */
  10830. export type SimpleStageAction = () => void;
  10831. /**
  10832. * Strong typing of a render target action.
  10833. */
  10834. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10835. /**
  10836. * Strong typing of a pointer move action.
  10837. */
  10838. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10839. /**
  10840. * Strong typing of a pointer up/down action.
  10841. */
  10842. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10843. /**
  10844. * Representation of a stage in the scene (Basically a list of ordered steps)
  10845. * @hidden
  10846. */
  10847. export class Stage<T extends Function> extends Array<{
  10848. index: number;
  10849. component: ISceneComponent;
  10850. action: T;
  10851. }> {
  10852. /**
  10853. * Hide ctor from the rest of the world.
  10854. * @param items The items to add.
  10855. */
  10856. private constructor();
  10857. /**
  10858. * Creates a new Stage.
  10859. * @returns A new instance of a Stage
  10860. */
  10861. static Create<T extends Function>(): Stage<T>;
  10862. /**
  10863. * Registers a step in an ordered way in the targeted stage.
  10864. * @param index Defines the position to register the step in
  10865. * @param component Defines the component attached to the step
  10866. * @param action Defines the action to launch during the step
  10867. */
  10868. registerStep(index: number, component: ISceneComponent, action: T): void;
  10869. /**
  10870. * Clears all the steps from the stage.
  10871. */
  10872. clear(): void;
  10873. }
  10874. }
  10875. declare module BABYLON {
  10876. interface Scene {
  10877. /** @hidden */
  10878. _pointerOverSprite: Nullable<Sprite>;
  10879. /** @hidden */
  10880. _pickedDownSprite: Nullable<Sprite>;
  10881. /** @hidden */
  10882. _tempSpritePickingRay: Nullable<Ray>;
  10883. /**
  10884. * All of the sprite managers added to this scene
  10885. * @see https://doc.babylonjs.com/babylon101/sprites
  10886. */
  10887. spriteManagers: Array<ISpriteManager>;
  10888. /**
  10889. * An event triggered when sprites rendering is about to start
  10890. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10891. */
  10892. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10893. /**
  10894. * An event triggered when sprites rendering is done
  10895. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10896. */
  10897. onAfterSpritesRenderingObservable: Observable<Scene>;
  10898. /** @hidden */
  10899. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10900. /** Launch a ray to try to pick a sprite in the scene
  10901. * @param x position on screen
  10902. * @param y position on screen
  10903. * @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
  10904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10905. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10906. * @returns a PickingInfo
  10907. */
  10908. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10909. /** Use the given ray to pick a sprite in the scene
  10910. * @param ray The ray (in world space) to use to pick meshes
  10911. * @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
  10912. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10913. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10914. * @returns a PickingInfo
  10915. */
  10916. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10917. /** @hidden */
  10918. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10919. /** Launch a ray to try to pick sprites in the scene
  10920. * @param x position on screen
  10921. * @param y position on screen
  10922. * @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
  10923. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10924. * @returns a PickingInfo array
  10925. */
  10926. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10927. /** Use the given ray to pick sprites in the scene
  10928. * @param ray The ray (in world space) to use to pick meshes
  10929. * @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
  10930. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10931. * @returns a PickingInfo array
  10932. */
  10933. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10934. /**
  10935. * Force the sprite under the pointer
  10936. * @param sprite defines the sprite to use
  10937. */
  10938. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10939. /**
  10940. * Gets the sprite under the pointer
  10941. * @returns a Sprite or null if no sprite is under the pointer
  10942. */
  10943. getPointerOverSprite(): Nullable<Sprite>;
  10944. }
  10945. /**
  10946. * Defines the sprite scene component responsible to manage sprites
  10947. * in a given scene.
  10948. */
  10949. export class SpriteSceneComponent implements ISceneComponent {
  10950. /**
  10951. * The component name helpfull to identify the component in the list of scene components.
  10952. */
  10953. readonly name: string;
  10954. /**
  10955. * The scene the component belongs to.
  10956. */
  10957. scene: Scene;
  10958. /** @hidden */
  10959. private _spritePredicate;
  10960. /**
  10961. * Creates a new instance of the component for the given scene
  10962. * @param scene Defines the scene to register the component in
  10963. */
  10964. constructor(scene: Scene);
  10965. /**
  10966. * Registers the component in a given scene
  10967. */
  10968. register(): void;
  10969. /**
  10970. * Rebuilds the elements related to this component in case of
  10971. * context lost for instance.
  10972. */
  10973. rebuild(): void;
  10974. /**
  10975. * Disposes the component and the associated ressources.
  10976. */
  10977. dispose(): void;
  10978. private _pickSpriteButKeepRay;
  10979. private _pointerMove;
  10980. private _pointerDown;
  10981. private _pointerUp;
  10982. }
  10983. }
  10984. declare module BABYLON {
  10985. /** @hidden */
  10986. export var fogFragmentDeclaration: {
  10987. name: string;
  10988. shader: string;
  10989. };
  10990. }
  10991. declare module BABYLON {
  10992. /** @hidden */
  10993. export var fogFragment: {
  10994. name: string;
  10995. shader: string;
  10996. };
  10997. }
  10998. declare module BABYLON {
  10999. /** @hidden */
  11000. export var imageProcessingCompatibility: {
  11001. name: string;
  11002. shader: string;
  11003. };
  11004. }
  11005. declare module BABYLON {
  11006. /** @hidden */
  11007. export var spritesPixelShader: {
  11008. name: string;
  11009. shader: string;
  11010. };
  11011. }
  11012. declare module BABYLON {
  11013. /** @hidden */
  11014. export var fogVertexDeclaration: {
  11015. name: string;
  11016. shader: string;
  11017. };
  11018. }
  11019. declare module BABYLON {
  11020. /** @hidden */
  11021. export var spritesVertexShader: {
  11022. name: string;
  11023. shader: string;
  11024. };
  11025. }
  11026. declare module BABYLON {
  11027. /**
  11028. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11029. */
  11030. export interface ISpriteManager extends IDisposable {
  11031. /**
  11032. * Gets manager's name
  11033. */
  11034. name: string;
  11035. /**
  11036. * Restricts the camera to viewing objects with the same layerMask.
  11037. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11038. */
  11039. layerMask: number;
  11040. /**
  11041. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11042. */
  11043. isPickable: boolean;
  11044. /**
  11045. * Gets the hosting scene
  11046. */
  11047. scene: Scene;
  11048. /**
  11049. * Specifies the rendering group id for this mesh (0 by default)
  11050. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11051. */
  11052. renderingGroupId: number;
  11053. /**
  11054. * Defines the list of sprites managed by the manager.
  11055. */
  11056. sprites: Array<Sprite>;
  11057. /**
  11058. * Gets or sets the spritesheet texture
  11059. */
  11060. texture: Texture;
  11061. /** Defines the default width of a cell in the spritesheet */
  11062. cellWidth: number;
  11063. /** Defines the default height of a cell in the spritesheet */
  11064. cellHeight: number;
  11065. /**
  11066. * Tests the intersection of a sprite with a specific ray.
  11067. * @param ray The ray we are sending to test the collision
  11068. * @param camera The camera space we are sending rays in
  11069. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11071. * @returns picking info or null.
  11072. */
  11073. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11074. /**
  11075. * Intersects the sprites with a ray
  11076. * @param ray defines the ray to intersect with
  11077. * @param camera defines the current active camera
  11078. * @param predicate defines a predicate used to select candidate sprites
  11079. * @returns null if no hit or a PickingInfo array
  11080. */
  11081. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11082. /**
  11083. * Renders the list of sprites on screen.
  11084. */
  11085. render(): void;
  11086. }
  11087. /**
  11088. * Class used to manage multiple sprites on the same spritesheet
  11089. * @see https://doc.babylonjs.com/babylon101/sprites
  11090. */
  11091. export class SpriteManager implements ISpriteManager {
  11092. /** defines the manager's name */
  11093. name: string;
  11094. /** Define the Url to load snippets */
  11095. static SnippetUrl: string;
  11096. /** Snippet ID if the manager was created from the snippet server */
  11097. snippetId: string;
  11098. /** Gets the list of sprites */
  11099. sprites: Sprite[];
  11100. /** Gets or sets the rendering group id (0 by default) */
  11101. renderingGroupId: number;
  11102. /** Gets or sets camera layer mask */
  11103. layerMask: number;
  11104. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11105. fogEnabled: boolean;
  11106. /** Gets or sets a boolean indicating if the sprites are pickable */
  11107. isPickable: boolean;
  11108. /** Defines the default width of a cell in the spritesheet */
  11109. cellWidth: number;
  11110. /** Defines the default height of a cell in the spritesheet */
  11111. cellHeight: number;
  11112. /** Associative array from JSON sprite data file */
  11113. private _cellData;
  11114. /** Array of sprite names from JSON sprite data file */
  11115. private _spriteMap;
  11116. /** True when packed cell data from JSON file is ready*/
  11117. private _packedAndReady;
  11118. private _textureContent;
  11119. private _useInstancing;
  11120. /**
  11121. * An event triggered when the manager is disposed.
  11122. */
  11123. onDisposeObservable: Observable<SpriteManager>;
  11124. private _onDisposeObserver;
  11125. /**
  11126. * Callback called when the manager is disposed
  11127. */
  11128. set onDispose(callback: () => void);
  11129. private _capacity;
  11130. private _fromPacked;
  11131. private _spriteTexture;
  11132. private _epsilon;
  11133. private _scene;
  11134. private _vertexData;
  11135. private _buffer;
  11136. private _vertexBuffers;
  11137. private _spriteBuffer;
  11138. private _indexBuffer;
  11139. private _effectBase;
  11140. private _effectFog;
  11141. private _vertexBufferSize;
  11142. /**
  11143. * Gets or sets the unique id of the sprite
  11144. */
  11145. uniqueId: number;
  11146. /**
  11147. * Gets the array of sprites
  11148. */
  11149. get children(): Sprite[];
  11150. /**
  11151. * Gets the hosting scene
  11152. */
  11153. get scene(): Scene;
  11154. /**
  11155. * Gets the capacity of the manager
  11156. */
  11157. get capacity(): number;
  11158. /**
  11159. * Gets or sets the spritesheet texture
  11160. */
  11161. get texture(): Texture;
  11162. set texture(value: Texture);
  11163. private _blendMode;
  11164. /**
  11165. * Blend mode use to render the particle, it can be any of
  11166. * the static Constants.ALPHA_x properties provided in this class.
  11167. * Default value is Constants.ALPHA_COMBINE
  11168. */
  11169. get blendMode(): number;
  11170. set blendMode(blendMode: number);
  11171. /** Disables writing to the depth buffer when rendering the sprites.
  11172. * It can be handy to disable depth writing when using textures without alpha channel
  11173. * and setting some specific blend modes.
  11174. */
  11175. disableDepthWrite: boolean;
  11176. /**
  11177. * Creates a new sprite manager
  11178. * @param name defines the manager's name
  11179. * @param imgUrl defines the sprite sheet url
  11180. * @param capacity defines the maximum allowed number of sprites
  11181. * @param cellSize defines the size of a sprite cell
  11182. * @param scene defines the hosting scene
  11183. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11184. * @param samplingMode defines the smapling mode to use with spritesheet
  11185. * @param fromPacked set to false; do not alter
  11186. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11187. */
  11188. constructor(
  11189. /** defines the manager's name */
  11190. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11191. /**
  11192. * Returns the string "SpriteManager"
  11193. * @returns "SpriteManager"
  11194. */
  11195. getClassName(): string;
  11196. private _makePacked;
  11197. private _appendSpriteVertex;
  11198. private _checkTextureAlpha;
  11199. /**
  11200. * Intersects the sprites with a ray
  11201. * @param ray defines the ray to intersect with
  11202. * @param camera defines the current active camera
  11203. * @param predicate defines a predicate used to select candidate sprites
  11204. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11205. * @returns null if no hit or a PickingInfo
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Render all child sprites
  11218. */
  11219. render(): void;
  11220. /**
  11221. * Release associated resources
  11222. */
  11223. dispose(): void;
  11224. /**
  11225. * Serializes the sprite manager to a JSON object
  11226. * @param serializeTexture defines if the texture must be serialized as well
  11227. * @returns the JSON object
  11228. */
  11229. serialize(serializeTexture?: boolean): any;
  11230. /**
  11231. * Parses a JSON object to create a new sprite manager.
  11232. * @param parsedManager The JSON object to parse
  11233. * @param scene The scene to create the sprite managerin
  11234. * @param rootUrl The root url to use to load external dependencies like texture
  11235. * @returns the new sprite manager
  11236. */
  11237. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11238. /**
  11239. * Creates a sprite manager from a snippet saved in a remote file
  11240. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11241. * @param url defines the url to load from
  11242. * @param scene defines the hosting scene
  11243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11244. * @returns a promise that will resolve to the new sprite manager
  11245. */
  11246. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11247. /**
  11248. * Creates a sprite manager from a snippet saved by the sprite editor
  11249. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11250. * @param scene defines the hosting scene
  11251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11252. * @returns a promise that will resolve to the new sprite manager
  11253. */
  11254. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11255. }
  11256. }
  11257. declare module BABYLON {
  11258. /** Interface used by value gradients (color, factor, ...) */
  11259. export interface IValueGradient {
  11260. /**
  11261. * Gets or sets the gradient value (between 0 and 1)
  11262. */
  11263. gradient: number;
  11264. }
  11265. /** Class used to store color4 gradient */
  11266. export class ColorGradient implements IValueGradient {
  11267. /**
  11268. * Gets or sets the gradient value (between 0 and 1)
  11269. */
  11270. gradient: number;
  11271. /**
  11272. * Gets or sets first associated color
  11273. */
  11274. color1: Color4;
  11275. /**
  11276. * Gets or sets second associated color
  11277. */
  11278. color2?: Color4 | undefined;
  11279. /**
  11280. * Creates a new color4 gradient
  11281. * @param gradient gets or sets the gradient value (between 0 and 1)
  11282. * @param color1 gets or sets first associated color
  11283. * @param color2 gets or sets first second color
  11284. */
  11285. constructor(
  11286. /**
  11287. * Gets or sets the gradient value (between 0 and 1)
  11288. */
  11289. gradient: number,
  11290. /**
  11291. * Gets or sets first associated color
  11292. */
  11293. color1: Color4,
  11294. /**
  11295. * Gets or sets second associated color
  11296. */
  11297. color2?: Color4 | undefined);
  11298. /**
  11299. * Will get a color picked randomly between color1 and color2.
  11300. * If color2 is undefined then color1 will be used
  11301. * @param result defines the target Color4 to store the result in
  11302. */
  11303. getColorToRef(result: Color4): void;
  11304. }
  11305. /** Class used to store color 3 gradient */
  11306. export class Color3Gradient implements IValueGradient {
  11307. /**
  11308. * Gets or sets the gradient value (between 0 and 1)
  11309. */
  11310. gradient: number;
  11311. /**
  11312. * Gets or sets the associated color
  11313. */
  11314. color: Color3;
  11315. /**
  11316. * Creates a new color3 gradient
  11317. * @param gradient gets or sets the gradient value (between 0 and 1)
  11318. * @param color gets or sets associated color
  11319. */
  11320. constructor(
  11321. /**
  11322. * Gets or sets the gradient value (between 0 and 1)
  11323. */
  11324. gradient: number,
  11325. /**
  11326. * Gets or sets the associated color
  11327. */
  11328. color: Color3);
  11329. }
  11330. /** Class used to store factor gradient */
  11331. export class FactorGradient implements IValueGradient {
  11332. /**
  11333. * Gets or sets the gradient value (between 0 and 1)
  11334. */
  11335. gradient: number;
  11336. /**
  11337. * Gets or sets first associated factor
  11338. */
  11339. factor1: number;
  11340. /**
  11341. * Gets or sets second associated factor
  11342. */
  11343. factor2?: number | undefined;
  11344. /**
  11345. * Creates a new factor gradient
  11346. * @param gradient gets or sets the gradient value (between 0 and 1)
  11347. * @param factor1 gets or sets first associated factor
  11348. * @param factor2 gets or sets second associated factor
  11349. */
  11350. constructor(
  11351. /**
  11352. * Gets or sets the gradient value (between 0 and 1)
  11353. */
  11354. gradient: number,
  11355. /**
  11356. * Gets or sets first associated factor
  11357. */
  11358. factor1: number,
  11359. /**
  11360. * Gets or sets second associated factor
  11361. */
  11362. factor2?: number | undefined);
  11363. /**
  11364. * Will get a number picked randomly between factor1 and factor2.
  11365. * If factor2 is undefined then factor1 will be used
  11366. * @returns the picked number
  11367. */
  11368. getFactor(): number;
  11369. }
  11370. /**
  11371. * Helper used to simplify some generic gradient tasks
  11372. */
  11373. export class GradientHelper {
  11374. /**
  11375. * Gets the current gradient from an array of IValueGradient
  11376. * @param ratio defines the current ratio to get
  11377. * @param gradients defines the array of IValueGradient
  11378. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11379. */
  11380. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11381. }
  11382. }
  11383. declare module BABYLON {
  11384. interface ThinEngine {
  11385. /**
  11386. * Creates a raw texture
  11387. * @param data defines the data to store in the texture
  11388. * @param width defines the width of the texture
  11389. * @param height defines the height of the texture
  11390. * @param format defines the format of the data
  11391. * @param generateMipMaps defines if the engine should generate the mip levels
  11392. * @param invertY defines if data must be stored with Y axis inverted
  11393. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11394. * @param compression defines the compression used (null by default)
  11395. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11396. * @returns the raw texture inside an InternalTexture
  11397. */
  11398. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11399. /**
  11400. * Update a raw texture
  11401. * @param texture defines the texture to update
  11402. * @param data defines the data to store in the texture
  11403. * @param format defines the format of the data
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. */
  11406. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11407. /**
  11408. * Update a raw texture
  11409. * @param texture defines the texture to update
  11410. * @param data defines the data to store in the texture
  11411. * @param format defines the format of the data
  11412. * @param invertY defines if data must be stored with Y axis inverted
  11413. * @param compression defines the compression used (null by default)
  11414. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11415. */
  11416. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11417. /**
  11418. * Creates a new raw cube texture
  11419. * @param data defines the array of data to use to create each face
  11420. * @param size defines the size of the textures
  11421. * @param format defines the format of the data
  11422. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11423. * @param generateMipMaps defines if the engine should generate the mip levels
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11426. * @param compression defines the compression used (null by default)
  11427. * @returns the cube texture as an InternalTexture
  11428. */
  11429. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11430. /**
  11431. * Update a raw cube texture
  11432. * @param texture defines the texture to udpdate
  11433. * @param data defines the data to store
  11434. * @param format defines the data format
  11435. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. */
  11438. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11439. /**
  11440. * Update a raw cube texture
  11441. * @param texture defines the texture to udpdate
  11442. * @param data defines the data to store
  11443. * @param format defines the data format
  11444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. * @param compression defines the compression used (null by default)
  11447. */
  11448. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11449. /**
  11450. * Update a raw cube texture
  11451. * @param texture defines the texture to udpdate
  11452. * @param data defines the data to store
  11453. * @param format defines the data format
  11454. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11455. * @param invertY defines if data must be stored with Y axis inverted
  11456. * @param compression defines the compression used (null by default)
  11457. * @param level defines which level of the texture to update
  11458. */
  11459. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11460. /**
  11461. * Creates a new raw cube texture from a specified url
  11462. * @param url defines the url where the data is located
  11463. * @param scene defines the current scene
  11464. * @param size defines the size of the textures
  11465. * @param format defines the format of the data
  11466. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11467. * @param noMipmap defines if the engine should avoid generating the mip levels
  11468. * @param callback defines a callback used to extract texture data from loaded data
  11469. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11470. * @param onLoad defines a callback called when texture is loaded
  11471. * @param onError defines a callback called if there is an error
  11472. * @returns the cube texture as an InternalTexture
  11473. */
  11474. 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;
  11475. /**
  11476. * Creates a new raw cube texture from a specified url
  11477. * @param url defines the url where the data is located
  11478. * @param scene defines the current scene
  11479. * @param size defines the size of the textures
  11480. * @param format defines the format of the data
  11481. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11482. * @param noMipmap defines if the engine should avoid generating the mip levels
  11483. * @param callback defines a callback used to extract texture data from loaded data
  11484. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11485. * @param onLoad defines a callback called when texture is loaded
  11486. * @param onError defines a callback called if there is an error
  11487. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11488. * @param invertY defines if data must be stored with Y axis inverted
  11489. * @returns the cube texture as an InternalTexture
  11490. */
  11491. 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;
  11492. /**
  11493. * Creates a new raw 3D texture
  11494. * @param data defines the data used to create the texture
  11495. * @param width defines the width of the texture
  11496. * @param height defines the height of the texture
  11497. * @param depth defines the depth of the texture
  11498. * @param format defines the format of the texture
  11499. * @param generateMipMaps defines if the engine must generate mip levels
  11500. * @param invertY defines if data must be stored with Y axis inverted
  11501. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11502. * @param compression defines the compressed used (can be null)
  11503. * @param textureType defines the compressed used (can be null)
  11504. * @returns a new raw 3D texture (stored in an InternalTexture)
  11505. */
  11506. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11507. /**
  11508. * Update a raw 3D texture
  11509. * @param texture defines the texture to update
  11510. * @param data defines the data to store
  11511. * @param format defines the data format
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. */
  11514. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11515. /**
  11516. * Update a raw 3D texture
  11517. * @param texture defines the texture to update
  11518. * @param data defines the data to store
  11519. * @param format defines the data format
  11520. * @param invertY defines if data must be stored with Y axis inverted
  11521. * @param compression defines the used compression (can be null)
  11522. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11523. */
  11524. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11525. /**
  11526. * Creates a new raw 2D array texture
  11527. * @param data defines the data used to create the texture
  11528. * @param width defines the width of the texture
  11529. * @param height defines the height of the texture
  11530. * @param depth defines the number of layers of the texture
  11531. * @param format defines the format of the texture
  11532. * @param generateMipMaps defines if the engine must generate mip levels
  11533. * @param invertY defines if data must be stored with Y axis inverted
  11534. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11535. * @param compression defines the compressed used (can be null)
  11536. * @param textureType defines the compressed used (can be null)
  11537. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11538. */
  11539. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11540. /**
  11541. * Update a raw 2D array texture
  11542. * @param texture defines the texture to update
  11543. * @param data defines the data to store
  11544. * @param format defines the data format
  11545. * @param invertY defines if data must be stored with Y axis inverted
  11546. */
  11547. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11548. /**
  11549. * Update a raw 2D array texture
  11550. * @param texture defines the texture to update
  11551. * @param data defines the data to store
  11552. * @param format defines the data format
  11553. * @param invertY defines if data must be stored with Y axis inverted
  11554. * @param compression defines the used compression (can be null)
  11555. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11556. */
  11557. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11558. }
  11559. }
  11560. declare module BABYLON {
  11561. /**
  11562. * Raw texture can help creating a texture directly from an array of data.
  11563. * This can be super useful if you either get the data from an uncompressed source or
  11564. * if you wish to create your texture pixel by pixel.
  11565. */
  11566. export class RawTexture extends Texture {
  11567. /**
  11568. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11569. */
  11570. format: number;
  11571. /**
  11572. * Instantiates a new RawTexture.
  11573. * Raw texture can help creating a texture directly from an array of data.
  11574. * This can be super useful if you either get the data from an uncompressed source or
  11575. * if you wish to create your texture pixel by pixel.
  11576. * @param data define the array of data to use to create the texture
  11577. * @param width define the width of the texture
  11578. * @param height define the height of the texture
  11579. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11580. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11581. * @param generateMipMaps define whether mip maps should be generated or not
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. */
  11586. constructor(data: ArrayBufferView, width: number, height: number,
  11587. /**
  11588. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11589. */
  11590. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11591. /**
  11592. * Updates the texture underlying data.
  11593. * @param data Define the new data of the texture
  11594. */
  11595. update(data: ArrayBufferView): void;
  11596. /**
  11597. * Creates a luminance texture from some data.
  11598. * @param data Define the texture data
  11599. * @param width Define the width of the texture
  11600. * @param height Define the height of the texture
  11601. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11602. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11603. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11604. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11605. * @returns the luminance texture
  11606. */
  11607. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11608. /**
  11609. * Creates a luminance alpha texture from some data.
  11610. * @param data Define the texture data
  11611. * @param width Define the width of the texture
  11612. * @param height Define the height of the texture
  11613. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11614. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11615. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11616. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11617. * @returns the luminance alpha texture
  11618. */
  11619. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11620. /**
  11621. * Creates an alpha texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the alpha texture
  11630. */
  11631. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a RGB texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11642. * @returns the RGB alpha texture
  11643. */
  11644. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11645. /**
  11646. * Creates a RGBA texture from some data.
  11647. * @param data Define the texture data
  11648. * @param width Define the width of the texture
  11649. * @param height Define the height of the texture
  11650. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11651. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11652. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11653. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11654. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11655. * @returns the RGBA texture
  11656. */
  11657. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11658. /**
  11659. * Creates a R texture from some data.
  11660. * @param data Define the texture data
  11661. * @param width Define the width of the texture
  11662. * @param height Define the height of the texture
  11663. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11667. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11668. * @returns the R texture
  11669. */
  11670. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11671. }
  11672. }
  11673. declare module BABYLON {
  11674. interface ThinEngine {
  11675. /**
  11676. * Update a dynamic index buffer
  11677. * @param indexBuffer defines the target index buffer
  11678. * @param indices defines the data to update
  11679. * @param offset defines the offset in the target index buffer where update should start
  11680. */
  11681. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11682. /**
  11683. * Updates a dynamic vertex buffer.
  11684. * @param vertexBuffer the vertex buffer to update
  11685. * @param data the data used to update the vertex buffer
  11686. * @param byteOffset the byte offset of the data
  11687. * @param byteLength the byte length of the data
  11688. */
  11689. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11690. }
  11691. }
  11692. declare module BABYLON {
  11693. interface AbstractScene {
  11694. /**
  11695. * The list of procedural textures added to the scene
  11696. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11697. */
  11698. proceduralTextures: Array<ProceduralTexture>;
  11699. }
  11700. /**
  11701. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11702. * in a given scene.
  11703. */
  11704. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11705. /**
  11706. * The component name helpfull to identify the component in the list of scene components.
  11707. */
  11708. readonly name: string;
  11709. /**
  11710. * The scene the component belongs to.
  11711. */
  11712. scene: Scene;
  11713. /**
  11714. * Creates a new instance of the component for the given scene
  11715. * @param scene Defines the scene to register the component in
  11716. */
  11717. constructor(scene: Scene);
  11718. /**
  11719. * Registers the component in a given scene
  11720. */
  11721. register(): void;
  11722. /**
  11723. * Rebuilds the elements related to this component in case of
  11724. * context lost for instance.
  11725. */
  11726. rebuild(): void;
  11727. /**
  11728. * Disposes the component and the associated ressources.
  11729. */
  11730. dispose(): void;
  11731. private _beforeClear;
  11732. }
  11733. }
  11734. declare module BABYLON {
  11735. interface ThinEngine {
  11736. /**
  11737. * Creates a new render target cube texture
  11738. * @param size defines the size of the texture
  11739. * @param options defines the options used to create the texture
  11740. * @returns a new render target cube texture stored in an InternalTexture
  11741. */
  11742. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11743. }
  11744. }
  11745. declare module BABYLON {
  11746. /** @hidden */
  11747. export var proceduralVertexShader: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module BABYLON {
  11753. /**
  11754. * 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.
  11755. * This is the base class of any Procedural texture and contains most of the shareable code.
  11756. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11757. */
  11758. export class ProceduralTexture extends Texture {
  11759. /**
  11760. * Define if the texture is enabled or not (disabled texture will not render)
  11761. */
  11762. isEnabled: boolean;
  11763. /**
  11764. * Define if the texture must be cleared before rendering (default is true)
  11765. */
  11766. autoClear: boolean;
  11767. /**
  11768. * Callback called when the texture is generated
  11769. */
  11770. onGenerated: () => void;
  11771. /**
  11772. * Event raised when the texture is generated
  11773. */
  11774. onGeneratedObservable: Observable<ProceduralTexture>;
  11775. /**
  11776. * Event raised before the texture is generated
  11777. */
  11778. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11779. /**
  11780. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11781. */
  11782. nodeMaterialSource: Nullable<NodeMaterial>;
  11783. /** @hidden */
  11784. _generateMipMaps: boolean;
  11785. /** @hidden **/
  11786. _effect: Effect;
  11787. /** @hidden */
  11788. _textures: {
  11789. [key: string]: Texture;
  11790. };
  11791. /** @hidden */
  11792. protected _fallbackTexture: Nullable<Texture>;
  11793. private _size;
  11794. private _currentRefreshId;
  11795. private _frameId;
  11796. private _refreshRate;
  11797. private _vertexBuffers;
  11798. private _indexBuffer;
  11799. private _uniforms;
  11800. private _samplers;
  11801. private _fragment;
  11802. private _floats;
  11803. private _ints;
  11804. private _floatsArrays;
  11805. private _colors3;
  11806. private _colors4;
  11807. private _vectors2;
  11808. private _vectors3;
  11809. private _matrices;
  11810. private _fallbackTextureUsed;
  11811. private _fullEngine;
  11812. private _cachedDefines;
  11813. private _contentUpdateId;
  11814. private _contentData;
  11815. /**
  11816. * Instantiates a new procedural texture.
  11817. * 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.
  11818. * This is the base class of any Procedural texture and contains most of the shareable code.
  11819. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11820. * @param name Define the name of the texture
  11821. * @param size Define the size of the texture to create
  11822. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11823. * @param scene Define the scene the texture belongs to
  11824. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11825. * @param generateMipMaps Define if the texture should creates mip maps or not
  11826. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11827. * @param textureType The FBO internal texture type
  11828. */
  11829. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11830. /**
  11831. * The effect that is created when initializing the post process.
  11832. * @returns The created effect corresponding the the postprocess.
  11833. */
  11834. getEffect(): Effect;
  11835. /**
  11836. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11837. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11838. */
  11839. getContent(): Nullable<ArrayBufferView>;
  11840. private _createIndexBuffer;
  11841. /** @hidden */
  11842. _rebuild(): void;
  11843. /**
  11844. * Resets the texture in order to recreate its associated resources.
  11845. * This can be called in case of context loss
  11846. */
  11847. reset(): void;
  11848. protected _getDefines(): string;
  11849. /**
  11850. * Is the texture ready to be used ? (rendered at least once)
  11851. * @returns true if ready, otherwise, false.
  11852. */
  11853. isReady(): boolean;
  11854. /**
  11855. * Resets the refresh counter of the texture and start bak from scratch.
  11856. * Could be useful to regenerate the texture if it is setup to render only once.
  11857. */
  11858. resetRefreshCounter(): void;
  11859. /**
  11860. * Set the fragment shader to use in order to render the texture.
  11861. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11862. */
  11863. setFragment(fragment: any): void;
  11864. /**
  11865. * Define the refresh rate of the texture or the rendering frequency.
  11866. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11867. */
  11868. get refreshRate(): number;
  11869. set refreshRate(value: number);
  11870. /** @hidden */
  11871. _shouldRender(): boolean;
  11872. /**
  11873. * Get the size the texture is rendering at.
  11874. * @returns the size (on cube texture it is always squared)
  11875. */
  11876. getRenderSize(): RenderTargetTextureSize;
  11877. /**
  11878. * Resize the texture to new value.
  11879. * @param size Define the new size the texture should have
  11880. * @param generateMipMaps Define whether the new texture should create mip maps
  11881. */
  11882. resize(size: number, generateMipMaps: boolean): void;
  11883. private _checkUniform;
  11884. /**
  11885. * Set a texture in the shader program used to render.
  11886. * @param name Define the name of the uniform samplers as defined in the shader
  11887. * @param texture Define the texture to bind to this sampler
  11888. * @return the texture itself allowing "fluent" like uniform updates
  11889. */
  11890. setTexture(name: string, texture: Texture): ProceduralTexture;
  11891. /**
  11892. * Set a float in the shader.
  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. setFloat(name: string, value: number): ProceduralTexture;
  11898. /**
  11899. * Set a int in the shader.
  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. setInt(name: string, value: number): ProceduralTexture;
  11905. /**
  11906. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ProceduralTexture;
  11912. /**
  11913. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  11919. /**
  11920. * Set a vec4 in the shader from a Color4.
  11921. * @param name Define the name of the uniform as defined in the shader
  11922. * @param value Define the value to give to the uniform
  11923. * @return the texture itself allowing "fluent" like uniform updates
  11924. */
  11925. setColor4(name: string, value: Color4): ProceduralTexture;
  11926. /**
  11927. * Set a vec2 in the shader from a Vector2.
  11928. * @param name Define the name of the uniform as defined in the shader
  11929. * @param value Define the value to give to the uniform
  11930. * @return the texture itself allowing "fluent" like uniform updates
  11931. */
  11932. setVector2(name: string, value: Vector2): ProceduralTexture;
  11933. /**
  11934. * Set a vec3 in the shader from a Vector3.
  11935. * @param name Define the name of the uniform as defined in the shader
  11936. * @param value Define the value to give to the uniform
  11937. * @return the texture itself allowing "fluent" like uniform updates
  11938. */
  11939. setVector3(name: string, value: Vector3): ProceduralTexture;
  11940. /**
  11941. * Set a mat4 in the shader from a MAtrix.
  11942. * @param name Define the name of the uniform as defined in the shader
  11943. * @param value Define the value to give to the uniform
  11944. * @return the texture itself allowing "fluent" like uniform updates
  11945. */
  11946. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11947. /**
  11948. * Render the texture to its associated render target.
  11949. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11950. */
  11951. render(useCameraPostProcess?: boolean): void;
  11952. /**
  11953. * Clone the texture.
  11954. * @returns the cloned texture
  11955. */
  11956. clone(): ProceduralTexture;
  11957. /**
  11958. * Dispose the texture and release its asoociated resources.
  11959. */
  11960. dispose(): void;
  11961. }
  11962. }
  11963. declare module BABYLON {
  11964. /**
  11965. * This represents the base class for particle system in Babylon.
  11966. * 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.
  11967. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11968. * @example https://doc.babylonjs.com/babylon101/particles
  11969. */
  11970. export class BaseParticleSystem {
  11971. /**
  11972. * Source color is added to the destination color without alpha affecting the result
  11973. */
  11974. static BLENDMODE_ONEONE: number;
  11975. /**
  11976. * Blend current color and particle color using particle’s alpha
  11977. */
  11978. static BLENDMODE_STANDARD: number;
  11979. /**
  11980. * Add current color and particle color multiplied by particle’s alpha
  11981. */
  11982. static BLENDMODE_ADD: number;
  11983. /**
  11984. * Multiply current color with particle color
  11985. */
  11986. static BLENDMODE_MULTIPLY: number;
  11987. /**
  11988. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11989. */
  11990. static BLENDMODE_MULTIPLYADD: number;
  11991. /**
  11992. * List of animations used by the particle system.
  11993. */
  11994. animations: Animation[];
  11995. /**
  11996. * Gets or sets the unique id of the particle system
  11997. */
  11998. uniqueId: number;
  11999. /**
  12000. * The id of the Particle system.
  12001. */
  12002. id: string;
  12003. /**
  12004. * The friendly name of the Particle system.
  12005. */
  12006. name: string;
  12007. /**
  12008. * Snippet ID if the particle system was created from the snippet server
  12009. */
  12010. snippetId: string;
  12011. /**
  12012. * The rendering group used by the Particle system to chose when to render.
  12013. */
  12014. renderingGroupId: number;
  12015. /**
  12016. * The emitter represents the Mesh or position we are attaching the particle system to.
  12017. */
  12018. emitter: Nullable<AbstractMesh | Vector3>;
  12019. /**
  12020. * The maximum number of particles to emit per frame
  12021. */
  12022. emitRate: number;
  12023. /**
  12024. * If you want to launch only a few particles at once, that can be done, as well.
  12025. */
  12026. manualEmitCount: number;
  12027. /**
  12028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12029. */
  12030. updateSpeed: number;
  12031. /**
  12032. * The amount of time the particle system is running (depends of the overall update speed).
  12033. */
  12034. targetStopDuration: number;
  12035. /**
  12036. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12037. */
  12038. disposeOnStop: boolean;
  12039. /**
  12040. * Minimum power of emitting particles.
  12041. */
  12042. minEmitPower: number;
  12043. /**
  12044. * Maximum power of emitting particles.
  12045. */
  12046. maxEmitPower: number;
  12047. /**
  12048. * Minimum life time of emitting particles.
  12049. */
  12050. minLifeTime: number;
  12051. /**
  12052. * Maximum life time of emitting particles.
  12053. */
  12054. maxLifeTime: number;
  12055. /**
  12056. * Minimum Size of emitting particles.
  12057. */
  12058. minSize: number;
  12059. /**
  12060. * Maximum Size of emitting particles.
  12061. */
  12062. maxSize: number;
  12063. /**
  12064. * Minimum scale of emitting particles on X axis.
  12065. */
  12066. minScaleX: number;
  12067. /**
  12068. * Maximum scale of emitting particles on X axis.
  12069. */
  12070. maxScaleX: number;
  12071. /**
  12072. * Minimum scale of emitting particles on Y axis.
  12073. */
  12074. minScaleY: number;
  12075. /**
  12076. * Maximum scale of emitting particles on Y axis.
  12077. */
  12078. maxScaleY: number;
  12079. /**
  12080. * Gets or sets the minimal initial rotation in radians.
  12081. */
  12082. minInitialRotation: number;
  12083. /**
  12084. * Gets or sets the maximal initial rotation in radians.
  12085. */
  12086. maxInitialRotation: number;
  12087. /**
  12088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12089. */
  12090. minAngularSpeed: number;
  12091. /**
  12092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12093. */
  12094. maxAngularSpeed: number;
  12095. /**
  12096. * The texture used to render each particle. (this can be a spritesheet)
  12097. */
  12098. particleTexture: Nullable<BaseTexture>;
  12099. /**
  12100. * The layer mask we are rendering the particles through.
  12101. */
  12102. layerMask: number;
  12103. /**
  12104. * This can help using your own shader to render the particle system.
  12105. * The according effect will be created
  12106. */
  12107. customShader: any;
  12108. /**
  12109. * By default particle system starts as soon as they are created. This prevents the
  12110. * automatic start to happen and let you decide when to start emitting particles.
  12111. */
  12112. preventAutoStart: boolean;
  12113. private _noiseTexture;
  12114. /**
  12115. * Gets or sets a texture used to add random noise to particle positions
  12116. */
  12117. get noiseTexture(): Nullable<ProceduralTexture>;
  12118. set noiseTexture(value: Nullable<ProceduralTexture>);
  12119. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12120. noiseStrength: Vector3;
  12121. /**
  12122. * Callback triggered when the particle animation is ending.
  12123. */
  12124. onAnimationEnd: Nullable<() => void>;
  12125. /**
  12126. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12127. */
  12128. blendMode: number;
  12129. /**
  12130. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12131. * to override the particles.
  12132. */
  12133. forceDepthWrite: boolean;
  12134. /** 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 */
  12135. preWarmCycles: number;
  12136. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12137. preWarmStepOffset: number;
  12138. /**
  12139. * 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)
  12140. */
  12141. spriteCellChangeSpeed: number;
  12142. /**
  12143. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12144. */
  12145. startSpriteCellID: number;
  12146. /**
  12147. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12148. */
  12149. endSpriteCellID: number;
  12150. /**
  12151. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12152. */
  12153. spriteCellWidth: number;
  12154. /**
  12155. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12156. */
  12157. spriteCellHeight: number;
  12158. /**
  12159. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12160. */
  12161. spriteRandomStartCell: boolean;
  12162. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12163. translationPivot: Vector2;
  12164. /** @hidden */
  12165. protected _isAnimationSheetEnabled: boolean;
  12166. /**
  12167. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12168. */
  12169. beginAnimationOnStart: boolean;
  12170. /**
  12171. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12172. */
  12173. beginAnimationFrom: number;
  12174. /**
  12175. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12176. */
  12177. beginAnimationTo: number;
  12178. /**
  12179. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12180. */
  12181. beginAnimationLoop: boolean;
  12182. /**
  12183. * Gets or sets a world offset applied to all particles
  12184. */
  12185. worldOffset: Vector3;
  12186. /**
  12187. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12188. */
  12189. get isAnimationSheetEnabled(): boolean;
  12190. set isAnimationSheetEnabled(value: boolean);
  12191. /**
  12192. * Get hosting scene
  12193. * @returns the scene
  12194. */
  12195. getScene(): Nullable<Scene>;
  12196. /**
  12197. * You can use gravity if you want to give an orientation to your particles.
  12198. */
  12199. gravity: Vector3;
  12200. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12201. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12202. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12203. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12204. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12205. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12206. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12207. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12208. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12209. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12210. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12211. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12212. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12213. /**
  12214. * Defines the delay in milliseconds before starting the system (0 by default)
  12215. */
  12216. startDelay: number;
  12217. /**
  12218. * Gets the current list of drag gradients.
  12219. * You must use addDragGradient and removeDragGradient to udpate this list
  12220. * @returns the list of drag gradients
  12221. */
  12222. getDragGradients(): Nullable<Array<FactorGradient>>;
  12223. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12224. limitVelocityDamping: number;
  12225. /**
  12226. * Gets the current list of limit velocity gradients.
  12227. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12228. * @returns the list of limit velocity gradients
  12229. */
  12230. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12231. /**
  12232. * Gets the current list of color gradients.
  12233. * You must use addColorGradient and removeColorGradient to udpate this list
  12234. * @returns the list of color gradients
  12235. */
  12236. getColorGradients(): Nullable<Array<ColorGradient>>;
  12237. /**
  12238. * Gets the current list of size gradients.
  12239. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12240. * @returns the list of size gradients
  12241. */
  12242. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12243. /**
  12244. * Gets the current list of color remap gradients.
  12245. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12246. * @returns the list of color remap gradients
  12247. */
  12248. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12249. /**
  12250. * Gets the current list of alpha remap gradients.
  12251. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12252. * @returns the list of alpha remap gradients
  12253. */
  12254. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of life time gradients.
  12257. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12258. * @returns the list of life time gradients
  12259. */
  12260. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12261. /**
  12262. * Gets the current list of angular speed gradients.
  12263. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12264. * @returns the list of angular speed gradients
  12265. */
  12266. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of velocity gradients.
  12269. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12270. * @returns the list of velocity gradients
  12271. */
  12272. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of start size gradients.
  12275. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12276. * @returns the list of start size gradients
  12277. */
  12278. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of emit rate gradients.
  12281. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12282. * @returns the list of emit rate gradients
  12283. */
  12284. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12287. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12288. */
  12289. get direction1(): Vector3;
  12290. set direction1(value: Vector3);
  12291. /**
  12292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12293. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12294. */
  12295. get direction2(): Vector3;
  12296. set direction2(value: Vector3);
  12297. /**
  12298. * 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.
  12299. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12300. */
  12301. get minEmitBox(): Vector3;
  12302. set minEmitBox(value: Vector3);
  12303. /**
  12304. * 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.
  12305. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12306. */
  12307. get maxEmitBox(): Vector3;
  12308. set maxEmitBox(value: Vector3);
  12309. /**
  12310. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12311. */
  12312. color1: Color4;
  12313. /**
  12314. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12315. */
  12316. color2: Color4;
  12317. /**
  12318. * Color the particle will have at the end of its lifetime
  12319. */
  12320. colorDead: Color4;
  12321. /**
  12322. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12323. */
  12324. textureMask: Color4;
  12325. /**
  12326. * The particle emitter type defines the emitter used by the particle system.
  12327. * It can be for example box, sphere, or cone...
  12328. */
  12329. particleEmitterType: IParticleEmitterType;
  12330. /** @hidden */
  12331. _isSubEmitter: boolean;
  12332. /**
  12333. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12334. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12335. */
  12336. billboardMode: number;
  12337. protected _isBillboardBased: boolean;
  12338. /**
  12339. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12340. */
  12341. get isBillboardBased(): boolean;
  12342. set isBillboardBased(value: boolean);
  12343. /**
  12344. * The scene the particle system belongs to.
  12345. */
  12346. protected _scene: Nullable<Scene>;
  12347. /**
  12348. * The engine the particle system belongs to.
  12349. */
  12350. protected _engine: ThinEngine;
  12351. /**
  12352. * Local cache of defines for image processing.
  12353. */
  12354. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12355. /**
  12356. * Default configuration related to image processing available in the standard Material.
  12357. */
  12358. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12359. /**
  12360. * Gets the image processing configuration used either in this material.
  12361. */
  12362. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12363. /**
  12364. * Sets the Default image processing configuration used either in the this material.
  12365. *
  12366. * If sets to null, the scene one is in use.
  12367. */
  12368. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12369. /**
  12370. * Attaches a new image processing configuration to the Standard Material.
  12371. * @param configuration
  12372. */
  12373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12374. /** @hidden */
  12375. protected _reset(): void;
  12376. /** @hidden */
  12377. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12378. /**
  12379. * Instantiates a particle system.
  12380. * 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.
  12381. * @param name The name of the particle system
  12382. */
  12383. constructor(name: string);
  12384. /**
  12385. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12386. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12387. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12388. * @returns the emitter
  12389. */
  12390. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12391. /**
  12392. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12393. * @param radius The radius of the hemisphere to emit from
  12394. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12395. * @returns the emitter
  12396. */
  12397. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12398. /**
  12399. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12400. * @param radius The radius of the sphere to emit from
  12401. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12402. * @returns the emitter
  12403. */
  12404. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12405. /**
  12406. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12407. * @param radius The radius of the sphere to emit from
  12408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12410. * @returns the emitter
  12411. */
  12412. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12413. /**
  12414. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12415. * @param radius The radius of the emission cylinder
  12416. * @param height The height of the emission cylinder
  12417. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12418. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12419. * @returns the emitter
  12420. */
  12421. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12422. /**
  12423. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12424. * @param radius The radius of the cylinder to emit from
  12425. * @param height The height of the emission cylinder
  12426. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12427. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12428. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12429. * @returns the emitter
  12430. */
  12431. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12432. /**
  12433. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12434. * @param radius The radius of the cone to emit from
  12435. * @param angle The base angle of the cone
  12436. * @returns the emitter
  12437. */
  12438. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12439. /**
  12440. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12443. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12444. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12445. * @returns the emitter
  12446. */
  12447. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12448. }
  12449. }
  12450. declare module BABYLON {
  12451. /**
  12452. * Type of sub emitter
  12453. */
  12454. export enum SubEmitterType {
  12455. /**
  12456. * Attached to the particle over it's lifetime
  12457. */
  12458. ATTACHED = 0,
  12459. /**
  12460. * Created when the particle dies
  12461. */
  12462. END = 1
  12463. }
  12464. /**
  12465. * Sub emitter class used to emit particles from an existing particle
  12466. */
  12467. export class SubEmitter {
  12468. /**
  12469. * the particle system to be used by the sub emitter
  12470. */
  12471. particleSystem: ParticleSystem;
  12472. /**
  12473. * Type of the submitter (Default: END)
  12474. */
  12475. type: SubEmitterType;
  12476. /**
  12477. * 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)
  12478. * Note: This only is supported when using an emitter of type Mesh
  12479. */
  12480. inheritDirection: boolean;
  12481. /**
  12482. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12483. */
  12484. inheritedVelocityAmount: number;
  12485. /**
  12486. * Creates a sub emitter
  12487. * @param particleSystem the particle system to be used by the sub emitter
  12488. */
  12489. constructor(
  12490. /**
  12491. * the particle system to be used by the sub emitter
  12492. */
  12493. particleSystem: ParticleSystem);
  12494. /**
  12495. * Clones the sub emitter
  12496. * @returns the cloned sub emitter
  12497. */
  12498. clone(): SubEmitter;
  12499. /**
  12500. * Serialize current object to a JSON object
  12501. * @returns the serialized object
  12502. */
  12503. serialize(): any;
  12504. /** @hidden */
  12505. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12506. /**
  12507. * Creates a new SubEmitter from a serialized JSON version
  12508. * @param serializationObject defines the JSON object to read from
  12509. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12510. * @param rootUrl defines the rootUrl for data loading
  12511. * @returns a new SubEmitter
  12512. */
  12513. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12514. /** Release associated resources */
  12515. dispose(): void;
  12516. }
  12517. }
  12518. declare module BABYLON {
  12519. /** @hidden */
  12520. export var imageProcessingDeclaration: {
  12521. name: string;
  12522. shader: string;
  12523. };
  12524. }
  12525. declare module BABYLON {
  12526. /** @hidden */
  12527. export var imageProcessingFunctions: {
  12528. name: string;
  12529. shader: string;
  12530. };
  12531. }
  12532. declare module BABYLON {
  12533. /** @hidden */
  12534. export var particlesPixelShader: {
  12535. name: string;
  12536. shader: string;
  12537. };
  12538. }
  12539. declare module BABYLON {
  12540. /** @hidden */
  12541. export var particlesVertexShader: {
  12542. name: string;
  12543. shader: string;
  12544. };
  12545. }
  12546. declare module BABYLON {
  12547. /**
  12548. * Interface used to define entities containing multiple clip planes
  12549. */
  12550. export interface IClipPlanesHolder {
  12551. /**
  12552. * Gets or sets the active clipplane 1
  12553. */
  12554. clipPlane: Nullable<Plane>;
  12555. /**
  12556. * Gets or sets the active clipplane 2
  12557. */
  12558. clipPlane2: Nullable<Plane>;
  12559. /**
  12560. * Gets or sets the active clipplane 3
  12561. */
  12562. clipPlane3: Nullable<Plane>;
  12563. /**
  12564. * Gets or sets the active clipplane 4
  12565. */
  12566. clipPlane4: Nullable<Plane>;
  12567. /**
  12568. * Gets or sets the active clipplane 5
  12569. */
  12570. clipPlane5: Nullable<Plane>;
  12571. /**
  12572. * Gets or sets the active clipplane 6
  12573. */
  12574. clipPlane6: Nullable<Plane>;
  12575. }
  12576. }
  12577. declare module BABYLON {
  12578. /**
  12579. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12580. *
  12581. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12582. *
  12583. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12584. */
  12585. export class ThinMaterialHelper {
  12586. /**
  12587. * Binds the clip plane information from the holder to the effect.
  12588. * @param effect The effect we are binding the data to
  12589. * @param holder The entity containing the clip plane information
  12590. */
  12591. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12592. }
  12593. }
  12594. declare module BABYLON {
  12595. interface ThinEngine {
  12596. /**
  12597. * Sets alpha constants used by some alpha blending modes
  12598. * @param r defines the red component
  12599. * @param g defines the green component
  12600. * @param b defines the blue component
  12601. * @param a defines the alpha component
  12602. */
  12603. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12604. /**
  12605. * Sets the current alpha mode
  12606. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12607. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12608. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12609. */
  12610. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12611. /**
  12612. * Gets the current alpha mode
  12613. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12614. * @returns the current alpha mode
  12615. */
  12616. getAlphaMode(): number;
  12617. /**
  12618. * Sets the current alpha equation
  12619. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12620. */
  12621. setAlphaEquation(equation: number): void;
  12622. /**
  12623. * Gets the current alpha equation.
  12624. * @returns the current alpha equation
  12625. */
  12626. getAlphaEquation(): number;
  12627. }
  12628. }
  12629. declare module BABYLON {
  12630. /**
  12631. * This represents a particle system in Babylon.
  12632. * 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.
  12633. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12634. * @example https://doc.babylonjs.com/babylon101/particles
  12635. */
  12636. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12637. /**
  12638. * Billboard mode will only apply to Y axis
  12639. */
  12640. static readonly BILLBOARDMODE_Y: number;
  12641. /**
  12642. * Billboard mode will apply to all axes
  12643. */
  12644. static readonly BILLBOARDMODE_ALL: number;
  12645. /**
  12646. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12647. */
  12648. static readonly BILLBOARDMODE_STRETCHED: number;
  12649. /**
  12650. * This function can be defined to provide custom update for active particles.
  12651. * This function will be called instead of regular update (age, position, color, etc.).
  12652. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12653. */
  12654. updateFunction: (particles: Particle[]) => void;
  12655. private _emitterWorldMatrix;
  12656. /**
  12657. * This function can be defined to specify initial direction for every new particle.
  12658. * It by default use the emitterType defined function
  12659. */
  12660. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12661. /**
  12662. * This function can be defined to specify initial position for every new particle.
  12663. * It by default use the emitterType defined function
  12664. */
  12665. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12666. /**
  12667. * @hidden
  12668. */
  12669. _inheritedVelocityOffset: Vector3;
  12670. /**
  12671. * An event triggered when the system is disposed
  12672. */
  12673. onDisposeObservable: Observable<IParticleSystem>;
  12674. /**
  12675. * An event triggered when the system is stopped
  12676. */
  12677. onStoppedObservable: Observable<IParticleSystem>;
  12678. private _onDisposeObserver;
  12679. /**
  12680. * Sets a callback that will be triggered when the system is disposed
  12681. */
  12682. set onDispose(callback: () => void);
  12683. private _particles;
  12684. private _epsilon;
  12685. private _capacity;
  12686. private _stockParticles;
  12687. private _newPartsExcess;
  12688. private _vertexData;
  12689. private _vertexBuffer;
  12690. private _vertexBuffers;
  12691. private _spriteBuffer;
  12692. private _indexBuffer;
  12693. private _effect;
  12694. private _customEffect;
  12695. private _cachedDefines;
  12696. private _scaledColorStep;
  12697. private _colorDiff;
  12698. private _scaledDirection;
  12699. private _scaledGravity;
  12700. private _currentRenderId;
  12701. private _alive;
  12702. private _useInstancing;
  12703. private _vertexArrayObject;
  12704. private _started;
  12705. private _stopped;
  12706. private _actualFrame;
  12707. private _scaledUpdateSpeed;
  12708. private _vertexBufferSize;
  12709. /** @hidden */
  12710. _currentEmitRateGradient: Nullable<FactorGradient>;
  12711. /** @hidden */
  12712. _currentEmitRate1: number;
  12713. /** @hidden */
  12714. _currentEmitRate2: number;
  12715. /** @hidden */
  12716. _currentStartSizeGradient: Nullable<FactorGradient>;
  12717. /** @hidden */
  12718. _currentStartSize1: number;
  12719. /** @hidden */
  12720. _currentStartSize2: number;
  12721. private readonly _rawTextureWidth;
  12722. private _rampGradientsTexture;
  12723. private _useRampGradients;
  12724. /** Gets or sets a matrix to use to compute projection */
  12725. defaultProjectionMatrix: Matrix;
  12726. /** Gets or sets a matrix to use to compute view */
  12727. defaultViewMatrix: Matrix;
  12728. /** Gets or sets a boolean indicating that ramp gradients must be used
  12729. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12730. */
  12731. get useRampGradients(): boolean;
  12732. set useRampGradients(value: boolean);
  12733. /**
  12734. * 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.
  12735. * 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: [])
  12736. */
  12737. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12738. private _subEmitters;
  12739. /**
  12740. * @hidden
  12741. * If the particle systems emitter should be disposed when the particle system is disposed
  12742. */
  12743. _disposeEmitterOnDispose: boolean;
  12744. /**
  12745. * The current active Sub-systems, this property is used by the root particle system only.
  12746. */
  12747. activeSubSystems: Array<ParticleSystem>;
  12748. /**
  12749. * Specifies if the particles are updated in emitter local space or world space
  12750. */
  12751. isLocal: boolean;
  12752. private _rootParticleSystem;
  12753. /**
  12754. * Gets the current list of active particles
  12755. */
  12756. get particles(): Particle[];
  12757. /**
  12758. * Gets the number of particles active at the same time.
  12759. * @returns The number of active particles.
  12760. */
  12761. getActiveCount(): number;
  12762. /**
  12763. * Returns the string "ParticleSystem"
  12764. * @returns a string containing the class name
  12765. */
  12766. getClassName(): string;
  12767. /**
  12768. * Gets a boolean indicating that the system is stopping
  12769. * @returns true if the system is currently stopping
  12770. */
  12771. isStopping(): boolean;
  12772. /**
  12773. * Gets the custom effect used to render the particles
  12774. * @param blendMode Blend mode for which the effect should be retrieved
  12775. * @returns The effect
  12776. */
  12777. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12778. /**
  12779. * Sets the custom effect used to render the particles
  12780. * @param effect The effect to set
  12781. * @param blendMode Blend mode for which the effect should be set
  12782. */
  12783. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12784. /** @hidden */
  12785. private _onBeforeDrawParticlesObservable;
  12786. /**
  12787. * Observable that will be called just before the particles are drawn
  12788. */
  12789. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12790. /**
  12791. * Gets the name of the particle vertex shader
  12792. */
  12793. get vertexShaderName(): string;
  12794. /**
  12795. * Instantiates a particle system.
  12796. * 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.
  12797. * @param name The name of the particle system
  12798. * @param capacity The max number of particles alive at the same time
  12799. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12800. * @param customEffect a custom effect used to change the way particles are rendered by default
  12801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12802. * @param epsilon Offset used to render the particles
  12803. */
  12804. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12805. private _addFactorGradient;
  12806. private _removeFactorGradient;
  12807. /**
  12808. * Adds a new life time gradient
  12809. * @param gradient defines the gradient to use (between 0 and 1)
  12810. * @param factor defines the life time factor to affect to the specified gradient
  12811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12812. * @returns the current particle system
  12813. */
  12814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12815. /**
  12816. * Remove a specific life time gradient
  12817. * @param gradient defines the gradient to remove
  12818. * @returns the current particle system
  12819. */
  12820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12821. /**
  12822. * Adds a new size gradient
  12823. * @param gradient defines the gradient to use (between 0 and 1)
  12824. * @param factor defines the size factor to affect to the specified gradient
  12825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12826. * @returns the current particle system
  12827. */
  12828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12829. /**
  12830. * Remove a specific size gradient
  12831. * @param gradient defines the gradient to remove
  12832. * @returns the current particle system
  12833. */
  12834. removeSizeGradient(gradient: number): IParticleSystem;
  12835. /**
  12836. * Adds a new color remap gradient
  12837. * @param gradient defines the gradient to use (between 0 and 1)
  12838. * @param min defines the color remap minimal range
  12839. * @param max defines the color remap maximal range
  12840. * @returns the current particle system
  12841. */
  12842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12843. /**
  12844. * Remove a specific color remap gradient
  12845. * @param gradient defines the gradient to remove
  12846. * @returns the current particle system
  12847. */
  12848. removeColorRemapGradient(gradient: number): IParticleSystem;
  12849. /**
  12850. * Adds a new alpha remap gradient
  12851. * @param gradient defines the gradient to use (between 0 and 1)
  12852. * @param min defines the alpha remap minimal range
  12853. * @param max defines the alpha remap maximal range
  12854. * @returns the current particle system
  12855. */
  12856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12857. /**
  12858. * Remove a specific alpha remap gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12863. /**
  12864. * Adds a new angular speed gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param factor defines the angular speed to affect to the specified gradient
  12867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12868. * @returns the current particle system
  12869. */
  12870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12871. /**
  12872. * Remove a specific angular speed gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns the current particle system
  12875. */
  12876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12877. /**
  12878. * Adds a new velocity gradient
  12879. * @param gradient defines the gradient to use (between 0 and 1)
  12880. * @param factor defines the velocity to affect to the specified gradient
  12881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12882. * @returns the current particle system
  12883. */
  12884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12885. /**
  12886. * Remove a specific velocity gradient
  12887. * @param gradient defines the gradient to remove
  12888. * @returns the current particle system
  12889. */
  12890. removeVelocityGradient(gradient: number): IParticleSystem;
  12891. /**
  12892. * Adds a new limit velocity gradient
  12893. * @param gradient defines the gradient to use (between 0 and 1)
  12894. * @param factor defines the limit velocity value to affect to the specified gradient
  12895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12896. * @returns the current particle system
  12897. */
  12898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12899. /**
  12900. * Remove a specific limit velocity gradient
  12901. * @param gradient defines the gradient to remove
  12902. * @returns the current particle system
  12903. */
  12904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12905. /**
  12906. * Adds a new drag gradient
  12907. * @param gradient defines the gradient to use (between 0 and 1)
  12908. * @param factor defines the drag value to affect to the specified gradient
  12909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12910. * @returns the current particle system
  12911. */
  12912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12913. /**
  12914. * Remove a specific drag gradient
  12915. * @param gradient defines the gradient to remove
  12916. * @returns the current particle system
  12917. */
  12918. removeDragGradient(gradient: number): IParticleSystem;
  12919. /**
  12920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12921. * @param gradient defines the gradient to use (between 0 and 1)
  12922. * @param factor defines the emit rate value to affect to the specified gradient
  12923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12924. * @returns the current particle system
  12925. */
  12926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12927. /**
  12928. * Remove a specific emit rate gradient
  12929. * @param gradient defines the gradient to remove
  12930. * @returns the current particle system
  12931. */
  12932. removeEmitRateGradient(gradient: number): IParticleSystem;
  12933. /**
  12934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12935. * @param gradient defines the gradient to use (between 0 and 1)
  12936. * @param factor defines the start size value to affect to the specified gradient
  12937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12938. * @returns the current particle system
  12939. */
  12940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12941. /**
  12942. * Remove a specific start size gradient
  12943. * @param gradient defines the gradient to remove
  12944. * @returns the current particle system
  12945. */
  12946. removeStartSizeGradient(gradient: number): IParticleSystem;
  12947. private _createRampGradientTexture;
  12948. /**
  12949. * Gets the current list of ramp gradients.
  12950. * You must use addRampGradient and removeRampGradient to udpate this list
  12951. * @returns the list of ramp gradients
  12952. */
  12953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12954. /** Force the system to rebuild all gradients that need to be resync */
  12955. forceRefreshGradients(): void;
  12956. private _syncRampGradientTexture;
  12957. /**
  12958. * Adds a new ramp gradient used to remap particle colors
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param color defines the color to affect to the specified gradient
  12961. * @returns the current particle system
  12962. */
  12963. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12964. /**
  12965. * Remove a specific ramp gradient
  12966. * @param gradient defines the gradient to remove
  12967. * @returns the current particle system
  12968. */
  12969. removeRampGradient(gradient: number): ParticleSystem;
  12970. /**
  12971. * Adds a new color gradient
  12972. * @param gradient defines the gradient to use (between 0 and 1)
  12973. * @param color1 defines the color to affect to the specified gradient
  12974. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12975. * @returns this particle system
  12976. */
  12977. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12978. /**
  12979. * Remove a specific color gradient
  12980. * @param gradient defines the gradient to remove
  12981. * @returns this particle system
  12982. */
  12983. removeColorGradient(gradient: number): IParticleSystem;
  12984. private _fetchR;
  12985. protected _reset(): void;
  12986. private _resetEffect;
  12987. private _createVertexBuffers;
  12988. private _createIndexBuffer;
  12989. /**
  12990. * Gets the maximum number of particles active at the same time.
  12991. * @returns The max number of active particles.
  12992. */
  12993. getCapacity(): number;
  12994. /**
  12995. * Gets whether there are still active particles in the system.
  12996. * @returns True if it is alive, otherwise false.
  12997. */
  12998. isAlive(): boolean;
  12999. /**
  13000. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13001. * @returns True if it has been started, otherwise false.
  13002. */
  13003. isStarted(): boolean;
  13004. private _prepareSubEmitterInternalArray;
  13005. /**
  13006. * Starts the particle system and begins to emit
  13007. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13008. */
  13009. start(delay?: number): void;
  13010. /**
  13011. * Stops the particle system.
  13012. * @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.
  13013. */
  13014. stop(stopSubEmitters?: boolean): void;
  13015. /**
  13016. * Remove all active particles
  13017. */
  13018. reset(): void;
  13019. /**
  13020. * @hidden (for internal use only)
  13021. */
  13022. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13023. /**
  13024. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13025. * Its lifetime will start back at 0.
  13026. */
  13027. recycleParticle: (particle: Particle) => void;
  13028. private _stopSubEmitters;
  13029. private _createParticle;
  13030. private _removeFromRoot;
  13031. private _emitFromParticle;
  13032. private _update;
  13033. /** @hidden */
  13034. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13035. /** @hidden */
  13036. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13037. /**
  13038. * Fill the defines array according to the current settings of the particle system
  13039. * @param defines Array to be updated
  13040. * @param blendMode blend mode to take into account when updating the array
  13041. */
  13042. fillDefines(defines: Array<string>, blendMode: number): void;
  13043. /**
  13044. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13045. * @param uniforms Uniforms array to fill
  13046. * @param attributes Attributes array to fill
  13047. * @param samplers Samplers array to fill
  13048. */
  13049. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13050. /** @hidden */
  13051. private _getEffect;
  13052. /**
  13053. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13054. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13055. */
  13056. animate(preWarmOnly?: boolean): void;
  13057. private _appendParticleVertices;
  13058. /**
  13059. * Rebuilds the particle system.
  13060. */
  13061. rebuild(): void;
  13062. /**
  13063. * Is this system ready to be used/rendered
  13064. * @return true if the system is ready
  13065. */
  13066. isReady(): boolean;
  13067. private _render;
  13068. /**
  13069. * Renders the particle system in its current state.
  13070. * @returns the current number of particles
  13071. */
  13072. render(): number;
  13073. /**
  13074. * Disposes the particle system and free the associated resources
  13075. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13076. */
  13077. dispose(disposeTexture?: boolean): void;
  13078. /**
  13079. * Clones the particle system.
  13080. * @param name The name of the cloned object
  13081. * @param newEmitter The new emitter to use
  13082. * @returns the cloned particle system
  13083. */
  13084. clone(name: string, newEmitter: any): ParticleSystem;
  13085. /**
  13086. * Serializes the particle system to a JSON object
  13087. * @param serializeTexture defines if the texture must be serialized as well
  13088. * @returns the JSON object
  13089. */
  13090. serialize(serializeTexture?: boolean): any;
  13091. /** @hidden */
  13092. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13093. /** @hidden */
  13094. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13095. /**
  13096. * Parses a JSON object to create a particle system.
  13097. * @param parsedParticleSystem The JSON object to parse
  13098. * @param sceneOrEngine The scene or the engine to create the particle system in
  13099. * @param rootUrl The root url to use to load external dependencies like texture
  13100. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13101. * @returns the Parsed particle system
  13102. */
  13103. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13104. }
  13105. }
  13106. declare module BABYLON {
  13107. /**
  13108. * A particle represents one of the element emitted by a particle system.
  13109. * This is mainly define by its coordinates, direction, velocity and age.
  13110. */
  13111. export class Particle {
  13112. /**
  13113. * The particle system the particle belongs to.
  13114. */
  13115. particleSystem: ParticleSystem;
  13116. private static _Count;
  13117. /**
  13118. * Unique ID of the particle
  13119. */
  13120. id: number;
  13121. /**
  13122. * The world position of the particle in the scene.
  13123. */
  13124. position: Vector3;
  13125. /**
  13126. * The world direction of the particle in the scene.
  13127. */
  13128. direction: Vector3;
  13129. /**
  13130. * The color of the particle.
  13131. */
  13132. color: Color4;
  13133. /**
  13134. * The color change of the particle per step.
  13135. */
  13136. colorStep: Color4;
  13137. /**
  13138. * Defines how long will the life of the particle be.
  13139. */
  13140. lifeTime: number;
  13141. /**
  13142. * The current age of the particle.
  13143. */
  13144. age: number;
  13145. /**
  13146. * The current size of the particle.
  13147. */
  13148. size: number;
  13149. /**
  13150. * The current scale of the particle.
  13151. */
  13152. scale: Vector2;
  13153. /**
  13154. * The current angle of the particle.
  13155. */
  13156. angle: number;
  13157. /**
  13158. * Defines how fast is the angle changing.
  13159. */
  13160. angularSpeed: number;
  13161. /**
  13162. * Defines the cell index used by the particle to be rendered from a sprite.
  13163. */
  13164. cellIndex: number;
  13165. /**
  13166. * The information required to support color remapping
  13167. */
  13168. remapData: Vector4;
  13169. /** @hidden */
  13170. _randomCellOffset?: number;
  13171. /** @hidden */
  13172. _initialDirection: Nullable<Vector3>;
  13173. /** @hidden */
  13174. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13175. /** @hidden */
  13176. _initialStartSpriteCellID: number;
  13177. /** @hidden */
  13178. _initialEndSpriteCellID: number;
  13179. /** @hidden */
  13180. _currentColorGradient: Nullable<ColorGradient>;
  13181. /** @hidden */
  13182. _currentColor1: Color4;
  13183. /** @hidden */
  13184. _currentColor2: Color4;
  13185. /** @hidden */
  13186. _currentSizeGradient: Nullable<FactorGradient>;
  13187. /** @hidden */
  13188. _currentSize1: number;
  13189. /** @hidden */
  13190. _currentSize2: number;
  13191. /** @hidden */
  13192. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13193. /** @hidden */
  13194. _currentAngularSpeed1: number;
  13195. /** @hidden */
  13196. _currentAngularSpeed2: number;
  13197. /** @hidden */
  13198. _currentVelocityGradient: Nullable<FactorGradient>;
  13199. /** @hidden */
  13200. _currentVelocity1: number;
  13201. /** @hidden */
  13202. _currentVelocity2: number;
  13203. /** @hidden */
  13204. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13205. /** @hidden */
  13206. _currentLimitVelocity1: number;
  13207. /** @hidden */
  13208. _currentLimitVelocity2: number;
  13209. /** @hidden */
  13210. _currentDragGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentDrag1: number;
  13213. /** @hidden */
  13214. _currentDrag2: number;
  13215. /** @hidden */
  13216. _randomNoiseCoordinates1: Vector3;
  13217. /** @hidden */
  13218. _randomNoiseCoordinates2: Vector3;
  13219. /** @hidden */
  13220. _localPosition?: Vector3;
  13221. /**
  13222. * Creates a new instance Particle
  13223. * @param particleSystem the particle system the particle belongs to
  13224. */
  13225. constructor(
  13226. /**
  13227. * The particle system the particle belongs to.
  13228. */
  13229. particleSystem: ParticleSystem);
  13230. private updateCellInfoFromSystem;
  13231. /**
  13232. * Defines how the sprite cell index is updated for the particle
  13233. */
  13234. updateCellIndex(): void;
  13235. /** @hidden */
  13236. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13237. /** @hidden */
  13238. _inheritParticleInfoToSubEmitters(): void;
  13239. /** @hidden */
  13240. _reset(): void;
  13241. /**
  13242. * Copy the properties of particle to another one.
  13243. * @param other the particle to copy the information to.
  13244. */
  13245. copyTo(other: Particle): void;
  13246. }
  13247. }
  13248. declare module BABYLON {
  13249. /**
  13250. * Particle emitter represents a volume emitting particles.
  13251. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13252. */
  13253. export interface IParticleEmitterType {
  13254. /**
  13255. * Called by the particle System when the direction is computed for the created particle.
  13256. * @param worldMatrix is the world matrix of the particle system
  13257. * @param directionToUpdate is the direction vector to update with the result
  13258. * @param particle is the particle we are computed the direction for
  13259. * @param isLocal defines if the direction should be set in local space
  13260. */
  13261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13262. /**
  13263. * Called by the particle System when the position is computed for the created particle.
  13264. * @param worldMatrix is the world matrix of the particle system
  13265. * @param positionToUpdate is the position vector to update with the result
  13266. * @param particle is the particle we are computed the position for
  13267. * @param isLocal defines if the position should be set in local space
  13268. */
  13269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13270. /**
  13271. * Clones the current emitter and returns a copy of it
  13272. * @returns the new emitter
  13273. */
  13274. clone(): IParticleEmitterType;
  13275. /**
  13276. * Called by the GPUParticleSystem to setup the update shader
  13277. * @param effect defines the update shader
  13278. */
  13279. applyToShader(effect: Effect): void;
  13280. /**
  13281. * Returns a string to use to update the GPU particles update shader
  13282. * @returns the effect defines string
  13283. */
  13284. getEffectDefines(): string;
  13285. /**
  13286. * Returns a string representing the class name
  13287. * @returns a string containing the class name
  13288. */
  13289. getClassName(): string;
  13290. /**
  13291. * Serializes the particle system to a JSON object.
  13292. * @returns the JSON object
  13293. */
  13294. serialize(): any;
  13295. /**
  13296. * Parse properties from a JSON object
  13297. * @param serializationObject defines the JSON object
  13298. * @param scene defines the hosting scene
  13299. */
  13300. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13301. }
  13302. }
  13303. declare module BABYLON {
  13304. /**
  13305. * Particle emitter emitting particles from the inside of a box.
  13306. * It emits the particles randomly between 2 given directions.
  13307. */
  13308. export class BoxParticleEmitter implements IParticleEmitterType {
  13309. /**
  13310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13311. */
  13312. direction1: Vector3;
  13313. /**
  13314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13315. */
  13316. direction2: Vector3;
  13317. /**
  13318. * 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.
  13319. */
  13320. minEmitBox: Vector3;
  13321. /**
  13322. * 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.
  13323. */
  13324. maxEmitBox: Vector3;
  13325. /**
  13326. * Creates a new instance BoxParticleEmitter
  13327. */
  13328. constructor();
  13329. /**
  13330. * Called by the particle System when the direction is computed for the created particle.
  13331. * @param worldMatrix is the world matrix of the particle system
  13332. * @param directionToUpdate is the direction vector to update with the result
  13333. * @param particle is the particle we are computed the direction for
  13334. * @param isLocal defines if the direction should be set in local space
  13335. */
  13336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13337. /**
  13338. * Called by the particle System when the position is computed for the created particle.
  13339. * @param worldMatrix is the world matrix of the particle system
  13340. * @param positionToUpdate is the position vector to update with the result
  13341. * @param particle is the particle we are computed the position for
  13342. * @param isLocal defines if the position should be set in local space
  13343. */
  13344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13345. /**
  13346. * Clones the current emitter and returns a copy of it
  13347. * @returns the new emitter
  13348. */
  13349. clone(): BoxParticleEmitter;
  13350. /**
  13351. * Called by the GPUParticleSystem to setup the update shader
  13352. * @param effect defines the update shader
  13353. */
  13354. applyToShader(effect: Effect): void;
  13355. /**
  13356. * Returns a string to use to update the GPU particles update shader
  13357. * @returns a string containng the defines string
  13358. */
  13359. getEffectDefines(): string;
  13360. /**
  13361. * Returns the string "BoxParticleEmitter"
  13362. * @returns a string containing the class name
  13363. */
  13364. getClassName(): string;
  13365. /**
  13366. * Serializes the particle system to a JSON object.
  13367. * @returns the JSON object
  13368. */
  13369. serialize(): any;
  13370. /**
  13371. * Parse properties from a JSON object
  13372. * @param serializationObject defines the JSON object
  13373. */
  13374. parse(serializationObject: any): void;
  13375. }
  13376. }
  13377. declare module BABYLON {
  13378. /**
  13379. * Particle emitter emitting particles from the inside of a cone.
  13380. * It emits the particles alongside the cone volume from the base to the particle.
  13381. * The emission direction might be randomized.
  13382. */
  13383. export class ConeParticleEmitter implements IParticleEmitterType {
  13384. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13385. directionRandomizer: number;
  13386. private _radius;
  13387. private _angle;
  13388. private _height;
  13389. /**
  13390. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13391. */
  13392. radiusRange: number;
  13393. /**
  13394. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13395. */
  13396. heightRange: number;
  13397. /**
  13398. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13399. */
  13400. emitFromSpawnPointOnly: boolean;
  13401. /**
  13402. * Gets or sets the radius of the emission cone
  13403. */
  13404. get radius(): number;
  13405. set radius(value: number);
  13406. /**
  13407. * Gets or sets the angle of the emission cone
  13408. */
  13409. get angle(): number;
  13410. set angle(value: number);
  13411. private _buildHeight;
  13412. /**
  13413. * Creates a new instance ConeParticleEmitter
  13414. * @param radius the radius of the emission cone (1 by default)
  13415. * @param angle the cone base angle (PI by default)
  13416. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13417. */
  13418. constructor(radius?: number, angle?: number,
  13419. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13420. directionRandomizer?: number);
  13421. /**
  13422. * Called by the particle System when the direction is computed for the created particle.
  13423. * @param worldMatrix is the world matrix of the particle system
  13424. * @param directionToUpdate is the direction vector to update with the result
  13425. * @param particle is the particle we are computed the direction for
  13426. * @param isLocal defines if the direction should be set in local space
  13427. */
  13428. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13429. /**
  13430. * Called by the particle System when the position is computed for the created particle.
  13431. * @param worldMatrix is the world matrix of the particle system
  13432. * @param positionToUpdate is the position vector to update with the result
  13433. * @param particle is the particle we are computed the position for
  13434. * @param isLocal defines if the position should be set in local space
  13435. */
  13436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13437. /**
  13438. * Clones the current emitter and returns a copy of it
  13439. * @returns the new emitter
  13440. */
  13441. clone(): ConeParticleEmitter;
  13442. /**
  13443. * Called by the GPUParticleSystem to setup the update shader
  13444. * @param effect defines the update shader
  13445. */
  13446. applyToShader(effect: Effect): void;
  13447. /**
  13448. * Returns a string to use to update the GPU particles update shader
  13449. * @returns a string containng the defines string
  13450. */
  13451. getEffectDefines(): string;
  13452. /**
  13453. * Returns the string "ConeParticleEmitter"
  13454. * @returns a string containing the class name
  13455. */
  13456. getClassName(): string;
  13457. /**
  13458. * Serializes the particle system to a JSON object.
  13459. * @returns the JSON object
  13460. */
  13461. serialize(): any;
  13462. /**
  13463. * Parse properties from a JSON object
  13464. * @param serializationObject defines the JSON object
  13465. */
  13466. parse(serializationObject: any): void;
  13467. }
  13468. }
  13469. declare module BABYLON {
  13470. /**
  13471. * Particle emitter emitting particles from the inside of a cylinder.
  13472. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13473. */
  13474. export class CylinderParticleEmitter implements IParticleEmitterType {
  13475. /**
  13476. * The radius of the emission cylinder.
  13477. */
  13478. radius: number;
  13479. /**
  13480. * The height of the emission cylinder.
  13481. */
  13482. height: number;
  13483. /**
  13484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13485. */
  13486. radiusRange: number;
  13487. /**
  13488. * How much to randomize the particle direction [0-1].
  13489. */
  13490. directionRandomizer: number;
  13491. /**
  13492. * Creates a new instance CylinderParticleEmitter
  13493. * @param radius the radius of the emission cylinder (1 by default)
  13494. * @param height the height of the emission cylinder (1 by default)
  13495. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13496. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13497. */
  13498. constructor(
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius?: number,
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height?: number,
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange?: number,
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer?: number);
  13515. /**
  13516. * Called by the particle System when the direction is computed for the created particle.
  13517. * @param worldMatrix is the world matrix of the particle system
  13518. * @param directionToUpdate is the direction vector to update with the result
  13519. * @param particle is the particle we are computed the direction for
  13520. * @param isLocal defines if the direction should be set in local space
  13521. */
  13522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13523. /**
  13524. * Called by the particle System when the position is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param positionToUpdate is the position vector to update with the result
  13527. * @param particle is the particle we are computed the position for
  13528. * @param isLocal defines if the position should be set in local space
  13529. */
  13530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Clones the current emitter and returns a copy of it
  13533. * @returns the new emitter
  13534. */
  13535. clone(): CylinderParticleEmitter;
  13536. /**
  13537. * Called by the GPUParticleSystem to setup the update shader
  13538. * @param effect defines the update shader
  13539. */
  13540. applyToShader(effect: Effect): void;
  13541. /**
  13542. * Returns a string to use to update the GPU particles update shader
  13543. * @returns a string containng the defines string
  13544. */
  13545. getEffectDefines(): string;
  13546. /**
  13547. * Returns the string "CylinderParticleEmitter"
  13548. * @returns a string containing the class name
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Serializes the particle system to a JSON object.
  13553. * @returns the JSON object
  13554. */
  13555. serialize(): any;
  13556. /**
  13557. * Parse properties from a JSON object
  13558. * @param serializationObject defines the JSON object
  13559. */
  13560. parse(serializationObject: any): void;
  13561. }
  13562. /**
  13563. * Particle emitter emitting particles from the inside of a cylinder.
  13564. * It emits the particles randomly between two vectors.
  13565. */
  13566. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13567. /**
  13568. * The min limit of the emission direction.
  13569. */
  13570. direction1: Vector3;
  13571. /**
  13572. * The max limit of the emission direction.
  13573. */
  13574. direction2: Vector3;
  13575. /**
  13576. * Creates a new instance CylinderDirectedParticleEmitter
  13577. * @param radius the radius of the emission cylinder (1 by default)
  13578. * @param height the height of the emission cylinder (1 by default)
  13579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13580. * @param direction1 the min limit of the emission direction (up vector by default)
  13581. * @param direction2 the max limit of the emission direction (up vector by default)
  13582. */
  13583. constructor(radius?: number, height?: number, radiusRange?: number,
  13584. /**
  13585. * The min limit of the emission direction.
  13586. */
  13587. direction1?: Vector3,
  13588. /**
  13589. * The max limit of the emission direction.
  13590. */
  13591. direction2?: Vector3);
  13592. /**
  13593. * Called by the particle System when the direction is computed for the created particle.
  13594. * @param worldMatrix is the world matrix of the particle system
  13595. * @param directionToUpdate is the direction vector to update with the result
  13596. * @param particle is the particle we are computed the direction for
  13597. */
  13598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13599. /**
  13600. * Clones the current emitter and returns a copy of it
  13601. * @returns the new emitter
  13602. */
  13603. clone(): CylinderDirectedParticleEmitter;
  13604. /**
  13605. * Called by the GPUParticleSystem to setup the update shader
  13606. * @param effect defines the update shader
  13607. */
  13608. applyToShader(effect: Effect): void;
  13609. /**
  13610. * Returns a string to use to update the GPU particles update shader
  13611. * @returns a string containng the defines string
  13612. */
  13613. getEffectDefines(): string;
  13614. /**
  13615. * Returns the string "CylinderDirectedParticleEmitter"
  13616. * @returns a string containing the class name
  13617. */
  13618. getClassName(): string;
  13619. /**
  13620. * Serializes the particle system to a JSON object.
  13621. * @returns the JSON object
  13622. */
  13623. serialize(): any;
  13624. /**
  13625. * Parse properties from a JSON object
  13626. * @param serializationObject defines the JSON object
  13627. */
  13628. parse(serializationObject: any): void;
  13629. }
  13630. }
  13631. declare module BABYLON {
  13632. /**
  13633. * Particle emitter emitting particles from the inside of a hemisphere.
  13634. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13635. */
  13636. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13637. /**
  13638. * The radius of the emission hemisphere.
  13639. */
  13640. radius: number;
  13641. /**
  13642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13643. */
  13644. radiusRange: number;
  13645. /**
  13646. * How much to randomize the particle direction [0-1].
  13647. */
  13648. directionRandomizer: number;
  13649. /**
  13650. * Creates a new instance HemisphericParticleEmitter
  13651. * @param radius the radius of the emission hemisphere (1 by default)
  13652. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13654. */
  13655. constructor(
  13656. /**
  13657. * The radius of the emission hemisphere.
  13658. */
  13659. radius?: number,
  13660. /**
  13661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13662. */
  13663. radiusRange?: number,
  13664. /**
  13665. * How much to randomize the particle direction [0-1].
  13666. */
  13667. directionRandomizer?: number);
  13668. /**
  13669. * Called by the particle System when the direction is computed for the created particle.
  13670. * @param worldMatrix is the world matrix of the particle system
  13671. * @param directionToUpdate is the direction vector to update with the result
  13672. * @param particle is the particle we are computed the direction for
  13673. * @param isLocal defines if the direction should be set in local space
  13674. */
  13675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13676. /**
  13677. * Called by the particle System when the position is computed for the created particle.
  13678. * @param worldMatrix is the world matrix of the particle system
  13679. * @param positionToUpdate is the position vector to update with the result
  13680. * @param particle is the particle we are computed the position for
  13681. * @param isLocal defines if the position should be set in local space
  13682. */
  13683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13684. /**
  13685. * Clones the current emitter and returns a copy of it
  13686. * @returns the new emitter
  13687. */
  13688. clone(): HemisphericParticleEmitter;
  13689. /**
  13690. * Called by the GPUParticleSystem to setup the update shader
  13691. * @param effect defines the update shader
  13692. */
  13693. applyToShader(effect: Effect): void;
  13694. /**
  13695. * Returns a string to use to update the GPU particles update shader
  13696. * @returns a string containng the defines string
  13697. */
  13698. getEffectDefines(): string;
  13699. /**
  13700. * Returns the string "HemisphericParticleEmitter"
  13701. * @returns a string containing the class name
  13702. */
  13703. getClassName(): string;
  13704. /**
  13705. * Serializes the particle system to a JSON object.
  13706. * @returns the JSON object
  13707. */
  13708. serialize(): any;
  13709. /**
  13710. * Parse properties from a JSON object
  13711. * @param serializationObject defines the JSON object
  13712. */
  13713. parse(serializationObject: any): void;
  13714. }
  13715. }
  13716. declare module BABYLON {
  13717. /**
  13718. * Particle emitter emitting particles from a point.
  13719. * It emits the particles randomly between 2 given directions.
  13720. */
  13721. export class PointParticleEmitter implements IParticleEmitterType {
  13722. /**
  13723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13724. */
  13725. direction1: Vector3;
  13726. /**
  13727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13728. */
  13729. direction2: Vector3;
  13730. /**
  13731. * Creates a new instance PointParticleEmitter
  13732. */
  13733. constructor();
  13734. /**
  13735. * Called by the particle System when the direction is computed for the created particle.
  13736. * @param worldMatrix is the world matrix of the particle system
  13737. * @param directionToUpdate is the direction vector to update with the result
  13738. * @param particle is the particle we are computed the direction for
  13739. * @param isLocal defines if the direction should be set in local space
  13740. */
  13741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13742. /**
  13743. * Called by the particle System when the position is computed for the created particle.
  13744. * @param worldMatrix is the world matrix of the particle system
  13745. * @param positionToUpdate is the position vector to update with the result
  13746. * @param particle is the particle we are computed the position for
  13747. * @param isLocal defines if the position should be set in local space
  13748. */
  13749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13750. /**
  13751. * Clones the current emitter and returns a copy of it
  13752. * @returns the new emitter
  13753. */
  13754. clone(): PointParticleEmitter;
  13755. /**
  13756. * Called by the GPUParticleSystem to setup the update shader
  13757. * @param effect defines the update shader
  13758. */
  13759. applyToShader(effect: Effect): void;
  13760. /**
  13761. * Returns a string to use to update the GPU particles update shader
  13762. * @returns a string containng the defines string
  13763. */
  13764. getEffectDefines(): string;
  13765. /**
  13766. * Returns the string "PointParticleEmitter"
  13767. * @returns a string containing the class name
  13768. */
  13769. getClassName(): string;
  13770. /**
  13771. * Serializes the particle system to a JSON object.
  13772. * @returns the JSON object
  13773. */
  13774. serialize(): any;
  13775. /**
  13776. * Parse properties from a JSON object
  13777. * @param serializationObject defines the JSON object
  13778. */
  13779. parse(serializationObject: any): void;
  13780. }
  13781. }
  13782. declare module BABYLON {
  13783. /**
  13784. * Particle emitter emitting particles from the inside of a sphere.
  13785. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13786. */
  13787. export class SphereParticleEmitter implements IParticleEmitterType {
  13788. /**
  13789. * The radius of the emission sphere.
  13790. */
  13791. radius: number;
  13792. /**
  13793. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13794. */
  13795. radiusRange: number;
  13796. /**
  13797. * How much to randomize the particle direction [0-1].
  13798. */
  13799. directionRandomizer: number;
  13800. /**
  13801. * Creates a new instance SphereParticleEmitter
  13802. * @param radius the radius of the emission sphere (1 by default)
  13803. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13804. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13805. */
  13806. constructor(
  13807. /**
  13808. * The radius of the emission sphere.
  13809. */
  13810. radius?: number,
  13811. /**
  13812. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13813. */
  13814. radiusRange?: number,
  13815. /**
  13816. * How much to randomize the particle direction [0-1].
  13817. */
  13818. directionRandomizer?: number);
  13819. /**
  13820. * Called by the particle System when the direction is computed for the created particle.
  13821. * @param worldMatrix is the world matrix of the particle system
  13822. * @param directionToUpdate is the direction vector to update with the result
  13823. * @param particle is the particle we are computed the direction for
  13824. * @param isLocal defines if the direction should be set in local space
  13825. */
  13826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13827. /**
  13828. * Called by the particle System when the position is computed for the created particle.
  13829. * @param worldMatrix is the world matrix of the particle system
  13830. * @param positionToUpdate is the position vector to update with the result
  13831. * @param particle is the particle we are computed the position for
  13832. * @param isLocal defines if the position should be set in local space
  13833. */
  13834. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13835. /**
  13836. * Clones the current emitter and returns a copy of it
  13837. * @returns the new emitter
  13838. */
  13839. clone(): SphereParticleEmitter;
  13840. /**
  13841. * Called by the GPUParticleSystem to setup the update shader
  13842. * @param effect defines the update shader
  13843. */
  13844. applyToShader(effect: Effect): void;
  13845. /**
  13846. * Returns a string to use to update the GPU particles update shader
  13847. * @returns a string containng the defines string
  13848. */
  13849. getEffectDefines(): string;
  13850. /**
  13851. * Returns the string "SphereParticleEmitter"
  13852. * @returns a string containing the class name
  13853. */
  13854. getClassName(): string;
  13855. /**
  13856. * Serializes the particle system to a JSON object.
  13857. * @returns the JSON object
  13858. */
  13859. serialize(): any;
  13860. /**
  13861. * Parse properties from a JSON object
  13862. * @param serializationObject defines the JSON object
  13863. */
  13864. parse(serializationObject: any): void;
  13865. }
  13866. /**
  13867. * Particle emitter emitting particles from the inside of a sphere.
  13868. * It emits the particles randomly between two vectors.
  13869. */
  13870. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13871. /**
  13872. * The min limit of the emission direction.
  13873. */
  13874. direction1: Vector3;
  13875. /**
  13876. * The max limit of the emission direction.
  13877. */
  13878. direction2: Vector3;
  13879. /**
  13880. * Creates a new instance SphereDirectedParticleEmitter
  13881. * @param radius the radius of the emission sphere (1 by default)
  13882. * @param direction1 the min limit of the emission direction (up vector by default)
  13883. * @param direction2 the max limit of the emission direction (up vector by default)
  13884. */
  13885. constructor(radius?: number,
  13886. /**
  13887. * The min limit of the emission direction.
  13888. */
  13889. direction1?: Vector3,
  13890. /**
  13891. * The max limit of the emission direction.
  13892. */
  13893. direction2?: Vector3);
  13894. /**
  13895. * Called by the particle System when the direction is computed for the created particle.
  13896. * @param worldMatrix is the world matrix of the particle system
  13897. * @param directionToUpdate is the direction vector to update with the result
  13898. * @param particle is the particle we are computed the direction for
  13899. */
  13900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13901. /**
  13902. * Clones the current emitter and returns a copy of it
  13903. * @returns the new emitter
  13904. */
  13905. clone(): SphereDirectedParticleEmitter;
  13906. /**
  13907. * Called by the GPUParticleSystem to setup the update shader
  13908. * @param effect defines the update shader
  13909. */
  13910. applyToShader(effect: Effect): void;
  13911. /**
  13912. * Returns a string to use to update the GPU particles update shader
  13913. * @returns a string containng the defines string
  13914. */
  13915. getEffectDefines(): string;
  13916. /**
  13917. * Returns the string "SphereDirectedParticleEmitter"
  13918. * @returns a string containing the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Serializes the particle system to a JSON object.
  13923. * @returns the JSON object
  13924. */
  13925. serialize(): any;
  13926. /**
  13927. * Parse properties from a JSON object
  13928. * @param serializationObject defines the JSON object
  13929. */
  13930. parse(serializationObject: any): void;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Particle emitter emitting particles from a custom list of positions.
  13936. */
  13937. export class CustomParticleEmitter implements IParticleEmitterType {
  13938. /**
  13939. * Gets or sets the position generator that will create the inital position of each particle.
  13940. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13941. */
  13942. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13943. /**
  13944. * Gets or sets the destination generator that will create the final destination of each particle.
  13945. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13946. */
  13947. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13948. /**
  13949. * Creates a new instance CustomParticleEmitter
  13950. */
  13951. constructor();
  13952. /**
  13953. * Called by the particle System when the direction is computed for the created particle.
  13954. * @param worldMatrix is the world matrix of the particle system
  13955. * @param directionToUpdate is the direction vector to update with the result
  13956. * @param particle is the particle we are computed the direction for
  13957. * @param isLocal defines if the direction should be set in local space
  13958. */
  13959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13960. /**
  13961. * Called by the particle System when the position is computed for the created particle.
  13962. * @param worldMatrix is the world matrix of the particle system
  13963. * @param positionToUpdate is the position vector to update with the result
  13964. * @param particle is the particle we are computed the position for
  13965. * @param isLocal defines if the position should be set in local space
  13966. */
  13967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13968. /**
  13969. * Clones the current emitter and returns a copy of it
  13970. * @returns the new emitter
  13971. */
  13972. clone(): CustomParticleEmitter;
  13973. /**
  13974. * Called by the GPUParticleSystem to setup the update shader
  13975. * @param effect defines the update shader
  13976. */
  13977. applyToShader(effect: Effect): void;
  13978. /**
  13979. * Returns a string to use to update the GPU particles update shader
  13980. * @returns a string containng the defines string
  13981. */
  13982. getEffectDefines(): string;
  13983. /**
  13984. * Returns the string "PointParticleEmitter"
  13985. * @returns a string containing the class name
  13986. */
  13987. getClassName(): string;
  13988. /**
  13989. * Serializes the particle system to a JSON object.
  13990. * @returns the JSON object
  13991. */
  13992. serialize(): any;
  13993. /**
  13994. * Parse properties from a JSON object
  13995. * @param serializationObject defines the JSON object
  13996. */
  13997. parse(serializationObject: any): void;
  13998. }
  13999. }
  14000. declare module BABYLON {
  14001. /**
  14002. * Particle emitter emitting particles from the inside of a box.
  14003. * It emits the particles randomly between 2 given directions.
  14004. */
  14005. export class MeshParticleEmitter implements IParticleEmitterType {
  14006. private _indices;
  14007. private _positions;
  14008. private _normals;
  14009. private _storedNormal;
  14010. private _mesh;
  14011. /**
  14012. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14013. */
  14014. direction1: Vector3;
  14015. /**
  14016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14017. */
  14018. direction2: Vector3;
  14019. /**
  14020. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14021. */
  14022. useMeshNormalsForDirection: boolean;
  14023. /** Defines the mesh to use as source */
  14024. get mesh(): Nullable<AbstractMesh>;
  14025. set mesh(value: Nullable<AbstractMesh>);
  14026. /**
  14027. * Creates a new instance MeshParticleEmitter
  14028. * @param mesh defines the mesh to use as source
  14029. */
  14030. constructor(mesh?: Nullable<AbstractMesh>);
  14031. /**
  14032. * Called by the particle System when the direction is computed for the created particle.
  14033. * @param worldMatrix is the world matrix of the particle system
  14034. * @param directionToUpdate is the direction vector to update with the result
  14035. * @param particle is the particle we are computed the direction for
  14036. * @param isLocal defines if the direction should be set in local space
  14037. */
  14038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14039. /**
  14040. * Called by the particle System when the position is computed for the created particle.
  14041. * @param worldMatrix is the world matrix of the particle system
  14042. * @param positionToUpdate is the position vector to update with the result
  14043. * @param particle is the particle we are computed the position for
  14044. * @param isLocal defines if the position should be set in local space
  14045. */
  14046. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14047. /**
  14048. * Clones the current emitter and returns a copy of it
  14049. * @returns the new emitter
  14050. */
  14051. clone(): MeshParticleEmitter;
  14052. /**
  14053. * Called by the GPUParticleSystem to setup the update shader
  14054. * @param effect defines the update shader
  14055. */
  14056. applyToShader(effect: Effect): void;
  14057. /**
  14058. * Returns a string to use to update the GPU particles update shader
  14059. * @returns a string containng the defines string
  14060. */
  14061. getEffectDefines(): string;
  14062. /**
  14063. * Returns the string "BoxParticleEmitter"
  14064. * @returns a string containing the class name
  14065. */
  14066. getClassName(): string;
  14067. /**
  14068. * Serializes the particle system to a JSON object.
  14069. * @returns the JSON object
  14070. */
  14071. serialize(): any;
  14072. /**
  14073. * Parse properties from a JSON object
  14074. * @param serializationObject defines the JSON object
  14075. * @param scene defines the hosting scene
  14076. */
  14077. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14078. }
  14079. }
  14080. declare module BABYLON {
  14081. /**
  14082. * Interface representing a particle system in Babylon.js.
  14083. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14084. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14085. */
  14086. export interface IParticleSystem {
  14087. /**
  14088. * List of animations used by the particle system.
  14089. */
  14090. animations: Animation[];
  14091. /**
  14092. * The id of the Particle system.
  14093. */
  14094. id: string;
  14095. /**
  14096. * The name of the Particle system.
  14097. */
  14098. name: string;
  14099. /**
  14100. * The emitter represents the Mesh or position we are attaching the particle system to.
  14101. */
  14102. emitter: Nullable<AbstractMesh | Vector3>;
  14103. /**
  14104. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14105. */
  14106. isBillboardBased: boolean;
  14107. /**
  14108. * The rendering group used by the Particle system to chose when to render.
  14109. */
  14110. renderingGroupId: number;
  14111. /**
  14112. * The layer mask we are rendering the particles through.
  14113. */
  14114. layerMask: number;
  14115. /**
  14116. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14117. */
  14118. updateSpeed: number;
  14119. /**
  14120. * The amount of time the particle system is running (depends of the overall update speed).
  14121. */
  14122. targetStopDuration: number;
  14123. /**
  14124. * The texture used to render each particle. (this can be a spritesheet)
  14125. */
  14126. particleTexture: Nullable<BaseTexture>;
  14127. /**
  14128. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14129. */
  14130. blendMode: number;
  14131. /**
  14132. * Minimum life time of emitting particles.
  14133. */
  14134. minLifeTime: number;
  14135. /**
  14136. * Maximum life time of emitting particles.
  14137. */
  14138. maxLifeTime: number;
  14139. /**
  14140. * Minimum Size of emitting particles.
  14141. */
  14142. minSize: number;
  14143. /**
  14144. * Maximum Size of emitting particles.
  14145. */
  14146. maxSize: number;
  14147. /**
  14148. * Minimum scale of emitting particles on X axis.
  14149. */
  14150. minScaleX: number;
  14151. /**
  14152. * Maximum scale of emitting particles on X axis.
  14153. */
  14154. maxScaleX: number;
  14155. /**
  14156. * Minimum scale of emitting particles on Y axis.
  14157. */
  14158. minScaleY: number;
  14159. /**
  14160. * Maximum scale of emitting particles on Y axis.
  14161. */
  14162. maxScaleY: number;
  14163. /**
  14164. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14165. */
  14166. color1: Color4;
  14167. /**
  14168. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14169. */
  14170. color2: Color4;
  14171. /**
  14172. * Color the particle will have at the end of its lifetime.
  14173. */
  14174. colorDead: Color4;
  14175. /**
  14176. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14177. */
  14178. emitRate: number;
  14179. /**
  14180. * You can use gravity if you want to give an orientation to your particles.
  14181. */
  14182. gravity: Vector3;
  14183. /**
  14184. * Minimum power of emitting particles.
  14185. */
  14186. minEmitPower: number;
  14187. /**
  14188. * Maximum power of emitting particles.
  14189. */
  14190. maxEmitPower: number;
  14191. /**
  14192. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14193. */
  14194. minAngularSpeed: number;
  14195. /**
  14196. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14197. */
  14198. maxAngularSpeed: number;
  14199. /**
  14200. * Gets or sets the minimal initial rotation in radians.
  14201. */
  14202. minInitialRotation: number;
  14203. /**
  14204. * Gets or sets the maximal initial rotation in radians.
  14205. */
  14206. maxInitialRotation: number;
  14207. /**
  14208. * The particle emitter type defines the emitter used by the particle system.
  14209. * It can be for example box, sphere, or cone...
  14210. */
  14211. particleEmitterType: Nullable<IParticleEmitterType>;
  14212. /**
  14213. * Defines the delay in milliseconds before starting the system (0 by default)
  14214. */
  14215. startDelay: number;
  14216. /**
  14217. * 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
  14218. */
  14219. preWarmCycles: number;
  14220. /**
  14221. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14222. */
  14223. preWarmStepOffset: number;
  14224. /**
  14225. * 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)
  14226. */
  14227. spriteCellChangeSpeed: number;
  14228. /**
  14229. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14230. */
  14231. startSpriteCellID: number;
  14232. /**
  14233. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14234. */
  14235. endSpriteCellID: number;
  14236. /**
  14237. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14238. */
  14239. spriteCellWidth: number;
  14240. /**
  14241. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14242. */
  14243. spriteCellHeight: number;
  14244. /**
  14245. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14246. */
  14247. spriteRandomStartCell: boolean;
  14248. /**
  14249. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14250. */
  14251. isAnimationSheetEnabled: boolean;
  14252. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14253. translationPivot: Vector2;
  14254. /**
  14255. * Gets or sets a texture used to add random noise to particle positions
  14256. */
  14257. noiseTexture: Nullable<BaseTexture>;
  14258. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14259. noiseStrength: Vector3;
  14260. /**
  14261. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14262. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14263. */
  14264. billboardMode: number;
  14265. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14266. limitVelocityDamping: number;
  14267. /**
  14268. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14269. */
  14270. beginAnimationOnStart: boolean;
  14271. /**
  14272. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14273. */
  14274. beginAnimationFrom: number;
  14275. /**
  14276. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14277. */
  14278. beginAnimationTo: number;
  14279. /**
  14280. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14281. */
  14282. beginAnimationLoop: boolean;
  14283. /**
  14284. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14285. */
  14286. disposeOnStop: boolean;
  14287. /**
  14288. * Specifies if the particles are updated in emitter local space or world space
  14289. */
  14290. isLocal: boolean;
  14291. /** Snippet ID if the particle system was created from the snippet server */
  14292. snippetId: string;
  14293. /** Gets or sets a matrix to use to compute projection */
  14294. defaultProjectionMatrix: Matrix;
  14295. /**
  14296. * Gets the maximum number of particles active at the same time.
  14297. * @returns The max number of active particles.
  14298. */
  14299. getCapacity(): number;
  14300. /**
  14301. * Gets the number of particles active at the same time.
  14302. * @returns The number of active particles.
  14303. */
  14304. getActiveCount(): number;
  14305. /**
  14306. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14307. * @returns True if it has been started, otherwise false.
  14308. */
  14309. isStarted(): boolean;
  14310. /**
  14311. * Animates the particle system for this frame.
  14312. */
  14313. animate(): void;
  14314. /**
  14315. * Renders the particle system in its current state.
  14316. * @returns the current number of particles
  14317. */
  14318. render(): number;
  14319. /**
  14320. * Dispose the particle system and frees its associated resources.
  14321. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14322. */
  14323. dispose(disposeTexture?: boolean): void;
  14324. /**
  14325. * An event triggered when the system is disposed
  14326. */
  14327. onDisposeObservable: Observable<IParticleSystem>;
  14328. /**
  14329. * An event triggered when the system is stopped
  14330. */
  14331. onStoppedObservable: Observable<IParticleSystem>;
  14332. /**
  14333. * Clones the particle system.
  14334. * @param name The name of the cloned object
  14335. * @param newEmitter The new emitter to use
  14336. * @returns the cloned particle system
  14337. */
  14338. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14339. /**
  14340. * Serializes the particle system to a JSON object
  14341. * @param serializeTexture defines if the texture must be serialized as well
  14342. * @returns the JSON object
  14343. */
  14344. serialize(serializeTexture: boolean): any;
  14345. /**
  14346. * Rebuild the particle system
  14347. */
  14348. rebuild(): void;
  14349. /** Force the system to rebuild all gradients that need to be resync */
  14350. forceRefreshGradients(): void;
  14351. /**
  14352. * Starts the particle system and begins to emit
  14353. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14354. */
  14355. start(delay?: number): void;
  14356. /**
  14357. * Stops the particle system.
  14358. */
  14359. stop(): void;
  14360. /**
  14361. * Remove all active particles
  14362. */
  14363. reset(): void;
  14364. /**
  14365. * Gets a boolean indicating that the system is stopping
  14366. * @returns true if the system is currently stopping
  14367. */
  14368. isStopping(): boolean;
  14369. /**
  14370. * Is this system ready to be used/rendered
  14371. * @return true if the system is ready
  14372. */
  14373. isReady(): boolean;
  14374. /**
  14375. * Returns the string "ParticleSystem"
  14376. * @returns a string containing the class name
  14377. */
  14378. getClassName(): string;
  14379. /**
  14380. * Gets the custom effect used to render the particles
  14381. * @param blendMode Blend mode for which the effect should be retrieved
  14382. * @returns The effect
  14383. */
  14384. getCustomEffect(blendMode: number): Nullable<Effect>;
  14385. /**
  14386. * Sets the custom effect used to render the particles
  14387. * @param effect The effect to set
  14388. * @param blendMode Blend mode for which the effect should be set
  14389. */
  14390. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14391. /**
  14392. * Fill the defines array according to the current settings of the particle system
  14393. * @param defines Array to be updated
  14394. * @param blendMode blend mode to take into account when updating the array
  14395. */
  14396. fillDefines(defines: Array<string>, blendMode: number): void;
  14397. /**
  14398. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14399. * @param uniforms Uniforms array to fill
  14400. * @param attributes Attributes array to fill
  14401. * @param samplers Samplers array to fill
  14402. */
  14403. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14404. /**
  14405. * Observable that will be called just before the particles are drawn
  14406. */
  14407. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14408. /**
  14409. * Gets the name of the particle vertex shader
  14410. */
  14411. vertexShaderName: string;
  14412. /**
  14413. * Adds a new color gradient
  14414. * @param gradient defines the gradient to use (between 0 and 1)
  14415. * @param color1 defines the color to affect to the specified gradient
  14416. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14417. * @returns the current particle system
  14418. */
  14419. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14420. /**
  14421. * Remove a specific color gradient
  14422. * @param gradient defines the gradient to remove
  14423. * @returns the current particle system
  14424. */
  14425. removeColorGradient(gradient: number): IParticleSystem;
  14426. /**
  14427. * Adds a new size gradient
  14428. * @param gradient defines the gradient to use (between 0 and 1)
  14429. * @param factor defines the size factor to affect to the specified gradient
  14430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14431. * @returns the current particle system
  14432. */
  14433. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14434. /**
  14435. * Remove a specific size gradient
  14436. * @param gradient defines the gradient to remove
  14437. * @returns the current particle system
  14438. */
  14439. removeSizeGradient(gradient: number): IParticleSystem;
  14440. /**
  14441. * Gets the current list of color gradients.
  14442. * You must use addColorGradient and removeColorGradient to udpate this list
  14443. * @returns the list of color gradients
  14444. */
  14445. getColorGradients(): Nullable<Array<ColorGradient>>;
  14446. /**
  14447. * Gets the current list of size gradients.
  14448. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14449. * @returns the list of size gradients
  14450. */
  14451. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14452. /**
  14453. * Gets the current list of angular speed gradients.
  14454. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14455. * @returns the list of angular speed gradients
  14456. */
  14457. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14458. /**
  14459. * Adds a new angular speed gradient
  14460. * @param gradient defines the gradient to use (between 0 and 1)
  14461. * @param factor defines the angular speed to affect to the specified gradient
  14462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14463. * @returns the current particle system
  14464. */
  14465. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14466. /**
  14467. * Remove a specific angular speed gradient
  14468. * @param gradient defines the gradient to remove
  14469. * @returns the current particle system
  14470. */
  14471. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14472. /**
  14473. * Gets the current list of velocity gradients.
  14474. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14475. * @returns the list of velocity gradients
  14476. */
  14477. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14478. /**
  14479. * Adds a new velocity gradient
  14480. * @param gradient defines the gradient to use (between 0 and 1)
  14481. * @param factor defines the velocity to affect to the specified gradient
  14482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14483. * @returns the current particle system
  14484. */
  14485. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14486. /**
  14487. * Remove a specific velocity gradient
  14488. * @param gradient defines the gradient to remove
  14489. * @returns the current particle system
  14490. */
  14491. removeVelocityGradient(gradient: number): IParticleSystem;
  14492. /**
  14493. * Gets the current list of limit velocity gradients.
  14494. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14495. * @returns the list of limit velocity gradients
  14496. */
  14497. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14498. /**
  14499. * Adds a new limit velocity gradient
  14500. * @param gradient defines the gradient to use (between 0 and 1)
  14501. * @param factor defines the limit velocity to affect to the specified gradient
  14502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14503. * @returns the current particle system
  14504. */
  14505. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14506. /**
  14507. * Remove a specific limit velocity gradient
  14508. * @param gradient defines the gradient to remove
  14509. * @returns the current particle system
  14510. */
  14511. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14512. /**
  14513. * Adds a new drag gradient
  14514. * @param gradient defines the gradient to use (between 0 and 1)
  14515. * @param factor defines the drag to affect to the specified gradient
  14516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14517. * @returns the current particle system
  14518. */
  14519. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14520. /**
  14521. * Remove a specific drag gradient
  14522. * @param gradient defines the gradient to remove
  14523. * @returns the current particle system
  14524. */
  14525. removeDragGradient(gradient: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of drag gradients.
  14528. * You must use addDragGradient and removeDragGradient to udpate this list
  14529. * @returns the list of drag gradients
  14530. */
  14531. getDragGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14534. * @param gradient defines the gradient to use (between 0 and 1)
  14535. * @param factor defines the emit rate to affect to the specified gradient
  14536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14537. * @returns the current particle system
  14538. */
  14539. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14540. /**
  14541. * Remove a specific emit rate gradient
  14542. * @param gradient defines the gradient to remove
  14543. * @returns the current particle system
  14544. */
  14545. removeEmitRateGradient(gradient: number): IParticleSystem;
  14546. /**
  14547. * Gets the current list of emit rate gradients.
  14548. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14549. * @returns the list of emit rate gradients
  14550. */
  14551. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14552. /**
  14553. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14554. * @param gradient defines the gradient to use (between 0 and 1)
  14555. * @param factor defines the start size to affect to the specified gradient
  14556. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14557. * @returns the current particle system
  14558. */
  14559. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14560. /**
  14561. * Remove a specific start size gradient
  14562. * @param gradient defines the gradient to remove
  14563. * @returns the current particle system
  14564. */
  14565. removeStartSizeGradient(gradient: number): IParticleSystem;
  14566. /**
  14567. * Gets the current list of start size gradients.
  14568. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14569. * @returns the list of start size gradients
  14570. */
  14571. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14572. /**
  14573. * Adds a new life time gradient
  14574. * @param gradient defines the gradient to use (between 0 and 1)
  14575. * @param factor defines the life time factor to affect to the specified gradient
  14576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14577. * @returns the current particle system
  14578. */
  14579. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14580. /**
  14581. * Remove a specific life time gradient
  14582. * @param gradient defines the gradient to remove
  14583. * @returns the current particle system
  14584. */
  14585. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14586. /**
  14587. * Gets the current list of life time gradients.
  14588. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14589. * @returns the list of life time gradients
  14590. */
  14591. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Gets the current list of color gradients.
  14594. * You must use addColorGradient and removeColorGradient to udpate this list
  14595. * @returns the list of color gradients
  14596. */
  14597. getColorGradients(): Nullable<Array<ColorGradient>>;
  14598. /**
  14599. * Adds a new ramp gradient used to remap particle colors
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param color defines the color to affect to the specified gradient
  14602. * @returns the current particle system
  14603. */
  14604. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14605. /**
  14606. * Gets the current list of ramp gradients.
  14607. * You must use addRampGradient and removeRampGradient to udpate this list
  14608. * @returns the list of ramp gradients
  14609. */
  14610. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14611. /** Gets or sets a boolean indicating that ramp gradients must be used
  14612. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14613. */
  14614. useRampGradients: boolean;
  14615. /**
  14616. * Adds a new color remap gradient
  14617. * @param gradient defines the gradient to use (between 0 and 1)
  14618. * @param min defines the color remap minimal range
  14619. * @param max defines the color remap maximal range
  14620. * @returns the current particle system
  14621. */
  14622. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14623. /**
  14624. * Gets the current list of color remap gradients.
  14625. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14626. * @returns the list of color remap gradients
  14627. */
  14628. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14629. /**
  14630. * Adds a new alpha remap gradient
  14631. * @param gradient defines the gradient to use (between 0 and 1)
  14632. * @param min defines the alpha remap minimal range
  14633. * @param max defines the alpha remap maximal range
  14634. * @returns the current particle system
  14635. */
  14636. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14637. /**
  14638. * Gets the current list of alpha remap gradients.
  14639. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14640. * @returns the list of alpha remap gradients
  14641. */
  14642. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14645. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14646. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14647. * @returns the emitter
  14648. */
  14649. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14650. /**
  14651. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14652. * @param radius The radius of the hemisphere to emit from
  14653. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14654. * @returns the emitter
  14655. */
  14656. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14657. /**
  14658. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14659. * @param radius The radius of the sphere to emit from
  14660. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14661. * @returns the emitter
  14662. */
  14663. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14664. /**
  14665. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14666. * @param radius The radius of the sphere to emit from
  14667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14669. * @returns the emitter
  14670. */
  14671. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14672. /**
  14673. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14674. * @param radius The radius of the emission cylinder
  14675. * @param height The height of the emission cylinder
  14676. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14677. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14678. * @returns the emitter
  14679. */
  14680. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14681. /**
  14682. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14683. * @param radius The radius of the cylinder to emit from
  14684. * @param height The height of the emission cylinder
  14685. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14688. * @returns the emitter
  14689. */
  14690. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14691. /**
  14692. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14693. * @param radius The radius of the cone to emit from
  14694. * @param angle The base angle of the cone
  14695. * @returns the emitter
  14696. */
  14697. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14698. /**
  14699. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14702. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14703. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14704. * @returns the emitter
  14705. */
  14706. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14707. /**
  14708. * Get hosting scene
  14709. * @returns the scene
  14710. */
  14711. getScene(): Nullable<Scene>;
  14712. }
  14713. }
  14714. declare module BABYLON {
  14715. /**
  14716. * 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.
  14717. * @see https://doc.babylonjs.com/how_to/transformnode
  14718. */
  14719. export class TransformNode extends Node {
  14720. /**
  14721. * Object will not rotate to face the camera
  14722. */
  14723. static BILLBOARDMODE_NONE: number;
  14724. /**
  14725. * Object will rotate to face the camera but only on the x axis
  14726. */
  14727. static BILLBOARDMODE_X: number;
  14728. /**
  14729. * Object will rotate to face the camera but only on the y axis
  14730. */
  14731. static BILLBOARDMODE_Y: number;
  14732. /**
  14733. * Object will rotate to face the camera but only on the z axis
  14734. */
  14735. static BILLBOARDMODE_Z: number;
  14736. /**
  14737. * Object will rotate to face the camera
  14738. */
  14739. static BILLBOARDMODE_ALL: number;
  14740. /**
  14741. * Object will rotate to face the camera's position instead of orientation
  14742. */
  14743. static BILLBOARDMODE_USE_POSITION: number;
  14744. private static _TmpRotation;
  14745. private static _TmpScaling;
  14746. private static _TmpTranslation;
  14747. private _forward;
  14748. private _forwardInverted;
  14749. private _up;
  14750. private _right;
  14751. private _rightInverted;
  14752. private _position;
  14753. private _rotation;
  14754. private _rotationQuaternion;
  14755. protected _scaling: Vector3;
  14756. protected _isDirty: boolean;
  14757. private _transformToBoneReferal;
  14758. private _isAbsoluteSynced;
  14759. private _billboardMode;
  14760. /**
  14761. * Gets or sets the billboard mode. Default is 0.
  14762. *
  14763. * | Value | Type | Description |
  14764. * | --- | --- | --- |
  14765. * | 0 | BILLBOARDMODE_NONE | |
  14766. * | 1 | BILLBOARDMODE_X | |
  14767. * | 2 | BILLBOARDMODE_Y | |
  14768. * | 4 | BILLBOARDMODE_Z | |
  14769. * | 7 | BILLBOARDMODE_ALL | |
  14770. *
  14771. */
  14772. get billboardMode(): number;
  14773. set billboardMode(value: number);
  14774. private _preserveParentRotationForBillboard;
  14775. /**
  14776. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14777. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14778. */
  14779. get preserveParentRotationForBillboard(): boolean;
  14780. set preserveParentRotationForBillboard(value: boolean);
  14781. /**
  14782. * 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
  14783. */
  14784. scalingDeterminant: number;
  14785. private _infiniteDistance;
  14786. /**
  14787. * Gets or sets the distance of the object to max, often used by skybox
  14788. */
  14789. get infiniteDistance(): boolean;
  14790. set infiniteDistance(value: boolean);
  14791. /**
  14792. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14793. * By default the system will update normals to compensate
  14794. */
  14795. ignoreNonUniformScaling: boolean;
  14796. /**
  14797. * 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
  14798. */
  14799. reIntegrateRotationIntoRotationQuaternion: boolean;
  14800. /** @hidden */
  14801. _poseMatrix: Nullable<Matrix>;
  14802. /** @hidden */
  14803. _localMatrix: Matrix;
  14804. private _usePivotMatrix;
  14805. private _absolutePosition;
  14806. private _absoluteScaling;
  14807. private _absoluteRotationQuaternion;
  14808. private _pivotMatrix;
  14809. private _pivotMatrixInverse;
  14810. /** @hidden */
  14811. _postMultiplyPivotMatrix: boolean;
  14812. protected _isWorldMatrixFrozen: boolean;
  14813. /** @hidden */
  14814. _indexInSceneTransformNodesArray: number;
  14815. /**
  14816. * An event triggered after the world matrix is updated
  14817. */
  14818. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14819. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14820. /**
  14821. * Gets a string identifying the name of the class
  14822. * @returns "TransformNode" string
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14827. */
  14828. get position(): Vector3;
  14829. set position(newPosition: Vector3);
  14830. /**
  14831. * 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)).
  14832. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14833. */
  14834. get rotation(): Vector3;
  14835. set rotation(newRotation: Vector3);
  14836. /**
  14837. * 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)).
  14838. */
  14839. get scaling(): Vector3;
  14840. set scaling(newScaling: Vector3);
  14841. /**
  14842. * 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).
  14843. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14844. */
  14845. get rotationQuaternion(): Nullable<Quaternion>;
  14846. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14847. /**
  14848. * The forward direction of that transform in world space.
  14849. */
  14850. get forward(): Vector3;
  14851. /**
  14852. * The up direction of that transform in world space.
  14853. */
  14854. get up(): Vector3;
  14855. /**
  14856. * The right direction of that transform in world space.
  14857. */
  14858. get right(): Vector3;
  14859. /**
  14860. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14861. * @param matrix the matrix to copy the pose from
  14862. * @returns this TransformNode.
  14863. */
  14864. updatePoseMatrix(matrix: Matrix): TransformNode;
  14865. /**
  14866. * Returns the mesh Pose matrix.
  14867. * @returns the pose matrix
  14868. */
  14869. getPoseMatrix(): Matrix;
  14870. /** @hidden */
  14871. _isSynchronized(): boolean;
  14872. /** @hidden */
  14873. _initCache(): void;
  14874. /**
  14875. * Flag the transform node as dirty (Forcing it to update everything)
  14876. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14877. * @returns this transform node
  14878. */
  14879. markAsDirty(property: string): TransformNode;
  14880. /**
  14881. * Returns the current mesh absolute position.
  14882. * Returns a Vector3.
  14883. */
  14884. get absolutePosition(): Vector3;
  14885. /**
  14886. * Returns the current mesh absolute scaling.
  14887. * Returns a Vector3.
  14888. */
  14889. get absoluteScaling(): Vector3;
  14890. /**
  14891. * Returns the current mesh absolute rotation.
  14892. * Returns a Quaternion.
  14893. */
  14894. get absoluteRotationQuaternion(): Quaternion;
  14895. /**
  14896. * Sets a new matrix to apply before all other transformation
  14897. * @param matrix defines the transform matrix
  14898. * @returns the current TransformNode
  14899. */
  14900. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14901. /**
  14902. * Sets a new pivot matrix to the current node
  14903. * @param matrix defines the new pivot matrix to use
  14904. * @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
  14905. * @returns the current TransformNode
  14906. */
  14907. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14908. /**
  14909. * Returns the mesh pivot matrix.
  14910. * Default : Identity.
  14911. * @returns the matrix
  14912. */
  14913. getPivotMatrix(): Matrix;
  14914. /**
  14915. * Instantiate (when possible) or clone that node with its hierarchy
  14916. * @param newParent defines the new parent to use for the instance (or clone)
  14917. * @param options defines options to configure how copy is done
  14918. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14919. * @returns an instance (or a clone) of the current node with its hiearchy
  14920. */
  14921. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14922. doNotInstantiate: boolean;
  14923. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14924. /**
  14925. * Prevents the World matrix to be computed any longer
  14926. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14927. * @returns the TransformNode.
  14928. */
  14929. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14930. /**
  14931. * Allows back the World matrix computation.
  14932. * @returns the TransformNode.
  14933. */
  14934. unfreezeWorldMatrix(): this;
  14935. /**
  14936. * True if the World matrix has been frozen.
  14937. */
  14938. get isWorldMatrixFrozen(): boolean;
  14939. /**
  14940. * Retuns the mesh absolute position in the World.
  14941. * @returns a Vector3.
  14942. */
  14943. getAbsolutePosition(): Vector3;
  14944. /**
  14945. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14946. * @param absolutePosition the absolute position to set
  14947. * @returns the TransformNode.
  14948. */
  14949. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14950. /**
  14951. * Sets the mesh position in its local space.
  14952. * @param vector3 the position to set in localspace
  14953. * @returns the TransformNode.
  14954. */
  14955. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14956. /**
  14957. * Returns the mesh position in the local space from the current World matrix values.
  14958. * @returns a new Vector3.
  14959. */
  14960. getPositionExpressedInLocalSpace(): Vector3;
  14961. /**
  14962. * Translates the mesh along the passed Vector3 in its local space.
  14963. * @param vector3 the distance to translate in localspace
  14964. * @returns the TransformNode.
  14965. */
  14966. locallyTranslate(vector3: Vector3): TransformNode;
  14967. private static _lookAtVectorCache;
  14968. /**
  14969. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14970. * @param targetPoint the position (must be in same space as current mesh) to look at
  14971. * @param yawCor optional yaw (y-axis) correction in radians
  14972. * @param pitchCor optional pitch (x-axis) correction in radians
  14973. * @param rollCor optional roll (z-axis) correction in radians
  14974. * @param space the choosen space of the target
  14975. * @returns the TransformNode.
  14976. */
  14977. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14978. /**
  14979. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14980. * This Vector3 is expressed in the World space.
  14981. * @param localAxis axis to rotate
  14982. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14983. */
  14984. getDirection(localAxis: Vector3): Vector3;
  14985. /**
  14986. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14987. * localAxis is expressed in the mesh local space.
  14988. * result is computed in the Wordl space from the mesh World matrix.
  14989. * @param localAxis axis to rotate
  14990. * @param result the resulting transformnode
  14991. * @returns this TransformNode.
  14992. */
  14993. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14994. /**
  14995. * Sets this transform node rotation to the given local axis.
  14996. * @param localAxis the axis in local space
  14997. * @param yawCor optional yaw (y-axis) correction in radians
  14998. * @param pitchCor optional pitch (x-axis) correction in radians
  14999. * @param rollCor optional roll (z-axis) correction in radians
  15000. * @returns this TransformNode
  15001. */
  15002. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15003. /**
  15004. * Sets a new pivot point to the current node
  15005. * @param point defines the new pivot point to use
  15006. * @param space defines if the point is in world or local space (local by default)
  15007. * @returns the current TransformNode
  15008. */
  15009. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15010. /**
  15011. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15012. * @returns the pivot point
  15013. */
  15014. getPivotPoint(): Vector3;
  15015. /**
  15016. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15017. * @param result the vector3 to store the result
  15018. * @returns this TransformNode.
  15019. */
  15020. getPivotPointToRef(result: Vector3): TransformNode;
  15021. /**
  15022. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15023. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15024. */
  15025. getAbsolutePivotPoint(): Vector3;
  15026. /**
  15027. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15028. * @param result vector3 to store the result
  15029. * @returns this TransformNode.
  15030. */
  15031. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15032. /**
  15033. * Defines the passed node as the parent of the current node.
  15034. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15035. * @see https://doc.babylonjs.com/how_to/parenting
  15036. * @param node the node ot set as the parent
  15037. * @returns this TransformNode.
  15038. */
  15039. setParent(node: Nullable<Node>): TransformNode;
  15040. private _nonUniformScaling;
  15041. /**
  15042. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15043. */
  15044. get nonUniformScaling(): boolean;
  15045. /** @hidden */
  15046. _updateNonUniformScalingState(value: boolean): boolean;
  15047. /**
  15048. * Attach the current TransformNode to another TransformNode associated with a bone
  15049. * @param bone Bone affecting the TransformNode
  15050. * @param affectedTransformNode TransformNode associated with the bone
  15051. * @returns this object
  15052. */
  15053. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15054. /**
  15055. * Detach the transform node if its associated with a bone
  15056. * @returns this object
  15057. */
  15058. detachFromBone(): TransformNode;
  15059. private static _rotationAxisCache;
  15060. /**
  15061. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15062. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15063. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15064. * The passed axis is also normalized.
  15065. * @param axis the axis to rotate around
  15066. * @param amount the amount to rotate in radians
  15067. * @param space Space to rotate in (Default: local)
  15068. * @returns the TransformNode.
  15069. */
  15070. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15071. /**
  15072. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15073. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15074. * The passed axis is also normalized. .
  15075. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15076. * @param point the point to rotate around
  15077. * @param axis the axis to rotate around
  15078. * @param amount the amount to rotate in radians
  15079. * @returns the TransformNode
  15080. */
  15081. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15082. /**
  15083. * Translates the mesh along the axis vector for the passed distance in the given space.
  15084. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15085. * @param axis the axis to translate in
  15086. * @param distance the distance to translate
  15087. * @param space Space to rotate in (Default: local)
  15088. * @returns the TransformNode.
  15089. */
  15090. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15091. /**
  15092. * Adds a rotation step to the mesh current rotation.
  15093. * x, y, z are Euler angles expressed in radians.
  15094. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15095. * This means this rotation is made in the mesh local space only.
  15096. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15097. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15098. * ```javascript
  15099. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15100. * ```
  15101. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15102. * 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.
  15103. * @param x Rotation to add
  15104. * @param y Rotation to add
  15105. * @param z Rotation to add
  15106. * @returns the TransformNode.
  15107. */
  15108. addRotation(x: number, y: number, z: number): TransformNode;
  15109. /**
  15110. * @hidden
  15111. */
  15112. protected _getEffectiveParent(): Nullable<Node>;
  15113. /**
  15114. * Computes the world matrix of the node
  15115. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15116. * @returns the world matrix
  15117. */
  15118. computeWorldMatrix(force?: boolean): Matrix;
  15119. /**
  15120. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15121. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15122. */
  15123. resetLocalMatrix(independentOfChildren?: boolean): void;
  15124. protected _afterComputeWorldMatrix(): void;
  15125. /**
  15126. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15127. * @param func callback function to add
  15128. *
  15129. * @returns the TransformNode.
  15130. */
  15131. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15132. /**
  15133. * Removes a registered callback function.
  15134. * @param func callback function to remove
  15135. * @returns the TransformNode.
  15136. */
  15137. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15138. /**
  15139. * Gets the position of the current mesh in camera space
  15140. * @param camera defines the camera to use
  15141. * @returns a position
  15142. */
  15143. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15144. /**
  15145. * Returns the distance from the mesh to the active camera
  15146. * @param camera defines the camera to use
  15147. * @returns the distance
  15148. */
  15149. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15150. /**
  15151. * Clone the current transform node
  15152. * @param name Name of the new clone
  15153. * @param newParent New parent for the clone
  15154. * @param doNotCloneChildren Do not clone children hierarchy
  15155. * @returns the new transform node
  15156. */
  15157. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15158. /**
  15159. * Serializes the objects information.
  15160. * @param currentSerializationObject defines the object to serialize in
  15161. * @returns the serialized object
  15162. */
  15163. serialize(currentSerializationObject?: any): any;
  15164. /**
  15165. * Returns a new TransformNode object parsed from the source provided.
  15166. * @param parsedTransformNode is the source.
  15167. * @param scene the scne the object belongs to
  15168. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15169. * @returns a new TransformNode object parsed from the source provided.
  15170. */
  15171. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15172. /**
  15173. * Get all child-transformNodes of this node
  15174. * @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
  15175. * @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
  15176. * @returns an array of TransformNode
  15177. */
  15178. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15179. /**
  15180. * Releases resources associated with this transform node.
  15181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15183. */
  15184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15185. /**
  15186. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15187. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15188. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15189. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15190. * @returns the current mesh
  15191. */
  15192. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15193. private _syncAbsoluteScalingAndRotation;
  15194. }
  15195. }
  15196. declare module BABYLON {
  15197. /**
  15198. * Class used to override all child animations of a given target
  15199. */
  15200. export class AnimationPropertiesOverride {
  15201. /**
  15202. * Gets or sets a value indicating if animation blending must be used
  15203. */
  15204. enableBlending: boolean;
  15205. /**
  15206. * Gets or sets the blending speed to use when enableBlending is true
  15207. */
  15208. blendingSpeed: number;
  15209. /**
  15210. * Gets or sets the default loop mode to use
  15211. */
  15212. loopMode: number;
  15213. }
  15214. }
  15215. declare module BABYLON {
  15216. /**
  15217. * Class used to store bone information
  15218. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15219. */
  15220. export class Bone extends Node {
  15221. /**
  15222. * defines the bone name
  15223. */
  15224. name: string;
  15225. private static _tmpVecs;
  15226. private static _tmpQuat;
  15227. private static _tmpMats;
  15228. /**
  15229. * Gets the list of child bones
  15230. */
  15231. children: Bone[];
  15232. /** Gets the animations associated with this bone */
  15233. animations: Animation[];
  15234. /**
  15235. * Gets or sets bone length
  15236. */
  15237. length: number;
  15238. /**
  15239. * @hidden Internal only
  15240. * Set this value to map this bone to a different index in the transform matrices
  15241. * Set this value to -1 to exclude the bone from the transform matrices
  15242. */
  15243. _index: Nullable<number>;
  15244. private _skeleton;
  15245. private _localMatrix;
  15246. private _restPose;
  15247. private _bindPose;
  15248. private _baseMatrix;
  15249. private _absoluteTransform;
  15250. private _invertedAbsoluteTransform;
  15251. private _parent;
  15252. private _scalingDeterminant;
  15253. private _worldTransform;
  15254. private _localScaling;
  15255. private _localRotation;
  15256. private _localPosition;
  15257. private _needToDecompose;
  15258. private _needToCompose;
  15259. /** @hidden */
  15260. _linkedTransformNode: Nullable<TransformNode>;
  15261. /** @hidden */
  15262. _waitingTransformNodeId: Nullable<string>;
  15263. /** @hidden */
  15264. get _matrix(): Matrix;
  15265. /** @hidden */
  15266. set _matrix(value: Matrix);
  15267. /**
  15268. * Create a new bone
  15269. * @param name defines the bone name
  15270. * @param skeleton defines the parent skeleton
  15271. * @param parentBone defines the parent (can be null if the bone is the root)
  15272. * @param localMatrix defines the local matrix
  15273. * @param restPose defines the rest pose matrix
  15274. * @param baseMatrix defines the base matrix
  15275. * @param index defines index of the bone in the hiearchy
  15276. */
  15277. constructor(
  15278. /**
  15279. * defines the bone name
  15280. */
  15281. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15282. /**
  15283. * Gets the current object class name.
  15284. * @return the class name
  15285. */
  15286. getClassName(): string;
  15287. /**
  15288. * Gets the parent skeleton
  15289. * @returns a skeleton
  15290. */
  15291. getSkeleton(): Skeleton;
  15292. /**
  15293. * Gets parent bone
  15294. * @returns a bone or null if the bone is the root of the bone hierarchy
  15295. */
  15296. getParent(): Nullable<Bone>;
  15297. /**
  15298. * Returns an array containing the root bones
  15299. * @returns an array containing the root bones
  15300. */
  15301. getChildren(): Array<Bone>;
  15302. /**
  15303. * Gets the node index in matrix array generated for rendering
  15304. * @returns the node index
  15305. */
  15306. getIndex(): number;
  15307. /**
  15308. * Sets the parent bone
  15309. * @param parent defines the parent (can be null if the bone is the root)
  15310. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15311. */
  15312. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15313. /**
  15314. * Gets the local matrix
  15315. * @returns a matrix
  15316. */
  15317. getLocalMatrix(): Matrix;
  15318. /**
  15319. * Gets the base matrix (initial matrix which remains unchanged)
  15320. * @returns a matrix
  15321. */
  15322. getBaseMatrix(): Matrix;
  15323. /**
  15324. * Gets the rest pose matrix
  15325. * @returns a matrix
  15326. */
  15327. getRestPose(): Matrix;
  15328. /**
  15329. * Sets the rest pose matrix
  15330. * @param matrix the local-space rest pose to set for this bone
  15331. */
  15332. setRestPose(matrix: Matrix): void;
  15333. /**
  15334. * Gets the bind pose matrix
  15335. * @returns the bind pose matrix
  15336. */
  15337. getBindPose(): Matrix;
  15338. /**
  15339. * Sets the bind pose matrix
  15340. * @param matrix the local-space bind pose to set for this bone
  15341. */
  15342. setBindPose(matrix: Matrix): void;
  15343. /**
  15344. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15345. */
  15346. getWorldMatrix(): Matrix;
  15347. /**
  15348. * Sets the local matrix to rest pose matrix
  15349. */
  15350. returnToRest(): void;
  15351. /**
  15352. * Gets the inverse of the absolute transform matrix.
  15353. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15354. * @returns a matrix
  15355. */
  15356. getInvertedAbsoluteTransform(): Matrix;
  15357. /**
  15358. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15359. * @returns a matrix
  15360. */
  15361. getAbsoluteTransform(): Matrix;
  15362. /**
  15363. * Links with the given transform node.
  15364. * The local matrix of this bone is copied from the transform node every frame.
  15365. * @param transformNode defines the transform node to link to
  15366. */
  15367. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15368. /**
  15369. * Gets the node used to drive the bone's transformation
  15370. * @returns a transform node or null
  15371. */
  15372. getTransformNode(): Nullable<TransformNode>;
  15373. /** Gets or sets current position (in local space) */
  15374. get position(): Vector3;
  15375. set position(newPosition: Vector3);
  15376. /** Gets or sets current rotation (in local space) */
  15377. get rotation(): Vector3;
  15378. set rotation(newRotation: Vector3);
  15379. /** Gets or sets current rotation quaternion (in local space) */
  15380. get rotationQuaternion(): Quaternion;
  15381. set rotationQuaternion(newRotation: Quaternion);
  15382. /** Gets or sets current scaling (in local space) */
  15383. get scaling(): Vector3;
  15384. set scaling(newScaling: Vector3);
  15385. /**
  15386. * Gets the animation properties override
  15387. */
  15388. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15389. private _decompose;
  15390. private _compose;
  15391. /**
  15392. * Update the base and local matrices
  15393. * @param matrix defines the new base or local matrix
  15394. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15395. * @param updateLocalMatrix defines if the local matrix should be updated
  15396. */
  15397. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15398. /** @hidden */
  15399. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15400. /**
  15401. * Flag the bone as dirty (Forcing it to update everything)
  15402. */
  15403. markAsDirty(): void;
  15404. /** @hidden */
  15405. _markAsDirtyAndCompose(): void;
  15406. private _markAsDirtyAndDecompose;
  15407. /**
  15408. * Translate the bone in local or world space
  15409. * @param vec The amount to translate the bone
  15410. * @param space The space that the translation is in
  15411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15412. */
  15413. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15414. /**
  15415. * Set the postion of the bone in local or world space
  15416. * @param position The position to set the bone
  15417. * @param space The space that the position is in
  15418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15419. */
  15420. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15421. /**
  15422. * Set the absolute position of the bone (world space)
  15423. * @param position The position to set the bone
  15424. * @param mesh The mesh that this bone is attached to
  15425. */
  15426. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15427. /**
  15428. * Scale the bone on the x, y and z axes (in local space)
  15429. * @param x The amount to scale the bone on the x axis
  15430. * @param y The amount to scale the bone on the y axis
  15431. * @param z The amount to scale the bone on the z axis
  15432. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15433. */
  15434. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15435. /**
  15436. * Set the bone scaling in local space
  15437. * @param scale defines the scaling vector
  15438. */
  15439. setScale(scale: Vector3): void;
  15440. /**
  15441. * Gets the current scaling in local space
  15442. * @returns the current scaling vector
  15443. */
  15444. getScale(): Vector3;
  15445. /**
  15446. * Gets the current scaling in local space and stores it in a target vector
  15447. * @param result defines the target vector
  15448. */
  15449. getScaleToRef(result: Vector3): void;
  15450. /**
  15451. * Set the yaw, pitch, and roll of the bone in local or world space
  15452. * @param yaw The rotation of the bone on the y axis
  15453. * @param pitch The rotation of the bone on the x axis
  15454. * @param roll The rotation of the bone on the z axis
  15455. * @param space The space that the axes of rotation are in
  15456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15457. */
  15458. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15459. /**
  15460. * Add a rotation to the bone on an axis in local or world space
  15461. * @param axis The axis to rotate the bone on
  15462. * @param amount The amount to rotate the bone
  15463. * @param space The space that the axis is in
  15464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15465. */
  15466. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15467. /**
  15468. * Set the rotation of the bone to a particular axis angle in local or world space
  15469. * @param axis The axis to rotate the bone on
  15470. * @param angle The angle that the bone should be rotated to
  15471. * @param space The space that the axis is in
  15472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15473. */
  15474. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15475. /**
  15476. * Set the euler rotation of the bone in local or world space
  15477. * @param rotation The euler rotation that the bone should be set to
  15478. * @param space The space that the rotation is in
  15479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15480. */
  15481. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15482. /**
  15483. * Set the quaternion rotation of the bone in local or world space
  15484. * @param quat The quaternion rotation that the bone should be set to
  15485. * @param space The space that the rotation is in
  15486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15487. */
  15488. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15489. /**
  15490. * Set the rotation matrix of the bone in local or world space
  15491. * @param rotMat The rotation matrix that the bone should be set to
  15492. * @param space The space that the rotation is in
  15493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15494. */
  15495. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15496. private _rotateWithMatrix;
  15497. private _getNegativeRotationToRef;
  15498. /**
  15499. * Get the position of the bone in local or world space
  15500. * @param space The space that the returned position is in
  15501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15502. * @returns The position of the bone
  15503. */
  15504. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15505. /**
  15506. * Copy the position of the bone to a vector3 in local or world space
  15507. * @param space The space that the returned position is in
  15508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15509. * @param result The vector3 to copy the position to
  15510. */
  15511. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15512. /**
  15513. * Get the absolute position of the bone (world space)
  15514. * @param mesh The mesh that this bone is attached to
  15515. * @returns The absolute position of the bone
  15516. */
  15517. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15518. /**
  15519. * Copy the absolute position of the bone (world space) to the result param
  15520. * @param mesh The mesh that this bone is attached to
  15521. * @param result The vector3 to copy the absolute position to
  15522. */
  15523. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15524. /**
  15525. * Compute the absolute transforms of this bone and its children
  15526. */
  15527. computeAbsoluteTransforms(): void;
  15528. /**
  15529. * Get the world direction from an axis that is in the local space of the bone
  15530. * @param localAxis The local direction that is used to compute the world direction
  15531. * @param mesh The mesh that this bone is attached to
  15532. * @returns The world direction
  15533. */
  15534. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15535. /**
  15536. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15537. * @param localAxis The local direction that is used to compute the world direction
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @param result The vector3 that the world direction will be copied to
  15540. */
  15541. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15542. /**
  15543. * Get the euler rotation of the bone in local or world space
  15544. * @param space The space that the rotation should be in
  15545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15546. * @returns The euler rotation
  15547. */
  15548. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15549. /**
  15550. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15551. * @param space The space that the rotation should be in
  15552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15553. * @param result The vector3 that the rotation should be copied to
  15554. */
  15555. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15556. /**
  15557. * Get the quaternion rotation of the bone in either local or world space
  15558. * @param space The space that the rotation should be in
  15559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15560. * @returns The quaternion rotation
  15561. */
  15562. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15563. /**
  15564. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15565. * @param space The space that the rotation should be in
  15566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15567. * @param result The quaternion that the rotation should be copied to
  15568. */
  15569. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15570. /**
  15571. * Get the rotation matrix of the bone in local or world space
  15572. * @param space The space that the rotation should be in
  15573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15574. * @returns The rotation matrix
  15575. */
  15576. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15577. /**
  15578. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15579. * @param space The space that the rotation should be in
  15580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15581. * @param result The quaternion that the rotation should be copied to
  15582. */
  15583. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15584. /**
  15585. * Get the world position of a point that is in the local space of the bone
  15586. * @param position The local position
  15587. * @param mesh The mesh that this bone is attached to
  15588. * @returns The world position
  15589. */
  15590. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15591. /**
  15592. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15593. * @param position The local position
  15594. * @param mesh The mesh that this bone is attached to
  15595. * @param result The vector3 that the world position should be copied to
  15596. */
  15597. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15598. /**
  15599. * Get the local position of a point that is in world space
  15600. * @param position The world position
  15601. * @param mesh The mesh that this bone is attached to
  15602. * @returns The local position
  15603. */
  15604. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15605. /**
  15606. * Get the local position of a point that is in world space and copy it to the result param
  15607. * @param position The world position
  15608. * @param mesh The mesh that this bone is attached to
  15609. * @param result The vector3 that the local position should be copied to
  15610. */
  15611. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15612. /**
  15613. * Set the current local matrix as the restPose for this bone.
  15614. */
  15615. setCurrentPoseAsRest(): void;
  15616. }
  15617. }
  15618. declare module BABYLON {
  15619. /**
  15620. * Defines a runtime animation
  15621. */
  15622. export class RuntimeAnimation {
  15623. private _events;
  15624. /**
  15625. * The current frame of the runtime animation
  15626. */
  15627. private _currentFrame;
  15628. /**
  15629. * The animation used by the runtime animation
  15630. */
  15631. private _animation;
  15632. /**
  15633. * The target of the runtime animation
  15634. */
  15635. private _target;
  15636. /**
  15637. * The initiating animatable
  15638. */
  15639. private _host;
  15640. /**
  15641. * The original value of the runtime animation
  15642. */
  15643. private _originalValue;
  15644. /**
  15645. * The original blend value of the runtime animation
  15646. */
  15647. private _originalBlendValue;
  15648. /**
  15649. * The offsets cache of the runtime animation
  15650. */
  15651. private _offsetsCache;
  15652. /**
  15653. * The high limits cache of the runtime animation
  15654. */
  15655. private _highLimitsCache;
  15656. /**
  15657. * Specifies if the runtime animation has been stopped
  15658. */
  15659. private _stopped;
  15660. /**
  15661. * The blending factor of the runtime animation
  15662. */
  15663. private _blendingFactor;
  15664. /**
  15665. * The BabylonJS scene
  15666. */
  15667. private _scene;
  15668. /**
  15669. * The current value of the runtime animation
  15670. */
  15671. private _currentValue;
  15672. /** @hidden */
  15673. _animationState: _IAnimationState;
  15674. /**
  15675. * The active target of the runtime animation
  15676. */
  15677. private _activeTargets;
  15678. private _currentActiveTarget;
  15679. private _directTarget;
  15680. /**
  15681. * The target path of the runtime animation
  15682. */
  15683. private _targetPath;
  15684. /**
  15685. * The weight of the runtime animation
  15686. */
  15687. private _weight;
  15688. /**
  15689. * The ratio offset of the runtime animation
  15690. */
  15691. private _ratioOffset;
  15692. /**
  15693. * The previous delay of the runtime animation
  15694. */
  15695. private _previousDelay;
  15696. /**
  15697. * The previous ratio of the runtime animation
  15698. */
  15699. private _previousRatio;
  15700. private _enableBlending;
  15701. private _keys;
  15702. private _minFrame;
  15703. private _maxFrame;
  15704. private _minValue;
  15705. private _maxValue;
  15706. private _targetIsArray;
  15707. /**
  15708. * Gets the current frame of the runtime animation
  15709. */
  15710. get currentFrame(): number;
  15711. /**
  15712. * Gets the weight of the runtime animation
  15713. */
  15714. get weight(): number;
  15715. /**
  15716. * Gets the current value of the runtime animation
  15717. */
  15718. get currentValue(): any;
  15719. /**
  15720. * Gets the target path of the runtime animation
  15721. */
  15722. get targetPath(): string;
  15723. /**
  15724. * Gets the actual target of the runtime animation
  15725. */
  15726. get target(): any;
  15727. /**
  15728. * Gets the additive state of the runtime animation
  15729. */
  15730. get isAdditive(): boolean;
  15731. /** @hidden */
  15732. _onLoop: () => void;
  15733. /**
  15734. * Create a new RuntimeAnimation object
  15735. * @param target defines the target of the animation
  15736. * @param animation defines the source animation object
  15737. * @param scene defines the hosting scene
  15738. * @param host defines the initiating Animatable
  15739. */
  15740. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15741. private _preparePath;
  15742. /**
  15743. * Gets the animation from the runtime animation
  15744. */
  15745. get animation(): Animation;
  15746. /**
  15747. * Resets the runtime animation to the beginning
  15748. * @param restoreOriginal defines whether to restore the target property to the original value
  15749. */
  15750. reset(restoreOriginal?: boolean): void;
  15751. /**
  15752. * Specifies if the runtime animation is stopped
  15753. * @returns Boolean specifying if the runtime animation is stopped
  15754. */
  15755. isStopped(): boolean;
  15756. /**
  15757. * Disposes of the runtime animation
  15758. */
  15759. dispose(): void;
  15760. /**
  15761. * Apply the interpolated value to the target
  15762. * @param currentValue defines the value computed by the animation
  15763. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15764. */
  15765. setValue(currentValue: any, weight: number): void;
  15766. private _getOriginalValues;
  15767. private _setValue;
  15768. /**
  15769. * Gets the loop pmode of the runtime animation
  15770. * @returns Loop Mode
  15771. */
  15772. private _getCorrectLoopMode;
  15773. /**
  15774. * Move the current animation to a given frame
  15775. * @param frame defines the frame to move to
  15776. */
  15777. goToFrame(frame: number): void;
  15778. /**
  15779. * @hidden Internal use only
  15780. */
  15781. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15782. /**
  15783. * Execute the current animation
  15784. * @param delay defines the delay to add to the current frame
  15785. * @param from defines the lower bound of the animation range
  15786. * @param to defines the upper bound of the animation range
  15787. * @param loop defines if the current animation must loop
  15788. * @param speedRatio defines the current speed ratio
  15789. * @param weight defines the weight of the animation (default is -1 so no weight)
  15790. * @param onLoop optional callback called when animation loops
  15791. * @returns a boolean indicating if the animation is running
  15792. */
  15793. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15794. }
  15795. }
  15796. declare module BABYLON {
  15797. /**
  15798. * Class used to store an actual running animation
  15799. */
  15800. export class Animatable {
  15801. /** defines the target object */
  15802. target: any;
  15803. /** defines the starting frame number (default is 0) */
  15804. fromFrame: number;
  15805. /** defines the ending frame number (default is 100) */
  15806. toFrame: number;
  15807. /** defines if the animation must loop (default is false) */
  15808. loopAnimation: boolean;
  15809. /** defines a callback to call when animation ends if it is not looping */
  15810. onAnimationEnd?: (() => void) | null | undefined;
  15811. /** defines a callback to call when animation loops */
  15812. onAnimationLoop?: (() => void) | null | undefined;
  15813. /** defines whether the animation should be evaluated additively */
  15814. isAdditive: boolean;
  15815. private _localDelayOffset;
  15816. private _pausedDelay;
  15817. private _runtimeAnimations;
  15818. private _paused;
  15819. private _scene;
  15820. private _speedRatio;
  15821. private _weight;
  15822. private _syncRoot;
  15823. /**
  15824. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15825. * This will only apply for non looping animation (default is true)
  15826. */
  15827. disposeOnEnd: boolean;
  15828. /**
  15829. * Gets a boolean indicating if the animation has started
  15830. */
  15831. animationStarted: boolean;
  15832. /**
  15833. * Observer raised when the animation ends
  15834. */
  15835. onAnimationEndObservable: Observable<Animatable>;
  15836. /**
  15837. * Observer raised when the animation loops
  15838. */
  15839. onAnimationLoopObservable: Observable<Animatable>;
  15840. /**
  15841. * Gets the root Animatable used to synchronize and normalize animations
  15842. */
  15843. get syncRoot(): Nullable<Animatable>;
  15844. /**
  15845. * Gets the current frame of the first RuntimeAnimation
  15846. * Used to synchronize Animatables
  15847. */
  15848. get masterFrame(): number;
  15849. /**
  15850. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15851. */
  15852. get weight(): number;
  15853. set weight(value: number);
  15854. /**
  15855. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15856. */
  15857. get speedRatio(): number;
  15858. set speedRatio(value: number);
  15859. /**
  15860. * Creates a new Animatable
  15861. * @param scene defines the hosting scene
  15862. * @param target defines the target object
  15863. * @param fromFrame defines the starting frame number (default is 0)
  15864. * @param toFrame defines the ending frame number (default is 100)
  15865. * @param loopAnimation defines if the animation must loop (default is false)
  15866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15868. * @param animations defines a group of animation to add to the new Animatable
  15869. * @param onAnimationLoop defines a callback to call when animation loops
  15870. * @param isAdditive defines whether the animation should be evaluated additively
  15871. */
  15872. constructor(scene: Scene,
  15873. /** defines the target object */
  15874. target: any,
  15875. /** defines the starting frame number (default is 0) */
  15876. fromFrame?: number,
  15877. /** defines the ending frame number (default is 100) */
  15878. toFrame?: number,
  15879. /** defines if the animation must loop (default is false) */
  15880. loopAnimation?: boolean, speedRatio?: number,
  15881. /** defines a callback to call when animation ends if it is not looping */
  15882. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15883. /** defines a callback to call when animation loops */
  15884. onAnimationLoop?: (() => void) | null | undefined,
  15885. /** defines whether the animation should be evaluated additively */
  15886. isAdditive?: boolean);
  15887. /**
  15888. * Synchronize and normalize current Animatable with a source Animatable
  15889. * This is useful when using animation weights and when animations are not of the same length
  15890. * @param root defines the root Animatable to synchronize with
  15891. * @returns the current Animatable
  15892. */
  15893. syncWith(root: Animatable): Animatable;
  15894. /**
  15895. * Gets the list of runtime animations
  15896. * @returns an array of RuntimeAnimation
  15897. */
  15898. getAnimations(): RuntimeAnimation[];
  15899. /**
  15900. * Adds more animations to the current animatable
  15901. * @param target defines the target of the animations
  15902. * @param animations defines the new animations to add
  15903. */
  15904. appendAnimations(target: any, animations: Animation[]): void;
  15905. /**
  15906. * Gets the source animation for a specific property
  15907. * @param property defines the propertyu to look for
  15908. * @returns null or the source animation for the given property
  15909. */
  15910. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15911. /**
  15912. * Gets the runtime animation for a specific property
  15913. * @param property defines the propertyu to look for
  15914. * @returns null or the runtime animation for the given property
  15915. */
  15916. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15917. /**
  15918. * Resets the animatable to its original state
  15919. */
  15920. reset(): void;
  15921. /**
  15922. * Allows the animatable to blend with current running animations
  15923. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15924. * @param blendingSpeed defines the blending speed to use
  15925. */
  15926. enableBlending(blendingSpeed: number): void;
  15927. /**
  15928. * Disable animation blending
  15929. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15930. */
  15931. disableBlending(): void;
  15932. /**
  15933. * Jump directly to a given frame
  15934. * @param frame defines the frame to jump to
  15935. */
  15936. goToFrame(frame: number): void;
  15937. /**
  15938. * Pause the animation
  15939. */
  15940. pause(): void;
  15941. /**
  15942. * Restart the animation
  15943. */
  15944. restart(): void;
  15945. private _raiseOnAnimationEnd;
  15946. /**
  15947. * Stop and delete the current animation
  15948. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15949. * @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)
  15950. */
  15951. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15952. /**
  15953. * Wait asynchronously for the animation to end
  15954. * @returns a promise which will be fullfilled when the animation ends
  15955. */
  15956. waitAsync(): Promise<Animatable>;
  15957. /** @hidden */
  15958. _animate(delay: number): boolean;
  15959. }
  15960. interface Scene {
  15961. /** @hidden */
  15962. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15963. /** @hidden */
  15964. _processLateAnimationBindingsForMatrices(holder: {
  15965. totalWeight: number;
  15966. totalAdditiveWeight: number;
  15967. animations: RuntimeAnimation[];
  15968. additiveAnimations: RuntimeAnimation[];
  15969. originalValue: Matrix;
  15970. }): any;
  15971. /** @hidden */
  15972. _processLateAnimationBindingsForQuaternions(holder: {
  15973. totalWeight: number;
  15974. totalAdditiveWeight: number;
  15975. animations: RuntimeAnimation[];
  15976. additiveAnimations: RuntimeAnimation[];
  15977. originalValue: Quaternion;
  15978. }, refQuaternion: Quaternion): Quaternion;
  15979. /** @hidden */
  15980. _processLateAnimationBindings(): void;
  15981. /**
  15982. * Will start the animation sequence of a given target
  15983. * @param target defines the target
  15984. * @param from defines from which frame should animation start
  15985. * @param to defines until which frame should animation run.
  15986. * @param weight defines the weight to apply to the animation (1.0 by default)
  15987. * @param loop defines if the animation loops
  15988. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15989. * @param onAnimationEnd defines the function to be executed when the animation ends
  15990. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15991. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15992. * @param onAnimationLoop defines the callback to call when an animation loops
  15993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15994. * @returns the animatable object created for this animation
  15995. */
  15996. 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;
  15997. /**
  15998. * Will start the animation sequence of a given target
  15999. * @param target defines the target
  16000. * @param from defines from which frame should animation start
  16001. * @param to defines until which frame should animation run.
  16002. * @param loop defines if the animation loops
  16003. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16004. * @param onAnimationEnd defines the function to be executed when the animation ends
  16005. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16006. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16007. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16008. * @param onAnimationLoop defines the callback to call when an animation loops
  16009. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16010. * @returns the animatable object created for this animation
  16011. */
  16012. 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;
  16013. /**
  16014. * Will start the animation sequence of a given target and its hierarchy
  16015. * @param target defines the target
  16016. * @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.
  16017. * @param from defines from which frame should animation start
  16018. * @param to defines until which frame should animation run.
  16019. * @param loop defines if the animation loops
  16020. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16021. * @param onAnimationEnd defines the function to be executed when the animation ends
  16022. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16023. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16024. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16025. * @param onAnimationLoop defines the callback to call when an animation loops
  16026. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16027. * @returns the list of created animatables
  16028. */
  16029. 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[];
  16030. /**
  16031. * Begin a new animation on a given node
  16032. * @param target defines the target where the animation will take place
  16033. * @param animations defines the list of animations to start
  16034. * @param from defines the initial value
  16035. * @param to defines the final value
  16036. * @param loop defines if you want animation to loop (off by default)
  16037. * @param speedRatio defines the speed ratio to apply to all animations
  16038. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16039. * @param onAnimationLoop defines the callback to call when an animation loops
  16040. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16041. * @returns the list of created animatables
  16042. */
  16043. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16044. /**
  16045. * Begin a new animation on a given node and its hierarchy
  16046. * @param target defines the root node where the animation will take place
  16047. * @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.
  16048. * @param animations defines the list of animations to start
  16049. * @param from defines the initial value
  16050. * @param to defines the final value
  16051. * @param loop defines if you want animation to loop (off by default)
  16052. * @param speedRatio defines the speed ratio to apply to all animations
  16053. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16054. * @param onAnimationLoop defines the callback to call when an animation loops
  16055. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16056. * @returns the list of animatables created for all nodes
  16057. */
  16058. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16059. /**
  16060. * Gets the animatable associated with a specific target
  16061. * @param target defines the target of the animatable
  16062. * @returns the required animatable if found
  16063. */
  16064. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16065. /**
  16066. * Gets all animatables associated with a given target
  16067. * @param target defines the target to look animatables for
  16068. * @returns an array of Animatables
  16069. */
  16070. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16071. /**
  16072. * Stops and removes all animations that have been applied to the scene
  16073. */
  16074. stopAllAnimations(): void;
  16075. /**
  16076. * Gets the current delta time used by animation engine
  16077. */
  16078. deltaTime: number;
  16079. }
  16080. interface Bone {
  16081. /**
  16082. * Copy an animation range from another bone
  16083. * @param source defines the source bone
  16084. * @param rangeName defines the range name to copy
  16085. * @param frameOffset defines the frame offset
  16086. * @param rescaleAsRequired defines if rescaling must be applied if required
  16087. * @param skelDimensionsRatio defines the scaling ratio
  16088. * @returns true if operation was successful
  16089. */
  16090. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16091. }
  16092. }
  16093. declare module BABYLON {
  16094. /**
  16095. * Class used to handle skinning animations
  16096. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16097. */
  16098. export class Skeleton implements IAnimatable {
  16099. /** defines the skeleton name */
  16100. name: string;
  16101. /** defines the skeleton Id */
  16102. id: string;
  16103. /**
  16104. * Defines the list of child bones
  16105. */
  16106. bones: Bone[];
  16107. /**
  16108. * Defines an estimate of the dimension of the skeleton at rest
  16109. */
  16110. dimensionsAtRest: Vector3;
  16111. /**
  16112. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16113. */
  16114. needInitialSkinMatrix: boolean;
  16115. /**
  16116. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16117. */
  16118. overrideMesh: Nullable<AbstractMesh>;
  16119. /**
  16120. * Gets the list of animations attached to this skeleton
  16121. */
  16122. animations: Array<Animation>;
  16123. private _scene;
  16124. private _isDirty;
  16125. private _transformMatrices;
  16126. private _transformMatrixTexture;
  16127. private _meshesWithPoseMatrix;
  16128. private _animatables;
  16129. private _identity;
  16130. private _synchronizedWithMesh;
  16131. private _ranges;
  16132. private _lastAbsoluteTransformsUpdateId;
  16133. private _canUseTextureForBones;
  16134. private _uniqueId;
  16135. /** @hidden */
  16136. _numBonesWithLinkedTransformNode: number;
  16137. /** @hidden */
  16138. _hasWaitingData: Nullable<boolean>;
  16139. /** @hidden */
  16140. _waitingOverrideMeshId: Nullable<string>;
  16141. /**
  16142. * Specifies if the skeleton should be serialized
  16143. */
  16144. doNotSerialize: boolean;
  16145. private _useTextureToStoreBoneMatrices;
  16146. /**
  16147. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16148. * Please note that this option is not available if the hardware does not support it
  16149. */
  16150. get useTextureToStoreBoneMatrices(): boolean;
  16151. set useTextureToStoreBoneMatrices(value: boolean);
  16152. private _animationPropertiesOverride;
  16153. /**
  16154. * Gets or sets the animation properties override
  16155. */
  16156. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16157. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16158. /**
  16159. * List of inspectable custom properties (used by the Inspector)
  16160. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16161. */
  16162. inspectableCustomProperties: IInspectable[];
  16163. /**
  16164. * An observable triggered before computing the skeleton's matrices
  16165. */
  16166. onBeforeComputeObservable: Observable<Skeleton>;
  16167. /**
  16168. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16169. */
  16170. get isUsingTextureForMatrices(): boolean;
  16171. /**
  16172. * Gets the unique ID of this skeleton
  16173. */
  16174. get uniqueId(): number;
  16175. /**
  16176. * Creates a new skeleton
  16177. * @param name defines the skeleton name
  16178. * @param id defines the skeleton Id
  16179. * @param scene defines the hosting scene
  16180. */
  16181. constructor(
  16182. /** defines the skeleton name */
  16183. name: string,
  16184. /** defines the skeleton Id */
  16185. id: string, scene: Scene);
  16186. /**
  16187. * Gets the current object class name.
  16188. * @return the class name
  16189. */
  16190. getClassName(): string;
  16191. /**
  16192. * Returns an array containing the root bones
  16193. * @returns an array containing the root bones
  16194. */
  16195. getChildren(): Array<Bone>;
  16196. /**
  16197. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16199. * @returns a Float32Array containing matrices data
  16200. */
  16201. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16202. /**
  16203. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16204. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16205. * @returns a raw texture containing the data
  16206. */
  16207. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16208. /**
  16209. * Gets the current hosting scene
  16210. * @returns a scene object
  16211. */
  16212. getScene(): Scene;
  16213. /**
  16214. * Gets a string representing the current skeleton data
  16215. * @param fullDetails defines a boolean indicating if we want a verbose version
  16216. * @returns a string representing the current skeleton data
  16217. */
  16218. toString(fullDetails?: boolean): string;
  16219. /**
  16220. * Get bone's index searching by name
  16221. * @param name defines bone's name to search for
  16222. * @return the indice of the bone. Returns -1 if not found
  16223. */
  16224. getBoneIndexByName(name: string): number;
  16225. /**
  16226. * Creater a new animation range
  16227. * @param name defines the name of the range
  16228. * @param from defines the start key
  16229. * @param to defines the end key
  16230. */
  16231. createAnimationRange(name: string, from: number, to: number): void;
  16232. /**
  16233. * Delete a specific animation range
  16234. * @param name defines the name of the range
  16235. * @param deleteFrames defines if frames must be removed as well
  16236. */
  16237. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16238. /**
  16239. * Gets a specific animation range
  16240. * @param name defines the name of the range to look for
  16241. * @returns the requested animation range or null if not found
  16242. */
  16243. getAnimationRange(name: string): Nullable<AnimationRange>;
  16244. /**
  16245. * Gets the list of all animation ranges defined on this skeleton
  16246. * @returns an array
  16247. */
  16248. getAnimationRanges(): Nullable<AnimationRange>[];
  16249. /**
  16250. * Copy animation range from a source skeleton.
  16251. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16252. * @param source defines the source skeleton
  16253. * @param name defines the name of the range to copy
  16254. * @param rescaleAsRequired defines if rescaling must be applied if required
  16255. * @returns true if operation was successful
  16256. */
  16257. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16258. /**
  16259. * Forces the skeleton to go to rest pose
  16260. */
  16261. returnToRest(): void;
  16262. private _getHighestAnimationFrame;
  16263. /**
  16264. * Begin a specific animation range
  16265. * @param name defines the name of the range to start
  16266. * @param loop defines if looping must be turned on (false by default)
  16267. * @param speedRatio defines the speed ratio to apply (1 by default)
  16268. * @param onAnimationEnd defines a callback which will be called when animation will end
  16269. * @returns a new animatable
  16270. */
  16271. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16272. /**
  16273. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16274. * @param skeleton defines the Skeleton containing the animation range to convert
  16275. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16276. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16277. * @returns the original skeleton
  16278. */
  16279. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16280. /** @hidden */
  16281. _markAsDirty(): void;
  16282. /** @hidden */
  16283. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16284. /** @hidden */
  16285. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16286. private _computeTransformMatrices;
  16287. /**
  16288. * Build all resources required to render a skeleton
  16289. */
  16290. prepare(): void;
  16291. /**
  16292. * Gets the list of animatables currently running for this skeleton
  16293. * @returns an array of animatables
  16294. */
  16295. getAnimatables(): IAnimatable[];
  16296. /**
  16297. * Clone the current skeleton
  16298. * @param name defines the name of the new skeleton
  16299. * @param id defines the id of the new skeleton
  16300. * @returns the new skeleton
  16301. */
  16302. clone(name: string, id?: string): Skeleton;
  16303. /**
  16304. * Enable animation blending for this skeleton
  16305. * @param blendingSpeed defines the blending speed to apply
  16306. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16307. */
  16308. enableBlending(blendingSpeed?: number): void;
  16309. /**
  16310. * Releases all resources associated with the current skeleton
  16311. */
  16312. dispose(): void;
  16313. /**
  16314. * Serialize the skeleton in a JSON object
  16315. * @returns a JSON object
  16316. */
  16317. serialize(): any;
  16318. /**
  16319. * Creates a new skeleton from serialized data
  16320. * @param parsedSkeleton defines the serialized data
  16321. * @param scene defines the hosting scene
  16322. * @returns a new skeleton
  16323. */
  16324. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16325. /**
  16326. * Compute all node absolute transforms
  16327. * @param forceUpdate defines if computation must be done even if cache is up to date
  16328. */
  16329. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16330. /**
  16331. * Gets the root pose matrix
  16332. * @returns a matrix
  16333. */
  16334. getPoseMatrix(): Nullable<Matrix>;
  16335. /**
  16336. * Sorts bones per internal index
  16337. */
  16338. sortBones(): void;
  16339. private _sortBones;
  16340. /**
  16341. * Set the current local matrix as the restPose for all bones in the skeleton.
  16342. */
  16343. setCurrentPoseAsRest(): void;
  16344. }
  16345. }
  16346. declare module BABYLON {
  16347. /**
  16348. * Creates an instance based on a source mesh.
  16349. */
  16350. export class InstancedMesh extends AbstractMesh {
  16351. private _sourceMesh;
  16352. private _currentLOD;
  16353. /** @hidden */
  16354. _indexInSourceMeshInstanceArray: number;
  16355. constructor(name: string, source: Mesh);
  16356. /**
  16357. * Returns the string "InstancedMesh".
  16358. */
  16359. getClassName(): string;
  16360. /** Gets the list of lights affecting that mesh */
  16361. get lightSources(): Light[];
  16362. _resyncLightSources(): void;
  16363. _resyncLightSource(light: Light): void;
  16364. _removeLightSource(light: Light, dispose: boolean): void;
  16365. /**
  16366. * If the source mesh receives shadows
  16367. */
  16368. get receiveShadows(): boolean;
  16369. /**
  16370. * The material of the source mesh
  16371. */
  16372. get material(): Nullable<Material>;
  16373. /**
  16374. * Visibility of the source mesh
  16375. */
  16376. get visibility(): number;
  16377. /**
  16378. * Skeleton of the source mesh
  16379. */
  16380. get skeleton(): Nullable<Skeleton>;
  16381. /**
  16382. * Rendering ground id of the source mesh
  16383. */
  16384. get renderingGroupId(): number;
  16385. set renderingGroupId(value: number);
  16386. /**
  16387. * Returns the total number of vertices (integer).
  16388. */
  16389. getTotalVertices(): number;
  16390. /**
  16391. * Returns a positive integer : the total number of indices in this mesh geometry.
  16392. * @returns the numner of indices or zero if the mesh has no geometry.
  16393. */
  16394. getTotalIndices(): number;
  16395. /**
  16396. * The source mesh of the instance
  16397. */
  16398. get sourceMesh(): Mesh;
  16399. /**
  16400. * Creates a new InstancedMesh object from the mesh model.
  16401. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16402. * @param name defines the name of the new instance
  16403. * @returns a new InstancedMesh
  16404. */
  16405. createInstance(name: string): InstancedMesh;
  16406. /**
  16407. * Is this node ready to be used/rendered
  16408. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16409. * @return {boolean} is it ready
  16410. */
  16411. isReady(completeCheck?: boolean): boolean;
  16412. /**
  16413. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16414. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16415. * @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.
  16416. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16417. */
  16418. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16419. /**
  16420. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16421. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16422. * The `data` are either a numeric array either a Float32Array.
  16423. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16424. * 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).
  16425. * Note that a new underlying VertexBuffer object is created each call.
  16426. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16427. *
  16428. * Possible `kind` values :
  16429. * - VertexBuffer.PositionKind
  16430. * - VertexBuffer.UVKind
  16431. * - VertexBuffer.UV2Kind
  16432. * - VertexBuffer.UV3Kind
  16433. * - VertexBuffer.UV4Kind
  16434. * - VertexBuffer.UV5Kind
  16435. * - VertexBuffer.UV6Kind
  16436. * - VertexBuffer.ColorKind
  16437. * - VertexBuffer.MatricesIndicesKind
  16438. * - VertexBuffer.MatricesIndicesExtraKind
  16439. * - VertexBuffer.MatricesWeightsKind
  16440. * - VertexBuffer.MatricesWeightsExtraKind
  16441. *
  16442. * Returns the Mesh.
  16443. */
  16444. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16445. /**
  16446. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16447. * If the mesh has no geometry, it is simply returned as it is.
  16448. * The `data` are either a numeric array either a Float32Array.
  16449. * No new underlying VertexBuffer object is created.
  16450. * 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.
  16451. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16452. *
  16453. * Possible `kind` values :
  16454. * - VertexBuffer.PositionKind
  16455. * - VertexBuffer.UVKind
  16456. * - VertexBuffer.UV2Kind
  16457. * - VertexBuffer.UV3Kind
  16458. * - VertexBuffer.UV4Kind
  16459. * - VertexBuffer.UV5Kind
  16460. * - VertexBuffer.UV6Kind
  16461. * - VertexBuffer.ColorKind
  16462. * - VertexBuffer.MatricesIndicesKind
  16463. * - VertexBuffer.MatricesIndicesExtraKind
  16464. * - VertexBuffer.MatricesWeightsKind
  16465. * - VertexBuffer.MatricesWeightsExtraKind
  16466. *
  16467. * Returns the Mesh.
  16468. */
  16469. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16470. /**
  16471. * Sets the mesh indices.
  16472. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16473. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16474. * This method creates a new index buffer each call.
  16475. * Returns the Mesh.
  16476. */
  16477. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16478. /**
  16479. * Boolean : True if the mesh owns the requested kind of data.
  16480. */
  16481. isVerticesDataPresent(kind: string): boolean;
  16482. /**
  16483. * Returns an array of indices (IndicesArray).
  16484. */
  16485. getIndices(): Nullable<IndicesArray>;
  16486. get _positions(): Nullable<Vector3[]>;
  16487. /**
  16488. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16489. * This means the mesh underlying bounding box and sphere are recomputed.
  16490. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16491. * @returns the current mesh
  16492. */
  16493. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16494. /** @hidden */
  16495. _preActivate(): InstancedMesh;
  16496. /** @hidden */
  16497. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16498. /** @hidden */
  16499. _postActivate(): void;
  16500. getWorldMatrix(): Matrix;
  16501. get isAnInstance(): boolean;
  16502. /**
  16503. * Returns the current associated LOD AbstractMesh.
  16504. */
  16505. getLOD(camera: Camera): AbstractMesh;
  16506. /** @hidden */
  16507. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16508. /** @hidden */
  16509. _syncSubMeshes(): InstancedMesh;
  16510. /** @hidden */
  16511. _generatePointsArray(): boolean;
  16512. /** @hidden */
  16513. _updateBoundingInfo(): AbstractMesh;
  16514. /**
  16515. * Creates a new InstancedMesh from the current mesh.
  16516. * - name (string) : the cloned mesh name
  16517. * - newParent (optional Node) : the optional Node to parent the clone to.
  16518. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16519. *
  16520. * Returns the clone.
  16521. */
  16522. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16523. /**
  16524. * Disposes the InstancedMesh.
  16525. * Returns nothing.
  16526. */
  16527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16528. }
  16529. interface Mesh {
  16530. /**
  16531. * Register a custom buffer that will be instanced
  16532. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16533. * @param kind defines the buffer kind
  16534. * @param stride defines the stride in floats
  16535. */
  16536. registerInstancedBuffer(kind: string, stride: number): void;
  16537. /**
  16538. * true to use the edge renderer for all instances of this mesh
  16539. */
  16540. edgesShareWithInstances: boolean;
  16541. /** @hidden */
  16542. _userInstancedBuffersStorage: {
  16543. data: {
  16544. [key: string]: Float32Array;
  16545. };
  16546. sizes: {
  16547. [key: string]: number;
  16548. };
  16549. vertexBuffers: {
  16550. [key: string]: Nullable<VertexBuffer>;
  16551. };
  16552. strides: {
  16553. [key: string]: number;
  16554. };
  16555. };
  16556. }
  16557. interface AbstractMesh {
  16558. /**
  16559. * Object used to store instanced buffers defined by user
  16560. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16561. */
  16562. instancedBuffers: {
  16563. [key: string]: any;
  16564. };
  16565. }
  16566. }
  16567. declare module BABYLON {
  16568. /**
  16569. * Defines the options associated with the creation of a shader material.
  16570. */
  16571. export interface IShaderMaterialOptions {
  16572. /**
  16573. * Does the material work in alpha blend mode
  16574. */
  16575. needAlphaBlending: boolean;
  16576. /**
  16577. * Does the material work in alpha test mode
  16578. */
  16579. needAlphaTesting: boolean;
  16580. /**
  16581. * The list of attribute names used in the shader
  16582. */
  16583. attributes: string[];
  16584. /**
  16585. * The list of unifrom names used in the shader
  16586. */
  16587. uniforms: string[];
  16588. /**
  16589. * The list of UBO names used in the shader
  16590. */
  16591. uniformBuffers: string[];
  16592. /**
  16593. * The list of sampler names used in the shader
  16594. */
  16595. samplers: string[];
  16596. /**
  16597. * The list of defines used in the shader
  16598. */
  16599. defines: string[];
  16600. }
  16601. /**
  16602. * 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.
  16603. *
  16604. * This returned material effects how the mesh will look based on the code in the shaders.
  16605. *
  16606. * @see https://doc.babylonjs.com/how_to/shader_material
  16607. */
  16608. export class ShaderMaterial extends Material {
  16609. private _shaderPath;
  16610. private _options;
  16611. private _textures;
  16612. private _textureArrays;
  16613. private _floats;
  16614. private _ints;
  16615. private _floatsArrays;
  16616. private _colors3;
  16617. private _colors3Arrays;
  16618. private _colors4;
  16619. private _colors4Arrays;
  16620. private _vectors2;
  16621. private _vectors3;
  16622. private _vectors4;
  16623. private _matrices;
  16624. private _matrixArrays;
  16625. private _matrices3x3;
  16626. private _matrices2x2;
  16627. private _vectors2Arrays;
  16628. private _vectors3Arrays;
  16629. private _vectors4Arrays;
  16630. private _cachedWorldViewMatrix;
  16631. private _cachedWorldViewProjectionMatrix;
  16632. private _renderId;
  16633. private _multiview;
  16634. private _cachedDefines;
  16635. /** Define the Url to load snippets */
  16636. static SnippetUrl: string;
  16637. /** Snippet ID if the material was created from the snippet server */
  16638. snippetId: string;
  16639. /**
  16640. * Instantiate a new shader material.
  16641. * 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.
  16642. * This returned material effects how the mesh will look based on the code in the shaders.
  16643. * @see https://doc.babylonjs.com/how_to/shader_material
  16644. * @param name Define the name of the material in the scene
  16645. * @param scene Define the scene the material belongs to
  16646. * @param shaderPath Defines the route to the shader code in one of three ways:
  16647. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16648. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16649. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16650. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16651. * @param options Define the options used to create the shader
  16652. */
  16653. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16654. /**
  16655. * Gets the shader path used to define the shader code
  16656. * It can be modified to trigger a new compilation
  16657. */
  16658. get shaderPath(): any;
  16659. /**
  16660. * Sets the shader path used to define the shader code
  16661. * It can be modified to trigger a new compilation
  16662. */
  16663. set shaderPath(shaderPath: any);
  16664. /**
  16665. * Gets the options used to compile the shader.
  16666. * They can be modified to trigger a new compilation
  16667. */
  16668. get options(): IShaderMaterialOptions;
  16669. /**
  16670. * Gets the current class name of the material e.g. "ShaderMaterial"
  16671. * Mainly use in serialization.
  16672. * @returns the class name
  16673. */
  16674. getClassName(): string;
  16675. /**
  16676. * Specifies if the material will require alpha blending
  16677. * @returns a boolean specifying if alpha blending is needed
  16678. */
  16679. needAlphaBlending(): boolean;
  16680. /**
  16681. * Specifies if this material should be rendered in alpha test mode
  16682. * @returns a boolean specifying if an alpha test is needed.
  16683. */
  16684. needAlphaTesting(): boolean;
  16685. private _checkUniform;
  16686. /**
  16687. * Set a texture in the shader.
  16688. * @param name Define the name of the uniform samplers as defined in the shader
  16689. * @param texture Define the texture to bind to this sampler
  16690. * @return the material itself allowing "fluent" like uniform updates
  16691. */
  16692. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16693. /**
  16694. * Set a texture array in the shader.
  16695. * @param name Define the name of the uniform sampler array as defined in the shader
  16696. * @param textures Define the list of textures to bind to this sampler
  16697. * @return the material itself allowing "fluent" like uniform updates
  16698. */
  16699. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16700. /**
  16701. * Set a float in the shader.
  16702. * @param name Define the name of the uniform as defined in the shader
  16703. * @param value Define the value to give to the uniform
  16704. * @return the material itself allowing "fluent" like uniform updates
  16705. */
  16706. setFloat(name: string, value: number): ShaderMaterial;
  16707. /**
  16708. * Set a int in the shader.
  16709. * @param name Define the name of the uniform as defined in the shader
  16710. * @param value Define the value to give to the uniform
  16711. * @return the material itself allowing "fluent" like uniform updates
  16712. */
  16713. setInt(name: string, value: number): ShaderMaterial;
  16714. /**
  16715. * Set an array of floats in the shader.
  16716. * @param name Define the name of the uniform as defined in the shader
  16717. * @param value Define the value to give to the uniform
  16718. * @return the material itself allowing "fluent" like uniform updates
  16719. */
  16720. setFloats(name: string, value: number[]): ShaderMaterial;
  16721. /**
  16722. * Set a vec3 in the shader from a Color3.
  16723. * @param name Define the name of the uniform as defined in the shader
  16724. * @param value Define the value to give to the uniform
  16725. * @return the material itself allowing "fluent" like uniform updates
  16726. */
  16727. setColor3(name: string, value: Color3): ShaderMaterial;
  16728. /**
  16729. * Set a vec3 array in the shader from a Color3 array.
  16730. * @param name Define the name of the uniform as defined in the shader
  16731. * @param value Define the value to give to the uniform
  16732. * @return the material itself allowing "fluent" like uniform updates
  16733. */
  16734. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16735. /**
  16736. * Set a vec4 in the shader from a Color4.
  16737. * @param name Define the name of the uniform as defined in the shader
  16738. * @param value Define the value to give to the uniform
  16739. * @return the material itself allowing "fluent" like uniform updates
  16740. */
  16741. setColor4(name: string, value: Color4): ShaderMaterial;
  16742. /**
  16743. * Set a vec4 array in the shader from a Color4 array.
  16744. * @param name Define the name of the uniform as defined in the shader
  16745. * @param value Define the value to give to the uniform
  16746. * @return the material itself allowing "fluent" like uniform updates
  16747. */
  16748. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16749. /**
  16750. * Set a vec2 in the shader from a Vector2.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the material itself allowing "fluent" like uniform updates
  16754. */
  16755. setVector2(name: string, value: Vector2): ShaderMaterial;
  16756. /**
  16757. * Set a vec3 in the shader from a Vector3.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the material itself allowing "fluent" like uniform updates
  16761. */
  16762. setVector3(name: string, value: Vector3): ShaderMaterial;
  16763. /**
  16764. * Set a vec4 in the shader from a Vector4.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the material itself allowing "fluent" like uniform updates
  16768. */
  16769. setVector4(name: string, value: Vector4): ShaderMaterial;
  16770. /**
  16771. * Set a mat4 in the shader from a Matrix.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the material itself allowing "fluent" like uniform updates
  16775. */
  16776. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16777. /**
  16778. * Set a float32Array in the shader from a matrix array.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the material itself allowing "fluent" like uniform updates
  16782. */
  16783. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16784. /**
  16785. * Set a mat3 in the shader from a Float32Array.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the material itself allowing "fluent" like uniform updates
  16789. */
  16790. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16791. /**
  16792. * Set a mat2 in the shader from a Float32Array.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the material itself allowing "fluent" like uniform updates
  16796. */
  16797. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16798. /**
  16799. * Set a vec2 array in the shader from a number array.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the material itself allowing "fluent" like uniform updates
  16803. */
  16804. setArray2(name: string, value: number[]): ShaderMaterial;
  16805. /**
  16806. * Set a vec3 array in the shader from a number array.
  16807. * @param name Define the name of the uniform as defined in the shader
  16808. * @param value Define the value to give to the uniform
  16809. * @return the material itself allowing "fluent" like uniform updates
  16810. */
  16811. setArray3(name: string, value: number[]): ShaderMaterial;
  16812. /**
  16813. * Set a vec4 array in the shader from a number array.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setArray4(name: string, value: number[]): ShaderMaterial;
  16819. private _checkCache;
  16820. /**
  16821. * Specifies that the submesh is ready to be used
  16822. * @param mesh defines the mesh to check
  16823. * @param subMesh defines which submesh to check
  16824. * @param useInstances specifies that instances should be used
  16825. * @returns a boolean indicating that the submesh is ready or not
  16826. */
  16827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16828. /**
  16829. * Checks if the material is ready to render the requested mesh
  16830. * @param mesh Define the mesh to render
  16831. * @param useInstances Define whether or not the material is used with instances
  16832. * @returns true if ready, otherwise false
  16833. */
  16834. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16835. /**
  16836. * Binds the world matrix to the material
  16837. * @param world defines the world transformation matrix
  16838. * @param effectOverride - If provided, use this effect instead of internal effect
  16839. */
  16840. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16841. /**
  16842. * Binds the submesh to this material by preparing the effect and shader to draw
  16843. * @param world defines the world transformation matrix
  16844. * @param mesh defines the mesh containing the submesh
  16845. * @param subMesh defines the submesh to bind the material to
  16846. */
  16847. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16848. /**
  16849. * Binds the material to the mesh
  16850. * @param world defines the world transformation matrix
  16851. * @param mesh defines the mesh to bind the material to
  16852. * @param effectOverride - If provided, use this effect instead of internal effect
  16853. */
  16854. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16855. protected _afterBind(mesh?: Mesh): void;
  16856. /**
  16857. * Gets the active textures from the material
  16858. * @returns an array of textures
  16859. */
  16860. getActiveTextures(): BaseTexture[];
  16861. /**
  16862. * Specifies if the material uses a texture
  16863. * @param texture defines the texture to check against the material
  16864. * @returns a boolean specifying if the material uses the texture
  16865. */
  16866. hasTexture(texture: BaseTexture): boolean;
  16867. /**
  16868. * Makes a duplicate of the material, and gives it a new name
  16869. * @param name defines the new name for the duplicated material
  16870. * @returns the cloned material
  16871. */
  16872. clone(name: string): ShaderMaterial;
  16873. /**
  16874. * Disposes the material
  16875. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16876. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16877. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16878. */
  16879. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16880. /**
  16881. * Serializes this material in a JSON representation
  16882. * @returns the serialized material object
  16883. */
  16884. serialize(): any;
  16885. /**
  16886. * Creates a shader material from parsed shader material data
  16887. * @param source defines the JSON represnetation of the material
  16888. * @param scene defines the hosting scene
  16889. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16890. * @returns a new material
  16891. */
  16892. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16893. /**
  16894. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16895. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16896. * @param url defines the url to load from
  16897. * @param scene defines the hosting scene
  16898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16899. * @returns a promise that will resolve to the new ShaderMaterial
  16900. */
  16901. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16902. /**
  16903. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16904. * @param snippetId defines the snippet to load
  16905. * @param scene defines the hosting scene
  16906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16907. * @returns a promise that will resolve to the new ShaderMaterial
  16908. */
  16909. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16910. }
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var colorPixelShader: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /** @hidden */
  16921. export var colorVertexShader: {
  16922. name: string;
  16923. shader: string;
  16924. };
  16925. }
  16926. declare module BABYLON {
  16927. /**
  16928. * Line mesh
  16929. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16930. */
  16931. export class LinesMesh extends Mesh {
  16932. /**
  16933. * If vertex color should be applied to the mesh
  16934. */
  16935. readonly useVertexColor?: boolean | undefined;
  16936. /**
  16937. * If vertex alpha should be applied to the mesh
  16938. */
  16939. readonly useVertexAlpha?: boolean | undefined;
  16940. /**
  16941. * Color of the line (Default: White)
  16942. */
  16943. color: Color3;
  16944. /**
  16945. * Alpha of the line (Default: 1)
  16946. */
  16947. alpha: number;
  16948. /**
  16949. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16950. * This margin is expressed in world space coordinates, so its value may vary.
  16951. * Default value is 0.1
  16952. */
  16953. intersectionThreshold: number;
  16954. private _colorShader;
  16955. private color4;
  16956. /**
  16957. * Creates a new LinesMesh
  16958. * @param name defines the name
  16959. * @param scene defines the hosting scene
  16960. * @param parent defines the parent mesh if any
  16961. * @param source defines the optional source LinesMesh used to clone data from
  16962. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16963. * When false, achieved by calling a clone(), also passing False.
  16964. * This will make creation of children, recursive.
  16965. * @param useVertexColor defines if this LinesMesh supports vertex color
  16966. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16967. */
  16968. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16969. /**
  16970. * If vertex color should be applied to the mesh
  16971. */
  16972. useVertexColor?: boolean | undefined,
  16973. /**
  16974. * If vertex alpha should be applied to the mesh
  16975. */
  16976. useVertexAlpha?: boolean | undefined);
  16977. private _addClipPlaneDefine;
  16978. private _removeClipPlaneDefine;
  16979. isReady(): boolean;
  16980. /**
  16981. * Returns the string "LineMesh"
  16982. */
  16983. getClassName(): string;
  16984. /**
  16985. * @hidden
  16986. */
  16987. get material(): Material;
  16988. /**
  16989. * @hidden
  16990. */
  16991. set material(value: Material);
  16992. /**
  16993. * @hidden
  16994. */
  16995. get checkCollisions(): boolean;
  16996. /** @hidden */
  16997. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16998. /** @hidden */
  16999. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17000. /**
  17001. * Disposes of the line mesh
  17002. * @param doNotRecurse If children should be disposed
  17003. */
  17004. dispose(doNotRecurse?: boolean): void;
  17005. /**
  17006. * Returns a new LineMesh object cloned from the current one.
  17007. */
  17008. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17009. /**
  17010. * Creates a new InstancedLinesMesh object from the mesh model.
  17011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17012. * @param name defines the name of the new instance
  17013. * @returns a new InstancedLinesMesh
  17014. */
  17015. createInstance(name: string): InstancedLinesMesh;
  17016. }
  17017. /**
  17018. * Creates an instance based on a source LinesMesh
  17019. */
  17020. export class InstancedLinesMesh extends InstancedMesh {
  17021. /**
  17022. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17023. * This margin is expressed in world space coordinates, so its value may vary.
  17024. * Initilized with the intersectionThreshold value of the source LinesMesh
  17025. */
  17026. intersectionThreshold: number;
  17027. constructor(name: string, source: LinesMesh);
  17028. /**
  17029. * Returns the string "InstancedLinesMesh".
  17030. */
  17031. getClassName(): string;
  17032. }
  17033. }
  17034. declare module BABYLON {
  17035. /** @hidden */
  17036. export var linePixelShader: {
  17037. name: string;
  17038. shader: string;
  17039. };
  17040. }
  17041. declare module BABYLON {
  17042. /** @hidden */
  17043. export var lineVertexShader: {
  17044. name: string;
  17045. shader: string;
  17046. };
  17047. }
  17048. declare module BABYLON {
  17049. interface Scene {
  17050. /** @hidden */
  17051. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17052. }
  17053. interface AbstractMesh {
  17054. /**
  17055. * Gets the edgesRenderer associated with the mesh
  17056. */
  17057. edgesRenderer: Nullable<EdgesRenderer>;
  17058. }
  17059. interface LinesMesh {
  17060. /**
  17061. * Enables the edge rendering mode on the mesh.
  17062. * This mode makes the mesh edges visible
  17063. * @param epsilon defines the maximal distance between two angles to detect a face
  17064. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17065. * @returns the currentAbstractMesh
  17066. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17067. */
  17068. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17069. }
  17070. interface InstancedLinesMesh {
  17071. /**
  17072. * Enables the edge rendering mode on the mesh.
  17073. * This mode makes the mesh edges visible
  17074. * @param epsilon defines the maximal distance between two angles to detect a face
  17075. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17076. * @returns the current InstancedLinesMesh
  17077. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17078. */
  17079. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17080. }
  17081. /**
  17082. * Defines the minimum contract an Edges renderer should follow.
  17083. */
  17084. export interface IEdgesRenderer extends IDisposable {
  17085. /**
  17086. * Gets or sets a boolean indicating if the edgesRenderer is active
  17087. */
  17088. isEnabled: boolean;
  17089. /**
  17090. * Renders the edges of the attached mesh,
  17091. */
  17092. render(): void;
  17093. /**
  17094. * Checks wether or not the edges renderer is ready to render.
  17095. * @return true if ready, otherwise false.
  17096. */
  17097. isReady(): boolean;
  17098. /**
  17099. * List of instances to render in case the source mesh has instances
  17100. */
  17101. customInstances: SmartArray<Matrix>;
  17102. }
  17103. /**
  17104. * Defines the additional options of the edges renderer
  17105. */
  17106. export interface IEdgesRendererOptions {
  17107. /**
  17108. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17109. * If not defined, the default value is true
  17110. */
  17111. useAlternateEdgeFinder?: boolean;
  17112. /**
  17113. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17114. * If not defined, the default value is true.
  17115. * 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)
  17116. * This option is used only if useAlternateEdgeFinder = true
  17117. */
  17118. useFastVertexMerger?: boolean;
  17119. /**
  17120. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17121. * The default value is 1e-6
  17122. * This option is used only if useAlternateEdgeFinder = true
  17123. */
  17124. epsilonVertexMerge?: number;
  17125. /**
  17126. * 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
  17127. * 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.
  17128. * This option is used only if useAlternateEdgeFinder = true
  17129. */
  17130. applyTessellation?: boolean;
  17131. /**
  17132. * 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
  17133. * The default value is 1e-6
  17134. * This option is used only if useAlternateEdgeFinder = true
  17135. */
  17136. epsilonVertexAligned?: number;
  17137. }
  17138. /**
  17139. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17140. */
  17141. export class EdgesRenderer implements IEdgesRenderer {
  17142. /**
  17143. * Define the size of the edges with an orthographic camera
  17144. */
  17145. edgesWidthScalerForOrthographic: number;
  17146. /**
  17147. * Define the size of the edges with a perspective camera
  17148. */
  17149. edgesWidthScalerForPerspective: number;
  17150. protected _source: AbstractMesh;
  17151. protected _linesPositions: number[];
  17152. protected _linesNormals: number[];
  17153. protected _linesIndices: number[];
  17154. protected _epsilon: number;
  17155. protected _indicesCount: number;
  17156. protected _lineShader: ShaderMaterial;
  17157. protected _ib: DataBuffer;
  17158. protected _buffers: {
  17159. [key: string]: Nullable<VertexBuffer>;
  17160. };
  17161. protected _buffersForInstances: {
  17162. [key: string]: Nullable<VertexBuffer>;
  17163. };
  17164. protected _checkVerticesInsteadOfIndices: boolean;
  17165. protected _options: Nullable<IEdgesRendererOptions>;
  17166. private _meshRebuildObserver;
  17167. private _meshDisposeObserver;
  17168. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17169. isEnabled: boolean;
  17170. /**
  17171. * List of instances to render in case the source mesh has instances
  17172. */
  17173. customInstances: SmartArray<Matrix>;
  17174. private static GetShader;
  17175. /**
  17176. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17177. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17178. * @param source Mesh used to create edges
  17179. * @param epsilon sum of angles in adjacency to check for edge
  17180. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17181. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17182. * @param options The options to apply when generating the edges
  17183. */
  17184. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17185. protected _prepareRessources(): void;
  17186. /** @hidden */
  17187. _rebuild(): void;
  17188. /**
  17189. * Releases the required resources for the edges renderer
  17190. */
  17191. dispose(): void;
  17192. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17193. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17194. /**
  17195. * Checks if the pair of p0 and p1 is en edge
  17196. * @param faceIndex
  17197. * @param edge
  17198. * @param faceNormals
  17199. * @param p0
  17200. * @param p1
  17201. * @private
  17202. */
  17203. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17204. /**
  17205. * push line into the position, normal and index buffer
  17206. * @protected
  17207. */
  17208. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17209. /**
  17210. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17211. */
  17212. private _tessellateTriangle;
  17213. private _generateEdgesLinesAlternate;
  17214. /**
  17215. * Generates lines edges from adjacencjes
  17216. * @private
  17217. */
  17218. _generateEdgesLines(): void;
  17219. /**
  17220. * Checks wether or not the edges renderer is ready to render.
  17221. * @return true if ready, otherwise false.
  17222. */
  17223. isReady(): boolean;
  17224. /**
  17225. * Renders the edges of the attached mesh,
  17226. */
  17227. render(): void;
  17228. }
  17229. /**
  17230. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17231. */
  17232. export class LineEdgesRenderer extends EdgesRenderer {
  17233. /**
  17234. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17235. * @param source LineMesh used to generate edges
  17236. * @param epsilon not important (specified angle for edge detection)
  17237. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17238. */
  17239. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17240. /**
  17241. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17242. */
  17243. _generateEdgesLines(): void;
  17244. }
  17245. }
  17246. declare module BABYLON {
  17247. /**
  17248. * This represents the object necessary to create a rendering group.
  17249. * This is exclusively used and created by the rendering manager.
  17250. * To modify the behavior, you use the available helpers in your scene or meshes.
  17251. * @hidden
  17252. */
  17253. export class RenderingGroup {
  17254. index: number;
  17255. private static _zeroVector;
  17256. private _scene;
  17257. private _opaqueSubMeshes;
  17258. private _transparentSubMeshes;
  17259. private _alphaTestSubMeshes;
  17260. private _depthOnlySubMeshes;
  17261. private _particleSystems;
  17262. private _spriteManagers;
  17263. private _opaqueSortCompareFn;
  17264. private _alphaTestSortCompareFn;
  17265. private _transparentSortCompareFn;
  17266. private _renderOpaque;
  17267. private _renderAlphaTest;
  17268. private _renderTransparent;
  17269. /** @hidden */
  17270. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17271. onBeforeTransparentRendering: () => void;
  17272. /**
  17273. * Set the opaque sort comparison function.
  17274. * If null the sub meshes will be render in the order they were created
  17275. */
  17276. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17277. /**
  17278. * Set the alpha test sort comparison function.
  17279. * If null the sub meshes will be render in the order they were created
  17280. */
  17281. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17282. /**
  17283. * Set the transparent sort comparison function.
  17284. * If null the sub meshes will be render in the order they were created
  17285. */
  17286. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17287. /**
  17288. * Creates a new rendering group.
  17289. * @param index The rendering group index
  17290. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17291. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17292. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17293. */
  17294. 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>);
  17295. /**
  17296. * Render all the sub meshes contained in the group.
  17297. * @param customRenderFunction Used to override the default render behaviour of the group.
  17298. * @returns true if rendered some submeshes.
  17299. */
  17300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17301. /**
  17302. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17303. * @param subMeshes The submeshes to render
  17304. */
  17305. private renderOpaqueSorted;
  17306. /**
  17307. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17308. * @param subMeshes The submeshes to render
  17309. */
  17310. private renderAlphaTestSorted;
  17311. /**
  17312. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17313. * @param subMeshes The submeshes to render
  17314. */
  17315. private renderTransparentSorted;
  17316. /**
  17317. * Renders the submeshes in a specified order.
  17318. * @param subMeshes The submeshes to sort before render
  17319. * @param sortCompareFn The comparison function use to sort
  17320. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17321. * @param transparent Specifies to activate blending if true
  17322. */
  17323. private static renderSorted;
  17324. /**
  17325. * Renders the submeshes in the order they were dispatched (no sort applied).
  17326. * @param subMeshes The submeshes to render
  17327. */
  17328. private static renderUnsorted;
  17329. /**
  17330. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17331. * are rendered back to front if in the same alpha index.
  17332. *
  17333. * @param a The first submesh
  17334. * @param b The second submesh
  17335. * @returns The result of the comparison
  17336. */
  17337. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17338. /**
  17339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17340. * are rendered back to front.
  17341. *
  17342. * @param a The first submesh
  17343. * @param b The second submesh
  17344. * @returns The result of the comparison
  17345. */
  17346. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17347. /**
  17348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17349. * are rendered front to back (prevent overdraw).
  17350. *
  17351. * @param a The first submesh
  17352. * @param b The second submesh
  17353. * @returns The result of the comparison
  17354. */
  17355. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17356. /**
  17357. * Resets the different lists of submeshes to prepare a new frame.
  17358. */
  17359. prepare(): void;
  17360. dispose(): void;
  17361. /**
  17362. * Inserts the submesh in its correct queue depending on its material.
  17363. * @param subMesh The submesh to dispatch
  17364. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17365. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17366. */
  17367. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17368. dispatchSprites(spriteManager: ISpriteManager): void;
  17369. dispatchParticles(particleSystem: IParticleSystem): void;
  17370. private _renderParticles;
  17371. private _renderSprites;
  17372. }
  17373. }
  17374. declare module BABYLON {
  17375. /**
  17376. * Interface describing the different options available in the rendering manager
  17377. * regarding Auto Clear between groups.
  17378. */
  17379. export interface IRenderingManagerAutoClearSetup {
  17380. /**
  17381. * Defines whether or not autoclear is enable.
  17382. */
  17383. autoClear: boolean;
  17384. /**
  17385. * Defines whether or not to autoclear the depth buffer.
  17386. */
  17387. depth: boolean;
  17388. /**
  17389. * Defines whether or not to autoclear the stencil buffer.
  17390. */
  17391. stencil: boolean;
  17392. }
  17393. /**
  17394. * This class is used by the onRenderingGroupObservable
  17395. */
  17396. export class RenderingGroupInfo {
  17397. /**
  17398. * The Scene that being rendered
  17399. */
  17400. scene: Scene;
  17401. /**
  17402. * The camera currently used for the rendering pass
  17403. */
  17404. camera: Nullable<Camera>;
  17405. /**
  17406. * The ID of the renderingGroup being processed
  17407. */
  17408. renderingGroupId: number;
  17409. }
  17410. /**
  17411. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17412. * It is enable to manage the different groups as well as the different necessary sort functions.
  17413. * This should not be used directly aside of the few static configurations
  17414. */
  17415. export class RenderingManager {
  17416. /**
  17417. * The max id used for rendering groups (not included)
  17418. */
  17419. static MAX_RENDERINGGROUPS: number;
  17420. /**
  17421. * The min id used for rendering groups (included)
  17422. */
  17423. static MIN_RENDERINGGROUPS: number;
  17424. /**
  17425. * Used to globally prevent autoclearing scenes.
  17426. */
  17427. static AUTOCLEAR: boolean;
  17428. /**
  17429. * @hidden
  17430. */
  17431. _useSceneAutoClearSetup: boolean;
  17432. private _scene;
  17433. private _renderingGroups;
  17434. private _depthStencilBufferAlreadyCleaned;
  17435. private _autoClearDepthStencil;
  17436. private _customOpaqueSortCompareFn;
  17437. private _customAlphaTestSortCompareFn;
  17438. private _customTransparentSortCompareFn;
  17439. private _renderingGroupInfo;
  17440. /**
  17441. * Instantiates a new rendering group for a particular scene
  17442. * @param scene Defines the scene the groups belongs to
  17443. */
  17444. constructor(scene: Scene);
  17445. private _clearDepthStencilBuffer;
  17446. /**
  17447. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17448. * @hidden
  17449. */
  17450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17451. /**
  17452. * Resets the different information of the group to prepare a new frame
  17453. * @hidden
  17454. */
  17455. reset(): void;
  17456. /**
  17457. * Dispose and release the group and its associated resources.
  17458. * @hidden
  17459. */
  17460. dispose(): void;
  17461. /**
  17462. * Clear the info related to rendering groups preventing retention points during dispose.
  17463. */
  17464. freeRenderingGroups(): void;
  17465. private _prepareRenderingGroup;
  17466. /**
  17467. * Add a sprite manager to the rendering manager in order to render it this frame.
  17468. * @param spriteManager Define the sprite manager to render
  17469. */
  17470. dispatchSprites(spriteManager: ISpriteManager): void;
  17471. /**
  17472. * Add a particle system to the rendering manager in order to render it this frame.
  17473. * @param particleSystem Define the particle system to render
  17474. */
  17475. dispatchParticles(particleSystem: IParticleSystem): void;
  17476. /**
  17477. * Add a submesh to the manager in order to render it this frame
  17478. * @param subMesh The submesh to dispatch
  17479. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17480. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17481. */
  17482. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17483. /**
  17484. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17485. * This allowed control for front to back rendering or reversly depending of the special needs.
  17486. *
  17487. * @param renderingGroupId The rendering group id corresponding to its index
  17488. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17489. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17490. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17491. */
  17492. 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;
  17493. /**
  17494. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17495. *
  17496. * @param renderingGroupId The rendering group id corresponding to its index
  17497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17498. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17499. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17500. */
  17501. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17502. /**
  17503. * Gets the current auto clear configuration for one rendering group of the rendering
  17504. * manager.
  17505. * @param index the rendering group index to get the information for
  17506. * @returns The auto clear setup for the requested rendering group
  17507. */
  17508. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17509. }
  17510. }
  17511. declare module BABYLON {
  17512. /**
  17513. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17514. */
  17515. export interface ICustomShaderOptions {
  17516. /**
  17517. * Gets or sets the custom shader name to use
  17518. */
  17519. shaderName: string;
  17520. /**
  17521. * The list of attribute names used in the shader
  17522. */
  17523. attributes?: string[];
  17524. /**
  17525. * The list of unifrom names used in the shader
  17526. */
  17527. uniforms?: string[];
  17528. /**
  17529. * The list of sampler names used in the shader
  17530. */
  17531. samplers?: string[];
  17532. /**
  17533. * The list of defines used in the shader
  17534. */
  17535. defines?: string[];
  17536. }
  17537. /**
  17538. * Interface to implement to create a shadow generator compatible with BJS.
  17539. */
  17540. export interface IShadowGenerator {
  17541. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17542. id: string;
  17543. /**
  17544. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17545. * @returns The render target texture if present otherwise, null
  17546. */
  17547. getShadowMap(): Nullable<RenderTargetTexture>;
  17548. /**
  17549. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17550. * @param subMesh The submesh we want to render in the shadow map
  17551. * @param useInstances Defines wether will draw in the map using instances
  17552. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17553. * @returns true if ready otherwise, false
  17554. */
  17555. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17556. /**
  17557. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17558. * @param defines Defines of the material we want to update
  17559. * @param lightIndex Index of the light in the enabled light list of the material
  17560. */
  17561. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17562. /**
  17563. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17564. * defined in the generator but impacting the effect).
  17565. * It implies the unifroms available on the materials are the standard BJS ones.
  17566. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17567. * @param effect The effect we are binfing the information for
  17568. */
  17569. bindShadowLight(lightIndex: string, effect: Effect): void;
  17570. /**
  17571. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17572. * (eq to shadow prjection matrix * light transform matrix)
  17573. * @returns The transform matrix used to create the shadow map
  17574. */
  17575. getTransformMatrix(): Matrix;
  17576. /**
  17577. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17578. * Cube and 2D textures for instance.
  17579. */
  17580. recreateShadowMap(): void;
  17581. /**
  17582. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17583. * @param onCompiled Callback triggered at the and of the effects compilation
  17584. * @param options Sets of optional options forcing the compilation with different modes
  17585. */
  17586. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17587. useInstances: boolean;
  17588. }>): void;
  17589. /**
  17590. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17591. * @param options Sets of optional options forcing the compilation with different modes
  17592. * @returns A promise that resolves when the compilation completes
  17593. */
  17594. forceCompilationAsync(options?: Partial<{
  17595. useInstances: boolean;
  17596. }>): Promise<void>;
  17597. /**
  17598. * Serializes the shadow generator setup to a json object.
  17599. * @returns The serialized JSON object
  17600. */
  17601. serialize(): any;
  17602. /**
  17603. * Disposes the Shadow map and related Textures and effects.
  17604. */
  17605. dispose(): void;
  17606. }
  17607. /**
  17608. * Default implementation IShadowGenerator.
  17609. * This is the main object responsible of generating shadows in the framework.
  17610. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17611. */
  17612. export class ShadowGenerator implements IShadowGenerator {
  17613. /**
  17614. * Name of the shadow generator class
  17615. */
  17616. static CLASSNAME: string;
  17617. /**
  17618. * Shadow generator mode None: no filtering applied.
  17619. */
  17620. static readonly FILTER_NONE: number;
  17621. /**
  17622. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17624. */
  17625. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17626. /**
  17627. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17628. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17629. */
  17630. static readonly FILTER_POISSONSAMPLING: number;
  17631. /**
  17632. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17633. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17634. */
  17635. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17636. /**
  17637. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17638. * edge artifacts on steep falloff.
  17639. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17640. */
  17641. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17642. /**
  17643. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17644. * edge artifacts on steep falloff.
  17645. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17646. */
  17647. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17648. /**
  17649. * Shadow generator mode PCF: Percentage Closer Filtering
  17650. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17651. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17652. */
  17653. static readonly FILTER_PCF: number;
  17654. /**
  17655. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17656. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17657. * Contact Hardening
  17658. */
  17659. static readonly FILTER_PCSS: number;
  17660. /**
  17661. * Reserved for PCF and PCSS
  17662. * Highest Quality.
  17663. *
  17664. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17665. *
  17666. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17667. */
  17668. static readonly QUALITY_HIGH: number;
  17669. /**
  17670. * Reserved for PCF and PCSS
  17671. * Good tradeoff for quality/perf cross devices
  17672. *
  17673. * Execute PCF on a 3*3 kernel.
  17674. *
  17675. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17676. */
  17677. static readonly QUALITY_MEDIUM: number;
  17678. /**
  17679. * Reserved for PCF and PCSS
  17680. * The lowest quality but the fastest.
  17681. *
  17682. * Execute PCF on a 1*1 kernel.
  17683. *
  17684. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17685. */
  17686. static readonly QUALITY_LOW: number;
  17687. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17688. id: string;
  17689. /** Gets or sets the custom shader name to use */
  17690. customShaderOptions: ICustomShaderOptions;
  17691. /**
  17692. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17693. */
  17694. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17695. /**
  17696. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17697. */
  17698. onAfterShadowMapRenderObservable: Observable<Effect>;
  17699. /**
  17700. * Observable triggered before a mesh is rendered in the shadow map.
  17701. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17702. */
  17703. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17704. /**
  17705. * Observable triggered after a mesh is rendered in the shadow map.
  17706. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17707. */
  17708. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17709. protected _bias: number;
  17710. /**
  17711. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17712. */
  17713. get bias(): number;
  17714. /**
  17715. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17716. */
  17717. set bias(bias: number);
  17718. protected _normalBias: number;
  17719. /**
  17720. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17721. */
  17722. get normalBias(): number;
  17723. /**
  17724. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17725. */
  17726. set normalBias(normalBias: number);
  17727. protected _blurBoxOffset: number;
  17728. /**
  17729. * Gets the blur box offset: offset applied during the blur pass.
  17730. * Only useful if useKernelBlur = false
  17731. */
  17732. get blurBoxOffset(): number;
  17733. /**
  17734. * Sets the blur box offset: offset applied during the blur pass.
  17735. * Only useful if useKernelBlur = false
  17736. */
  17737. set blurBoxOffset(value: number);
  17738. protected _blurScale: number;
  17739. /**
  17740. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17741. * 2 means half of the size.
  17742. */
  17743. get blurScale(): number;
  17744. /**
  17745. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17746. * 2 means half of the size.
  17747. */
  17748. set blurScale(value: number);
  17749. protected _blurKernel: number;
  17750. /**
  17751. * Gets the blur kernel: kernel size of the blur pass.
  17752. * Only useful if useKernelBlur = true
  17753. */
  17754. get blurKernel(): number;
  17755. /**
  17756. * Sets the blur kernel: kernel size of the blur pass.
  17757. * Only useful if useKernelBlur = true
  17758. */
  17759. set blurKernel(value: number);
  17760. protected _useKernelBlur: boolean;
  17761. /**
  17762. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17763. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17764. */
  17765. get useKernelBlur(): boolean;
  17766. /**
  17767. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17768. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17769. */
  17770. set useKernelBlur(value: boolean);
  17771. protected _depthScale: number;
  17772. /**
  17773. * Gets the depth scale used in ESM mode.
  17774. */
  17775. get depthScale(): number;
  17776. /**
  17777. * Sets the depth scale used in ESM mode.
  17778. * This can override the scale stored on the light.
  17779. */
  17780. set depthScale(value: number);
  17781. protected _validateFilter(filter: number): number;
  17782. protected _filter: number;
  17783. /**
  17784. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17785. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17786. */
  17787. get filter(): number;
  17788. /**
  17789. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17790. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17791. */
  17792. set filter(value: number);
  17793. /**
  17794. * Gets if the current filter is set to Poisson Sampling.
  17795. */
  17796. get usePoissonSampling(): boolean;
  17797. /**
  17798. * Sets the current filter to Poisson Sampling.
  17799. */
  17800. set usePoissonSampling(value: boolean);
  17801. /**
  17802. * Gets if the current filter is set to ESM.
  17803. */
  17804. get useExponentialShadowMap(): boolean;
  17805. /**
  17806. * Sets the current filter is to ESM.
  17807. */
  17808. set useExponentialShadowMap(value: boolean);
  17809. /**
  17810. * Gets if the current filter is set to filtered ESM.
  17811. */
  17812. get useBlurExponentialShadowMap(): boolean;
  17813. /**
  17814. * Gets if the current filter is set to filtered ESM.
  17815. */
  17816. set useBlurExponentialShadowMap(value: boolean);
  17817. /**
  17818. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17819. * exponential to prevent steep falloff artifacts).
  17820. */
  17821. get useCloseExponentialShadowMap(): boolean;
  17822. /**
  17823. * Sets the current filter to "close ESM" (using the inverse of the
  17824. * exponential to prevent steep falloff artifacts).
  17825. */
  17826. set useCloseExponentialShadowMap(value: boolean);
  17827. /**
  17828. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17829. * exponential to prevent steep falloff artifacts).
  17830. */
  17831. get useBlurCloseExponentialShadowMap(): boolean;
  17832. /**
  17833. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17834. * exponential to prevent steep falloff artifacts).
  17835. */
  17836. set useBlurCloseExponentialShadowMap(value: boolean);
  17837. /**
  17838. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17839. */
  17840. get usePercentageCloserFiltering(): boolean;
  17841. /**
  17842. * Sets the current filter to "PCF" (percentage closer filtering).
  17843. */
  17844. set usePercentageCloserFiltering(value: boolean);
  17845. protected _filteringQuality: number;
  17846. /**
  17847. * Gets the PCF or PCSS Quality.
  17848. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17849. */
  17850. get filteringQuality(): number;
  17851. /**
  17852. * Sets the PCF or PCSS Quality.
  17853. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17854. */
  17855. set filteringQuality(filteringQuality: number);
  17856. /**
  17857. * Gets if the current filter is set to "PCSS" (contact hardening).
  17858. */
  17859. get useContactHardeningShadow(): boolean;
  17860. /**
  17861. * Sets the current filter to "PCSS" (contact hardening).
  17862. */
  17863. set useContactHardeningShadow(value: boolean);
  17864. protected _contactHardeningLightSizeUVRatio: number;
  17865. /**
  17866. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17867. * Using a ratio helps keeping shape stability independently of the map size.
  17868. *
  17869. * It does not account for the light projection as it was having too much
  17870. * instability during the light setup or during light position changes.
  17871. *
  17872. * Only valid if useContactHardeningShadow is true.
  17873. */
  17874. get contactHardeningLightSizeUVRatio(): number;
  17875. /**
  17876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17877. * Using a ratio helps keeping shape stability independently of the map size.
  17878. *
  17879. * It does not account for the light projection as it was having too much
  17880. * instability during the light setup or during light position changes.
  17881. *
  17882. * Only valid if useContactHardeningShadow is true.
  17883. */
  17884. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17885. protected _darkness: number;
  17886. /** Gets or sets the actual darkness of a shadow */
  17887. get darkness(): number;
  17888. set darkness(value: number);
  17889. /**
  17890. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17891. * 0 means strongest and 1 would means no shadow.
  17892. * @returns the darkness.
  17893. */
  17894. getDarkness(): number;
  17895. /**
  17896. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17897. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17898. * @returns the shadow generator allowing fluent coding.
  17899. */
  17900. setDarkness(darkness: number): ShadowGenerator;
  17901. protected _transparencyShadow: boolean;
  17902. /** Gets or sets the ability to have transparent shadow */
  17903. get transparencyShadow(): boolean;
  17904. set transparencyShadow(value: boolean);
  17905. /**
  17906. * Sets the ability to have transparent shadow (boolean).
  17907. * @param transparent True if transparent else False
  17908. * @returns the shadow generator allowing fluent coding
  17909. */
  17910. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17911. /**
  17912. * Enables or disables shadows with varying strength based on the transparency
  17913. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17914. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17915. * mesh.visibility * alphaTexture.a
  17916. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17917. */
  17918. enableSoftTransparentShadow: boolean;
  17919. protected _shadowMap: Nullable<RenderTargetTexture>;
  17920. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17921. /**
  17922. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17923. * @returns The render target texture if present otherwise, null
  17924. */
  17925. getShadowMap(): Nullable<RenderTargetTexture>;
  17926. /**
  17927. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17928. * @returns The render target texture if the shadow map is present otherwise, null
  17929. */
  17930. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17931. /**
  17932. * Gets the class name of that object
  17933. * @returns "ShadowGenerator"
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17938. * @param mesh Mesh to add
  17939. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17940. * @returns the Shadow Generator itself
  17941. */
  17942. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17943. /**
  17944. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17945. * @param mesh Mesh to remove
  17946. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17947. * @returns the Shadow Generator itself
  17948. */
  17949. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17950. /**
  17951. * Controls the extent to which the shadows fade out at the edge of the frustum
  17952. */
  17953. frustumEdgeFalloff: number;
  17954. protected _light: IShadowLight;
  17955. /**
  17956. * Returns the associated light object.
  17957. * @returns the light generating the shadow
  17958. */
  17959. getLight(): IShadowLight;
  17960. /**
  17961. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17962. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17963. * It might on the other hand introduce peter panning.
  17964. */
  17965. forceBackFacesOnly: boolean;
  17966. protected _scene: Scene;
  17967. protected _lightDirection: Vector3;
  17968. protected _effect: Effect;
  17969. protected _viewMatrix: Matrix;
  17970. protected _projectionMatrix: Matrix;
  17971. protected _transformMatrix: Matrix;
  17972. protected _cachedPosition: Vector3;
  17973. protected _cachedDirection: Vector3;
  17974. protected _cachedDefines: string;
  17975. protected _currentRenderID: number;
  17976. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17977. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17978. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17979. protected _blurPostProcesses: PostProcess[];
  17980. protected _mapSize: number;
  17981. protected _currentFaceIndex: number;
  17982. protected _currentFaceIndexCache: number;
  17983. protected _textureType: number;
  17984. protected _defaultTextureMatrix: Matrix;
  17985. protected _storedUniqueId: Nullable<number>;
  17986. /** @hidden */
  17987. static _SceneComponentInitialization: (scene: Scene) => void;
  17988. /**
  17989. * Gets or sets the size of the texture what stores the shadows
  17990. */
  17991. get mapSize(): number;
  17992. set mapSize(size: number);
  17993. /**
  17994. * Creates a ShadowGenerator object.
  17995. * A ShadowGenerator is the required tool to use the shadows.
  17996. * Each light casting shadows needs to use its own ShadowGenerator.
  17997. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17998. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17999. * @param light The light object generating the shadows.
  18000. * @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.
  18001. */
  18002. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18003. protected _initializeGenerator(): void;
  18004. protected _createTargetRenderTexture(): void;
  18005. protected _initializeShadowMap(): void;
  18006. protected _initializeBlurRTTAndPostProcesses(): void;
  18007. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18008. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18009. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18010. protected _applyFilterValues(): void;
  18011. /**
  18012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18013. * @param onCompiled Callback triggered at the and of the effects compilation
  18014. * @param options Sets of optional options forcing the compilation with different modes
  18015. */
  18016. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18017. useInstances: boolean;
  18018. }>): void;
  18019. /**
  18020. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18021. * @param options Sets of optional options forcing the compilation with different modes
  18022. * @returns A promise that resolves when the compilation completes
  18023. */
  18024. forceCompilationAsync(options?: Partial<{
  18025. useInstances: boolean;
  18026. }>): Promise<void>;
  18027. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18028. private _prepareShadowDefines;
  18029. /**
  18030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18031. * @param subMesh The submesh we want to render in the shadow map
  18032. * @param useInstances Defines wether will draw in the map using instances
  18033. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18034. * @returns true if ready otherwise, false
  18035. */
  18036. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18037. /**
  18038. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18039. * @param defines Defines of the material we want to update
  18040. * @param lightIndex Index of the light in the enabled light list of the material
  18041. */
  18042. prepareDefines(defines: any, lightIndex: number): void;
  18043. /**
  18044. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18045. * defined in the generator but impacting the effect).
  18046. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18047. * @param effect The effect we are binfing the information for
  18048. */
  18049. bindShadowLight(lightIndex: string, effect: Effect): void;
  18050. /**
  18051. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18052. * (eq to shadow prjection matrix * light transform matrix)
  18053. * @returns The transform matrix used to create the shadow map
  18054. */
  18055. getTransformMatrix(): Matrix;
  18056. /**
  18057. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18058. * Cube and 2D textures for instance.
  18059. */
  18060. recreateShadowMap(): void;
  18061. protected _disposeBlurPostProcesses(): void;
  18062. protected _disposeRTTandPostProcesses(): void;
  18063. /**
  18064. * Disposes the ShadowGenerator.
  18065. * Returns nothing.
  18066. */
  18067. dispose(): void;
  18068. /**
  18069. * Serializes the shadow generator setup to a json object.
  18070. * @returns The serialized JSON object
  18071. */
  18072. serialize(): any;
  18073. /**
  18074. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18075. * @param parsedShadowGenerator The JSON object to parse
  18076. * @param scene The scene to create the shadow map for
  18077. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18078. * @returns The parsed shadow generator
  18079. */
  18080. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18081. }
  18082. }
  18083. declare module BABYLON {
  18084. /**
  18085. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18086. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18087. * 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.
  18088. */
  18089. export abstract class Light extends Node {
  18090. /**
  18091. * Falloff Default: light is falling off following the material specification:
  18092. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18093. */
  18094. static readonly FALLOFF_DEFAULT: number;
  18095. /**
  18096. * Falloff Physical: light is falling off following the inverse squared distance law.
  18097. */
  18098. static readonly FALLOFF_PHYSICAL: number;
  18099. /**
  18100. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18101. * to enhance interoperability with other engines.
  18102. */
  18103. static readonly FALLOFF_GLTF: number;
  18104. /**
  18105. * Falloff Standard: light is falling off like in the standard material
  18106. * to enhance interoperability with other materials.
  18107. */
  18108. static readonly FALLOFF_STANDARD: number;
  18109. /**
  18110. * If every light affecting the material is in this lightmapMode,
  18111. * material.lightmapTexture adds or multiplies
  18112. * (depends on material.useLightmapAsShadowmap)
  18113. * after every other light calculations.
  18114. */
  18115. static readonly LIGHTMAP_DEFAULT: number;
  18116. /**
  18117. * material.lightmapTexture as only diffuse lighting from this light
  18118. * adds only specular lighting from this light
  18119. * adds dynamic shadows
  18120. */
  18121. static readonly LIGHTMAP_SPECULAR: number;
  18122. /**
  18123. * material.lightmapTexture as only lighting
  18124. * no light calculation from this light
  18125. * only adds dynamic shadows from this light
  18126. */
  18127. static readonly LIGHTMAP_SHADOWSONLY: number;
  18128. /**
  18129. * Each light type uses the default quantity according to its type:
  18130. * point/spot lights use luminous intensity
  18131. * directional lights use illuminance
  18132. */
  18133. static readonly INTENSITYMODE_AUTOMATIC: number;
  18134. /**
  18135. * lumen (lm)
  18136. */
  18137. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18138. /**
  18139. * candela (lm/sr)
  18140. */
  18141. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18142. /**
  18143. * lux (lm/m^2)
  18144. */
  18145. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18146. /**
  18147. * nit (cd/m^2)
  18148. */
  18149. static readonly INTENSITYMODE_LUMINANCE: number;
  18150. /**
  18151. * Light type const id of the point light.
  18152. */
  18153. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18154. /**
  18155. * Light type const id of the directional light.
  18156. */
  18157. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18158. /**
  18159. * Light type const id of the spot light.
  18160. */
  18161. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18162. /**
  18163. * Light type const id of the hemispheric light.
  18164. */
  18165. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18166. /**
  18167. * Diffuse gives the basic color to an object.
  18168. */
  18169. diffuse: Color3;
  18170. /**
  18171. * Specular produces a highlight color on an object.
  18172. * Note: This is note affecting PBR materials.
  18173. */
  18174. specular: Color3;
  18175. /**
  18176. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18177. * falling off base on range or angle.
  18178. * This can be set to any values in Light.FALLOFF_x.
  18179. *
  18180. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18181. * other types of materials.
  18182. */
  18183. falloffType: number;
  18184. /**
  18185. * Strength of the light.
  18186. * Note: By default it is define in the framework own unit.
  18187. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18188. */
  18189. intensity: number;
  18190. private _range;
  18191. protected _inverseSquaredRange: number;
  18192. /**
  18193. * Defines how far from the source the light is impacting in scene units.
  18194. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18195. */
  18196. get range(): number;
  18197. /**
  18198. * Defines how far from the source the light is impacting in scene units.
  18199. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18200. */
  18201. set range(value: number);
  18202. /**
  18203. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18204. * of light.
  18205. */
  18206. private _photometricScale;
  18207. private _intensityMode;
  18208. /**
  18209. * Gets the photometric scale used to interpret the intensity.
  18210. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18211. */
  18212. get intensityMode(): number;
  18213. /**
  18214. * Sets the photometric scale used to interpret the intensity.
  18215. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18216. */
  18217. set intensityMode(value: number);
  18218. private _radius;
  18219. /**
  18220. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18221. */
  18222. get radius(): number;
  18223. /**
  18224. * sets the light radius used by PBR Materials to simulate soft area lights.
  18225. */
  18226. set radius(value: number);
  18227. private _renderPriority;
  18228. /**
  18229. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18230. * exceeding the number allowed of the materials.
  18231. */
  18232. renderPriority: number;
  18233. private _shadowEnabled;
  18234. /**
  18235. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18236. * the current shadow generator.
  18237. */
  18238. get shadowEnabled(): boolean;
  18239. /**
  18240. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18241. * the current shadow generator.
  18242. */
  18243. set shadowEnabled(value: boolean);
  18244. private _includedOnlyMeshes;
  18245. /**
  18246. * Gets the only meshes impacted by this light.
  18247. */
  18248. get includedOnlyMeshes(): AbstractMesh[];
  18249. /**
  18250. * Sets the only meshes impacted by this light.
  18251. */
  18252. set includedOnlyMeshes(value: AbstractMesh[]);
  18253. private _excludedMeshes;
  18254. /**
  18255. * Gets the meshes not impacted by this light.
  18256. */
  18257. get excludedMeshes(): AbstractMesh[];
  18258. /**
  18259. * Sets the meshes not impacted by this light.
  18260. */
  18261. set excludedMeshes(value: AbstractMesh[]);
  18262. private _excludeWithLayerMask;
  18263. /**
  18264. * Gets the layer id use to find what meshes are not impacted by the light.
  18265. * Inactive if 0
  18266. */
  18267. get excludeWithLayerMask(): number;
  18268. /**
  18269. * Sets the layer id use to find what meshes are not impacted by the light.
  18270. * Inactive if 0
  18271. */
  18272. set excludeWithLayerMask(value: number);
  18273. private _includeOnlyWithLayerMask;
  18274. /**
  18275. * Gets the layer id use to find what meshes are impacted by the light.
  18276. * Inactive if 0
  18277. */
  18278. get includeOnlyWithLayerMask(): number;
  18279. /**
  18280. * Sets the layer id use to find what meshes are impacted by the light.
  18281. * Inactive if 0
  18282. */
  18283. set includeOnlyWithLayerMask(value: number);
  18284. private _lightmapMode;
  18285. /**
  18286. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18287. */
  18288. get lightmapMode(): number;
  18289. /**
  18290. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18291. */
  18292. set lightmapMode(value: number);
  18293. /**
  18294. * Shadow generator associted to the light.
  18295. * @hidden Internal use only.
  18296. */
  18297. _shadowGenerator: Nullable<IShadowGenerator>;
  18298. /**
  18299. * @hidden Internal use only.
  18300. */
  18301. _excludedMeshesIds: string[];
  18302. /**
  18303. * @hidden Internal use only.
  18304. */
  18305. _includedOnlyMeshesIds: string[];
  18306. /**
  18307. * The current light unifom buffer.
  18308. * @hidden Internal use only.
  18309. */
  18310. _uniformBuffer: UniformBuffer;
  18311. /** @hidden */
  18312. _renderId: number;
  18313. /**
  18314. * Creates a Light object in the scene.
  18315. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18316. * @param name The firendly name of the light
  18317. * @param scene The scene the light belongs too
  18318. */
  18319. constructor(name: string, scene: Scene);
  18320. protected abstract _buildUniformLayout(): void;
  18321. /**
  18322. * Sets the passed Effect "effect" with the Light information.
  18323. * @param effect The effect to update
  18324. * @param lightIndex The index of the light in the effect to update
  18325. * @returns The light
  18326. */
  18327. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18328. /**
  18329. * Sets the passed Effect "effect" with the Light textures.
  18330. * @param effect The effect to update
  18331. * @param lightIndex The index of the light in the effect to update
  18332. * @returns The light
  18333. */
  18334. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18335. /**
  18336. * Binds the lights information from the scene to the effect for the given mesh.
  18337. * @param lightIndex Light index
  18338. * @param scene The scene where the light belongs to
  18339. * @param effect The effect we are binding the data to
  18340. * @param useSpecular Defines if specular is supported
  18341. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18342. */
  18343. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18344. /**
  18345. * Sets the passed Effect "effect" with the Light information.
  18346. * @param effect The effect to update
  18347. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18348. * @returns The light
  18349. */
  18350. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18351. /**
  18352. * Returns the string "Light".
  18353. * @returns the class name
  18354. */
  18355. getClassName(): string;
  18356. /** @hidden */
  18357. readonly _isLight: boolean;
  18358. /**
  18359. * Converts the light information to a readable string for debug purpose.
  18360. * @param fullDetails Supports for multiple levels of logging within scene loading
  18361. * @returns the human readable light info
  18362. */
  18363. toString(fullDetails?: boolean): string;
  18364. /** @hidden */
  18365. protected _syncParentEnabledState(): void;
  18366. /**
  18367. * Set the enabled state of this node.
  18368. * @param value - the new enabled state
  18369. */
  18370. setEnabled(value: boolean): void;
  18371. /**
  18372. * Returns the Light associated shadow generator if any.
  18373. * @return the associated shadow generator.
  18374. */
  18375. getShadowGenerator(): Nullable<IShadowGenerator>;
  18376. /**
  18377. * Returns a Vector3, the absolute light position in the World.
  18378. * @returns the world space position of the light
  18379. */
  18380. getAbsolutePosition(): Vector3;
  18381. /**
  18382. * Specifies if the light will affect the passed mesh.
  18383. * @param mesh The mesh to test against the light
  18384. * @return true the mesh is affected otherwise, false.
  18385. */
  18386. canAffectMesh(mesh: AbstractMesh): boolean;
  18387. /**
  18388. * Sort function to order lights for rendering.
  18389. * @param a First Light object to compare to second.
  18390. * @param b Second Light object to compare first.
  18391. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18392. */
  18393. static CompareLightsPriority(a: Light, b: Light): number;
  18394. /**
  18395. * Releases resources associated with this node.
  18396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18398. */
  18399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18400. /**
  18401. * Returns the light type ID (integer).
  18402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18403. */
  18404. getTypeID(): number;
  18405. /**
  18406. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18407. * @returns the scaled intensity in intensity mode unit
  18408. */
  18409. getScaledIntensity(): number;
  18410. /**
  18411. * Returns a new Light object, named "name", from the current one.
  18412. * @param name The name of the cloned light
  18413. * @param newParent The parent of this light, if it has one
  18414. * @returns the new created light
  18415. */
  18416. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18417. /**
  18418. * Serializes the current light into a Serialization object.
  18419. * @returns the serialized object.
  18420. */
  18421. serialize(): any;
  18422. /**
  18423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18424. * This new light is named "name" and added to the passed scene.
  18425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18426. * @param name The friendly name of the light
  18427. * @param scene The scene the new light will belong to
  18428. * @returns the constructor function
  18429. */
  18430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18431. /**
  18432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18433. * @param parsedLight The JSON representation of the light
  18434. * @param scene The scene to create the parsed light in
  18435. * @returns the created light after parsing
  18436. */
  18437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18438. private _hookArrayForExcluded;
  18439. private _hookArrayForIncludedOnly;
  18440. private _resyncMeshes;
  18441. /**
  18442. * Forces the meshes to update their light related information in their rendering used effects
  18443. * @hidden Internal Use Only
  18444. */
  18445. _markMeshesAsLightDirty(): void;
  18446. /**
  18447. * Recomputes the cached photometric scale if needed.
  18448. */
  18449. private _computePhotometricScale;
  18450. /**
  18451. * Returns the Photometric Scale according to the light type and intensity mode.
  18452. */
  18453. private _getPhotometricScale;
  18454. /**
  18455. * Reorder the light in the scene according to their defined priority.
  18456. * @hidden Internal Use Only
  18457. */
  18458. _reorderLightsInScene(): void;
  18459. /**
  18460. * Prepares the list of defines specific to the light type.
  18461. * @param defines the list of defines
  18462. * @param lightIndex defines the index of the light for the effect
  18463. */
  18464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18465. }
  18466. }
  18467. declare module BABYLON {
  18468. /**
  18469. * Configuration needed for prepass-capable materials
  18470. */
  18471. export class PrePassConfiguration {
  18472. /**
  18473. * Previous world matrices of meshes carrying this material
  18474. * Used for computing velocity
  18475. */
  18476. previousWorldMatrices: {
  18477. [index: number]: Matrix;
  18478. };
  18479. /**
  18480. * Previous view project matrix
  18481. * Used for computing velocity
  18482. */
  18483. previousViewProjection: Matrix;
  18484. /**
  18485. * Previous bones of meshes carrying this material
  18486. * Used for computing velocity
  18487. */
  18488. previousBones: {
  18489. [index: number]: Float32Array;
  18490. };
  18491. /**
  18492. * Add the required uniforms to the current list.
  18493. * @param uniforms defines the current uniform list.
  18494. */
  18495. static AddUniforms(uniforms: string[]): void;
  18496. /**
  18497. * Add the required samplers to the current list.
  18498. * @param samplers defines the current sampler list.
  18499. */
  18500. static AddSamplers(samplers: string[]): void;
  18501. /**
  18502. * Binds the material data.
  18503. * @param effect defines the effect to update
  18504. * @param scene defines the scene the material belongs to.
  18505. * @param mesh The mesh
  18506. * @param world World matrix of this mesh
  18507. * @param isFrozen Is the material frozen
  18508. */
  18509. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18510. }
  18511. }
  18512. declare module BABYLON {
  18513. /**
  18514. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18515. * This is the base of the follow, arc rotate cameras and Free camera
  18516. * @see https://doc.babylonjs.com/features/cameras
  18517. */
  18518. export class TargetCamera extends Camera {
  18519. private static _RigCamTransformMatrix;
  18520. private static _TargetTransformMatrix;
  18521. private static _TargetFocalPoint;
  18522. private _tmpUpVector;
  18523. private _tmpTargetVector;
  18524. /**
  18525. * Define the current direction the camera is moving to
  18526. */
  18527. cameraDirection: Vector3;
  18528. /**
  18529. * Define the current rotation the camera is rotating to
  18530. */
  18531. cameraRotation: Vector2;
  18532. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18533. ignoreParentScaling: boolean;
  18534. /**
  18535. * When set, the up vector of the camera will be updated by the rotation of the camera
  18536. */
  18537. updateUpVectorFromRotation: boolean;
  18538. private _tmpQuaternion;
  18539. /**
  18540. * Define the current rotation of the camera
  18541. */
  18542. rotation: Vector3;
  18543. /**
  18544. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18545. */
  18546. rotationQuaternion: Quaternion;
  18547. /**
  18548. * Define the current speed of the camera
  18549. */
  18550. speed: number;
  18551. /**
  18552. * Add constraint to the camera to prevent it to move freely in all directions and
  18553. * around all axis.
  18554. */
  18555. noRotationConstraint: boolean;
  18556. /**
  18557. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18558. * panning
  18559. */
  18560. invertRotation: boolean;
  18561. /**
  18562. * Speed multiplier for inverse camera panning
  18563. */
  18564. inverseRotationSpeed: number;
  18565. /**
  18566. * Define the current target of the camera as an object or a position.
  18567. */
  18568. lockedTarget: any;
  18569. /** @hidden */
  18570. _currentTarget: Vector3;
  18571. /** @hidden */
  18572. _initialFocalDistance: number;
  18573. /** @hidden */
  18574. _viewMatrix: Matrix;
  18575. /** @hidden */
  18576. _camMatrix: Matrix;
  18577. /** @hidden */
  18578. _cameraTransformMatrix: Matrix;
  18579. /** @hidden */
  18580. _cameraRotationMatrix: Matrix;
  18581. /** @hidden */
  18582. _referencePoint: Vector3;
  18583. /** @hidden */
  18584. _transformedReferencePoint: Vector3;
  18585. /** @hidden */
  18586. _reset: () => void;
  18587. private _defaultUp;
  18588. /**
  18589. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18590. * This is the base of the follow, arc rotate cameras and Free camera
  18591. * @see https://doc.babylonjs.com/features/cameras
  18592. * @param name Defines the name of the camera in the scene
  18593. * @param position Defines the start position of the camera in the scene
  18594. * @param scene Defines the scene the camera belongs to
  18595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18596. */
  18597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18598. /**
  18599. * Gets the position in front of the camera at a given distance.
  18600. * @param distance The distance from the camera we want the position to be
  18601. * @returns the position
  18602. */
  18603. getFrontPosition(distance: number): Vector3;
  18604. /** @hidden */
  18605. _getLockedTargetPosition(): Nullable<Vector3>;
  18606. private _storedPosition;
  18607. private _storedRotation;
  18608. private _storedRotationQuaternion;
  18609. /**
  18610. * Store current camera state of the camera (fov, position, rotation, etc..)
  18611. * @returns the camera
  18612. */
  18613. storeState(): Camera;
  18614. /**
  18615. * Restored camera state. You must call storeState() first
  18616. * @returns whether it was successful or not
  18617. * @hidden
  18618. */
  18619. _restoreStateValues(): boolean;
  18620. /** @hidden */
  18621. _initCache(): void;
  18622. /** @hidden */
  18623. _updateCache(ignoreParentClass?: boolean): void;
  18624. /** @hidden */
  18625. _isSynchronizedViewMatrix(): boolean;
  18626. /** @hidden */
  18627. _computeLocalCameraSpeed(): number;
  18628. /**
  18629. * Defines the target the camera should look at.
  18630. * @param target Defines the new target as a Vector or a mesh
  18631. */
  18632. setTarget(target: Vector3): void;
  18633. /**
  18634. * Defines the target point of the camera.
  18635. * The camera looks towards it form the radius distance.
  18636. */
  18637. get target(): Vector3;
  18638. set target(value: Vector3);
  18639. /**
  18640. * Return the current target position of the camera. This value is expressed in local space.
  18641. * @returns the target position
  18642. */
  18643. getTarget(): Vector3;
  18644. /** @hidden */
  18645. _decideIfNeedsToMove(): boolean;
  18646. /** @hidden */
  18647. _updatePosition(): void;
  18648. /** @hidden */
  18649. _checkInputs(): void;
  18650. protected _updateCameraRotationMatrix(): void;
  18651. /**
  18652. * 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)
  18653. * @returns the current camera
  18654. */
  18655. private _rotateUpVectorWithCameraRotationMatrix;
  18656. private _cachedRotationZ;
  18657. private _cachedQuaternionRotationZ;
  18658. /** @hidden */
  18659. _getViewMatrix(): Matrix;
  18660. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18661. /**
  18662. * @hidden
  18663. */
  18664. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18665. /**
  18666. * @hidden
  18667. */
  18668. _updateRigCameras(): void;
  18669. private _getRigCamPositionAndTarget;
  18670. /**
  18671. * Gets the current object class name.
  18672. * @return the class name
  18673. */
  18674. getClassName(): string;
  18675. }
  18676. }
  18677. declare module BABYLON {
  18678. /**
  18679. * Gather the list of keyboard event types as constants.
  18680. */
  18681. export class KeyboardEventTypes {
  18682. /**
  18683. * The keydown event is fired when a key becomes active (pressed).
  18684. */
  18685. static readonly KEYDOWN: number;
  18686. /**
  18687. * The keyup event is fired when a key has been released.
  18688. */
  18689. static readonly KEYUP: number;
  18690. }
  18691. /**
  18692. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18693. */
  18694. export class KeyboardInfo {
  18695. /**
  18696. * Defines the type of event (KeyboardEventTypes)
  18697. */
  18698. type: number;
  18699. /**
  18700. * Defines the related dom event
  18701. */
  18702. event: KeyboardEvent;
  18703. /**
  18704. * Instantiates a new keyboard info.
  18705. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18706. * @param type Defines the type of event (KeyboardEventTypes)
  18707. * @param event Defines the related dom event
  18708. */
  18709. constructor(
  18710. /**
  18711. * Defines the type of event (KeyboardEventTypes)
  18712. */
  18713. type: number,
  18714. /**
  18715. * Defines the related dom event
  18716. */
  18717. event: KeyboardEvent);
  18718. }
  18719. /**
  18720. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18721. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18722. */
  18723. export class KeyboardInfoPre extends KeyboardInfo {
  18724. /**
  18725. * Defines the type of event (KeyboardEventTypes)
  18726. */
  18727. type: number;
  18728. /**
  18729. * Defines the related dom event
  18730. */
  18731. event: KeyboardEvent;
  18732. /**
  18733. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18734. */
  18735. skipOnPointerObservable: boolean;
  18736. /**
  18737. * Instantiates a new keyboard pre info.
  18738. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18739. * @param type Defines the type of event (KeyboardEventTypes)
  18740. * @param event Defines the related dom event
  18741. */
  18742. constructor(
  18743. /**
  18744. * Defines the type of event (KeyboardEventTypes)
  18745. */
  18746. type: number,
  18747. /**
  18748. * Defines the related dom event
  18749. */
  18750. event: KeyboardEvent);
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /**
  18755. * Manage the keyboard inputs to control the movement of a free camera.
  18756. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18757. */
  18758. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18759. /**
  18760. * Defines the camera the input is attached to.
  18761. */
  18762. camera: FreeCamera;
  18763. /**
  18764. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18765. */
  18766. keysUp: number[];
  18767. /**
  18768. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18769. */
  18770. keysUpward: number[];
  18771. /**
  18772. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18773. */
  18774. keysDown: number[];
  18775. /**
  18776. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18777. */
  18778. keysDownward: number[];
  18779. /**
  18780. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18781. */
  18782. keysLeft: number[];
  18783. /**
  18784. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18785. */
  18786. keysRight: number[];
  18787. private _keys;
  18788. private _onCanvasBlurObserver;
  18789. private _onKeyboardObserver;
  18790. private _engine;
  18791. private _scene;
  18792. /**
  18793. * Attach the input controls to a specific dom element to get the input from.
  18794. * @param element Defines the element the controls should be listened from
  18795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18796. */
  18797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18798. /**
  18799. * Detach the current controls from the specified dom element.
  18800. * @param element Defines the element to stop listening the inputs from
  18801. */
  18802. detachControl(element: Nullable<HTMLElement>): void;
  18803. /**
  18804. * Update the current camera state depending on the inputs that have been used this frame.
  18805. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18806. */
  18807. checkInputs(): void;
  18808. /**
  18809. * Gets the class name of the current intput.
  18810. * @returns the class name
  18811. */
  18812. getClassName(): string;
  18813. /** @hidden */
  18814. _onLostFocus(): void;
  18815. /**
  18816. * Get the friendly name associated with the input class.
  18817. * @returns the input friendly name
  18818. */
  18819. getSimpleName(): string;
  18820. }
  18821. }
  18822. declare module BABYLON {
  18823. /**
  18824. * Gather the list of pointer event types as constants.
  18825. */
  18826. export class PointerEventTypes {
  18827. /**
  18828. * 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.
  18829. */
  18830. static readonly POINTERDOWN: number;
  18831. /**
  18832. * The pointerup event is fired when a pointer is no longer active.
  18833. */
  18834. static readonly POINTERUP: number;
  18835. /**
  18836. * The pointermove event is fired when a pointer changes coordinates.
  18837. */
  18838. static readonly POINTERMOVE: number;
  18839. /**
  18840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18841. */
  18842. static readonly POINTERWHEEL: number;
  18843. /**
  18844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18845. */
  18846. static readonly POINTERPICK: number;
  18847. /**
  18848. * The pointertap event is fired when a the object has been touched and released without drag.
  18849. */
  18850. static readonly POINTERTAP: number;
  18851. /**
  18852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18853. */
  18854. static readonly POINTERDOUBLETAP: number;
  18855. }
  18856. /**
  18857. * Base class of pointer info types.
  18858. */
  18859. export class PointerInfoBase {
  18860. /**
  18861. * Defines the type of event (PointerEventTypes)
  18862. */
  18863. type: number;
  18864. /**
  18865. * Defines the related dom event
  18866. */
  18867. event: PointerEvent | MouseWheelEvent;
  18868. /**
  18869. * Instantiates the base class of pointers info.
  18870. * @param type Defines the type of event (PointerEventTypes)
  18871. * @param event Defines the related dom event
  18872. */
  18873. constructor(
  18874. /**
  18875. * Defines the type of event (PointerEventTypes)
  18876. */
  18877. type: number,
  18878. /**
  18879. * Defines the related dom event
  18880. */
  18881. event: PointerEvent | MouseWheelEvent);
  18882. }
  18883. /**
  18884. * This class is used to store pointer related info for the onPrePointerObservable event.
  18885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18886. */
  18887. export class PointerInfoPre extends PointerInfoBase {
  18888. /**
  18889. * Ray from a pointer if availible (eg. 6dof controller)
  18890. */
  18891. ray: Nullable<Ray>;
  18892. /**
  18893. * Defines the local position of the pointer on the canvas.
  18894. */
  18895. localPosition: Vector2;
  18896. /**
  18897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18898. */
  18899. skipOnPointerObservable: boolean;
  18900. /**
  18901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18902. * @param type Defines the type of event (PointerEventTypes)
  18903. * @param event Defines the related dom event
  18904. * @param localX Defines the local x coordinates of the pointer when the event occured
  18905. * @param localY Defines the local y coordinates of the pointer when the event occured
  18906. */
  18907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18908. }
  18909. /**
  18910. * This type contains all the data related to a pointer event in Babylon.js.
  18911. * 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.
  18912. */
  18913. export class PointerInfo extends PointerInfoBase {
  18914. /**
  18915. * Defines the picking info associated to the info (if any)\
  18916. */
  18917. pickInfo: Nullable<PickingInfo>;
  18918. /**
  18919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18920. * @param type Defines the type of event (PointerEventTypes)
  18921. * @param event Defines the related dom event
  18922. * @param pickInfo Defines the picking info associated to the info (if any)\
  18923. */
  18924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18925. /**
  18926. * Defines the picking info associated to the info (if any)\
  18927. */
  18928. pickInfo: Nullable<PickingInfo>);
  18929. }
  18930. /**
  18931. * Data relating to a touch event on the screen.
  18932. */
  18933. export interface PointerTouch {
  18934. /**
  18935. * X coordinate of touch.
  18936. */
  18937. x: number;
  18938. /**
  18939. * Y coordinate of touch.
  18940. */
  18941. y: number;
  18942. /**
  18943. * Id of touch. Unique for each finger.
  18944. */
  18945. pointerId: number;
  18946. /**
  18947. * Event type passed from DOM.
  18948. */
  18949. type: any;
  18950. }
  18951. }
  18952. declare module BABYLON {
  18953. /**
  18954. * Manage the mouse inputs to control the movement of a free camera.
  18955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18956. */
  18957. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18958. /**
  18959. * Define if touch is enabled in the mouse input
  18960. */
  18961. touchEnabled: boolean;
  18962. /**
  18963. * Defines the camera the input is attached to.
  18964. */
  18965. camera: FreeCamera;
  18966. /**
  18967. * Defines the buttons associated with the input to handle camera move.
  18968. */
  18969. buttons: number[];
  18970. /**
  18971. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18972. */
  18973. angularSensibility: number;
  18974. private _pointerInput;
  18975. private _onMouseMove;
  18976. private _observer;
  18977. private previousPosition;
  18978. /**
  18979. * Observable for when a pointer move event occurs containing the move offset
  18980. */
  18981. onPointerMovedObservable: Observable<{
  18982. offsetX: number;
  18983. offsetY: number;
  18984. }>;
  18985. /**
  18986. * @hidden
  18987. * If the camera should be rotated automatically based on pointer movement
  18988. */
  18989. _allowCameraRotation: boolean;
  18990. /**
  18991. * Manage the mouse inputs to control the movement of a free camera.
  18992. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18993. * @param touchEnabled Defines if touch is enabled or not
  18994. */
  18995. constructor(
  18996. /**
  18997. * Define if touch is enabled in the mouse input
  18998. */
  18999. touchEnabled?: boolean);
  19000. /**
  19001. * Attach the input controls to a specific dom element to get the input from.
  19002. * @param element Defines the element the controls should be listened from
  19003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19004. */
  19005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19006. /**
  19007. * Called on JS contextmenu event.
  19008. * Override this method to provide functionality.
  19009. */
  19010. protected onContextMenu(evt: PointerEvent): void;
  19011. /**
  19012. * Detach the current controls from the specified dom element.
  19013. * @param element Defines the element to stop listening the inputs from
  19014. */
  19015. detachControl(element: Nullable<HTMLElement>): void;
  19016. /**
  19017. * Gets the class name of the current intput.
  19018. * @returns the class name
  19019. */
  19020. getClassName(): string;
  19021. /**
  19022. * Get the friendly name associated with the input class.
  19023. * @returns the input friendly name
  19024. */
  19025. getSimpleName(): string;
  19026. }
  19027. }
  19028. declare module BABYLON {
  19029. /**
  19030. * Manage the touch inputs to control the movement of a free camera.
  19031. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19032. */
  19033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19034. /**
  19035. * Define if mouse events can be treated as touch events
  19036. */
  19037. allowMouse: boolean;
  19038. /**
  19039. * Defines the camera the input is attached to.
  19040. */
  19041. camera: FreeCamera;
  19042. /**
  19043. * Defines the touch sensibility for rotation.
  19044. * The higher the faster.
  19045. */
  19046. touchAngularSensibility: number;
  19047. /**
  19048. * Defines the touch sensibility for move.
  19049. * The higher the faster.
  19050. */
  19051. touchMoveSensibility: number;
  19052. private _offsetX;
  19053. private _offsetY;
  19054. private _pointerPressed;
  19055. private _pointerInput;
  19056. private _observer;
  19057. private _onLostFocus;
  19058. /**
  19059. * Manage the touch inputs to control the movement of a free camera.
  19060. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19061. * @param allowMouse Defines if mouse events can be treated as touch events
  19062. */
  19063. constructor(
  19064. /**
  19065. * Define if mouse events can be treated as touch events
  19066. */
  19067. allowMouse?: boolean);
  19068. /**
  19069. * Attach the input controls to a specific dom element to get the input from.
  19070. * @param element Defines the element the controls should be listened from
  19071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19072. */
  19073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19074. /**
  19075. * Detach the current controls from the specified dom element.
  19076. * @param element Defines the element to stop listening the inputs from
  19077. */
  19078. detachControl(element: Nullable<HTMLElement>): void;
  19079. /**
  19080. * Update the current camera state depending on the inputs that have been used this frame.
  19081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19082. */
  19083. checkInputs(): void;
  19084. /**
  19085. * Gets the class name of the current intput.
  19086. * @returns the class name
  19087. */
  19088. getClassName(): string;
  19089. /**
  19090. * Get the friendly name associated with the input class.
  19091. * @returns the input friendly name
  19092. */
  19093. getSimpleName(): string;
  19094. }
  19095. }
  19096. declare module BABYLON {
  19097. /**
  19098. * Default Inputs manager for the FreeCamera.
  19099. * It groups all the default supported inputs for ease of use.
  19100. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19101. */
  19102. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19103. /**
  19104. * @hidden
  19105. */
  19106. _mouseInput: Nullable<FreeCameraMouseInput>;
  19107. /**
  19108. * Instantiates a new FreeCameraInputsManager.
  19109. * @param camera Defines the camera the inputs belong to
  19110. */
  19111. constructor(camera: FreeCamera);
  19112. /**
  19113. * Add keyboard input support to the input manager.
  19114. * @returns the current input manager
  19115. */
  19116. addKeyboard(): FreeCameraInputsManager;
  19117. /**
  19118. * Add mouse input support to the input manager.
  19119. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19120. * @returns the current input manager
  19121. */
  19122. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19123. /**
  19124. * Removes the mouse input support from the manager
  19125. * @returns the current input manager
  19126. */
  19127. removeMouse(): FreeCameraInputsManager;
  19128. /**
  19129. * Add touch input support to the input manager.
  19130. * @returns the current input manager
  19131. */
  19132. addTouch(): FreeCameraInputsManager;
  19133. /**
  19134. * Remove all attached input methods from a camera
  19135. */
  19136. clear(): void;
  19137. }
  19138. }
  19139. declare module BABYLON {
  19140. /**
  19141. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19142. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19143. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19144. */
  19145. export class FreeCamera extends TargetCamera {
  19146. /**
  19147. * Define the collision ellipsoid of the camera.
  19148. * This is helpful to simulate a camera body like the player body around the camera
  19149. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19150. */
  19151. ellipsoid: Vector3;
  19152. /**
  19153. * Define an offset for the position of the ellipsoid around the camera.
  19154. * This can be helpful to determine the center of the body near the gravity center of the body
  19155. * instead of its head.
  19156. */
  19157. ellipsoidOffset: Vector3;
  19158. /**
  19159. * Enable or disable collisions of the camera with the rest of the scene objects.
  19160. */
  19161. checkCollisions: boolean;
  19162. /**
  19163. * Enable or disable gravity on the camera.
  19164. */
  19165. applyGravity: boolean;
  19166. /**
  19167. * Define the input manager associated to the camera.
  19168. */
  19169. inputs: FreeCameraInputsManager;
  19170. /**
  19171. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19172. * Higher values reduce sensitivity.
  19173. */
  19174. get angularSensibility(): number;
  19175. /**
  19176. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19177. * Higher values reduce sensitivity.
  19178. */
  19179. set angularSensibility(value: number);
  19180. /**
  19181. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19182. */
  19183. get keysUp(): number[];
  19184. set keysUp(value: number[]);
  19185. /**
  19186. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19187. */
  19188. get keysUpward(): number[];
  19189. set keysUpward(value: number[]);
  19190. /**
  19191. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19192. */
  19193. get keysDown(): number[];
  19194. set keysDown(value: number[]);
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19197. */
  19198. get keysDownward(): number[];
  19199. set keysDownward(value: number[]);
  19200. /**
  19201. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19202. */
  19203. get keysLeft(): number[];
  19204. set keysLeft(value: number[]);
  19205. /**
  19206. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19207. */
  19208. get keysRight(): number[];
  19209. set keysRight(value: number[]);
  19210. /**
  19211. * Event raised when the camera collide with a mesh in the scene.
  19212. */
  19213. onCollide: (collidedMesh: AbstractMesh) => void;
  19214. private _collider;
  19215. private _needMoveForGravity;
  19216. private _oldPosition;
  19217. private _diffPosition;
  19218. private _newPosition;
  19219. /** @hidden */
  19220. _localDirection: Vector3;
  19221. /** @hidden */
  19222. _transformedDirection: Vector3;
  19223. /**
  19224. * Instantiates a Free Camera.
  19225. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19226. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19227. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19228. * @param name Define the name of the camera in the scene
  19229. * @param position Define the start position of the camera in the scene
  19230. * @param scene Define the scene the camera belongs to
  19231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19232. */
  19233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19234. /**
  19235. * Attached controls to the current camera.
  19236. * @param element Defines the element the controls should be listened from
  19237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19238. */
  19239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19240. /**
  19241. * Detach the current controls from the camera.
  19242. * The camera will stop reacting to inputs.
  19243. * @param element Defines the element to stop listening the inputs from
  19244. */
  19245. detachControl(element: HTMLElement): void;
  19246. private _collisionMask;
  19247. /**
  19248. * Define a collision mask to limit the list of object the camera can collide with
  19249. */
  19250. get collisionMask(): number;
  19251. set collisionMask(mask: number);
  19252. /** @hidden */
  19253. _collideWithWorld(displacement: Vector3): void;
  19254. private _onCollisionPositionChange;
  19255. /** @hidden */
  19256. _checkInputs(): void;
  19257. /** @hidden */
  19258. _decideIfNeedsToMove(): boolean;
  19259. /** @hidden */
  19260. _updatePosition(): void;
  19261. /**
  19262. * Destroy the camera and release the current resources hold by it.
  19263. */
  19264. dispose(): void;
  19265. /**
  19266. * Gets the current object class name.
  19267. * @return the class name
  19268. */
  19269. getClassName(): string;
  19270. }
  19271. }
  19272. declare module BABYLON {
  19273. /**
  19274. * Represents a gamepad control stick position
  19275. */
  19276. export class StickValues {
  19277. /**
  19278. * The x component of the control stick
  19279. */
  19280. x: number;
  19281. /**
  19282. * The y component of the control stick
  19283. */
  19284. y: number;
  19285. /**
  19286. * Initializes the gamepad x and y control stick values
  19287. * @param x The x component of the gamepad control stick value
  19288. * @param y The y component of the gamepad control stick value
  19289. */
  19290. constructor(
  19291. /**
  19292. * The x component of the control stick
  19293. */
  19294. x: number,
  19295. /**
  19296. * The y component of the control stick
  19297. */
  19298. y: number);
  19299. }
  19300. /**
  19301. * An interface which manages callbacks for gamepad button changes
  19302. */
  19303. export interface GamepadButtonChanges {
  19304. /**
  19305. * Called when a gamepad has been changed
  19306. */
  19307. changed: boolean;
  19308. /**
  19309. * Called when a gamepad press event has been triggered
  19310. */
  19311. pressChanged: boolean;
  19312. /**
  19313. * Called when a touch event has been triggered
  19314. */
  19315. touchChanged: boolean;
  19316. /**
  19317. * Called when a value has changed
  19318. */
  19319. valueChanged: boolean;
  19320. }
  19321. /**
  19322. * Represents a gamepad
  19323. */
  19324. export class Gamepad {
  19325. /**
  19326. * The id of the gamepad
  19327. */
  19328. id: string;
  19329. /**
  19330. * The index of the gamepad
  19331. */
  19332. index: number;
  19333. /**
  19334. * The browser gamepad
  19335. */
  19336. browserGamepad: any;
  19337. /**
  19338. * Specifies what type of gamepad this represents
  19339. */
  19340. type: number;
  19341. private _leftStick;
  19342. private _rightStick;
  19343. /** @hidden */
  19344. _isConnected: boolean;
  19345. private _leftStickAxisX;
  19346. private _leftStickAxisY;
  19347. private _rightStickAxisX;
  19348. private _rightStickAxisY;
  19349. /**
  19350. * Triggered when the left control stick has been changed
  19351. */
  19352. private _onleftstickchanged;
  19353. /**
  19354. * Triggered when the right control stick has been changed
  19355. */
  19356. private _onrightstickchanged;
  19357. /**
  19358. * Represents a gamepad controller
  19359. */
  19360. static GAMEPAD: number;
  19361. /**
  19362. * Represents a generic controller
  19363. */
  19364. static GENERIC: number;
  19365. /**
  19366. * Represents an XBox controller
  19367. */
  19368. static XBOX: number;
  19369. /**
  19370. * Represents a pose-enabled controller
  19371. */
  19372. static POSE_ENABLED: number;
  19373. /**
  19374. * Represents an Dual Shock controller
  19375. */
  19376. static DUALSHOCK: number;
  19377. /**
  19378. * Specifies whether the left control stick should be Y-inverted
  19379. */
  19380. protected _invertLeftStickY: boolean;
  19381. /**
  19382. * Specifies if the gamepad has been connected
  19383. */
  19384. get isConnected(): boolean;
  19385. /**
  19386. * Initializes the gamepad
  19387. * @param id The id of the gamepad
  19388. * @param index The index of the gamepad
  19389. * @param browserGamepad The browser gamepad
  19390. * @param leftStickX The x component of the left joystick
  19391. * @param leftStickY The y component of the left joystick
  19392. * @param rightStickX The x component of the right joystick
  19393. * @param rightStickY The y component of the right joystick
  19394. */
  19395. constructor(
  19396. /**
  19397. * The id of the gamepad
  19398. */
  19399. id: string,
  19400. /**
  19401. * The index of the gamepad
  19402. */
  19403. index: number,
  19404. /**
  19405. * The browser gamepad
  19406. */
  19407. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19408. /**
  19409. * Callback triggered when the left joystick has changed
  19410. * @param callback
  19411. */
  19412. onleftstickchanged(callback: (values: StickValues) => void): void;
  19413. /**
  19414. * Callback triggered when the right joystick has changed
  19415. * @param callback
  19416. */
  19417. onrightstickchanged(callback: (values: StickValues) => void): void;
  19418. /**
  19419. * Gets the left joystick
  19420. */
  19421. get leftStick(): StickValues;
  19422. /**
  19423. * Sets the left joystick values
  19424. */
  19425. set leftStick(newValues: StickValues);
  19426. /**
  19427. * Gets the right joystick
  19428. */
  19429. get rightStick(): StickValues;
  19430. /**
  19431. * Sets the right joystick value
  19432. */
  19433. set rightStick(newValues: StickValues);
  19434. /**
  19435. * Updates the gamepad joystick positions
  19436. */
  19437. update(): void;
  19438. /**
  19439. * Disposes the gamepad
  19440. */
  19441. dispose(): void;
  19442. }
  19443. /**
  19444. * Represents a generic gamepad
  19445. */
  19446. export class GenericPad extends Gamepad {
  19447. private _buttons;
  19448. private _onbuttondown;
  19449. private _onbuttonup;
  19450. /**
  19451. * Observable triggered when a button has been pressed
  19452. */
  19453. onButtonDownObservable: Observable<number>;
  19454. /**
  19455. * Observable triggered when a button has been released
  19456. */
  19457. onButtonUpObservable: Observable<number>;
  19458. /**
  19459. * Callback triggered when a button has been pressed
  19460. * @param callback Called when a button has been pressed
  19461. */
  19462. onbuttondown(callback: (buttonPressed: number) => void): void;
  19463. /**
  19464. * Callback triggered when a button has been released
  19465. * @param callback Called when a button has been released
  19466. */
  19467. onbuttonup(callback: (buttonReleased: number) => void): void;
  19468. /**
  19469. * Initializes the generic gamepad
  19470. * @param id The id of the generic gamepad
  19471. * @param index The index of the generic gamepad
  19472. * @param browserGamepad The browser gamepad
  19473. */
  19474. constructor(id: string, index: number, browserGamepad: any);
  19475. private _setButtonValue;
  19476. /**
  19477. * Updates the generic gamepad
  19478. */
  19479. update(): void;
  19480. /**
  19481. * Disposes the generic gamepad
  19482. */
  19483. dispose(): void;
  19484. }
  19485. }
  19486. declare module BABYLON {
  19487. /**
  19488. * Defines the types of pose enabled controllers that are supported
  19489. */
  19490. export enum PoseEnabledControllerType {
  19491. /**
  19492. * HTC Vive
  19493. */
  19494. VIVE = 0,
  19495. /**
  19496. * Oculus Rift
  19497. */
  19498. OCULUS = 1,
  19499. /**
  19500. * Windows mixed reality
  19501. */
  19502. WINDOWS = 2,
  19503. /**
  19504. * Samsung gear VR
  19505. */
  19506. GEAR_VR = 3,
  19507. /**
  19508. * Google Daydream
  19509. */
  19510. DAYDREAM = 4,
  19511. /**
  19512. * Generic
  19513. */
  19514. GENERIC = 5
  19515. }
  19516. /**
  19517. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19518. */
  19519. export interface MutableGamepadButton {
  19520. /**
  19521. * Value of the button/trigger
  19522. */
  19523. value: number;
  19524. /**
  19525. * If the button/trigger is currently touched
  19526. */
  19527. touched: boolean;
  19528. /**
  19529. * If the button/trigger is currently pressed
  19530. */
  19531. pressed: boolean;
  19532. }
  19533. /**
  19534. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19535. * @hidden
  19536. */
  19537. export interface ExtendedGamepadButton extends GamepadButton {
  19538. /**
  19539. * If the button/trigger is currently pressed
  19540. */
  19541. readonly pressed: boolean;
  19542. /**
  19543. * If the button/trigger is currently touched
  19544. */
  19545. readonly touched: boolean;
  19546. /**
  19547. * Value of the button/trigger
  19548. */
  19549. readonly value: number;
  19550. }
  19551. /** @hidden */
  19552. export interface _GamePadFactory {
  19553. /**
  19554. * Returns whether or not the current gamepad can be created for this type of controller.
  19555. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19556. * @returns true if it can be created, otherwise false
  19557. */
  19558. canCreate(gamepadInfo: any): boolean;
  19559. /**
  19560. * Creates a new instance of the Gamepad.
  19561. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19562. * @returns the new gamepad instance
  19563. */
  19564. create(gamepadInfo: any): Gamepad;
  19565. }
  19566. /**
  19567. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19568. */
  19569. export class PoseEnabledControllerHelper {
  19570. /** @hidden */
  19571. static _ControllerFactories: _GamePadFactory[];
  19572. /** @hidden */
  19573. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19574. /**
  19575. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19576. * @param vrGamepad the gamepad to initialized
  19577. * @returns a vr controller of the type the gamepad identified as
  19578. */
  19579. static InitiateController(vrGamepad: any): Gamepad;
  19580. }
  19581. /**
  19582. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19583. */
  19584. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19585. /**
  19586. * If the controller is used in a webXR session
  19587. */
  19588. isXR: boolean;
  19589. private _deviceRoomPosition;
  19590. private _deviceRoomRotationQuaternion;
  19591. /**
  19592. * The device position in babylon space
  19593. */
  19594. devicePosition: Vector3;
  19595. /**
  19596. * The device rotation in babylon space
  19597. */
  19598. deviceRotationQuaternion: Quaternion;
  19599. /**
  19600. * The scale factor of the device in babylon space
  19601. */
  19602. deviceScaleFactor: number;
  19603. /**
  19604. * (Likely devicePosition should be used instead) The device position in its room space
  19605. */
  19606. position: Vector3;
  19607. /**
  19608. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19609. */
  19610. rotationQuaternion: Quaternion;
  19611. /**
  19612. * The type of controller (Eg. Windows mixed reality)
  19613. */
  19614. controllerType: PoseEnabledControllerType;
  19615. protected _calculatedPosition: Vector3;
  19616. private _calculatedRotation;
  19617. /**
  19618. * The raw pose from the device
  19619. */
  19620. rawPose: DevicePose;
  19621. private _trackPosition;
  19622. private _maxRotationDistFromHeadset;
  19623. private _draggedRoomRotation;
  19624. /**
  19625. * @hidden
  19626. */
  19627. _disableTrackPosition(fixedPosition: Vector3): void;
  19628. /**
  19629. * Internal, the mesh attached to the controller
  19630. * @hidden
  19631. */
  19632. _mesh: Nullable<AbstractMesh>;
  19633. private _poseControlledCamera;
  19634. private _leftHandSystemQuaternion;
  19635. /**
  19636. * Internal, matrix used to convert room space to babylon space
  19637. * @hidden
  19638. */
  19639. _deviceToWorld: Matrix;
  19640. /**
  19641. * Node to be used when casting a ray from the controller
  19642. * @hidden
  19643. */
  19644. _pointingPoseNode: Nullable<TransformNode>;
  19645. /**
  19646. * Name of the child mesh that can be used to cast a ray from the controller
  19647. */
  19648. static readonly POINTING_POSE: string;
  19649. /**
  19650. * Creates a new PoseEnabledController from a gamepad
  19651. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19652. */
  19653. constructor(browserGamepad: any);
  19654. private _workingMatrix;
  19655. /**
  19656. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19657. */
  19658. update(): void;
  19659. /**
  19660. * Updates only the pose device and mesh without doing any button event checking
  19661. */
  19662. protected _updatePoseAndMesh(): void;
  19663. /**
  19664. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19665. * @param poseData raw pose fromthe device
  19666. */
  19667. updateFromDevice(poseData: DevicePose): void;
  19668. /**
  19669. * @hidden
  19670. */
  19671. _meshAttachedObservable: Observable<AbstractMesh>;
  19672. /**
  19673. * Attaches a mesh to the controller
  19674. * @param mesh the mesh to be attached
  19675. */
  19676. attachToMesh(mesh: AbstractMesh): void;
  19677. /**
  19678. * Attaches the controllers mesh to a camera
  19679. * @param camera the camera the mesh should be attached to
  19680. */
  19681. attachToPoseControlledCamera(camera: TargetCamera): void;
  19682. /**
  19683. * Disposes of the controller
  19684. */
  19685. dispose(): void;
  19686. /**
  19687. * The mesh that is attached to the controller
  19688. */
  19689. get mesh(): Nullable<AbstractMesh>;
  19690. /**
  19691. * Gets the ray of the controller in the direction the controller is pointing
  19692. * @param length the length the resulting ray should be
  19693. * @returns a ray in the direction the controller is pointing
  19694. */
  19695. getForwardRay(length?: number): Ray;
  19696. }
  19697. }
  19698. declare module BABYLON {
  19699. /**
  19700. * Defines the WebVRController object that represents controllers tracked in 3D space
  19701. */
  19702. export abstract class WebVRController extends PoseEnabledController {
  19703. /**
  19704. * Internal, the default controller model for the controller
  19705. */
  19706. protected _defaultModel: Nullable<AbstractMesh>;
  19707. /**
  19708. * Fired when the trigger state has changed
  19709. */
  19710. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19711. /**
  19712. * Fired when the main button state has changed
  19713. */
  19714. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19715. /**
  19716. * Fired when the secondary button state has changed
  19717. */
  19718. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19719. /**
  19720. * Fired when the pad state has changed
  19721. */
  19722. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19723. /**
  19724. * Fired when controllers stick values have changed
  19725. */
  19726. onPadValuesChangedObservable: Observable<StickValues>;
  19727. /**
  19728. * Array of button availible on the controller
  19729. */
  19730. protected _buttons: Array<MutableGamepadButton>;
  19731. private _onButtonStateChange;
  19732. /**
  19733. * Fired when a controller button's state has changed
  19734. * @param callback the callback containing the button that was modified
  19735. */
  19736. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19737. /**
  19738. * X and Y axis corresponding to the controllers joystick
  19739. */
  19740. pad: StickValues;
  19741. /**
  19742. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19743. */
  19744. hand: string;
  19745. /**
  19746. * The default controller model for the controller
  19747. */
  19748. get defaultModel(): Nullable<AbstractMesh>;
  19749. /**
  19750. * Creates a new WebVRController from a gamepad
  19751. * @param vrGamepad the gamepad that the WebVRController should be created from
  19752. */
  19753. constructor(vrGamepad: any);
  19754. /**
  19755. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19756. */
  19757. update(): void;
  19758. /**
  19759. * Function to be called when a button is modified
  19760. */
  19761. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19762. /**
  19763. * Loads a mesh and attaches it to the controller
  19764. * @param scene the scene the mesh should be added to
  19765. * @param meshLoaded callback for when the mesh has been loaded
  19766. */
  19767. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19768. private _setButtonValue;
  19769. private _changes;
  19770. private _checkChanges;
  19771. /**
  19772. * Disposes of th webVRCOntroller
  19773. */
  19774. dispose(): void;
  19775. }
  19776. }
  19777. declare module BABYLON {
  19778. /**
  19779. * The HemisphericLight simulates the ambient environment light,
  19780. * so the passed direction is the light reflection direction, not the incoming direction.
  19781. */
  19782. export class HemisphericLight extends Light {
  19783. /**
  19784. * The groundColor is the light in the opposite direction to the one specified during creation.
  19785. * 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.
  19786. */
  19787. groundColor: Color3;
  19788. /**
  19789. * The light reflection direction, not the incoming direction.
  19790. */
  19791. direction: Vector3;
  19792. /**
  19793. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19794. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19795. * The HemisphericLight can't cast shadows.
  19796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19797. * @param name The friendly name of the light
  19798. * @param direction The direction of the light reflection
  19799. * @param scene The scene the light belongs to
  19800. */
  19801. constructor(name: string, direction: Vector3, scene: Scene);
  19802. protected _buildUniformLayout(): void;
  19803. /**
  19804. * Returns the string "HemisphericLight".
  19805. * @return The class name
  19806. */
  19807. getClassName(): string;
  19808. /**
  19809. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19810. * Returns the updated direction.
  19811. * @param target The target the direction should point to
  19812. * @return The computed direction
  19813. */
  19814. setDirectionToTarget(target: Vector3): Vector3;
  19815. /**
  19816. * Returns the shadow generator associated to the light.
  19817. * @returns Always null for hemispheric lights because it does not support shadows.
  19818. */
  19819. getShadowGenerator(): Nullable<IShadowGenerator>;
  19820. /**
  19821. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19822. * @param effect The effect to update
  19823. * @param lightIndex The index of the light in the effect to update
  19824. * @returns The hemispheric light
  19825. */
  19826. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19827. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19828. /**
  19829. * Computes the world matrix of the node
  19830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19831. * @param useWasUpdatedFlag defines a reserved property
  19832. * @returns the world matrix
  19833. */
  19834. computeWorldMatrix(): Matrix;
  19835. /**
  19836. * Returns the integer 3.
  19837. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19838. */
  19839. getTypeID(): number;
  19840. /**
  19841. * Prepares the list of defines specific to the light type.
  19842. * @param defines the list of defines
  19843. * @param lightIndex defines the index of the light for the effect
  19844. */
  19845. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19846. }
  19847. }
  19848. declare module BABYLON {
  19849. /** @hidden */
  19850. export var vrMultiviewToSingleviewPixelShader: {
  19851. name: string;
  19852. shader: string;
  19853. };
  19854. }
  19855. declare module BABYLON {
  19856. /**
  19857. * Renders to multiple views with a single draw call
  19858. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19859. */
  19860. export class MultiviewRenderTarget extends RenderTargetTexture {
  19861. /**
  19862. * Creates a multiview render target
  19863. * @param scene scene used with the render target
  19864. * @param size the size of the render target (used for each view)
  19865. */
  19866. constructor(scene: Scene, size?: number | {
  19867. width: number;
  19868. height: number;
  19869. } | {
  19870. ratio: number;
  19871. });
  19872. /**
  19873. * @hidden
  19874. * @param faceIndex the face index, if its a cube texture
  19875. */
  19876. _bindFrameBuffer(faceIndex?: number): void;
  19877. /**
  19878. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19879. * @returns the view count
  19880. */
  19881. getViewCount(): number;
  19882. }
  19883. }
  19884. declare module BABYLON {
  19885. interface Engine {
  19886. /**
  19887. * Creates a new multiview render target
  19888. * @param width defines the width of the texture
  19889. * @param height defines the height of the texture
  19890. * @returns the created multiview texture
  19891. */
  19892. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19893. /**
  19894. * Binds a multiview framebuffer to be drawn to
  19895. * @param multiviewTexture texture to bind
  19896. */
  19897. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19898. }
  19899. interface Camera {
  19900. /**
  19901. * @hidden
  19902. * 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)
  19903. */
  19904. _useMultiviewToSingleView: boolean;
  19905. /**
  19906. * @hidden
  19907. * 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)
  19908. */
  19909. _multiviewTexture: Nullable<RenderTargetTexture>;
  19910. /**
  19911. * @hidden
  19912. * ensures the multiview texture of the camera exists and has the specified width/height
  19913. * @param width height to set on the multiview texture
  19914. * @param height width to set on the multiview texture
  19915. */
  19916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19917. }
  19918. interface Scene {
  19919. /** @hidden */
  19920. _transformMatrixR: Matrix;
  19921. /** @hidden */
  19922. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19923. /** @hidden */
  19924. _createMultiviewUbo(): void;
  19925. /** @hidden */
  19926. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19927. /** @hidden */
  19928. _renderMultiviewToSingleView(camera: Camera): void;
  19929. }
  19930. }
  19931. declare module BABYLON {
  19932. /**
  19933. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19934. * This will not be used for webXR as it supports displaying texture arrays directly
  19935. */
  19936. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19937. /**
  19938. * Gets a string identifying the name of the class
  19939. * @returns "VRMultiviewToSingleviewPostProcess" string
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * Initializes a VRMultiviewToSingleview
  19944. * @param name name of the post process
  19945. * @param camera camera to be applied to
  19946. * @param scaleFactor scaling factor to the size of the output texture
  19947. */
  19948. constructor(name: string, camera: Camera, scaleFactor: number);
  19949. }
  19950. }
  19951. declare module BABYLON {
  19952. /**
  19953. * Interface used to define additional presentation attributes
  19954. */
  19955. export interface IVRPresentationAttributes {
  19956. /**
  19957. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19958. */
  19959. highRefreshRate: boolean;
  19960. /**
  19961. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19962. */
  19963. foveationLevel: number;
  19964. }
  19965. interface Engine {
  19966. /** @hidden */
  19967. _vrDisplay: any;
  19968. /** @hidden */
  19969. _vrSupported: boolean;
  19970. /** @hidden */
  19971. _oldSize: Size;
  19972. /** @hidden */
  19973. _oldHardwareScaleFactor: number;
  19974. /** @hidden */
  19975. _vrExclusivePointerMode: boolean;
  19976. /** @hidden */
  19977. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19978. /** @hidden */
  19979. _onVRDisplayPointerRestricted: () => void;
  19980. /** @hidden */
  19981. _onVRDisplayPointerUnrestricted: () => void;
  19982. /** @hidden */
  19983. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19984. /** @hidden */
  19985. _onVrDisplayDisconnect: Nullable<() => void>;
  19986. /** @hidden */
  19987. _onVrDisplayPresentChange: Nullable<() => void>;
  19988. /**
  19989. * Observable signaled when VR display mode changes
  19990. */
  19991. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19992. /**
  19993. * Observable signaled when VR request present is complete
  19994. */
  19995. onVRRequestPresentComplete: Observable<boolean>;
  19996. /**
  19997. * Observable signaled when VR request present starts
  19998. */
  19999. onVRRequestPresentStart: Observable<Engine>;
  20000. /**
  20001. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20002. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20003. */
  20004. isInVRExclusivePointerMode: boolean;
  20005. /**
  20006. * Gets a boolean indicating if a webVR device was detected
  20007. * @returns true if a webVR device was detected
  20008. */
  20009. isVRDevicePresent(): boolean;
  20010. /**
  20011. * Gets the current webVR device
  20012. * @returns the current webVR device (or null)
  20013. */
  20014. getVRDevice(): any;
  20015. /**
  20016. * Initializes a webVR display and starts listening to display change events
  20017. * The onVRDisplayChangedObservable will be notified upon these changes
  20018. * @returns A promise containing a VRDisplay and if vr is supported
  20019. */
  20020. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20021. /** @hidden */
  20022. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20023. /**
  20024. * Gets or sets the presentation attributes used to configure VR rendering
  20025. */
  20026. vrPresentationAttributes?: IVRPresentationAttributes;
  20027. /**
  20028. * Call this function to switch to webVR mode
  20029. * Will do nothing if webVR is not supported or if there is no webVR device
  20030. * @param options the webvr options provided to the camera. mainly used for multiview
  20031. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20032. */
  20033. enableVR(options: WebVROptions): void;
  20034. /** @hidden */
  20035. _onVRFullScreenTriggered(): void;
  20036. }
  20037. }
  20038. declare module BABYLON {
  20039. /**
  20040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20041. * IMPORTANT!! The data is right-hand data.
  20042. * @export
  20043. * @interface DevicePose
  20044. */
  20045. export interface DevicePose {
  20046. /**
  20047. * The position of the device, values in array are [x,y,z].
  20048. */
  20049. readonly position: Nullable<Float32Array>;
  20050. /**
  20051. * The linearVelocity of the device, values in array are [x,y,z].
  20052. */
  20053. readonly linearVelocity: Nullable<Float32Array>;
  20054. /**
  20055. * The linearAcceleration of the device, values in array are [x,y,z].
  20056. */
  20057. readonly linearAcceleration: Nullable<Float32Array>;
  20058. /**
  20059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20060. */
  20061. readonly orientation: Nullable<Float32Array>;
  20062. /**
  20063. * The angularVelocity of the device, values in array are [x,y,z].
  20064. */
  20065. readonly angularVelocity: Nullable<Float32Array>;
  20066. /**
  20067. * The angularAcceleration of the device, values in array are [x,y,z].
  20068. */
  20069. readonly angularAcceleration: Nullable<Float32Array>;
  20070. }
  20071. /**
  20072. * Interface representing a pose controlled object in Babylon.
  20073. * A pose controlled object has both regular pose values as well as pose values
  20074. * from an external device such as a VR head mounted display
  20075. */
  20076. export interface PoseControlled {
  20077. /**
  20078. * The position of the object in babylon space.
  20079. */
  20080. position: Vector3;
  20081. /**
  20082. * The rotation quaternion of the object in babylon space.
  20083. */
  20084. rotationQuaternion: Quaternion;
  20085. /**
  20086. * The position of the device in babylon space.
  20087. */
  20088. devicePosition?: Vector3;
  20089. /**
  20090. * The rotation quaternion of the device in babylon space.
  20091. */
  20092. deviceRotationQuaternion: Quaternion;
  20093. /**
  20094. * The raw pose coming from the device.
  20095. */
  20096. rawPose: Nullable<DevicePose>;
  20097. /**
  20098. * The scale of the device to be used when translating from device space to babylon space.
  20099. */
  20100. deviceScaleFactor: number;
  20101. /**
  20102. * Updates the poseControlled values based on the input device pose.
  20103. * @param poseData the pose data to update the object with
  20104. */
  20105. updateFromDevice(poseData: DevicePose): void;
  20106. }
  20107. /**
  20108. * Set of options to customize the webVRCamera
  20109. */
  20110. export interface WebVROptions {
  20111. /**
  20112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20113. */
  20114. trackPosition?: boolean;
  20115. /**
  20116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20117. */
  20118. positionScale?: number;
  20119. /**
  20120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20121. */
  20122. displayName?: string;
  20123. /**
  20124. * Should the native controller meshes be initialized. (default: true)
  20125. */
  20126. controllerMeshes?: boolean;
  20127. /**
  20128. * Creating a default HemiLight only on controllers. (default: true)
  20129. */
  20130. defaultLightingOnControllers?: boolean;
  20131. /**
  20132. * If you don't want to use the default VR button of the helper. (default: false)
  20133. */
  20134. useCustomVRButton?: boolean;
  20135. /**
  20136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20137. */
  20138. customVRButton?: HTMLButtonElement;
  20139. /**
  20140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20141. */
  20142. rayLength?: number;
  20143. /**
  20144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20145. */
  20146. defaultHeight?: number;
  20147. /**
  20148. * If multiview should be used if availible (default: false)
  20149. */
  20150. useMultiview?: boolean;
  20151. }
  20152. /**
  20153. * This represents a WebVR camera.
  20154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20155. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20156. */
  20157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20158. private webVROptions;
  20159. /**
  20160. * @hidden
  20161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20162. */
  20163. _vrDevice: any;
  20164. /**
  20165. * The rawPose of the vrDevice.
  20166. */
  20167. rawPose: Nullable<DevicePose>;
  20168. private _onVREnabled;
  20169. private _specsVersion;
  20170. private _attached;
  20171. private _frameData;
  20172. protected _descendants: Array<Node>;
  20173. private _deviceRoomPosition;
  20174. /** @hidden */
  20175. _deviceRoomRotationQuaternion: Quaternion;
  20176. private _standingMatrix;
  20177. /**
  20178. * Represents device position in babylon space.
  20179. */
  20180. devicePosition: Vector3;
  20181. /**
  20182. * Represents device rotation in babylon space.
  20183. */
  20184. deviceRotationQuaternion: Quaternion;
  20185. /**
  20186. * The scale of the device to be used when translating from device space to babylon space.
  20187. */
  20188. deviceScaleFactor: number;
  20189. private _deviceToWorld;
  20190. private _worldToDevice;
  20191. /**
  20192. * References to the webVR controllers for the vrDevice.
  20193. */
  20194. controllers: Array<WebVRController>;
  20195. /**
  20196. * Emits an event when a controller is attached.
  20197. */
  20198. onControllersAttachedObservable: Observable<WebVRController[]>;
  20199. /**
  20200. * Emits an event when a controller's mesh has been loaded;
  20201. */
  20202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20203. /**
  20204. * Emits an event when the HMD's pose has been updated.
  20205. */
  20206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20207. private _poseSet;
  20208. /**
  20209. * If the rig cameras be used as parent instead of this camera.
  20210. */
  20211. rigParenting: boolean;
  20212. private _lightOnControllers;
  20213. private _defaultHeight?;
  20214. /**
  20215. * Instantiates a WebVRFreeCamera.
  20216. * @param name The name of the WebVRFreeCamera
  20217. * @param position The starting anchor position for the camera
  20218. * @param scene The scene the camera belongs to
  20219. * @param webVROptions a set of customizable options for the webVRCamera
  20220. */
  20221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20222. /**
  20223. * Gets the device distance from the ground in meters.
  20224. * @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.
  20225. */
  20226. deviceDistanceToRoomGround(): number;
  20227. /**
  20228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20230. */
  20231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20232. /**
  20233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20234. * @returns A promise with a boolean set to if the standing matrix is supported.
  20235. */
  20236. useStandingMatrixAsync(): Promise<boolean>;
  20237. /**
  20238. * Disposes the camera
  20239. */
  20240. dispose(): void;
  20241. /**
  20242. * Gets a vrController by name.
  20243. * @param name The name of the controller to retreive
  20244. * @returns the controller matching the name specified or null if not found
  20245. */
  20246. getControllerByName(name: string): Nullable<WebVRController>;
  20247. private _leftController;
  20248. /**
  20249. * The controller corresponding to the users left hand.
  20250. */
  20251. get leftController(): Nullable<WebVRController>;
  20252. private _rightController;
  20253. /**
  20254. * The controller corresponding to the users right hand.
  20255. */
  20256. get rightController(): Nullable<WebVRController>;
  20257. /**
  20258. * Casts a ray forward from the vrCamera's gaze.
  20259. * @param length Length of the ray (default: 100)
  20260. * @returns the ray corresponding to the gaze
  20261. */
  20262. getForwardRay(length?: number): Ray;
  20263. /**
  20264. * @hidden
  20265. * Updates the camera based on device's frame data
  20266. */
  20267. _checkInputs(): void;
  20268. /**
  20269. * Updates the poseControlled values based on the input device pose.
  20270. * @param poseData Pose coming from the device
  20271. */
  20272. updateFromDevice(poseData: DevicePose): void;
  20273. private _htmlElementAttached;
  20274. private _detachIfAttached;
  20275. /**
  20276. * WebVR's attach control will start broadcasting frames to the device.
  20277. * Note that in certain browsers (chrome for example) this function must be called
  20278. * within a user-interaction callback. Example:
  20279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20280. *
  20281. * @param element html element to attach the vrDevice to
  20282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20283. */
  20284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20285. /**
  20286. * Detaches the camera from the html element and disables VR
  20287. *
  20288. * @param element html element to detach from
  20289. */
  20290. detachControl(element: HTMLElement): void;
  20291. /**
  20292. * @returns the name of this class
  20293. */
  20294. getClassName(): string;
  20295. /**
  20296. * Calls resetPose on the vrDisplay
  20297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20298. */
  20299. resetToCurrentRotation(): void;
  20300. /**
  20301. * @hidden
  20302. * Updates the rig cameras (left and right eye)
  20303. */
  20304. _updateRigCameras(): void;
  20305. private _workingVector;
  20306. private _oneVector;
  20307. private _workingMatrix;
  20308. private updateCacheCalled;
  20309. private _correctPositionIfNotTrackPosition;
  20310. /**
  20311. * @hidden
  20312. * Updates the cached values of the camera
  20313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20314. */
  20315. _updateCache(ignoreParentClass?: boolean): void;
  20316. /**
  20317. * @hidden
  20318. * Get current device position in babylon world
  20319. */
  20320. _computeDevicePosition(): void;
  20321. /**
  20322. * Updates the current device position and rotation in the babylon world
  20323. */
  20324. update(): void;
  20325. /**
  20326. * @hidden
  20327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20328. * @returns an identity matrix
  20329. */
  20330. _getViewMatrix(): Matrix;
  20331. private _tmpMatrix;
  20332. /**
  20333. * This function is called by the two RIG cameras.
  20334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20335. * @hidden
  20336. */
  20337. _getWebVRViewMatrix(): Matrix;
  20338. /** @hidden */
  20339. _getWebVRProjectionMatrix(): Matrix;
  20340. private _onGamepadConnectedObserver;
  20341. private _onGamepadDisconnectedObserver;
  20342. private _updateCacheWhenTrackingDisabledObserver;
  20343. /**
  20344. * Initializes the controllers and their meshes
  20345. */
  20346. initControllers(): void;
  20347. }
  20348. }
  20349. declare module BABYLON {
  20350. /**
  20351. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20352. *
  20353. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20354. *
  20355. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20356. */
  20357. export class MaterialHelper {
  20358. /**
  20359. * Bind the current view position to an effect.
  20360. * @param effect The effect to be bound
  20361. * @param scene The scene the eyes position is used from
  20362. * @param variableName name of the shader variable that will hold the eye position
  20363. */
  20364. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20365. /**
  20366. * Helps preparing the defines values about the UVs in used in the effect.
  20367. * UVs are shared as much as we can accross channels in the shaders.
  20368. * @param texture The texture we are preparing the UVs for
  20369. * @param defines The defines to update
  20370. * @param key The channel key "diffuse", "specular"... used in the shader
  20371. */
  20372. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20373. /**
  20374. * Binds a texture matrix value to its corrsponding uniform
  20375. * @param texture The texture to bind the matrix for
  20376. * @param uniformBuffer The uniform buffer receivin the data
  20377. * @param key The channel key "diffuse", "specular"... used in the shader
  20378. */
  20379. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20380. /**
  20381. * Gets the current status of the fog (should it be enabled?)
  20382. * @param mesh defines the mesh to evaluate for fog support
  20383. * @param scene defines the hosting scene
  20384. * @returns true if fog must be enabled
  20385. */
  20386. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20387. /**
  20388. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20389. * @param mesh defines the current mesh
  20390. * @param scene defines the current scene
  20391. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20392. * @param pointsCloud defines if point cloud rendering has to be turned on
  20393. * @param fogEnabled defines if fog has to be turned on
  20394. * @param alphaTest defines if alpha testing has to be turned on
  20395. * @param defines defines the current list of defines
  20396. */
  20397. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20398. /**
  20399. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20400. * @param scene defines the current scene
  20401. * @param engine defines the current engine
  20402. * @param defines specifies the list of active defines
  20403. * @param useInstances defines if instances have to be turned on
  20404. * @param useClipPlane defines if clip plane have to be turned on
  20405. * @param useInstances defines if instances have to be turned on
  20406. * @param useThinInstances defines if thin instances have to be turned on
  20407. */
  20408. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20409. /**
  20410. * Prepares the defines for bones
  20411. * @param mesh The mesh containing the geometry data we will draw
  20412. * @param defines The defines to update
  20413. */
  20414. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20415. /**
  20416. * Prepares the defines for morph targets
  20417. * @param mesh The mesh containing the geometry data we will draw
  20418. * @param defines The defines to update
  20419. */
  20420. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20421. /**
  20422. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20423. * @param mesh The mesh containing the geometry data we will draw
  20424. * @param defines The defines to update
  20425. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20426. * @param useBones Precise whether bones should be used or not (override mesh info)
  20427. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20428. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20429. * @returns false if defines are considered not dirty and have not been checked
  20430. */
  20431. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20432. /**
  20433. * Prepares the defines related to multiview
  20434. * @param scene The scene we are intending to draw
  20435. * @param defines The defines to update
  20436. */
  20437. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20438. /**
  20439. * Prepares the defines related to the prepass
  20440. * @param scene The scene we are intending to draw
  20441. * @param defines The defines to update
  20442. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20443. */
  20444. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20445. /**
  20446. * Prepares the defines related to the light information passed in parameter
  20447. * @param scene The scene we are intending to draw
  20448. * @param mesh The mesh the effect is compiling for
  20449. * @param light The light the effect is compiling for
  20450. * @param lightIndex The index of the light
  20451. * @param defines The defines to update
  20452. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20453. * @param state Defines the current state regarding what is needed (normals, etc...)
  20454. */
  20455. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20456. needNormals: boolean;
  20457. needRebuild: boolean;
  20458. shadowEnabled: boolean;
  20459. specularEnabled: boolean;
  20460. lightmapMode: boolean;
  20461. }): void;
  20462. /**
  20463. * Prepares the defines related to the light information passed in parameter
  20464. * @param scene The scene we are intending to draw
  20465. * @param mesh The mesh the effect is compiling for
  20466. * @param defines The defines to update
  20467. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20468. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20469. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20470. * @returns true if normals will be required for the rest of the effect
  20471. */
  20472. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20473. /**
  20474. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20475. * @param lightIndex defines the light index
  20476. * @param uniformsList The uniform list
  20477. * @param samplersList The sampler list
  20478. * @param projectedLightTexture defines if projected texture must be used
  20479. * @param uniformBuffersList defines an optional list of uniform buffers
  20480. */
  20481. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20482. /**
  20483. * Prepares the uniforms and samplers list to be used in the effect
  20484. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20485. * @param samplersList The sampler list
  20486. * @param defines The defines helping in the list generation
  20487. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20488. */
  20489. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20490. /**
  20491. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20492. * @param defines The defines to update while falling back
  20493. * @param fallbacks The authorized effect fallbacks
  20494. * @param maxSimultaneousLights The maximum number of lights allowed
  20495. * @param rank the current rank of the Effect
  20496. * @returns The newly affected rank
  20497. */
  20498. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20499. private static _TmpMorphInfluencers;
  20500. /**
  20501. * Prepares the list of attributes required for morph targets according to the effect defines.
  20502. * @param attribs The current list of supported attribs
  20503. * @param mesh The mesh to prepare the morph targets attributes for
  20504. * @param influencers The number of influencers
  20505. */
  20506. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20507. /**
  20508. * Prepares the list of attributes required for morph targets according to the effect defines.
  20509. * @param attribs The current list of supported attribs
  20510. * @param mesh The mesh to prepare the morph targets attributes for
  20511. * @param defines The current Defines of the effect
  20512. */
  20513. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20514. /**
  20515. * Prepares the list of attributes required for bones according to the effect defines.
  20516. * @param attribs The current list of supported attribs
  20517. * @param mesh The mesh to prepare the bones attributes for
  20518. * @param defines The current Defines of the effect
  20519. * @param fallbacks The current efffect fallback strategy
  20520. */
  20521. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20522. /**
  20523. * Check and prepare the list of attributes required for instances according to the effect defines.
  20524. * @param attribs The current list of supported attribs
  20525. * @param defines The current MaterialDefines of the effect
  20526. */
  20527. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20528. /**
  20529. * Add the list of attributes required for instances to the attribs array.
  20530. * @param attribs The current list of supported attribs
  20531. */
  20532. static PushAttributesForInstances(attribs: string[]): void;
  20533. /**
  20534. * Binds the light information to the effect.
  20535. * @param light The light containing the generator
  20536. * @param effect The effect we are binding the data to
  20537. * @param lightIndex The light index in the effect used to render
  20538. */
  20539. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20540. /**
  20541. * Binds the lights information from the scene to the effect for the given mesh.
  20542. * @param light Light to bind
  20543. * @param lightIndex Light index
  20544. * @param scene The scene where the light belongs to
  20545. * @param effect The effect we are binding the data to
  20546. * @param useSpecular Defines if specular is supported
  20547. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20548. */
  20549. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20550. /**
  20551. * Binds the lights information from the scene to the effect for the given mesh.
  20552. * @param scene The scene the lights belongs to
  20553. * @param mesh The mesh we are binding the information to render
  20554. * @param effect The effect we are binding the data to
  20555. * @param defines The generated defines for the effect
  20556. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20557. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20558. */
  20559. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20560. private static _tempFogColor;
  20561. /**
  20562. * Binds the fog information from the scene to the effect for the given mesh.
  20563. * @param scene The scene the lights belongs to
  20564. * @param mesh The mesh we are binding the information to render
  20565. * @param effect The effect we are binding the data to
  20566. * @param linearSpace Defines if the fog effect is applied in linear space
  20567. */
  20568. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20569. /**
  20570. * Binds the bones information from the mesh to the effect.
  20571. * @param mesh The mesh we are binding the information to render
  20572. * @param effect The effect we are binding the data to
  20573. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20574. */
  20575. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20576. private static _CopyBonesTransformationMatrices;
  20577. /**
  20578. * Binds the morph targets information from the mesh to the effect.
  20579. * @param abstractMesh The mesh we are binding the information to render
  20580. * @param effect The effect we are binding the data to
  20581. */
  20582. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20583. /**
  20584. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20585. * @param defines The generated defines used in the effect
  20586. * @param effect The effect we are binding the data to
  20587. * @param scene The scene we are willing to render with logarithmic scale for
  20588. */
  20589. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20590. /**
  20591. * Binds the clip plane information from the scene to the effect.
  20592. * @param scene The scene the clip plane information are extracted from
  20593. * @param effect The effect we are binding the data to
  20594. */
  20595. static BindClipPlane(effect: Effect, scene: Scene): void;
  20596. }
  20597. }
  20598. declare module BABYLON {
  20599. /**
  20600. * Block used to expose an input value
  20601. */
  20602. export class InputBlock extends NodeMaterialBlock {
  20603. private _mode;
  20604. private _associatedVariableName;
  20605. private _storedValue;
  20606. private _valueCallback;
  20607. private _type;
  20608. private _animationType;
  20609. /** Gets or set a value used to limit the range of float values */
  20610. min: number;
  20611. /** Gets or set a value used to limit the range of float values */
  20612. max: number;
  20613. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20614. isBoolean: boolean;
  20615. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20616. matrixMode: number;
  20617. /** @hidden */
  20618. _systemValue: Nullable<NodeMaterialSystemValues>;
  20619. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20620. isConstant: boolean;
  20621. /** Gets or sets the group to use to display this block in the Inspector */
  20622. groupInInspector: string;
  20623. /** Gets an observable raised when the value is changed */
  20624. onValueChangedObservable: Observable<InputBlock>;
  20625. /**
  20626. * Gets or sets the connection point type (default is float)
  20627. */
  20628. get type(): NodeMaterialBlockConnectionPointTypes;
  20629. /**
  20630. * Creates a new InputBlock
  20631. * @param name defines the block name
  20632. * @param target defines the target of that block (Vertex by default)
  20633. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20634. */
  20635. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20636. /**
  20637. * Validates if a name is a reserve word.
  20638. * @param newName the new name to be given to the node.
  20639. * @returns false if the name is a reserve word, else true.
  20640. */
  20641. validateBlockName(newName: string): boolean;
  20642. /**
  20643. * Gets the output component
  20644. */
  20645. get output(): NodeMaterialConnectionPoint;
  20646. /**
  20647. * Set the source of this connection point to a vertex attribute
  20648. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20649. * @returns the current connection point
  20650. */
  20651. setAsAttribute(attributeName?: string): InputBlock;
  20652. /**
  20653. * Set the source of this connection point to a system value
  20654. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20655. * @returns the current connection point
  20656. */
  20657. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20658. /**
  20659. * Gets or sets the value of that point.
  20660. * Please note that this value will be ignored if valueCallback is defined
  20661. */
  20662. get value(): any;
  20663. set value(value: any);
  20664. /**
  20665. * Gets or sets a callback used to get the value of that point.
  20666. * Please note that setting this value will force the connection point to ignore the value property
  20667. */
  20668. get valueCallback(): () => any;
  20669. set valueCallback(value: () => any);
  20670. /**
  20671. * Gets or sets the associated variable name in the shader
  20672. */
  20673. get associatedVariableName(): string;
  20674. set associatedVariableName(value: string);
  20675. /** Gets or sets the type of animation applied to the input */
  20676. get animationType(): AnimatedInputBlockTypes;
  20677. set animationType(value: AnimatedInputBlockTypes);
  20678. /**
  20679. * Gets a boolean indicating that this connection point not defined yet
  20680. */
  20681. get isUndefined(): boolean;
  20682. /**
  20683. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20684. * In this case the connection point name must be the name of the uniform to use.
  20685. * Can only be set on inputs
  20686. */
  20687. get isUniform(): boolean;
  20688. set isUniform(value: boolean);
  20689. /**
  20690. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20691. * In this case the connection point name must be the name of the attribute to use
  20692. * Can only be set on inputs
  20693. */
  20694. get isAttribute(): boolean;
  20695. set isAttribute(value: boolean);
  20696. /**
  20697. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20698. * Can only be set on exit points
  20699. */
  20700. get isVarying(): boolean;
  20701. set isVarying(value: boolean);
  20702. /**
  20703. * Gets a boolean indicating that the current connection point is a system value
  20704. */
  20705. get isSystemValue(): boolean;
  20706. /**
  20707. * Gets or sets the current well known value or null if not defined as a system value
  20708. */
  20709. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20710. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20711. /**
  20712. * Gets the current class name
  20713. * @returns the class name
  20714. */
  20715. getClassName(): string;
  20716. /**
  20717. * Animate the input if animationType !== None
  20718. * @param scene defines the rendering scene
  20719. */
  20720. animate(scene: Scene): void;
  20721. private _emitDefine;
  20722. initialize(state: NodeMaterialBuildState): void;
  20723. /**
  20724. * Set the input block to its default value (based on its type)
  20725. */
  20726. setDefaultValue(): void;
  20727. private _emitConstant;
  20728. /** @hidden */
  20729. get _noContextSwitch(): boolean;
  20730. private _emit;
  20731. /** @hidden */
  20732. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20733. /** @hidden */
  20734. _transmit(effect: Effect, scene: Scene): void;
  20735. protected _buildBlock(state: NodeMaterialBuildState): void;
  20736. protected _dumpPropertiesCode(): string;
  20737. dispose(): void;
  20738. serialize(): any;
  20739. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20740. }
  20741. }
  20742. declare module BABYLON {
  20743. /**
  20744. * Enum used to define the compatibility state between two connection points
  20745. */
  20746. export enum NodeMaterialConnectionPointCompatibilityStates {
  20747. /** Points are compatibles */
  20748. Compatible = 0,
  20749. /** Points are incompatible because of their types */
  20750. TypeIncompatible = 1,
  20751. /** Points are incompatible because of their targets (vertex vs fragment) */
  20752. TargetIncompatible = 2
  20753. }
  20754. /**
  20755. * Defines the direction of a connection point
  20756. */
  20757. export enum NodeMaterialConnectionPointDirection {
  20758. /** Input */
  20759. Input = 0,
  20760. /** Output */
  20761. Output = 1
  20762. }
  20763. /**
  20764. * Defines a connection point for a block
  20765. */
  20766. export class NodeMaterialConnectionPoint {
  20767. /** @hidden */
  20768. _ownerBlock: NodeMaterialBlock;
  20769. /** @hidden */
  20770. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20771. private _endpoints;
  20772. private _associatedVariableName;
  20773. private _direction;
  20774. /** @hidden */
  20775. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20776. /** @hidden */
  20777. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20778. private _type;
  20779. /** @hidden */
  20780. _enforceAssociatedVariableName: boolean;
  20781. /** Gets the direction of the point */
  20782. get direction(): NodeMaterialConnectionPointDirection;
  20783. /** Indicates that this connection point needs dual validation before being connected to another point */
  20784. needDualDirectionValidation: boolean;
  20785. /**
  20786. * Gets or sets the additional types supported by this connection point
  20787. */
  20788. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20789. /**
  20790. * Gets or sets the additional types excluded by this connection point
  20791. */
  20792. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20793. /**
  20794. * Observable triggered when this point is connected
  20795. */
  20796. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20797. /**
  20798. * Gets or sets the associated variable name in the shader
  20799. */
  20800. get associatedVariableName(): string;
  20801. set associatedVariableName(value: string);
  20802. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20803. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20804. /**
  20805. * Gets or sets the connection point type (default is float)
  20806. */
  20807. get type(): NodeMaterialBlockConnectionPointTypes;
  20808. set type(value: NodeMaterialBlockConnectionPointTypes);
  20809. /**
  20810. * Gets or sets the connection point name
  20811. */
  20812. name: string;
  20813. /**
  20814. * Gets or sets the connection point name
  20815. */
  20816. displayName: string;
  20817. /**
  20818. * Gets or sets a boolean indicating that this connection point can be omitted
  20819. */
  20820. isOptional: boolean;
  20821. /**
  20822. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20823. */
  20824. isExposedOnFrame: boolean;
  20825. /**
  20826. * Gets or sets number indicating the position that the port is exposed to on a frame
  20827. */
  20828. exposedPortPosition: number;
  20829. /**
  20830. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20831. */
  20832. define: string;
  20833. /** @hidden */
  20834. _prioritizeVertex: boolean;
  20835. private _target;
  20836. /** Gets or sets the target of that connection point */
  20837. get target(): NodeMaterialBlockTargets;
  20838. set target(value: NodeMaterialBlockTargets);
  20839. /**
  20840. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20841. */
  20842. get isConnected(): boolean;
  20843. /**
  20844. * Gets a boolean indicating that the current point is connected to an input block
  20845. */
  20846. get isConnectedToInputBlock(): boolean;
  20847. /**
  20848. * Gets a the connected input block (if any)
  20849. */
  20850. get connectInputBlock(): Nullable<InputBlock>;
  20851. /** Get the other side of the connection (if any) */
  20852. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20853. /** Get the block that owns this connection point */
  20854. get ownerBlock(): NodeMaterialBlock;
  20855. /** Get the block connected on the other side of this connection (if any) */
  20856. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20857. /** Get the block connected on the endpoints of this connection (if any) */
  20858. get connectedBlocks(): Array<NodeMaterialBlock>;
  20859. /** Gets the list of connected endpoints */
  20860. get endpoints(): NodeMaterialConnectionPoint[];
  20861. /** Gets a boolean indicating if that output point is connected to at least one input */
  20862. get hasEndpoints(): boolean;
  20863. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20864. get isConnectedInVertexShader(): boolean;
  20865. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20866. get isConnectedInFragmentShader(): boolean;
  20867. /**
  20868. * Creates a block suitable to be used as an input for this input point.
  20869. * If null is returned, a block based on the point type will be created.
  20870. * @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
  20871. */
  20872. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20873. /**
  20874. * Creates a new connection point
  20875. * @param name defines the connection point name
  20876. * @param ownerBlock defines the block hosting this connection point
  20877. * @param direction defines the direction of the connection point
  20878. */
  20879. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20880. /**
  20881. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20882. * @returns the class name
  20883. */
  20884. getClassName(): string;
  20885. /**
  20886. * Gets a boolean indicating if the current point can be connected to another point
  20887. * @param connectionPoint defines the other connection point
  20888. * @returns a boolean
  20889. */
  20890. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20891. /**
  20892. * Gets a number indicating if the current point can be connected to another point
  20893. * @param connectionPoint defines the other connection point
  20894. * @returns a number defining the compatibility state
  20895. */
  20896. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20897. /**
  20898. * Connect this point to another connection point
  20899. * @param connectionPoint defines the other connection point
  20900. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20901. * @returns the current connection point
  20902. */
  20903. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20904. /**
  20905. * Disconnect this point from one of his endpoint
  20906. * @param endpoint defines the other connection point
  20907. * @returns the current connection point
  20908. */
  20909. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20910. /**
  20911. * Serializes this point in a JSON representation
  20912. * @param isInput defines if the connection point is an input (default is true)
  20913. * @returns the serialized point object
  20914. */
  20915. serialize(isInput?: boolean): any;
  20916. /**
  20917. * Release resources
  20918. */
  20919. dispose(): void;
  20920. }
  20921. }
  20922. declare module BABYLON {
  20923. /**
  20924. * Enum used to define the material modes
  20925. */
  20926. export enum NodeMaterialModes {
  20927. /** Regular material */
  20928. Material = 0,
  20929. /** For post process */
  20930. PostProcess = 1,
  20931. /** For particle system */
  20932. Particle = 2,
  20933. /** For procedural texture */
  20934. ProceduralTexture = 3
  20935. }
  20936. }
  20937. declare module BABYLON {
  20938. /**
  20939. * Block used to read a texture from a sampler
  20940. */
  20941. export class TextureBlock extends NodeMaterialBlock {
  20942. private _defineName;
  20943. private _linearDefineName;
  20944. private _gammaDefineName;
  20945. private _tempTextureRead;
  20946. private _samplerName;
  20947. private _transformedUVName;
  20948. private _textureTransformName;
  20949. private _textureInfoName;
  20950. private _mainUVName;
  20951. private _mainUVDefineName;
  20952. private _fragmentOnly;
  20953. /**
  20954. * Gets or sets the texture associated with the node
  20955. */
  20956. texture: Nullable<Texture>;
  20957. /**
  20958. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20959. */
  20960. convertToGammaSpace: boolean;
  20961. /**
  20962. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20963. */
  20964. convertToLinearSpace: boolean;
  20965. /**
  20966. * Create a new TextureBlock
  20967. * @param name defines the block name
  20968. */
  20969. constructor(name: string, fragmentOnly?: boolean);
  20970. /**
  20971. * Gets the current class name
  20972. * @returns the class name
  20973. */
  20974. getClassName(): string;
  20975. /**
  20976. * Gets the uv input component
  20977. */
  20978. get uv(): NodeMaterialConnectionPoint;
  20979. /**
  20980. * Gets the rgba output component
  20981. */
  20982. get rgba(): NodeMaterialConnectionPoint;
  20983. /**
  20984. * Gets the rgb output component
  20985. */
  20986. get rgb(): NodeMaterialConnectionPoint;
  20987. /**
  20988. * Gets the r output component
  20989. */
  20990. get r(): NodeMaterialConnectionPoint;
  20991. /**
  20992. * Gets the g output component
  20993. */
  20994. get g(): NodeMaterialConnectionPoint;
  20995. /**
  20996. * Gets the b output component
  20997. */
  20998. get b(): NodeMaterialConnectionPoint;
  20999. /**
  21000. * Gets the a output component
  21001. */
  21002. get a(): NodeMaterialConnectionPoint;
  21003. get target(): NodeMaterialBlockTargets;
  21004. autoConfigure(material: NodeMaterial): void;
  21005. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21006. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21007. isReady(): boolean;
  21008. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21009. private get _isMixed();
  21010. private _injectVertexCode;
  21011. private _writeTextureRead;
  21012. private _writeOutput;
  21013. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21014. protected _dumpPropertiesCode(): string;
  21015. serialize(): any;
  21016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /** @hidden */
  21021. export var reflectionFunction: {
  21022. name: string;
  21023. shader: string;
  21024. };
  21025. }
  21026. declare module BABYLON {
  21027. /**
  21028. * Base block used to read a reflection texture from a sampler
  21029. */
  21030. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21031. /** @hidden */
  21032. _define3DName: string;
  21033. /** @hidden */
  21034. _defineCubicName: string;
  21035. /** @hidden */
  21036. _defineExplicitName: string;
  21037. /** @hidden */
  21038. _defineProjectionName: string;
  21039. /** @hidden */
  21040. _defineLocalCubicName: string;
  21041. /** @hidden */
  21042. _defineSphericalName: string;
  21043. /** @hidden */
  21044. _definePlanarName: string;
  21045. /** @hidden */
  21046. _defineEquirectangularName: string;
  21047. /** @hidden */
  21048. _defineMirroredEquirectangularFixedName: string;
  21049. /** @hidden */
  21050. _defineEquirectangularFixedName: string;
  21051. /** @hidden */
  21052. _defineSkyboxName: string;
  21053. /** @hidden */
  21054. _defineOppositeZ: string;
  21055. /** @hidden */
  21056. _cubeSamplerName: string;
  21057. /** @hidden */
  21058. _2DSamplerName: string;
  21059. protected _positionUVWName: string;
  21060. protected _directionWName: string;
  21061. protected _reflectionVectorName: string;
  21062. /** @hidden */
  21063. _reflectionCoordsName: string;
  21064. /** @hidden */
  21065. _reflectionMatrixName: string;
  21066. protected _reflectionColorName: string;
  21067. /**
  21068. * Gets or sets the texture associated with the node
  21069. */
  21070. texture: Nullable<BaseTexture>;
  21071. /**
  21072. * Create a new ReflectionTextureBaseBlock
  21073. * @param name defines the block name
  21074. */
  21075. constructor(name: string);
  21076. /**
  21077. * Gets the current class name
  21078. * @returns the class name
  21079. */
  21080. getClassName(): string;
  21081. /**
  21082. * Gets the world position input component
  21083. */
  21084. abstract get position(): NodeMaterialConnectionPoint;
  21085. /**
  21086. * Gets the world position input component
  21087. */
  21088. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21089. /**
  21090. * Gets the world normal input component
  21091. */
  21092. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21093. /**
  21094. * Gets the world input component
  21095. */
  21096. abstract get world(): NodeMaterialConnectionPoint;
  21097. /**
  21098. * Gets the camera (or eye) position component
  21099. */
  21100. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21101. /**
  21102. * Gets the view input component
  21103. */
  21104. abstract get view(): NodeMaterialConnectionPoint;
  21105. protected _getTexture(): Nullable<BaseTexture>;
  21106. autoConfigure(material: NodeMaterial): void;
  21107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21108. isReady(): boolean;
  21109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21110. /**
  21111. * Gets the code to inject in the vertex shader
  21112. * @param state current state of the node material building
  21113. * @returns the shader code
  21114. */
  21115. handleVertexSide(state: NodeMaterialBuildState): string;
  21116. /**
  21117. * Handles the inits for the fragment code path
  21118. * @param state node material build state
  21119. */
  21120. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21121. /**
  21122. * Generates the reflection coords code for the fragment code path
  21123. * @param worldNormalVarName name of the world normal variable
  21124. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21125. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21126. * @returns the shader code
  21127. */
  21128. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21129. /**
  21130. * Generates the reflection color code for the fragment code path
  21131. * @param lodVarName name of the lod variable
  21132. * @param swizzleLookupTexture swizzle to use for the final color variable
  21133. * @returns the shader code
  21134. */
  21135. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21136. /**
  21137. * Generates the code corresponding to the connected output points
  21138. * @param state node material build state
  21139. * @param varName name of the variable to output
  21140. * @returns the shader code
  21141. */
  21142. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21143. protected _buildBlock(state: NodeMaterialBuildState): this;
  21144. protected _dumpPropertiesCode(): string;
  21145. serialize(): any;
  21146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21147. }
  21148. }
  21149. declare module BABYLON {
  21150. /**
  21151. * Defines a connection point to be used for points with a custom object type
  21152. */
  21153. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21154. private _blockType;
  21155. private _blockName;
  21156. private _nameForCheking?;
  21157. /**
  21158. * Creates a new connection point
  21159. * @param name defines the connection point name
  21160. * @param ownerBlock defines the block hosting this connection point
  21161. * @param direction defines the direction of the connection point
  21162. */
  21163. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21164. /**
  21165. * Gets a number indicating if the current point can be connected to another point
  21166. * @param connectionPoint defines the other connection point
  21167. * @returns a number defining the compatibility state
  21168. */
  21169. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21170. /**
  21171. * Creates a block suitable to be used as an input for this input point.
  21172. * If null is returned, a block based on the point type will be created.
  21173. * @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
  21174. */
  21175. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21176. }
  21177. }
  21178. declare module BABYLON {
  21179. /**
  21180. * Enum defining the type of properties that can be edited in the property pages in the NME
  21181. */
  21182. export enum PropertyTypeForEdition {
  21183. /** property is a boolean */
  21184. Boolean = 0,
  21185. /** property is a float */
  21186. Float = 1,
  21187. /** property is a Vector2 */
  21188. Vector2 = 2,
  21189. /** property is a list of values */
  21190. List = 3
  21191. }
  21192. /**
  21193. * Interface that defines an option in a variable of type list
  21194. */
  21195. export interface IEditablePropertyListOption {
  21196. /** label of the option */
  21197. "label": string;
  21198. /** value of the option */
  21199. "value": number;
  21200. }
  21201. /**
  21202. * Interface that defines the options available for an editable property
  21203. */
  21204. export interface IEditablePropertyOption {
  21205. /** min value */
  21206. "min"?: number;
  21207. /** max value */
  21208. "max"?: number;
  21209. /** notifiers: indicates which actions to take when the property is changed */
  21210. "notifiers"?: {
  21211. /** the material should be rebuilt */
  21212. "rebuild"?: boolean;
  21213. /** the preview should be updated */
  21214. "update"?: boolean;
  21215. };
  21216. /** list of the options for a variable of type list */
  21217. "options"?: IEditablePropertyListOption[];
  21218. }
  21219. /**
  21220. * Interface that describes an editable property
  21221. */
  21222. export interface IPropertyDescriptionForEdition {
  21223. /** name of the property */
  21224. "propertyName": string;
  21225. /** display name of the property */
  21226. "displayName": string;
  21227. /** type of the property */
  21228. "type": PropertyTypeForEdition;
  21229. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21230. "groupName": string;
  21231. /** options for the property */
  21232. "options": IEditablePropertyOption;
  21233. }
  21234. /**
  21235. * Decorator that flags a property in a node material block as being editable
  21236. */
  21237. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21238. }
  21239. declare module BABYLON {
  21240. /**
  21241. * Block used to implement the refraction part of the sub surface module of the PBR material
  21242. */
  21243. export class RefractionBlock extends NodeMaterialBlock {
  21244. /** @hidden */
  21245. _define3DName: string;
  21246. /** @hidden */
  21247. _refractionMatrixName: string;
  21248. /** @hidden */
  21249. _defineLODRefractionAlpha: string;
  21250. /** @hidden */
  21251. _defineLinearSpecularRefraction: string;
  21252. /** @hidden */
  21253. _defineOppositeZ: string;
  21254. /** @hidden */
  21255. _cubeSamplerName: string;
  21256. /** @hidden */
  21257. _2DSamplerName: string;
  21258. /** @hidden */
  21259. _vRefractionMicrosurfaceInfosName: string;
  21260. /** @hidden */
  21261. _vRefractionInfosName: string;
  21262. private _scene;
  21263. /**
  21264. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21265. * Materials half opaque for instance using refraction could benefit from this control.
  21266. */
  21267. linkRefractionWithTransparency: boolean;
  21268. /**
  21269. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21270. */
  21271. invertRefractionY: boolean;
  21272. /**
  21273. * Gets or sets the texture associated with the node
  21274. */
  21275. texture: Nullable<BaseTexture>;
  21276. /**
  21277. * Create a new RefractionBlock
  21278. * @param name defines the block name
  21279. */
  21280. constructor(name: string);
  21281. /**
  21282. * Gets the current class name
  21283. * @returns the class name
  21284. */
  21285. getClassName(): string;
  21286. /**
  21287. * Gets the intensity input component
  21288. */
  21289. get intensity(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Gets the index of refraction input component
  21292. */
  21293. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21294. /**
  21295. * Gets the tint at distance input component
  21296. */
  21297. get tintAtDistance(): NodeMaterialConnectionPoint;
  21298. /**
  21299. * Gets the view input component
  21300. */
  21301. get view(): NodeMaterialConnectionPoint;
  21302. /**
  21303. * Gets the refraction object output component
  21304. */
  21305. get refraction(): NodeMaterialConnectionPoint;
  21306. /**
  21307. * Returns true if the block has a texture
  21308. */
  21309. get hasTexture(): boolean;
  21310. protected _getTexture(): Nullable<BaseTexture>;
  21311. autoConfigure(material: NodeMaterial): void;
  21312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21313. isReady(): boolean;
  21314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21315. /**
  21316. * Gets the main code of the block (fragment side)
  21317. * @param state current state of the node material building
  21318. * @returns the shader code
  21319. */
  21320. getCode(state: NodeMaterialBuildState): string;
  21321. protected _buildBlock(state: NodeMaterialBuildState): this;
  21322. protected _dumpPropertiesCode(): string;
  21323. serialize(): any;
  21324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21325. }
  21326. }
  21327. declare module BABYLON {
  21328. /**
  21329. * Base block used as input for post process
  21330. */
  21331. export class CurrentScreenBlock extends NodeMaterialBlock {
  21332. private _samplerName;
  21333. private _linearDefineName;
  21334. private _gammaDefineName;
  21335. private _mainUVName;
  21336. private _tempTextureRead;
  21337. /**
  21338. * Gets or sets the texture associated with the node
  21339. */
  21340. texture: Nullable<BaseTexture>;
  21341. /**
  21342. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21343. */
  21344. convertToGammaSpace: boolean;
  21345. /**
  21346. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21347. */
  21348. convertToLinearSpace: boolean;
  21349. /**
  21350. * Create a new CurrentScreenBlock
  21351. * @param name defines the block name
  21352. */
  21353. constructor(name: string);
  21354. /**
  21355. * Gets the current class name
  21356. * @returns the class name
  21357. */
  21358. getClassName(): string;
  21359. /**
  21360. * Gets the uv input component
  21361. */
  21362. get uv(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the rgba output component
  21365. */
  21366. get rgba(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the rgb output component
  21369. */
  21370. get rgb(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Gets the r output component
  21373. */
  21374. get r(): NodeMaterialConnectionPoint;
  21375. /**
  21376. * Gets the g output component
  21377. */
  21378. get g(): NodeMaterialConnectionPoint;
  21379. /**
  21380. * Gets the b output component
  21381. */
  21382. get b(): NodeMaterialConnectionPoint;
  21383. /**
  21384. * Gets the a output component
  21385. */
  21386. get a(): NodeMaterialConnectionPoint;
  21387. /**
  21388. * Initialize the block and prepare the context for build
  21389. * @param state defines the state that will be used for the build
  21390. */
  21391. initialize(state: NodeMaterialBuildState): void;
  21392. get target(): NodeMaterialBlockTargets;
  21393. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21394. isReady(): boolean;
  21395. private _injectVertexCode;
  21396. private _writeTextureRead;
  21397. private _writeOutput;
  21398. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21399. serialize(): any;
  21400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21401. }
  21402. }
  21403. declare module BABYLON {
  21404. /**
  21405. * Base block used for the particle texture
  21406. */
  21407. export class ParticleTextureBlock extends NodeMaterialBlock {
  21408. private _samplerName;
  21409. private _linearDefineName;
  21410. private _gammaDefineName;
  21411. private _tempTextureRead;
  21412. /**
  21413. * Gets or sets the texture associated with the node
  21414. */
  21415. texture: Nullable<BaseTexture>;
  21416. /**
  21417. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21418. */
  21419. convertToGammaSpace: boolean;
  21420. /**
  21421. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21422. */
  21423. convertToLinearSpace: boolean;
  21424. /**
  21425. * Create a new ParticleTextureBlock
  21426. * @param name defines the block name
  21427. */
  21428. constructor(name: string);
  21429. /**
  21430. * Gets the current class name
  21431. * @returns the class name
  21432. */
  21433. getClassName(): string;
  21434. /**
  21435. * Gets the uv input component
  21436. */
  21437. get uv(): NodeMaterialConnectionPoint;
  21438. /**
  21439. * Gets the rgba output component
  21440. */
  21441. get rgba(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the rgb output component
  21444. */
  21445. get rgb(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Gets the r output component
  21448. */
  21449. get r(): NodeMaterialConnectionPoint;
  21450. /**
  21451. * Gets the g output component
  21452. */
  21453. get g(): NodeMaterialConnectionPoint;
  21454. /**
  21455. * Gets the b output component
  21456. */
  21457. get b(): NodeMaterialConnectionPoint;
  21458. /**
  21459. * Gets the a output component
  21460. */
  21461. get a(): NodeMaterialConnectionPoint;
  21462. /**
  21463. * Initialize the block and prepare the context for build
  21464. * @param state defines the state that will be used for the build
  21465. */
  21466. initialize(state: NodeMaterialBuildState): void;
  21467. autoConfigure(material: NodeMaterial): void;
  21468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21469. isReady(): boolean;
  21470. private _writeOutput;
  21471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21472. serialize(): any;
  21473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21474. }
  21475. }
  21476. declare module BABYLON {
  21477. /**
  21478. * Class used to store shared data between 2 NodeMaterialBuildState
  21479. */
  21480. export class NodeMaterialBuildStateSharedData {
  21481. /**
  21482. * Gets the list of emitted varyings
  21483. */
  21484. temps: string[];
  21485. /**
  21486. * Gets the list of emitted varyings
  21487. */
  21488. varyings: string[];
  21489. /**
  21490. * Gets the varying declaration string
  21491. */
  21492. varyingDeclaration: string;
  21493. /**
  21494. * Input blocks
  21495. */
  21496. inputBlocks: InputBlock[];
  21497. /**
  21498. * Input blocks
  21499. */
  21500. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21501. /**
  21502. * Bindable blocks (Blocks that need to set data to the effect)
  21503. */
  21504. bindableBlocks: NodeMaterialBlock[];
  21505. /**
  21506. * List of blocks that can provide a compilation fallback
  21507. */
  21508. blocksWithFallbacks: NodeMaterialBlock[];
  21509. /**
  21510. * List of blocks that can provide a define update
  21511. */
  21512. blocksWithDefines: NodeMaterialBlock[];
  21513. /**
  21514. * List of blocks that can provide a repeatable content
  21515. */
  21516. repeatableContentBlocks: NodeMaterialBlock[];
  21517. /**
  21518. * List of blocks that can provide a dynamic list of uniforms
  21519. */
  21520. dynamicUniformBlocks: NodeMaterialBlock[];
  21521. /**
  21522. * List of blocks that can block the isReady function for the material
  21523. */
  21524. blockingBlocks: NodeMaterialBlock[];
  21525. /**
  21526. * Gets the list of animated inputs
  21527. */
  21528. animatedInputs: InputBlock[];
  21529. /**
  21530. * Build Id used to avoid multiple recompilations
  21531. */
  21532. buildId: number;
  21533. /** List of emitted variables */
  21534. variableNames: {
  21535. [key: string]: number;
  21536. };
  21537. /** List of emitted defines */
  21538. defineNames: {
  21539. [key: string]: number;
  21540. };
  21541. /** Should emit comments? */
  21542. emitComments: boolean;
  21543. /** Emit build activity */
  21544. verbose: boolean;
  21545. /** Gets or sets the hosting scene */
  21546. scene: Scene;
  21547. /**
  21548. * Gets the compilation hints emitted at compilation time
  21549. */
  21550. hints: {
  21551. needWorldViewMatrix: boolean;
  21552. needWorldViewProjectionMatrix: boolean;
  21553. needAlphaBlending: boolean;
  21554. needAlphaTesting: boolean;
  21555. };
  21556. /**
  21557. * List of compilation checks
  21558. */
  21559. checks: {
  21560. emitVertex: boolean;
  21561. emitFragment: boolean;
  21562. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21563. };
  21564. /**
  21565. * Is vertex program allowed to be empty?
  21566. */
  21567. allowEmptyVertexProgram: boolean;
  21568. /** Creates a new shared data */
  21569. constructor();
  21570. /**
  21571. * Emits console errors and exceptions if there is a failing check
  21572. */
  21573. emitErrors(): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Class used to store node based material build state
  21579. */
  21580. export class NodeMaterialBuildState {
  21581. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21582. supportUniformBuffers: boolean;
  21583. /**
  21584. * Gets the list of emitted attributes
  21585. */
  21586. attributes: string[];
  21587. /**
  21588. * Gets the list of emitted uniforms
  21589. */
  21590. uniforms: string[];
  21591. /**
  21592. * Gets the list of emitted constants
  21593. */
  21594. constants: string[];
  21595. /**
  21596. * Gets the list of emitted samplers
  21597. */
  21598. samplers: string[];
  21599. /**
  21600. * Gets the list of emitted functions
  21601. */
  21602. functions: {
  21603. [key: string]: string;
  21604. };
  21605. /**
  21606. * Gets the list of emitted extensions
  21607. */
  21608. extensions: {
  21609. [key: string]: string;
  21610. };
  21611. /**
  21612. * Gets the target of the compilation state
  21613. */
  21614. target: NodeMaterialBlockTargets;
  21615. /**
  21616. * Gets the list of emitted counters
  21617. */
  21618. counters: {
  21619. [key: string]: number;
  21620. };
  21621. /**
  21622. * Shared data between multiple NodeMaterialBuildState instances
  21623. */
  21624. sharedData: NodeMaterialBuildStateSharedData;
  21625. /** @hidden */
  21626. _vertexState: NodeMaterialBuildState;
  21627. /** @hidden */
  21628. _attributeDeclaration: string;
  21629. /** @hidden */
  21630. _uniformDeclaration: string;
  21631. /** @hidden */
  21632. _constantDeclaration: string;
  21633. /** @hidden */
  21634. _samplerDeclaration: string;
  21635. /** @hidden */
  21636. _varyingTransfer: string;
  21637. /** @hidden */
  21638. _injectAtEnd: string;
  21639. private _repeatableContentAnchorIndex;
  21640. /** @hidden */
  21641. _builtCompilationString: string;
  21642. /**
  21643. * Gets the emitted compilation strings
  21644. */
  21645. compilationString: string;
  21646. /**
  21647. * Finalize the compilation strings
  21648. * @param state defines the current compilation state
  21649. */
  21650. finalize(state: NodeMaterialBuildState): void;
  21651. /** @hidden */
  21652. get _repeatableContentAnchor(): string;
  21653. /** @hidden */
  21654. _getFreeVariableName(prefix: string): string;
  21655. /** @hidden */
  21656. _getFreeDefineName(prefix: string): string;
  21657. /** @hidden */
  21658. _excludeVariableName(name: string): void;
  21659. /** @hidden */
  21660. _emit2DSampler(name: string): void;
  21661. /** @hidden */
  21662. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21663. /** @hidden */
  21664. _emitExtension(name: string, extension: string, define?: string): void;
  21665. /** @hidden */
  21666. _emitFunction(name: string, code: string, comments: string): void;
  21667. /** @hidden */
  21668. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21669. replaceStrings?: {
  21670. search: RegExp;
  21671. replace: string;
  21672. }[];
  21673. repeatKey?: string;
  21674. }): string;
  21675. /** @hidden */
  21676. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21677. repeatKey?: string;
  21678. removeAttributes?: boolean;
  21679. removeUniforms?: boolean;
  21680. removeVaryings?: boolean;
  21681. removeIfDef?: boolean;
  21682. replaceStrings?: {
  21683. search: RegExp;
  21684. replace: string;
  21685. }[];
  21686. }, storeKey?: string): void;
  21687. /** @hidden */
  21688. _registerTempVariable(name: string): boolean;
  21689. /** @hidden */
  21690. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21691. /** @hidden */
  21692. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21693. /** @hidden */
  21694. _emitFloat(value: number): string;
  21695. }
  21696. }
  21697. declare module BABYLON {
  21698. /**
  21699. * Helper class used to generate session unique ID
  21700. */
  21701. export class UniqueIdGenerator {
  21702. private static _UniqueIdCounter;
  21703. /**
  21704. * Gets an unique (relatively to the current scene) Id
  21705. */
  21706. static get UniqueId(): number;
  21707. }
  21708. }
  21709. declare module BABYLON {
  21710. /**
  21711. * Defines a block that can be used inside a node based material
  21712. */
  21713. export class NodeMaterialBlock {
  21714. private _buildId;
  21715. private _buildTarget;
  21716. private _target;
  21717. private _isFinalMerger;
  21718. private _isInput;
  21719. private _name;
  21720. protected _isUnique: boolean;
  21721. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21722. inputsAreExclusive: boolean;
  21723. /** @hidden */
  21724. _codeVariableName: string;
  21725. /** @hidden */
  21726. _inputs: NodeMaterialConnectionPoint[];
  21727. /** @hidden */
  21728. _outputs: NodeMaterialConnectionPoint[];
  21729. /** @hidden */
  21730. _preparationId: number;
  21731. /**
  21732. * Gets the name of the block
  21733. */
  21734. get name(): string;
  21735. /**
  21736. * Sets the name of the block. Will check if the name is valid.
  21737. */
  21738. set name(newName: string);
  21739. /**
  21740. * Gets or sets the unique id of the node
  21741. */
  21742. uniqueId: number;
  21743. /**
  21744. * Gets or sets the comments associated with this block
  21745. */
  21746. comments: string;
  21747. /**
  21748. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21749. */
  21750. get isUnique(): boolean;
  21751. /**
  21752. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21753. */
  21754. get isFinalMerger(): boolean;
  21755. /**
  21756. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21757. */
  21758. get isInput(): boolean;
  21759. /**
  21760. * Gets or sets the build Id
  21761. */
  21762. get buildId(): number;
  21763. set buildId(value: number);
  21764. /**
  21765. * Gets or sets the target of the block
  21766. */
  21767. get target(): NodeMaterialBlockTargets;
  21768. set target(value: NodeMaterialBlockTargets);
  21769. /**
  21770. * Gets the list of input points
  21771. */
  21772. get inputs(): NodeMaterialConnectionPoint[];
  21773. /** Gets the list of output points */
  21774. get outputs(): NodeMaterialConnectionPoint[];
  21775. /**
  21776. * Find an input by its name
  21777. * @param name defines the name of the input to look for
  21778. * @returns the input or null if not found
  21779. */
  21780. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21781. /**
  21782. * Find an output by its name
  21783. * @param name defines the name of the outputto look for
  21784. * @returns the output or null if not found
  21785. */
  21786. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21787. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21788. visibleInInspector: boolean;
  21789. /**
  21790. * Creates a new NodeMaterialBlock
  21791. * @param name defines the block name
  21792. * @param target defines the target of that block (Vertex by default)
  21793. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21794. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21795. */
  21796. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21797. /**
  21798. * Initialize the block and prepare the context for build
  21799. * @param state defines the state that will be used for the build
  21800. */
  21801. initialize(state: NodeMaterialBuildState): void;
  21802. /**
  21803. * Bind data to effect. Will only be called for blocks with isBindable === true
  21804. * @param effect defines the effect to bind data to
  21805. * @param nodeMaterial defines the hosting NodeMaterial
  21806. * @param mesh defines the mesh that will be rendered
  21807. * @param subMesh defines the submesh that will be rendered
  21808. */
  21809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21810. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21811. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21812. protected _writeFloat(value: number): string;
  21813. /**
  21814. * Gets the current class name e.g. "NodeMaterialBlock"
  21815. * @returns the class name
  21816. */
  21817. getClassName(): string;
  21818. /**
  21819. * Register a new input. Must be called inside a block constructor
  21820. * @param name defines the connection point name
  21821. * @param type defines the connection point type
  21822. * @param isOptional defines a boolean indicating that this input can be omitted
  21823. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21824. * @param point an already created connection point. If not provided, create a new one
  21825. * @returns the current block
  21826. */
  21827. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21828. /**
  21829. * Register a new output. Must be called inside a block constructor
  21830. * @param name defines the connection point name
  21831. * @param type defines the connection point type
  21832. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21833. * @param point an already created connection point. If not provided, create a new one
  21834. * @returns the current block
  21835. */
  21836. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21837. /**
  21838. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21839. * @param forOutput defines an optional connection point to check compatibility with
  21840. * @returns the first available input or null
  21841. */
  21842. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21843. /**
  21844. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21845. * @param forBlock defines an optional block to check compatibility with
  21846. * @returns the first available input or null
  21847. */
  21848. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21849. /**
  21850. * Gets the sibling of the given output
  21851. * @param current defines the current output
  21852. * @returns the next output in the list or null
  21853. */
  21854. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21855. /**
  21856. * Connect current block with another block
  21857. * @param other defines the block to connect with
  21858. * @param options define the various options to help pick the right connections
  21859. * @returns the current block
  21860. */
  21861. connectTo(other: NodeMaterialBlock, options?: {
  21862. input?: string;
  21863. output?: string;
  21864. outputSwizzle?: string;
  21865. }): this | undefined;
  21866. protected _buildBlock(state: NodeMaterialBuildState): void;
  21867. /**
  21868. * Add uniforms, samplers and uniform buffers at compilation time
  21869. * @param state defines the state to update
  21870. * @param nodeMaterial defines the node material requesting the update
  21871. * @param defines defines the material defines to update
  21872. * @param uniformBuffers defines the list of uniform buffer names
  21873. */
  21874. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21875. /**
  21876. * Add potential fallbacks if shader compilation fails
  21877. * @param mesh defines the mesh to be rendered
  21878. * @param fallbacks defines the current prioritized list of fallbacks
  21879. */
  21880. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21881. /**
  21882. * Initialize defines for shader compilation
  21883. * @param mesh defines the mesh to be rendered
  21884. * @param nodeMaterial defines the node material requesting the update
  21885. * @param defines defines the material defines to update
  21886. * @param useInstances specifies that instances should be used
  21887. */
  21888. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21889. /**
  21890. * Update defines for shader compilation
  21891. * @param mesh defines the mesh to be rendered
  21892. * @param nodeMaterial defines the node material requesting the update
  21893. * @param defines defines the material defines to update
  21894. * @param useInstances specifies that instances should be used
  21895. * @param subMesh defines which submesh to render
  21896. */
  21897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21898. /**
  21899. * Lets the block try to connect some inputs automatically
  21900. * @param material defines the hosting NodeMaterial
  21901. */
  21902. autoConfigure(material: NodeMaterial): void;
  21903. /**
  21904. * Function called when a block is declared as repeatable content generator
  21905. * @param vertexShaderState defines the current compilation state for the vertex shader
  21906. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21907. * @param mesh defines the mesh to be rendered
  21908. * @param defines defines the material defines to update
  21909. */
  21910. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21911. /**
  21912. * Checks if the block is ready
  21913. * @param mesh defines the mesh to be rendered
  21914. * @param nodeMaterial defines the node material requesting the update
  21915. * @param defines defines the material defines to update
  21916. * @param useInstances specifies that instances should be used
  21917. * @returns true if the block is ready
  21918. */
  21919. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21920. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21921. private _processBuild;
  21922. /**
  21923. * Validates the new name for the block node.
  21924. * @param newName the new name to be given to the node.
  21925. * @returns false if the name is a reserve word, else true.
  21926. */
  21927. validateBlockName(newName: string): boolean;
  21928. /**
  21929. * Compile the current node and generate the shader code
  21930. * @param state defines the current compilation state (uniforms, samplers, current string)
  21931. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21932. * @returns true if already built
  21933. */
  21934. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21935. protected _inputRename(name: string): string;
  21936. protected _outputRename(name: string): string;
  21937. protected _dumpPropertiesCode(): string;
  21938. /** @hidden */
  21939. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21940. /** @hidden */
  21941. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21942. /**
  21943. * Clone the current block to a new identical block
  21944. * @param scene defines the hosting scene
  21945. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21946. * @returns a copy of the current block
  21947. */
  21948. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21949. /**
  21950. * Serializes this block in a JSON representation
  21951. * @returns the serialized block object
  21952. */
  21953. serialize(): any;
  21954. /** @hidden */
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. private _deserializePortDisplayNamesAndExposedOnFrame;
  21957. /**
  21958. * Release resources
  21959. */
  21960. dispose(): void;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Base class of materials working in push mode in babylon JS
  21966. * @hidden
  21967. */
  21968. export class PushMaterial extends Material {
  21969. protected _activeEffect: Effect;
  21970. protected _normalMatrix: Matrix;
  21971. constructor(name: string, scene: Scene);
  21972. getEffect(): Effect;
  21973. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21974. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21975. /**
  21976. * Binds the given world matrix to the active effect
  21977. *
  21978. * @param world the matrix to bind
  21979. */
  21980. bindOnlyWorldMatrix(world: Matrix): void;
  21981. /**
  21982. * Binds the given normal matrix to the active effect
  21983. *
  21984. * @param normalMatrix the matrix to bind
  21985. */
  21986. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21987. bind(world: Matrix, mesh?: Mesh): void;
  21988. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21989. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21990. }
  21991. }
  21992. declare module BABYLON {
  21993. /**
  21994. * Root class for all node material optimizers
  21995. */
  21996. export class NodeMaterialOptimizer {
  21997. /**
  21998. * Function used to optimize a NodeMaterial graph
  21999. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22000. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22001. */
  22002. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22003. }
  22004. }
  22005. declare module BABYLON {
  22006. /**
  22007. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22008. */
  22009. export class TransformBlock extends NodeMaterialBlock {
  22010. /**
  22011. * Defines the value to use to complement W value to transform it to a Vector4
  22012. */
  22013. complementW: number;
  22014. /**
  22015. * Defines the value to use to complement z value to transform it to a Vector4
  22016. */
  22017. complementZ: number;
  22018. /**
  22019. * Creates a new TransformBlock
  22020. * @param name defines the block name
  22021. */
  22022. constructor(name: string);
  22023. /**
  22024. * Gets the current class name
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Gets the vector input
  22030. */
  22031. get vector(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the output component
  22034. */
  22035. get output(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the xyz output component
  22038. */
  22039. get xyz(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the matrix transform input
  22042. */
  22043. get transform(): NodeMaterialConnectionPoint;
  22044. protected _buildBlock(state: NodeMaterialBuildState): this;
  22045. /**
  22046. * Update defines for shader compilation
  22047. * @param mesh defines the mesh to be rendered
  22048. * @param nodeMaterial defines the node material requesting the update
  22049. * @param defines defines the material defines to update
  22050. * @param useInstances specifies that instances should be used
  22051. * @param subMesh defines which submesh to render
  22052. */
  22053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22054. serialize(): any;
  22055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22056. protected _dumpPropertiesCode(): string;
  22057. }
  22058. }
  22059. declare module BABYLON {
  22060. /**
  22061. * Block used to output the vertex position
  22062. */
  22063. export class VertexOutputBlock extends NodeMaterialBlock {
  22064. /**
  22065. * Creates a new VertexOutputBlock
  22066. * @param name defines the block name
  22067. */
  22068. constructor(name: string);
  22069. /**
  22070. * Gets the current class name
  22071. * @returns the class name
  22072. */
  22073. getClassName(): string;
  22074. /**
  22075. * Gets the vector input component
  22076. */
  22077. get vector(): NodeMaterialConnectionPoint;
  22078. protected _buildBlock(state: NodeMaterialBuildState): this;
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. /**
  22083. * Block used to output the final color
  22084. */
  22085. export class FragmentOutputBlock extends NodeMaterialBlock {
  22086. /**
  22087. * Create a new FragmentOutputBlock
  22088. * @param name defines the block name
  22089. */
  22090. constructor(name: string);
  22091. /**
  22092. * Gets the current class name
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Gets the rgba input component
  22098. */
  22099. get rgba(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the rgb input component
  22102. */
  22103. get rgb(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the a input component
  22106. */
  22107. get a(): NodeMaterialConnectionPoint;
  22108. protected _buildBlock(state: NodeMaterialBuildState): this;
  22109. }
  22110. }
  22111. declare module BABYLON {
  22112. /**
  22113. * Block used for the particle ramp gradient section
  22114. */
  22115. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22116. /**
  22117. * Create a new ParticleRampGradientBlock
  22118. * @param name defines the block name
  22119. */
  22120. constructor(name: string);
  22121. /**
  22122. * Gets the current class name
  22123. * @returns the class name
  22124. */
  22125. getClassName(): string;
  22126. /**
  22127. * Gets the color input component
  22128. */
  22129. get color(): NodeMaterialConnectionPoint;
  22130. /**
  22131. * Gets the rampColor output component
  22132. */
  22133. get rampColor(): NodeMaterialConnectionPoint;
  22134. /**
  22135. * Initialize the block and prepare the context for build
  22136. * @param state defines the state that will be used for the build
  22137. */
  22138. initialize(state: NodeMaterialBuildState): void;
  22139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22140. }
  22141. }
  22142. declare module BABYLON {
  22143. /**
  22144. * Block used for the particle blend multiply section
  22145. */
  22146. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22147. /**
  22148. * Create a new ParticleBlendMultiplyBlock
  22149. * @param name defines the block name
  22150. */
  22151. constructor(name: string);
  22152. /**
  22153. * Gets the current class name
  22154. * @returns the class name
  22155. */
  22156. getClassName(): string;
  22157. /**
  22158. * Gets the color input component
  22159. */
  22160. get color(): NodeMaterialConnectionPoint;
  22161. /**
  22162. * Gets the alphaTexture input component
  22163. */
  22164. get alphaTexture(): NodeMaterialConnectionPoint;
  22165. /**
  22166. * Gets the alphaColor input component
  22167. */
  22168. get alphaColor(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the blendColor output component
  22171. */
  22172. get blendColor(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Initialize the block and prepare the context for build
  22175. * @param state defines the state that will be used for the build
  22176. */
  22177. initialize(state: NodeMaterialBuildState): void;
  22178. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22179. }
  22180. }
  22181. declare module BABYLON {
  22182. /**
  22183. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22184. */
  22185. export class VectorMergerBlock extends NodeMaterialBlock {
  22186. /**
  22187. * Create a new VectorMergerBlock
  22188. * @param name defines the block name
  22189. */
  22190. constructor(name: string);
  22191. /**
  22192. * Gets the current class name
  22193. * @returns the class name
  22194. */
  22195. getClassName(): string;
  22196. /**
  22197. * Gets the xyz component (input)
  22198. */
  22199. get xyzIn(): NodeMaterialConnectionPoint;
  22200. /**
  22201. * Gets the xy component (input)
  22202. */
  22203. get xyIn(): NodeMaterialConnectionPoint;
  22204. /**
  22205. * Gets the x component (input)
  22206. */
  22207. get x(): NodeMaterialConnectionPoint;
  22208. /**
  22209. * Gets the y component (input)
  22210. */
  22211. get y(): NodeMaterialConnectionPoint;
  22212. /**
  22213. * Gets the z component (input)
  22214. */
  22215. get z(): NodeMaterialConnectionPoint;
  22216. /**
  22217. * Gets the w component (input)
  22218. */
  22219. get w(): NodeMaterialConnectionPoint;
  22220. /**
  22221. * Gets the xyzw component (output)
  22222. */
  22223. get xyzw(): NodeMaterialConnectionPoint;
  22224. /**
  22225. * Gets the xyz component (output)
  22226. */
  22227. get xyzOut(): NodeMaterialConnectionPoint;
  22228. /**
  22229. * Gets the xy component (output)
  22230. */
  22231. get xyOut(): NodeMaterialConnectionPoint;
  22232. /**
  22233. * Gets the xy component (output)
  22234. * @deprecated Please use xyOut instead.
  22235. */
  22236. get xy(): NodeMaterialConnectionPoint;
  22237. /**
  22238. * Gets the xyz component (output)
  22239. * @deprecated Please use xyzOut instead.
  22240. */
  22241. get xyz(): NodeMaterialConnectionPoint;
  22242. protected _buildBlock(state: NodeMaterialBuildState): this;
  22243. }
  22244. }
  22245. declare module BABYLON {
  22246. /**
  22247. * Block used to remap a float from a range to a new one
  22248. */
  22249. export class RemapBlock extends NodeMaterialBlock {
  22250. /**
  22251. * Gets or sets the source range
  22252. */
  22253. sourceRange: Vector2;
  22254. /**
  22255. * Gets or sets the target range
  22256. */
  22257. targetRange: Vector2;
  22258. /**
  22259. * Creates a new RemapBlock
  22260. * @param name defines the block name
  22261. */
  22262. constructor(name: string);
  22263. /**
  22264. * Gets the current class name
  22265. * @returns the class name
  22266. */
  22267. getClassName(): string;
  22268. /**
  22269. * Gets the input component
  22270. */
  22271. get input(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Gets the source min input component
  22274. */
  22275. get sourceMin(): NodeMaterialConnectionPoint;
  22276. /**
  22277. * Gets the source max input component
  22278. */
  22279. get sourceMax(): NodeMaterialConnectionPoint;
  22280. /**
  22281. * Gets the target min input component
  22282. */
  22283. get targetMin(): NodeMaterialConnectionPoint;
  22284. /**
  22285. * Gets the target max input component
  22286. */
  22287. get targetMax(): NodeMaterialConnectionPoint;
  22288. /**
  22289. * Gets the output component
  22290. */
  22291. get output(): NodeMaterialConnectionPoint;
  22292. protected _buildBlock(state: NodeMaterialBuildState): this;
  22293. protected _dumpPropertiesCode(): string;
  22294. serialize(): any;
  22295. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22296. }
  22297. }
  22298. declare module BABYLON {
  22299. /**
  22300. * Block used to multiply 2 values
  22301. */
  22302. export class MultiplyBlock extends NodeMaterialBlock {
  22303. /**
  22304. * Creates a new MultiplyBlock
  22305. * @param name defines the block name
  22306. */
  22307. constructor(name: string);
  22308. /**
  22309. * Gets the current class name
  22310. * @returns the class name
  22311. */
  22312. getClassName(): string;
  22313. /**
  22314. * Gets the left operand input component
  22315. */
  22316. get left(): NodeMaterialConnectionPoint;
  22317. /**
  22318. * Gets the right operand input component
  22319. */
  22320. get right(): NodeMaterialConnectionPoint;
  22321. /**
  22322. * Gets the output component
  22323. */
  22324. get output(): NodeMaterialConnectionPoint;
  22325. protected _buildBlock(state: NodeMaterialBuildState): this;
  22326. }
  22327. }
  22328. declare module BABYLON {
  22329. /**
  22330. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22331. */
  22332. export class ColorSplitterBlock extends NodeMaterialBlock {
  22333. /**
  22334. * Create a new ColorSplitterBlock
  22335. * @param name defines the block name
  22336. */
  22337. constructor(name: string);
  22338. /**
  22339. * Gets the current class name
  22340. * @returns the class name
  22341. */
  22342. getClassName(): string;
  22343. /**
  22344. * Gets the rgba component (input)
  22345. */
  22346. get rgba(): NodeMaterialConnectionPoint;
  22347. /**
  22348. * Gets the rgb component (input)
  22349. */
  22350. get rgbIn(): NodeMaterialConnectionPoint;
  22351. /**
  22352. * Gets the rgb component (output)
  22353. */
  22354. get rgbOut(): NodeMaterialConnectionPoint;
  22355. /**
  22356. * Gets the r component (output)
  22357. */
  22358. get r(): NodeMaterialConnectionPoint;
  22359. /**
  22360. * Gets the g component (output)
  22361. */
  22362. get g(): NodeMaterialConnectionPoint;
  22363. /**
  22364. * Gets the b component (output)
  22365. */
  22366. get b(): NodeMaterialConnectionPoint;
  22367. /**
  22368. * Gets the a component (output)
  22369. */
  22370. get a(): NodeMaterialConnectionPoint;
  22371. protected _inputRename(name: string): string;
  22372. protected _outputRename(name: string): string;
  22373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. /**
  22378. * Operations supported by the Trigonometry block
  22379. */
  22380. export enum TrigonometryBlockOperations {
  22381. /** Cos */
  22382. Cos = 0,
  22383. /** Sin */
  22384. Sin = 1,
  22385. /** Abs */
  22386. Abs = 2,
  22387. /** Exp */
  22388. Exp = 3,
  22389. /** Exp2 */
  22390. Exp2 = 4,
  22391. /** Round */
  22392. Round = 5,
  22393. /** Floor */
  22394. Floor = 6,
  22395. /** Ceiling */
  22396. Ceiling = 7,
  22397. /** Square root */
  22398. Sqrt = 8,
  22399. /** Log */
  22400. Log = 9,
  22401. /** Tangent */
  22402. Tan = 10,
  22403. /** Arc tangent */
  22404. ArcTan = 11,
  22405. /** Arc cosinus */
  22406. ArcCos = 12,
  22407. /** Arc sinus */
  22408. ArcSin = 13,
  22409. /** Fraction */
  22410. Fract = 14,
  22411. /** Sign */
  22412. Sign = 15,
  22413. /** To radians (from degrees) */
  22414. Radians = 16,
  22415. /** To degrees (from radians) */
  22416. Degrees = 17
  22417. }
  22418. /**
  22419. * Block used to apply trigonometry operation to floats
  22420. */
  22421. export class TrigonometryBlock extends NodeMaterialBlock {
  22422. /**
  22423. * Gets or sets the operation applied by the block
  22424. */
  22425. operation: TrigonometryBlockOperations;
  22426. /**
  22427. * Creates a new TrigonometryBlock
  22428. * @param name defines the block name
  22429. */
  22430. constructor(name: string);
  22431. /**
  22432. * Gets the current class name
  22433. * @returns the class name
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Gets the input component
  22438. */
  22439. get input(): NodeMaterialConnectionPoint;
  22440. /**
  22441. * Gets the output component
  22442. */
  22443. get output(): NodeMaterialConnectionPoint;
  22444. protected _buildBlock(state: NodeMaterialBuildState): this;
  22445. serialize(): any;
  22446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22447. protected _dumpPropertiesCode(): string;
  22448. }
  22449. }
  22450. declare module BABYLON {
  22451. /**
  22452. * Interface used to configure the node material editor
  22453. */
  22454. export interface INodeMaterialEditorOptions {
  22455. /** Define the URl to load node editor script */
  22456. editorURL?: string;
  22457. }
  22458. /** @hidden */
  22459. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22460. NORMAL: boolean;
  22461. TANGENT: boolean;
  22462. UV1: boolean;
  22463. /** BONES */
  22464. NUM_BONE_INFLUENCERS: number;
  22465. BonesPerMesh: number;
  22466. BONETEXTURE: boolean;
  22467. /** MORPH TARGETS */
  22468. MORPHTARGETS: boolean;
  22469. MORPHTARGETS_NORMAL: boolean;
  22470. MORPHTARGETS_TANGENT: boolean;
  22471. MORPHTARGETS_UV: boolean;
  22472. NUM_MORPH_INFLUENCERS: number;
  22473. /** IMAGE PROCESSING */
  22474. IMAGEPROCESSING: boolean;
  22475. VIGNETTE: boolean;
  22476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22477. VIGNETTEBLENDMODEOPAQUE: boolean;
  22478. TONEMAPPING: boolean;
  22479. TONEMAPPING_ACES: boolean;
  22480. CONTRAST: boolean;
  22481. EXPOSURE: boolean;
  22482. COLORCURVES: boolean;
  22483. COLORGRADING: boolean;
  22484. COLORGRADING3D: boolean;
  22485. SAMPLER3DGREENDEPTH: boolean;
  22486. SAMPLER3DBGRMAP: boolean;
  22487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22488. /** MISC. */
  22489. BUMPDIRECTUV: number;
  22490. constructor();
  22491. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22492. }
  22493. /**
  22494. * Class used to configure NodeMaterial
  22495. */
  22496. export interface INodeMaterialOptions {
  22497. /**
  22498. * Defines if blocks should emit comments
  22499. */
  22500. emitComments: boolean;
  22501. }
  22502. /**
  22503. * Class used to create a node based material built by assembling shader blocks
  22504. */
  22505. export class NodeMaterial extends PushMaterial {
  22506. private static _BuildIdGenerator;
  22507. private _options;
  22508. private _vertexCompilationState;
  22509. private _fragmentCompilationState;
  22510. private _sharedData;
  22511. private _buildId;
  22512. private _buildWasSuccessful;
  22513. private _cachedWorldViewMatrix;
  22514. private _cachedWorldViewProjectionMatrix;
  22515. private _optimizers;
  22516. private _animationFrame;
  22517. /** Define the Url to load node editor script */
  22518. static EditorURL: string;
  22519. /** Define the Url to load snippets */
  22520. static SnippetUrl: string;
  22521. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22522. static IgnoreTexturesAtLoadTime: boolean;
  22523. private BJSNODEMATERIALEDITOR;
  22524. /** Get the inspector from bundle or global */
  22525. private _getGlobalNodeMaterialEditor;
  22526. /**
  22527. * Snippet ID if the material was created from the snippet server
  22528. */
  22529. snippetId: string;
  22530. /**
  22531. * Gets or sets data used by visual editor
  22532. * @see https://nme.babylonjs.com
  22533. */
  22534. editorData: any;
  22535. /**
  22536. * 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)
  22537. */
  22538. ignoreAlpha: boolean;
  22539. /**
  22540. * Defines the maximum number of lights that can be used in the material
  22541. */
  22542. maxSimultaneousLights: number;
  22543. /**
  22544. * Observable raised when the material is built
  22545. */
  22546. onBuildObservable: Observable<NodeMaterial>;
  22547. /**
  22548. * Gets or sets the root nodes of the material vertex shader
  22549. */
  22550. _vertexOutputNodes: NodeMaterialBlock[];
  22551. /**
  22552. * Gets or sets the root nodes of the material fragment (pixel) shader
  22553. */
  22554. _fragmentOutputNodes: NodeMaterialBlock[];
  22555. /** Gets or sets options to control the node material overall behavior */
  22556. get options(): INodeMaterialOptions;
  22557. set options(options: INodeMaterialOptions);
  22558. /**
  22559. * Default configuration related to image processing available in the standard Material.
  22560. */
  22561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22562. /**
  22563. * Gets the image processing configuration used either in this material.
  22564. */
  22565. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22566. /**
  22567. * Sets the Default image processing configuration used either in the this material.
  22568. *
  22569. * If sets to null, the scene one is in use.
  22570. */
  22571. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22572. /**
  22573. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22574. */
  22575. attachedBlocks: NodeMaterialBlock[];
  22576. /**
  22577. * Specifies the mode of the node material
  22578. * @hidden
  22579. */
  22580. _mode: NodeMaterialModes;
  22581. /**
  22582. * Gets the mode property
  22583. */
  22584. get mode(): NodeMaterialModes;
  22585. /**
  22586. * Create a new node based material
  22587. * @param name defines the material name
  22588. * @param scene defines the hosting scene
  22589. * @param options defines creation option
  22590. */
  22591. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22592. /**
  22593. * Gets the current class name of the material e.g. "NodeMaterial"
  22594. * @returns the class name
  22595. */
  22596. getClassName(): string;
  22597. /**
  22598. * Keep track of the image processing observer to allow dispose and replace.
  22599. */
  22600. private _imageProcessingObserver;
  22601. /**
  22602. * Attaches a new image processing configuration to the Standard Material.
  22603. * @param configuration
  22604. */
  22605. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22606. /**
  22607. * Get a block by its name
  22608. * @param name defines the name of the block to retrieve
  22609. * @returns the required block or null if not found
  22610. */
  22611. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22612. /**
  22613. * Get a block by its name
  22614. * @param predicate defines the predicate used to find the good candidate
  22615. * @returns the required block or null if not found
  22616. */
  22617. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22618. /**
  22619. * Get an input block by its name
  22620. * @param predicate defines the predicate used to find the good candidate
  22621. * @returns the required input block or null if not found
  22622. */
  22623. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22624. /**
  22625. * Gets the list of input blocks attached to this material
  22626. * @returns an array of InputBlocks
  22627. */
  22628. getInputBlocks(): InputBlock[];
  22629. /**
  22630. * Adds a new optimizer to the list of optimizers
  22631. * @param optimizer defines the optimizers to add
  22632. * @returns the current material
  22633. */
  22634. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22635. /**
  22636. * Remove an optimizer from the list of optimizers
  22637. * @param optimizer defines the optimizers to remove
  22638. * @returns the current material
  22639. */
  22640. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22641. /**
  22642. * Add a new block to the list of output nodes
  22643. * @param node defines the node to add
  22644. * @returns the current material
  22645. */
  22646. addOutputNode(node: NodeMaterialBlock): this;
  22647. /**
  22648. * Remove a block from the list of root nodes
  22649. * @param node defines the node to remove
  22650. * @returns the current material
  22651. */
  22652. removeOutputNode(node: NodeMaterialBlock): this;
  22653. private _addVertexOutputNode;
  22654. private _removeVertexOutputNode;
  22655. private _addFragmentOutputNode;
  22656. private _removeFragmentOutputNode;
  22657. /**
  22658. * Specifies if the material will require alpha blending
  22659. * @returns a boolean specifying if alpha blending is needed
  22660. */
  22661. needAlphaBlending(): boolean;
  22662. /**
  22663. * Specifies if this material should be rendered in alpha test mode
  22664. * @returns a boolean specifying if an alpha test is needed.
  22665. */
  22666. needAlphaTesting(): boolean;
  22667. private _initializeBlock;
  22668. private _resetDualBlocks;
  22669. /**
  22670. * Remove a block from the current node material
  22671. * @param block defines the block to remove
  22672. */
  22673. removeBlock(block: NodeMaterialBlock): void;
  22674. /**
  22675. * Build the material and generates the inner effect
  22676. * @param verbose defines if the build should log activity
  22677. */
  22678. build(verbose?: boolean): void;
  22679. /**
  22680. * Runs an otpimization phase to try to improve the shader code
  22681. */
  22682. optimize(): void;
  22683. private _prepareDefinesForAttributes;
  22684. /**
  22685. * Create a post process from the material
  22686. * @param camera The camera to apply the render pass to.
  22687. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22689. * @param engine The engine which the post process will be applied. (default: current engine)
  22690. * @param reusable If the post process can be reused on the same frame. (default: false)
  22691. * @param textureType Type of textures used when performing the post process. (default: 0)
  22692. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22693. * @returns the post process created
  22694. */
  22695. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22696. /**
  22697. * Create the post process effect from the material
  22698. * @param postProcess The post process to create the effect for
  22699. */
  22700. createEffectForPostProcess(postProcess: PostProcess): void;
  22701. private _createEffectForPostProcess;
  22702. /**
  22703. * Create a new procedural texture based on this node material
  22704. * @param size defines the size of the texture
  22705. * @param scene defines the hosting scene
  22706. * @returns the new procedural texture attached to this node material
  22707. */
  22708. createProceduralTexture(size: number | {
  22709. width: number;
  22710. height: number;
  22711. layers?: number;
  22712. }, scene: Scene): Nullable<ProceduralTexture>;
  22713. private _createEffectForParticles;
  22714. private _checkInternals;
  22715. /**
  22716. * Create the effect to be used as the custom effect for a particle system
  22717. * @param particleSystem Particle system to create the effect for
  22718. * @param onCompiled defines a function to call when the effect creation is successful
  22719. * @param onError defines a function to call when the effect creation has failed
  22720. */
  22721. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22722. private _processDefines;
  22723. /**
  22724. * Get if the submesh is ready to be used and all its information available.
  22725. * Child classes can use it to update shaders
  22726. * @param mesh defines the mesh to check
  22727. * @param subMesh defines which submesh to check
  22728. * @param useInstances specifies that instances should be used
  22729. * @returns a boolean indicating that the submesh is ready or not
  22730. */
  22731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22732. /**
  22733. * Get a string representing the shaders built by the current node graph
  22734. */
  22735. get compiledShaders(): string;
  22736. /**
  22737. * Binds the world matrix to the material
  22738. * @param world defines the world transformation matrix
  22739. */
  22740. bindOnlyWorldMatrix(world: Matrix): void;
  22741. /**
  22742. * Binds the submesh to this material by preparing the effect and shader to draw
  22743. * @param world defines the world transformation matrix
  22744. * @param mesh defines the mesh containing the submesh
  22745. * @param subMesh defines the submesh to bind the material to
  22746. */
  22747. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22748. /**
  22749. * Gets the active textures from the material
  22750. * @returns an array of textures
  22751. */
  22752. getActiveTextures(): BaseTexture[];
  22753. /**
  22754. * Gets the list of texture blocks
  22755. * @returns an array of texture blocks
  22756. */
  22757. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22758. /**
  22759. * Specifies if the material uses a texture
  22760. * @param texture defines the texture to check against the material
  22761. * @returns a boolean specifying if the material uses the texture
  22762. */
  22763. hasTexture(texture: BaseTexture): boolean;
  22764. /**
  22765. * Disposes the material
  22766. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22767. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22768. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22769. */
  22770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22771. /** Creates the node editor window. */
  22772. private _createNodeEditor;
  22773. /**
  22774. * Launch the node material editor
  22775. * @param config Define the configuration of the editor
  22776. * @return a promise fulfilled when the node editor is visible
  22777. */
  22778. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22779. /**
  22780. * Clear the current material
  22781. */
  22782. clear(): void;
  22783. /**
  22784. * Clear the current material and set it to a default state
  22785. */
  22786. setToDefault(): void;
  22787. /**
  22788. * Clear the current material and set it to a default state for post process
  22789. */
  22790. setToDefaultPostProcess(): void;
  22791. /**
  22792. * Clear the current material and set it to a default state for procedural texture
  22793. */
  22794. setToDefaultProceduralTexture(): void;
  22795. /**
  22796. * Clear the current material and set it to a default state for particle
  22797. */
  22798. setToDefaultParticle(): void;
  22799. /**
  22800. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22801. * @param url defines the url to load from
  22802. * @returns a promise that will fullfil when the material is fully loaded
  22803. */
  22804. loadAsync(url: string): Promise<void>;
  22805. private _gatherBlocks;
  22806. /**
  22807. * Generate a string containing the code declaration required to create an equivalent of this material
  22808. * @returns a string
  22809. */
  22810. generateCode(): string;
  22811. /**
  22812. * Serializes this material in a JSON representation
  22813. * @returns the serialized material object
  22814. */
  22815. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22816. private _restoreConnections;
  22817. /**
  22818. * Clear the current graph and load a new one from a serialization object
  22819. * @param source defines the JSON representation of the material
  22820. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22821. * @param merge defines whether or not the source must be merged or replace the current content
  22822. */
  22823. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22824. /**
  22825. * Makes a duplicate of the current material.
  22826. * @param name - name to use for the new material.
  22827. */
  22828. clone(name: string): NodeMaterial;
  22829. /**
  22830. * Creates a node material from parsed material data
  22831. * @param source defines the JSON representation of the material
  22832. * @param scene defines the hosting scene
  22833. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22834. * @returns a new node material
  22835. */
  22836. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22837. /**
  22838. * Creates a node material from a snippet saved in a remote file
  22839. * @param name defines the name of the material to create
  22840. * @param url defines the url to load from
  22841. * @param scene defines the hosting scene
  22842. * @returns a promise that will resolve to the new node material
  22843. */
  22844. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22845. /**
  22846. * Creates a node material from a snippet saved by the node material editor
  22847. * @param snippetId defines the snippet to load
  22848. * @param scene defines the hosting scene
  22849. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22850. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22851. * @returns a promise that will resolve to the new node material
  22852. */
  22853. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22854. /**
  22855. * Creates a new node material set to default basic configuration
  22856. * @param name defines the name of the material
  22857. * @param scene defines the hosting scene
  22858. * @returns a new NodeMaterial
  22859. */
  22860. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22861. }
  22862. }
  22863. declare module BABYLON {
  22864. interface ThinEngine {
  22865. /**
  22866. * Unbind a list of render target textures from the webGL context
  22867. * This is used only when drawBuffer extension or webGL2 are active
  22868. * @param textures defines the render target textures to unbind
  22869. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22870. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22871. */
  22872. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22873. /**
  22874. * Create a multi render target texture
  22875. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22876. * @param size defines the size of the texture
  22877. * @param options defines the creation options
  22878. * @returns the cube texture as an InternalTexture
  22879. */
  22880. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22881. /**
  22882. * Update the sample count for a given multiple render target texture
  22883. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22884. * @param textures defines the textures to update
  22885. * @param samples defines the sample count to set
  22886. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22887. */
  22888. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22889. /**
  22890. * Select a subsets of attachments to draw to.
  22891. * @param attachments gl attachments
  22892. */
  22893. bindAttachments(attachments: number[]): void;
  22894. /**
  22895. * Creates a layout object to draw/clear on specific textures in a MRT
  22896. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22897. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22898. */
  22899. buildTextureLayout(textureStatus: boolean[]): number[];
  22900. /**
  22901. * Restores the webgl state to only draw on the main color attachment
  22902. */
  22903. restoreSingleAttachment(): void;
  22904. }
  22905. }
  22906. declare module BABYLON {
  22907. /**
  22908. * Creation options of the multi render target texture.
  22909. */
  22910. export interface IMultiRenderTargetOptions {
  22911. /**
  22912. * Define if the texture needs to create mip maps after render.
  22913. */
  22914. generateMipMaps?: boolean;
  22915. /**
  22916. * Define the types of all the draw buffers we want to create
  22917. */
  22918. types?: number[];
  22919. /**
  22920. * Define the sampling modes of all the draw buffers we want to create
  22921. */
  22922. samplingModes?: number[];
  22923. /**
  22924. * Define if a depth buffer is required
  22925. */
  22926. generateDepthBuffer?: boolean;
  22927. /**
  22928. * Define if a stencil buffer is required
  22929. */
  22930. generateStencilBuffer?: boolean;
  22931. /**
  22932. * Define if a depth texture is required instead of a depth buffer
  22933. */
  22934. generateDepthTexture?: boolean;
  22935. /**
  22936. * Define the number of desired draw buffers
  22937. */
  22938. textureCount?: number;
  22939. /**
  22940. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22941. */
  22942. doNotChangeAspectRatio?: boolean;
  22943. /**
  22944. * Define the default type of the buffers we are creating
  22945. */
  22946. defaultType?: number;
  22947. }
  22948. /**
  22949. * A multi render target, like a render target provides the ability to render to a texture.
  22950. * Unlike the render target, it can render to several draw buffers in one draw.
  22951. * This is specially interesting in deferred rendering or for any effects requiring more than
  22952. * just one color from a single pass.
  22953. */
  22954. export class MultiRenderTarget extends RenderTargetTexture {
  22955. private _internalTextures;
  22956. private _textures;
  22957. private _multiRenderTargetOptions;
  22958. private _count;
  22959. /**
  22960. * Get if draw buffers are currently supported by the used hardware and browser.
  22961. */
  22962. get isSupported(): boolean;
  22963. /**
  22964. * Get the list of textures generated by the multi render target.
  22965. */
  22966. get textures(): Texture[];
  22967. /**
  22968. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22969. */
  22970. get count(): number;
  22971. /**
  22972. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22973. */
  22974. get depthTexture(): Texture;
  22975. /**
  22976. * Set the wrapping mode on U of all the textures we are rendering to.
  22977. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22978. */
  22979. set wrapU(wrap: number);
  22980. /**
  22981. * Set the wrapping mode on V of all the textures we are rendering to.
  22982. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22983. */
  22984. set wrapV(wrap: number);
  22985. /**
  22986. * Instantiate a new multi render target texture.
  22987. * A multi render target, like a render target provides the ability to render to a texture.
  22988. * Unlike the render target, it can render to several draw buffers in one draw.
  22989. * This is specially interesting in deferred rendering or for any effects requiring more than
  22990. * just one color from a single pass.
  22991. * @param name Define the name of the texture
  22992. * @param size Define the size of the buffers to render to
  22993. * @param count Define the number of target we are rendering into
  22994. * @param scene Define the scene the texture belongs to
  22995. * @param options Define the options used to create the multi render target
  22996. */
  22997. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22998. private _initTypes;
  22999. /** @hidden */
  23000. _rebuild(forceFullRebuild?: boolean): void;
  23001. private _createInternalTextures;
  23002. private _createTextures;
  23003. /**
  23004. * Replaces a texture within the MRT.
  23005. * @param texture The new texture to insert in the MRT
  23006. * @param index The index of the texture to replace
  23007. */
  23008. replaceTexture(texture: Texture, index: number): void;
  23009. /**
  23010. * Define the number of samples used if MSAA is enabled.
  23011. */
  23012. get samples(): number;
  23013. set samples(value: number);
  23014. /**
  23015. * Resize all the textures in the multi render target.
  23016. * Be careful as it will recreate all the data in the new texture.
  23017. * @param size Define the new size
  23018. */
  23019. resize(size: any): void;
  23020. /**
  23021. * Changes the number of render targets in this MRT
  23022. * Be careful as it will recreate all the data in the new texture.
  23023. * @param count new texture count
  23024. * @param options Specifies texture types and sampling modes for new textures
  23025. */
  23026. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23028. /**
  23029. * Dispose the render targets and their associated resources
  23030. */
  23031. dispose(): void;
  23032. /**
  23033. * Release all the underlying texture used as draw buffers.
  23034. */
  23035. releaseInternalTextures(): void;
  23036. }
  23037. }
  23038. declare module BABYLON {
  23039. /** @hidden */
  23040. export var imageProcessingPixelShader: {
  23041. name: string;
  23042. shader: string;
  23043. };
  23044. }
  23045. declare module BABYLON {
  23046. /**
  23047. * ImageProcessingPostProcess
  23048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23049. */
  23050. export class ImageProcessingPostProcess extends PostProcess {
  23051. /**
  23052. * Default configuration related to image processing available in the PBR Material.
  23053. */
  23054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23055. /**
  23056. * Gets the image processing configuration used either in this material.
  23057. */
  23058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23059. /**
  23060. * Sets the Default image processing configuration used either in the this material.
  23061. *
  23062. * If sets to null, the scene one is in use.
  23063. */
  23064. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23065. /**
  23066. * Keep track of the image processing observer to allow dispose and replace.
  23067. */
  23068. private _imageProcessingObserver;
  23069. /**
  23070. * Attaches a new image processing configuration to the PBR Material.
  23071. * @param configuration
  23072. */
  23073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23074. /**
  23075. * If the post process is supported.
  23076. */
  23077. get isSupported(): boolean;
  23078. /**
  23079. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23080. */
  23081. get colorCurves(): Nullable<ColorCurves>;
  23082. /**
  23083. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23084. */
  23085. set colorCurves(value: Nullable<ColorCurves>);
  23086. /**
  23087. * Gets wether the color curves effect is enabled.
  23088. */
  23089. get colorCurvesEnabled(): boolean;
  23090. /**
  23091. * Sets wether the color curves effect is enabled.
  23092. */
  23093. set colorCurvesEnabled(value: boolean);
  23094. /**
  23095. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23096. */
  23097. get colorGradingTexture(): Nullable<BaseTexture>;
  23098. /**
  23099. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23100. */
  23101. set colorGradingTexture(value: Nullable<BaseTexture>);
  23102. /**
  23103. * Gets wether the color grading effect is enabled.
  23104. */
  23105. get colorGradingEnabled(): boolean;
  23106. /**
  23107. * Gets wether the color grading effect is enabled.
  23108. */
  23109. set colorGradingEnabled(value: boolean);
  23110. /**
  23111. * Gets exposure used in the effect.
  23112. */
  23113. get exposure(): number;
  23114. /**
  23115. * Sets exposure used in the effect.
  23116. */
  23117. set exposure(value: number);
  23118. /**
  23119. * Gets wether tonemapping is enabled or not.
  23120. */
  23121. get toneMappingEnabled(): boolean;
  23122. /**
  23123. * Sets wether tonemapping is enabled or not
  23124. */
  23125. set toneMappingEnabled(value: boolean);
  23126. /**
  23127. * Gets the type of tone mapping effect.
  23128. */
  23129. get toneMappingType(): number;
  23130. /**
  23131. * Sets the type of tone mapping effect.
  23132. */
  23133. set toneMappingType(value: number);
  23134. /**
  23135. * Gets contrast used in the effect.
  23136. */
  23137. get contrast(): number;
  23138. /**
  23139. * Sets contrast used in the effect.
  23140. */
  23141. set contrast(value: number);
  23142. /**
  23143. * Gets Vignette stretch size.
  23144. */
  23145. get vignetteStretch(): number;
  23146. /**
  23147. * Sets Vignette stretch size.
  23148. */
  23149. set vignetteStretch(value: number);
  23150. /**
  23151. * Gets Vignette centre X Offset.
  23152. */
  23153. get vignetteCentreX(): number;
  23154. /**
  23155. * Sets Vignette centre X Offset.
  23156. */
  23157. set vignetteCentreX(value: number);
  23158. /**
  23159. * Gets Vignette centre Y Offset.
  23160. */
  23161. get vignetteCentreY(): number;
  23162. /**
  23163. * Sets Vignette centre Y Offset.
  23164. */
  23165. set vignetteCentreY(value: number);
  23166. /**
  23167. * Gets Vignette weight or intensity of the vignette effect.
  23168. */
  23169. get vignetteWeight(): number;
  23170. /**
  23171. * Sets Vignette weight or intensity of the vignette effect.
  23172. */
  23173. set vignetteWeight(value: number);
  23174. /**
  23175. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23176. * if vignetteEnabled is set to true.
  23177. */
  23178. get vignetteColor(): Color4;
  23179. /**
  23180. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23181. * if vignetteEnabled is set to true.
  23182. */
  23183. set vignetteColor(value: Color4);
  23184. /**
  23185. * Gets Camera field of view used by the Vignette effect.
  23186. */
  23187. get vignetteCameraFov(): number;
  23188. /**
  23189. * Sets Camera field of view used by the Vignette effect.
  23190. */
  23191. set vignetteCameraFov(value: number);
  23192. /**
  23193. * Gets the vignette blend mode allowing different kind of effect.
  23194. */
  23195. get vignetteBlendMode(): number;
  23196. /**
  23197. * Sets the vignette blend mode allowing different kind of effect.
  23198. */
  23199. set vignetteBlendMode(value: number);
  23200. /**
  23201. * Gets wether the vignette effect is enabled.
  23202. */
  23203. get vignetteEnabled(): boolean;
  23204. /**
  23205. * Sets wether the vignette effect is enabled.
  23206. */
  23207. set vignetteEnabled(value: boolean);
  23208. private _fromLinearSpace;
  23209. /**
  23210. * Gets wether the input of the processing is in Gamma or Linear Space.
  23211. */
  23212. get fromLinearSpace(): boolean;
  23213. /**
  23214. * Sets wether the input of the processing is in Gamma or Linear Space.
  23215. */
  23216. set fromLinearSpace(value: boolean);
  23217. /**
  23218. * Defines cache preventing GC.
  23219. */
  23220. private _defines;
  23221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23222. /**
  23223. * "ImageProcessingPostProcess"
  23224. * @returns "ImageProcessingPostProcess"
  23225. */
  23226. getClassName(): string;
  23227. /**
  23228. * @hidden
  23229. */
  23230. _updateParameters(): void;
  23231. dispose(camera?: Camera): void;
  23232. }
  23233. }
  23234. declare module BABYLON {
  23235. /**
  23236. * Interface for defining prepass effects in the prepass post-process pipeline
  23237. */
  23238. export interface PrePassEffectConfiguration {
  23239. /**
  23240. * Name of the effect
  23241. */
  23242. name: string;
  23243. /**
  23244. * Post process to attach for this effect
  23245. */
  23246. postProcess?: PostProcess;
  23247. /**
  23248. * Textures required in the MRT
  23249. */
  23250. texturesRequired: number[];
  23251. /**
  23252. * Is the effect enabled
  23253. */
  23254. enabled: boolean;
  23255. /**
  23256. * Disposes the effect configuration
  23257. */
  23258. dispose?: () => void;
  23259. /**
  23260. * Creates the associated post process
  23261. */
  23262. createPostProcess?: () => PostProcess;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * Options to be used when creating a FresnelParameters.
  23268. */
  23269. export type IFresnelParametersCreationOptions = {
  23270. /**
  23271. * Define the color used on edges (grazing angle)
  23272. */
  23273. leftColor?: Color3;
  23274. /**
  23275. * Define the color used on center
  23276. */
  23277. rightColor?: Color3;
  23278. /**
  23279. * Define bias applied to computed fresnel term
  23280. */
  23281. bias?: number;
  23282. /**
  23283. * Defined the power exponent applied to fresnel term
  23284. */
  23285. power?: number;
  23286. /**
  23287. * Define if the fresnel effect is enable or not.
  23288. */
  23289. isEnabled?: boolean;
  23290. };
  23291. /**
  23292. * Serialized format for FresnelParameters.
  23293. */
  23294. export type IFresnelParametersSerialized = {
  23295. /**
  23296. * Define the color used on edges (grazing angle) [as an array]
  23297. */
  23298. leftColor: number[];
  23299. /**
  23300. * Define the color used on center [as an array]
  23301. */
  23302. rightColor: number[];
  23303. /**
  23304. * Define bias applied to computed fresnel term
  23305. */
  23306. bias: number;
  23307. /**
  23308. * Defined the power exponent applied to fresnel term
  23309. */
  23310. power?: number;
  23311. /**
  23312. * Define if the fresnel effect is enable or not.
  23313. */
  23314. isEnabled: boolean;
  23315. };
  23316. /**
  23317. * This represents all the required information to add a fresnel effect on a material:
  23318. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23319. */
  23320. export class FresnelParameters {
  23321. private _isEnabled;
  23322. /**
  23323. * Define if the fresnel effect is enable or not.
  23324. */
  23325. get isEnabled(): boolean;
  23326. set isEnabled(value: boolean);
  23327. /**
  23328. * Define the color used on edges (grazing angle)
  23329. */
  23330. leftColor: Color3;
  23331. /**
  23332. * Define the color used on center
  23333. */
  23334. rightColor: Color3;
  23335. /**
  23336. * Define bias applied to computed fresnel term
  23337. */
  23338. bias: number;
  23339. /**
  23340. * Defined the power exponent applied to fresnel term
  23341. */
  23342. power: number;
  23343. /**
  23344. * Creates a new FresnelParameters object.
  23345. *
  23346. * @param options provide your own settings to optionally to override defaults
  23347. */
  23348. constructor(options?: IFresnelParametersCreationOptions);
  23349. /**
  23350. * Clones the current fresnel and its valuues
  23351. * @returns a clone fresnel configuration
  23352. */
  23353. clone(): FresnelParameters;
  23354. /**
  23355. * Determines equality between FresnelParameters objects
  23356. * @param otherFresnelParameters defines the second operand
  23357. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23358. */
  23359. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23360. /**
  23361. * Serializes the current fresnel parameters to a JSON representation.
  23362. * @return the JSON serialization
  23363. */
  23364. serialize(): IFresnelParametersSerialized;
  23365. /**
  23366. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23367. * @param parsedFresnelParameters Define the JSON representation
  23368. * @returns the parsed parameters
  23369. */
  23370. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23371. }
  23372. }
  23373. declare module BABYLON {
  23374. /**
  23375. * This groups all the flags used to control the materials channel.
  23376. */
  23377. export class MaterialFlags {
  23378. private static _DiffuseTextureEnabled;
  23379. /**
  23380. * Are diffuse textures enabled in the application.
  23381. */
  23382. static get DiffuseTextureEnabled(): boolean;
  23383. static set DiffuseTextureEnabled(value: boolean);
  23384. private static _DetailTextureEnabled;
  23385. /**
  23386. * Are detail textures enabled in the application.
  23387. */
  23388. static get DetailTextureEnabled(): boolean;
  23389. static set DetailTextureEnabled(value: boolean);
  23390. private static _AmbientTextureEnabled;
  23391. /**
  23392. * Are ambient textures enabled in the application.
  23393. */
  23394. static get AmbientTextureEnabled(): boolean;
  23395. static set AmbientTextureEnabled(value: boolean);
  23396. private static _OpacityTextureEnabled;
  23397. /**
  23398. * Are opacity textures enabled in the application.
  23399. */
  23400. static get OpacityTextureEnabled(): boolean;
  23401. static set OpacityTextureEnabled(value: boolean);
  23402. private static _ReflectionTextureEnabled;
  23403. /**
  23404. * Are reflection textures enabled in the application.
  23405. */
  23406. static get ReflectionTextureEnabled(): boolean;
  23407. static set ReflectionTextureEnabled(value: boolean);
  23408. private static _EmissiveTextureEnabled;
  23409. /**
  23410. * Are emissive textures enabled in the application.
  23411. */
  23412. static get EmissiveTextureEnabled(): boolean;
  23413. static set EmissiveTextureEnabled(value: boolean);
  23414. private static _SpecularTextureEnabled;
  23415. /**
  23416. * Are specular textures enabled in the application.
  23417. */
  23418. static get SpecularTextureEnabled(): boolean;
  23419. static set SpecularTextureEnabled(value: boolean);
  23420. private static _BumpTextureEnabled;
  23421. /**
  23422. * Are bump textures enabled in the application.
  23423. */
  23424. static get BumpTextureEnabled(): boolean;
  23425. static set BumpTextureEnabled(value: boolean);
  23426. private static _LightmapTextureEnabled;
  23427. /**
  23428. * Are lightmap textures enabled in the application.
  23429. */
  23430. static get LightmapTextureEnabled(): boolean;
  23431. static set LightmapTextureEnabled(value: boolean);
  23432. private static _RefractionTextureEnabled;
  23433. /**
  23434. * Are refraction textures enabled in the application.
  23435. */
  23436. static get RefractionTextureEnabled(): boolean;
  23437. static set RefractionTextureEnabled(value: boolean);
  23438. private static _ColorGradingTextureEnabled;
  23439. /**
  23440. * Are color grading textures enabled in the application.
  23441. */
  23442. static get ColorGradingTextureEnabled(): boolean;
  23443. static set ColorGradingTextureEnabled(value: boolean);
  23444. private static _FresnelEnabled;
  23445. /**
  23446. * Are fresnels enabled in the application.
  23447. */
  23448. static get FresnelEnabled(): boolean;
  23449. static set FresnelEnabled(value: boolean);
  23450. private static _ClearCoatTextureEnabled;
  23451. /**
  23452. * Are clear coat textures enabled in the application.
  23453. */
  23454. static get ClearCoatTextureEnabled(): boolean;
  23455. static set ClearCoatTextureEnabled(value: boolean);
  23456. private static _ClearCoatBumpTextureEnabled;
  23457. /**
  23458. * Are clear coat bump textures enabled in the application.
  23459. */
  23460. static get ClearCoatBumpTextureEnabled(): boolean;
  23461. static set ClearCoatBumpTextureEnabled(value: boolean);
  23462. private static _ClearCoatTintTextureEnabled;
  23463. /**
  23464. * Are clear coat tint textures enabled in the application.
  23465. */
  23466. static get ClearCoatTintTextureEnabled(): boolean;
  23467. static set ClearCoatTintTextureEnabled(value: boolean);
  23468. private static _SheenTextureEnabled;
  23469. /**
  23470. * Are sheen textures enabled in the application.
  23471. */
  23472. static get SheenTextureEnabled(): boolean;
  23473. static set SheenTextureEnabled(value: boolean);
  23474. private static _AnisotropicTextureEnabled;
  23475. /**
  23476. * Are anisotropic textures enabled in the application.
  23477. */
  23478. static get AnisotropicTextureEnabled(): boolean;
  23479. static set AnisotropicTextureEnabled(value: boolean);
  23480. private static _ThicknessTextureEnabled;
  23481. /**
  23482. * Are thickness textures enabled in the application.
  23483. */
  23484. static get ThicknessTextureEnabled(): boolean;
  23485. static set ThicknessTextureEnabled(value: boolean);
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /** @hidden */
  23490. export var defaultFragmentDeclaration: {
  23491. name: string;
  23492. shader: string;
  23493. };
  23494. }
  23495. declare module BABYLON {
  23496. /** @hidden */
  23497. export var defaultUboDeclaration: {
  23498. name: string;
  23499. shader: string;
  23500. };
  23501. }
  23502. declare module BABYLON {
  23503. /** @hidden */
  23504. export var prePassDeclaration: {
  23505. name: string;
  23506. shader: string;
  23507. };
  23508. }
  23509. declare module BABYLON {
  23510. /** @hidden */
  23511. export var lightFragmentDeclaration: {
  23512. name: string;
  23513. shader: string;
  23514. };
  23515. }
  23516. declare module BABYLON {
  23517. /** @hidden */
  23518. export var lightUboDeclaration: {
  23519. name: string;
  23520. shader: string;
  23521. };
  23522. }
  23523. declare module BABYLON {
  23524. /** @hidden */
  23525. export var lightsFragmentFunctions: {
  23526. name: string;
  23527. shader: string;
  23528. };
  23529. }
  23530. declare module BABYLON {
  23531. /** @hidden */
  23532. export var shadowsFragmentFunctions: {
  23533. name: string;
  23534. shader: string;
  23535. };
  23536. }
  23537. declare module BABYLON {
  23538. /** @hidden */
  23539. export var fresnelFunction: {
  23540. name: string;
  23541. shader: string;
  23542. };
  23543. }
  23544. declare module BABYLON {
  23545. /** @hidden */
  23546. export var bumpFragmentMainFunctions: {
  23547. name: string;
  23548. shader: string;
  23549. };
  23550. }
  23551. declare module BABYLON {
  23552. /** @hidden */
  23553. export var bumpFragmentFunctions: {
  23554. name: string;
  23555. shader: string;
  23556. };
  23557. }
  23558. declare module BABYLON {
  23559. /** @hidden */
  23560. export var logDepthDeclaration: {
  23561. name: string;
  23562. shader: string;
  23563. };
  23564. }
  23565. declare module BABYLON {
  23566. /** @hidden */
  23567. export var bumpFragment: {
  23568. name: string;
  23569. shader: string;
  23570. };
  23571. }
  23572. declare module BABYLON {
  23573. /** @hidden */
  23574. export var depthPrePass: {
  23575. name: string;
  23576. shader: string;
  23577. };
  23578. }
  23579. declare module BABYLON {
  23580. /** @hidden */
  23581. export var lightFragment: {
  23582. name: string;
  23583. shader: string;
  23584. };
  23585. }
  23586. declare module BABYLON {
  23587. /** @hidden */
  23588. export var logDepthFragment: {
  23589. name: string;
  23590. shader: string;
  23591. };
  23592. }
  23593. declare module BABYLON {
  23594. /** @hidden */
  23595. export var defaultPixelShader: {
  23596. name: string;
  23597. shader: string;
  23598. };
  23599. }
  23600. declare module BABYLON {
  23601. /** @hidden */
  23602. export var defaultVertexDeclaration: {
  23603. name: string;
  23604. shader: string;
  23605. };
  23606. }
  23607. declare module BABYLON {
  23608. /** @hidden */
  23609. export var prePassVertexDeclaration: {
  23610. name: string;
  23611. shader: string;
  23612. };
  23613. }
  23614. declare module BABYLON {
  23615. /** @hidden */
  23616. export var bumpVertexDeclaration: {
  23617. name: string;
  23618. shader: string;
  23619. };
  23620. }
  23621. declare module BABYLON {
  23622. /** @hidden */
  23623. export var prePassVertex: {
  23624. name: string;
  23625. shader: string;
  23626. };
  23627. }
  23628. declare module BABYLON {
  23629. /** @hidden */
  23630. export var bumpVertex: {
  23631. name: string;
  23632. shader: string;
  23633. };
  23634. }
  23635. declare module BABYLON {
  23636. /** @hidden */
  23637. export var fogVertex: {
  23638. name: string;
  23639. shader: string;
  23640. };
  23641. }
  23642. declare module BABYLON {
  23643. /** @hidden */
  23644. export var shadowsVertex: {
  23645. name: string;
  23646. shader: string;
  23647. };
  23648. }
  23649. declare module BABYLON {
  23650. /** @hidden */
  23651. export var pointCloudVertex: {
  23652. name: string;
  23653. shader: string;
  23654. };
  23655. }
  23656. declare module BABYLON {
  23657. /** @hidden */
  23658. export var logDepthVertex: {
  23659. name: string;
  23660. shader: string;
  23661. };
  23662. }
  23663. declare module BABYLON {
  23664. /** @hidden */
  23665. export var defaultVertexShader: {
  23666. name: string;
  23667. shader: string;
  23668. };
  23669. }
  23670. declare module BABYLON {
  23671. /**
  23672. * @hidden
  23673. */
  23674. export interface IMaterialDetailMapDefines {
  23675. DETAIL: boolean;
  23676. DETAILDIRECTUV: number;
  23677. DETAIL_NORMALBLENDMETHOD: number;
  23678. /** @hidden */
  23679. _areTexturesDirty: boolean;
  23680. }
  23681. /**
  23682. * Define the code related to the detail map parameters of a material
  23683. *
  23684. * Inspired from:
  23685. * 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
  23686. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23687. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23688. */
  23689. export class DetailMapConfiguration {
  23690. private _texture;
  23691. /**
  23692. * The detail texture of the material.
  23693. */
  23694. texture: Nullable<BaseTexture>;
  23695. /**
  23696. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23697. * Bigger values mean stronger blending
  23698. */
  23699. diffuseBlendLevel: number;
  23700. /**
  23701. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23702. * Bigger values mean stronger blending. Only used with PBR materials
  23703. */
  23704. roughnessBlendLevel: number;
  23705. /**
  23706. * Defines how strong the bump effect from the detail map is
  23707. * Bigger values mean stronger effect
  23708. */
  23709. bumpLevel: number;
  23710. private _normalBlendMethod;
  23711. /**
  23712. * The method used to blend the bump and detail normals together
  23713. */
  23714. normalBlendMethod: number;
  23715. private _isEnabled;
  23716. /**
  23717. * Enable or disable the detail map on this material
  23718. */
  23719. isEnabled: boolean;
  23720. /** @hidden */
  23721. private _internalMarkAllSubMeshesAsTexturesDirty;
  23722. /** @hidden */
  23723. _markAllSubMeshesAsTexturesDirty(): void;
  23724. /**
  23725. * Instantiate a new detail map
  23726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23727. */
  23728. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23729. /**
  23730. * Gets whether the submesh is ready to be used or not.
  23731. * @param defines the list of "defines" to update.
  23732. * @param scene defines the scene the material belongs to.
  23733. * @returns - boolean indicating that the submesh is ready or not.
  23734. */
  23735. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23736. /**
  23737. * Update the defines for detail map usage
  23738. * @param defines the list of "defines" to update.
  23739. * @param scene defines the scene the material belongs to.
  23740. */
  23741. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23742. /**
  23743. * Binds the material data.
  23744. * @param uniformBuffer defines the Uniform buffer to fill in.
  23745. * @param scene defines the scene the material belongs to.
  23746. * @param isFrozen defines whether the material is frozen or not.
  23747. */
  23748. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23749. /**
  23750. * Checks to see if a texture is used in the material.
  23751. * @param texture - Base texture to use.
  23752. * @returns - Boolean specifying if a texture is used in the material.
  23753. */
  23754. hasTexture(texture: BaseTexture): boolean;
  23755. /**
  23756. * Returns an array of the actively used textures.
  23757. * @param activeTextures Array of BaseTextures
  23758. */
  23759. getActiveTextures(activeTextures: BaseTexture[]): void;
  23760. /**
  23761. * Returns the animatable textures.
  23762. * @param animatables Array of animatable textures.
  23763. */
  23764. getAnimatables(animatables: IAnimatable[]): void;
  23765. /**
  23766. * Disposes the resources of the material.
  23767. * @param forceDisposeTextures - Forces the disposal of all textures.
  23768. */
  23769. dispose(forceDisposeTextures?: boolean): void;
  23770. /**
  23771. * Get the current class name useful for serialization or dynamic coding.
  23772. * @returns "DetailMap"
  23773. */
  23774. getClassName(): string;
  23775. /**
  23776. * Add the required uniforms to the current list.
  23777. * @param uniforms defines the current uniform list.
  23778. */
  23779. static AddUniforms(uniforms: string[]): void;
  23780. /**
  23781. * Add the required samplers to the current list.
  23782. * @param samplers defines the current sampler list.
  23783. */
  23784. static AddSamplers(samplers: string[]): void;
  23785. /**
  23786. * Add the required uniforms to the current buffer.
  23787. * @param uniformBuffer defines the current uniform buffer.
  23788. */
  23789. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23790. /**
  23791. * Makes a duplicate of the current instance into another one.
  23792. * @param detailMap define the instance where to copy the info
  23793. */
  23794. copyTo(detailMap: DetailMapConfiguration): void;
  23795. /**
  23796. * Serializes this detail map instance
  23797. * @returns - An object with the serialized instance.
  23798. */
  23799. serialize(): any;
  23800. /**
  23801. * Parses a detail map setting from a serialized object.
  23802. * @param source - Serialized object.
  23803. * @param scene Defines the scene we are parsing for
  23804. * @param rootUrl Defines the rootUrl to load from
  23805. */
  23806. parse(source: any, scene: Scene, rootUrl: string): void;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /** @hidden */
  23811. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23812. MAINUV1: boolean;
  23813. MAINUV2: boolean;
  23814. DIFFUSE: boolean;
  23815. DIFFUSEDIRECTUV: number;
  23816. DETAIL: boolean;
  23817. DETAILDIRECTUV: number;
  23818. DETAIL_NORMALBLENDMETHOD: number;
  23819. AMBIENT: boolean;
  23820. AMBIENTDIRECTUV: number;
  23821. OPACITY: boolean;
  23822. OPACITYDIRECTUV: number;
  23823. OPACITYRGB: boolean;
  23824. REFLECTION: boolean;
  23825. EMISSIVE: boolean;
  23826. EMISSIVEDIRECTUV: number;
  23827. SPECULAR: boolean;
  23828. SPECULARDIRECTUV: number;
  23829. BUMP: boolean;
  23830. BUMPDIRECTUV: number;
  23831. PARALLAX: boolean;
  23832. PARALLAXOCCLUSION: boolean;
  23833. SPECULAROVERALPHA: boolean;
  23834. CLIPPLANE: boolean;
  23835. CLIPPLANE2: boolean;
  23836. CLIPPLANE3: boolean;
  23837. CLIPPLANE4: boolean;
  23838. CLIPPLANE5: boolean;
  23839. CLIPPLANE6: boolean;
  23840. ALPHATEST: boolean;
  23841. DEPTHPREPASS: boolean;
  23842. ALPHAFROMDIFFUSE: boolean;
  23843. POINTSIZE: boolean;
  23844. FOG: boolean;
  23845. SPECULARTERM: boolean;
  23846. DIFFUSEFRESNEL: boolean;
  23847. OPACITYFRESNEL: boolean;
  23848. REFLECTIONFRESNEL: boolean;
  23849. REFRACTIONFRESNEL: boolean;
  23850. EMISSIVEFRESNEL: boolean;
  23851. FRESNEL: boolean;
  23852. NORMAL: boolean;
  23853. UV1: boolean;
  23854. UV2: boolean;
  23855. VERTEXCOLOR: boolean;
  23856. VERTEXALPHA: boolean;
  23857. NUM_BONE_INFLUENCERS: number;
  23858. BonesPerMesh: number;
  23859. BONETEXTURE: boolean;
  23860. BONES_VELOCITY_ENABLED: boolean;
  23861. INSTANCES: boolean;
  23862. THIN_INSTANCES: boolean;
  23863. GLOSSINESS: boolean;
  23864. ROUGHNESS: boolean;
  23865. EMISSIVEASILLUMINATION: boolean;
  23866. LINKEMISSIVEWITHDIFFUSE: boolean;
  23867. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23868. LIGHTMAP: boolean;
  23869. LIGHTMAPDIRECTUV: number;
  23870. OBJECTSPACE_NORMALMAP: boolean;
  23871. USELIGHTMAPASSHADOWMAP: boolean;
  23872. REFLECTIONMAP_3D: boolean;
  23873. REFLECTIONMAP_SPHERICAL: boolean;
  23874. REFLECTIONMAP_PLANAR: boolean;
  23875. REFLECTIONMAP_CUBIC: boolean;
  23876. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23877. REFLECTIONMAP_PROJECTION: boolean;
  23878. REFLECTIONMAP_SKYBOX: boolean;
  23879. REFLECTIONMAP_EXPLICIT: boolean;
  23880. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23881. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23882. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23883. INVERTCUBICMAP: boolean;
  23884. LOGARITHMICDEPTH: boolean;
  23885. REFRACTION: boolean;
  23886. REFRACTIONMAP_3D: boolean;
  23887. REFLECTIONOVERALPHA: boolean;
  23888. TWOSIDEDLIGHTING: boolean;
  23889. SHADOWFLOAT: boolean;
  23890. MORPHTARGETS: boolean;
  23891. MORPHTARGETS_NORMAL: boolean;
  23892. MORPHTARGETS_TANGENT: boolean;
  23893. MORPHTARGETS_UV: boolean;
  23894. NUM_MORPH_INFLUENCERS: number;
  23895. NONUNIFORMSCALING: boolean;
  23896. PREMULTIPLYALPHA: boolean;
  23897. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23898. ALPHABLEND: boolean;
  23899. PREPASS: boolean;
  23900. PREPASS_IRRADIANCE: boolean;
  23901. PREPASS_IRRADIANCE_INDEX: number;
  23902. PREPASS_ALBEDO: boolean;
  23903. PREPASS_ALBEDO_INDEX: number;
  23904. PREPASS_DEPTHNORMAL: boolean;
  23905. PREPASS_DEPTHNORMAL_INDEX: number;
  23906. PREPASS_POSITION: boolean;
  23907. PREPASS_POSITION_INDEX: number;
  23908. PREPASS_VELOCITY: boolean;
  23909. PREPASS_VELOCITY_INDEX: number;
  23910. PREPASS_REFLECTIVITY: boolean;
  23911. PREPASS_REFLECTIVITY_INDEX: number;
  23912. SCENE_MRT_COUNT: number;
  23913. RGBDLIGHTMAP: boolean;
  23914. RGBDREFLECTION: boolean;
  23915. RGBDREFRACTION: boolean;
  23916. IMAGEPROCESSING: boolean;
  23917. VIGNETTE: boolean;
  23918. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23919. VIGNETTEBLENDMODEOPAQUE: boolean;
  23920. TONEMAPPING: boolean;
  23921. TONEMAPPING_ACES: boolean;
  23922. CONTRAST: boolean;
  23923. COLORCURVES: boolean;
  23924. COLORGRADING: boolean;
  23925. COLORGRADING3D: boolean;
  23926. SAMPLER3DGREENDEPTH: boolean;
  23927. SAMPLER3DBGRMAP: boolean;
  23928. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23929. MULTIVIEW: boolean;
  23930. /**
  23931. * If the reflection texture on this material is in linear color space
  23932. * @hidden
  23933. */
  23934. IS_REFLECTION_LINEAR: boolean;
  23935. /**
  23936. * If the refraction texture on this material is in linear color space
  23937. * @hidden
  23938. */
  23939. IS_REFRACTION_LINEAR: boolean;
  23940. EXPOSURE: boolean;
  23941. constructor();
  23942. setReflectionMode(modeToEnable: string): void;
  23943. }
  23944. /**
  23945. * This is the default material used in Babylon. It is the best trade off between quality
  23946. * and performances.
  23947. * @see https://doc.babylonjs.com/babylon101/materials
  23948. */
  23949. export class StandardMaterial extends PushMaterial {
  23950. private _diffuseTexture;
  23951. /**
  23952. * The basic texture of the material as viewed under a light.
  23953. */
  23954. diffuseTexture: Nullable<BaseTexture>;
  23955. private _ambientTexture;
  23956. /**
  23957. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23958. */
  23959. ambientTexture: Nullable<BaseTexture>;
  23960. private _opacityTexture;
  23961. /**
  23962. * Define the transparency of the material from a texture.
  23963. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23964. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23965. */
  23966. opacityTexture: Nullable<BaseTexture>;
  23967. private _reflectionTexture;
  23968. /**
  23969. * Define the texture used to display the reflection.
  23970. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23971. */
  23972. reflectionTexture: Nullable<BaseTexture>;
  23973. private _emissiveTexture;
  23974. /**
  23975. * Define texture of the material as if self lit.
  23976. * This will be mixed in the final result even in the absence of light.
  23977. */
  23978. emissiveTexture: Nullable<BaseTexture>;
  23979. private _specularTexture;
  23980. /**
  23981. * Define how the color and intensity of the highlight given by the light in the material.
  23982. */
  23983. specularTexture: Nullable<BaseTexture>;
  23984. private _bumpTexture;
  23985. /**
  23986. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23987. * 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.
  23988. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23989. */
  23990. bumpTexture: Nullable<BaseTexture>;
  23991. private _lightmapTexture;
  23992. /**
  23993. * Complex lighting can be computationally expensive to compute at runtime.
  23994. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23995. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23996. */
  23997. lightmapTexture: Nullable<BaseTexture>;
  23998. private _refractionTexture;
  23999. /**
  24000. * Define the texture used to display the refraction.
  24001. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24002. */
  24003. refractionTexture: Nullable<BaseTexture>;
  24004. /**
  24005. * The color of the material lit by the environmental background lighting.
  24006. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24007. */
  24008. ambientColor: Color3;
  24009. /**
  24010. * The basic color of the material as viewed under a light.
  24011. */
  24012. diffuseColor: Color3;
  24013. /**
  24014. * Define how the color and intensity of the highlight given by the light in the material.
  24015. */
  24016. specularColor: Color3;
  24017. /**
  24018. * Define the color of the material as if self lit.
  24019. * This will be mixed in the final result even in the absence of light.
  24020. */
  24021. emissiveColor: Color3;
  24022. /**
  24023. * Defines how sharp are the highlights in the material.
  24024. * The bigger the value the sharper giving a more glossy feeling to the result.
  24025. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24026. */
  24027. specularPower: number;
  24028. private _useAlphaFromDiffuseTexture;
  24029. /**
  24030. * Does the transparency come from the diffuse texture alpha channel.
  24031. */
  24032. useAlphaFromDiffuseTexture: boolean;
  24033. private _useEmissiveAsIllumination;
  24034. /**
  24035. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24036. */
  24037. useEmissiveAsIllumination: boolean;
  24038. private _linkEmissiveWithDiffuse;
  24039. /**
  24040. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24041. * the emissive level when the final color is close to one.
  24042. */
  24043. linkEmissiveWithDiffuse: boolean;
  24044. private _useSpecularOverAlpha;
  24045. /**
  24046. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24047. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24048. */
  24049. useSpecularOverAlpha: boolean;
  24050. private _useReflectionOverAlpha;
  24051. /**
  24052. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24053. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24054. */
  24055. useReflectionOverAlpha: boolean;
  24056. private _disableLighting;
  24057. /**
  24058. * Does lights from the scene impacts this material.
  24059. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24060. */
  24061. disableLighting: boolean;
  24062. private _useObjectSpaceNormalMap;
  24063. /**
  24064. * Allows using an object space normal map (instead of tangent space).
  24065. */
  24066. useObjectSpaceNormalMap: boolean;
  24067. private _useParallax;
  24068. /**
  24069. * Is parallax enabled or not.
  24070. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24071. */
  24072. useParallax: boolean;
  24073. private _useParallaxOcclusion;
  24074. /**
  24075. * Is parallax occlusion enabled or not.
  24076. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24077. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24078. */
  24079. useParallaxOcclusion: boolean;
  24080. /**
  24081. * 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.
  24082. */
  24083. parallaxScaleBias: number;
  24084. private _roughness;
  24085. /**
  24086. * Helps to define how blurry the reflections should appears in the material.
  24087. */
  24088. roughness: number;
  24089. /**
  24090. * In case of refraction, define the value of the index of refraction.
  24091. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24092. */
  24093. indexOfRefraction: number;
  24094. /**
  24095. * Invert the refraction texture alongside the y axis.
  24096. * It can be useful with procedural textures or probe for instance.
  24097. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24098. */
  24099. invertRefractionY: boolean;
  24100. /**
  24101. * Defines the alpha limits in alpha test mode.
  24102. */
  24103. alphaCutOff: number;
  24104. private _useLightmapAsShadowmap;
  24105. /**
  24106. * In case of light mapping, define whether the map contains light or shadow informations.
  24107. */
  24108. useLightmapAsShadowmap: boolean;
  24109. private _diffuseFresnelParameters;
  24110. /**
  24111. * Define the diffuse fresnel parameters of the material.
  24112. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24113. */
  24114. diffuseFresnelParameters: FresnelParameters;
  24115. private _opacityFresnelParameters;
  24116. /**
  24117. * Define the opacity fresnel parameters of the material.
  24118. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24119. */
  24120. opacityFresnelParameters: FresnelParameters;
  24121. private _reflectionFresnelParameters;
  24122. /**
  24123. * Define the reflection fresnel parameters of the material.
  24124. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24125. */
  24126. reflectionFresnelParameters: FresnelParameters;
  24127. private _refractionFresnelParameters;
  24128. /**
  24129. * Define the refraction fresnel parameters of the material.
  24130. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24131. */
  24132. refractionFresnelParameters: FresnelParameters;
  24133. private _emissiveFresnelParameters;
  24134. /**
  24135. * Define the emissive fresnel parameters of the material.
  24136. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24137. */
  24138. emissiveFresnelParameters: FresnelParameters;
  24139. private _useReflectionFresnelFromSpecular;
  24140. /**
  24141. * If true automatically deducts the fresnels values from the material specularity.
  24142. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24143. */
  24144. useReflectionFresnelFromSpecular: boolean;
  24145. private _useGlossinessFromSpecularMapAlpha;
  24146. /**
  24147. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24148. */
  24149. useGlossinessFromSpecularMapAlpha: boolean;
  24150. private _maxSimultaneousLights;
  24151. /**
  24152. * Defines the maximum number of lights that can be used in the material
  24153. */
  24154. maxSimultaneousLights: number;
  24155. private _invertNormalMapX;
  24156. /**
  24157. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24158. */
  24159. invertNormalMapX: boolean;
  24160. private _invertNormalMapY;
  24161. /**
  24162. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24163. */
  24164. invertNormalMapY: boolean;
  24165. private _twoSidedLighting;
  24166. /**
  24167. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24168. */
  24169. twoSidedLighting: boolean;
  24170. /**
  24171. * Default configuration related to image processing available in the standard Material.
  24172. */
  24173. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24174. /**
  24175. * Gets the image processing configuration used either in this material.
  24176. */
  24177. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24178. /**
  24179. * Sets the Default image processing configuration used either in the this material.
  24180. *
  24181. * If sets to null, the scene one is in use.
  24182. */
  24183. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24184. /**
  24185. * Keep track of the image processing observer to allow dispose and replace.
  24186. */
  24187. private _imageProcessingObserver;
  24188. /**
  24189. * Attaches a new image processing configuration to the Standard Material.
  24190. * @param configuration
  24191. */
  24192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24193. /**
  24194. * Defines additionnal PrePass parameters for the material.
  24195. */
  24196. readonly prePassConfiguration: PrePassConfiguration;
  24197. /**
  24198. * Gets wether the color curves effect is enabled.
  24199. */
  24200. get cameraColorCurvesEnabled(): boolean;
  24201. /**
  24202. * Sets wether the color curves effect is enabled.
  24203. */
  24204. set cameraColorCurvesEnabled(value: boolean);
  24205. /**
  24206. * Gets wether the color grading effect is enabled.
  24207. */
  24208. get cameraColorGradingEnabled(): boolean;
  24209. /**
  24210. * Gets wether the color grading effect is enabled.
  24211. */
  24212. set cameraColorGradingEnabled(value: boolean);
  24213. /**
  24214. * Gets wether tonemapping is enabled or not.
  24215. */
  24216. get cameraToneMappingEnabled(): boolean;
  24217. /**
  24218. * Sets wether tonemapping is enabled or not
  24219. */
  24220. set cameraToneMappingEnabled(value: boolean);
  24221. /**
  24222. * The camera exposure used on this material.
  24223. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24224. * This corresponds to a photographic exposure.
  24225. */
  24226. get cameraExposure(): number;
  24227. /**
  24228. * The camera exposure used on this material.
  24229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24230. * This corresponds to a photographic exposure.
  24231. */
  24232. set cameraExposure(value: number);
  24233. /**
  24234. * Gets The camera contrast used on this material.
  24235. */
  24236. get cameraContrast(): number;
  24237. /**
  24238. * Sets The camera contrast used on this material.
  24239. */
  24240. set cameraContrast(value: number);
  24241. /**
  24242. * Gets the Color Grading 2D Lookup Texture.
  24243. */
  24244. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24245. /**
  24246. * Sets the Color Grading 2D Lookup Texture.
  24247. */
  24248. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24249. /**
  24250. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24251. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24252. * 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;
  24253. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24254. */
  24255. get cameraColorCurves(): Nullable<ColorCurves>;
  24256. /**
  24257. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24258. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24259. * 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;
  24260. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24261. */
  24262. set cameraColorCurves(value: Nullable<ColorCurves>);
  24263. /**
  24264. * Can this material render to several textures at once
  24265. */
  24266. get canRenderToMRT(): boolean;
  24267. /**
  24268. * Defines the detail map parameters for the material.
  24269. */
  24270. readonly detailMap: DetailMapConfiguration;
  24271. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24272. protected _worldViewProjectionMatrix: Matrix;
  24273. protected _globalAmbientColor: Color3;
  24274. protected _useLogarithmicDepth: boolean;
  24275. protected _rebuildInParallel: boolean;
  24276. /**
  24277. * Instantiates a new standard material.
  24278. * This is the default material used in Babylon. It is the best trade off between quality
  24279. * and performances.
  24280. * @see https://doc.babylonjs.com/babylon101/materials
  24281. * @param name Define the name of the material in the scene
  24282. * @param scene Define the scene the material belong to
  24283. */
  24284. constructor(name: string, scene: Scene);
  24285. /**
  24286. * Gets a boolean indicating that current material needs to register RTT
  24287. */
  24288. get hasRenderTargetTextures(): boolean;
  24289. /**
  24290. * Gets the current class name of the material e.g. "StandardMaterial"
  24291. * Mainly use in serialization.
  24292. * @returns the class name
  24293. */
  24294. getClassName(): string;
  24295. /**
  24296. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24297. * You can try switching to logarithmic depth.
  24298. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24299. */
  24300. get useLogarithmicDepth(): boolean;
  24301. set useLogarithmicDepth(value: boolean);
  24302. /**
  24303. * Specifies if the material will require alpha blending
  24304. * @returns a boolean specifying if alpha blending is needed
  24305. */
  24306. needAlphaBlending(): boolean;
  24307. /**
  24308. * Specifies if this material should be rendered in alpha test mode
  24309. * @returns a boolean specifying if an alpha test is needed.
  24310. */
  24311. needAlphaTesting(): boolean;
  24312. /**
  24313. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24314. */
  24315. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24316. /**
  24317. * Specifies whether or not there is a usable alpha channel for transparency.
  24318. */
  24319. protected _hasAlphaChannel(): boolean;
  24320. /**
  24321. * Get the texture used for alpha test purpose.
  24322. * @returns the diffuse texture in case of the standard material.
  24323. */
  24324. getAlphaTestTexture(): Nullable<BaseTexture>;
  24325. /**
  24326. * Get if the submesh is ready to be used and all its information available.
  24327. * Child classes can use it to update shaders
  24328. * @param mesh defines the mesh to check
  24329. * @param subMesh defines which submesh to check
  24330. * @param useInstances specifies that instances should be used
  24331. * @returns a boolean indicating that the submesh is ready or not
  24332. */
  24333. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24334. /**
  24335. * Builds the material UBO layouts.
  24336. * Used internally during the effect preparation.
  24337. */
  24338. buildUniformLayout(): void;
  24339. /**
  24340. * Unbinds the material from the mesh
  24341. */
  24342. unbind(): void;
  24343. /**
  24344. * Binds the submesh to this material by preparing the effect and shader to draw
  24345. * @param world defines the world transformation matrix
  24346. * @param mesh defines the mesh containing the submesh
  24347. * @param subMesh defines the submesh to bind the material to
  24348. */
  24349. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24350. /**
  24351. * Get the list of animatables in the material.
  24352. * @returns the list of animatables object used in the material
  24353. */
  24354. getAnimatables(): IAnimatable[];
  24355. /**
  24356. * Gets the active textures from the material
  24357. * @returns an array of textures
  24358. */
  24359. getActiveTextures(): BaseTexture[];
  24360. /**
  24361. * Specifies if the material uses a texture
  24362. * @param texture defines the texture to check against the material
  24363. * @returns a boolean specifying if the material uses the texture
  24364. */
  24365. hasTexture(texture: BaseTexture): boolean;
  24366. /**
  24367. * Disposes the material
  24368. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24369. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24370. */
  24371. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24372. /**
  24373. * Makes a duplicate of the material, and gives it a new name
  24374. * @param name defines the new name for the duplicated material
  24375. * @returns the cloned material
  24376. */
  24377. clone(name: string): StandardMaterial;
  24378. /**
  24379. * Serializes this material in a JSON representation
  24380. * @returns the serialized material object
  24381. */
  24382. serialize(): any;
  24383. /**
  24384. * Creates a standard material from parsed material data
  24385. * @param source defines the JSON representation of the material
  24386. * @param scene defines the hosting scene
  24387. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24388. * @returns a new standard material
  24389. */
  24390. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24391. /**
  24392. * Are diffuse textures enabled in the application.
  24393. */
  24394. static get DiffuseTextureEnabled(): boolean;
  24395. static set DiffuseTextureEnabled(value: boolean);
  24396. /**
  24397. * Are detail textures enabled in the application.
  24398. */
  24399. static get DetailTextureEnabled(): boolean;
  24400. static set DetailTextureEnabled(value: boolean);
  24401. /**
  24402. * Are ambient textures enabled in the application.
  24403. */
  24404. static get AmbientTextureEnabled(): boolean;
  24405. static set AmbientTextureEnabled(value: boolean);
  24406. /**
  24407. * Are opacity textures enabled in the application.
  24408. */
  24409. static get OpacityTextureEnabled(): boolean;
  24410. static set OpacityTextureEnabled(value: boolean);
  24411. /**
  24412. * Are reflection textures enabled in the application.
  24413. */
  24414. static get ReflectionTextureEnabled(): boolean;
  24415. static set ReflectionTextureEnabled(value: boolean);
  24416. /**
  24417. * Are emissive textures enabled in the application.
  24418. */
  24419. static get EmissiveTextureEnabled(): boolean;
  24420. static set EmissiveTextureEnabled(value: boolean);
  24421. /**
  24422. * Are specular textures enabled in the application.
  24423. */
  24424. static get SpecularTextureEnabled(): boolean;
  24425. static set SpecularTextureEnabled(value: boolean);
  24426. /**
  24427. * Are bump textures enabled in the application.
  24428. */
  24429. static get BumpTextureEnabled(): boolean;
  24430. static set BumpTextureEnabled(value: boolean);
  24431. /**
  24432. * Are lightmap textures enabled in the application.
  24433. */
  24434. static get LightmapTextureEnabled(): boolean;
  24435. static set LightmapTextureEnabled(value: boolean);
  24436. /**
  24437. * Are refraction textures enabled in the application.
  24438. */
  24439. static get RefractionTextureEnabled(): boolean;
  24440. static set RefractionTextureEnabled(value: boolean);
  24441. /**
  24442. * Are color grading textures enabled in the application.
  24443. */
  24444. static get ColorGradingTextureEnabled(): boolean;
  24445. static set ColorGradingTextureEnabled(value: boolean);
  24446. /**
  24447. * Are fresnels enabled in the application.
  24448. */
  24449. static get FresnelEnabled(): boolean;
  24450. static set FresnelEnabled(value: boolean);
  24451. }
  24452. }
  24453. declare module BABYLON {
  24454. /** @hidden */
  24455. export var rgbdDecodePixelShader: {
  24456. name: string;
  24457. shader: string;
  24458. };
  24459. }
  24460. declare module BABYLON {
  24461. /**
  24462. * Class used to host RGBD texture specific utilities
  24463. */
  24464. export class RGBDTextureTools {
  24465. /**
  24466. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24467. * @param texture the texture to expand.
  24468. */
  24469. static ExpandRGBDTexture(texture: Texture): void;
  24470. }
  24471. }
  24472. declare module BABYLON {
  24473. /**
  24474. * Class used to host texture specific utilities
  24475. */
  24476. export class BRDFTextureTools {
  24477. /**
  24478. * Prevents texture cache collision
  24479. */
  24480. private static _instanceNumber;
  24481. /**
  24482. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24483. * @param scene defines the hosting scene
  24484. * @returns the environment BRDF texture
  24485. */
  24486. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24487. private static _environmentBRDFBase64Texture;
  24488. }
  24489. }
  24490. declare module BABYLON {
  24491. /**
  24492. * @hidden
  24493. */
  24494. export interface IMaterialClearCoatDefines {
  24495. CLEARCOAT: boolean;
  24496. CLEARCOAT_DEFAULTIOR: boolean;
  24497. CLEARCOAT_TEXTURE: boolean;
  24498. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24499. CLEARCOAT_TEXTUREDIRECTUV: number;
  24500. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24501. CLEARCOAT_BUMP: boolean;
  24502. CLEARCOAT_BUMPDIRECTUV: number;
  24503. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24504. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24505. CLEARCOAT_REMAP_F0: boolean;
  24506. CLEARCOAT_TINT: boolean;
  24507. CLEARCOAT_TINT_TEXTURE: boolean;
  24508. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24509. /** @hidden */
  24510. _areTexturesDirty: boolean;
  24511. }
  24512. /**
  24513. * Define the code related to the clear coat parameters of the pbr material.
  24514. */
  24515. export class PBRClearCoatConfiguration {
  24516. /**
  24517. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24518. * The default fits with a polyurethane material.
  24519. */
  24520. private static readonly _DefaultIndexOfRefraction;
  24521. private _isEnabled;
  24522. /**
  24523. * Defines if the clear coat is enabled in the material.
  24524. */
  24525. isEnabled: boolean;
  24526. /**
  24527. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24528. */
  24529. intensity: number;
  24530. /**
  24531. * Defines the clear coat layer roughness.
  24532. */
  24533. roughness: number;
  24534. private _indexOfRefraction;
  24535. /**
  24536. * Defines the index of refraction of the clear coat.
  24537. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24538. * The default fits with a polyurethane material.
  24539. * Changing the default value is more performance intensive.
  24540. */
  24541. indexOfRefraction: number;
  24542. private _texture;
  24543. /**
  24544. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24545. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24546. * if textureRoughness is not empty, else no texture roughness is used
  24547. */
  24548. texture: Nullable<BaseTexture>;
  24549. private _useRoughnessFromMainTexture;
  24550. /**
  24551. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24552. * If false, the green channel from textureRoughness is used for roughness
  24553. */
  24554. useRoughnessFromMainTexture: boolean;
  24555. private _textureRoughness;
  24556. /**
  24557. * Stores the clear coat roughness in a texture (green channel)
  24558. * Not used if useRoughnessFromMainTexture is true
  24559. */
  24560. textureRoughness: Nullable<BaseTexture>;
  24561. private _remapF0OnInterfaceChange;
  24562. /**
  24563. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24564. */
  24565. remapF0OnInterfaceChange: boolean;
  24566. private _bumpTexture;
  24567. /**
  24568. * Define the clear coat specific bump texture.
  24569. */
  24570. bumpTexture: Nullable<BaseTexture>;
  24571. private _isTintEnabled;
  24572. /**
  24573. * Defines if the clear coat tint is enabled in the material.
  24574. */
  24575. isTintEnabled: boolean;
  24576. /**
  24577. * Defines the clear coat tint of the material.
  24578. * This is only use if tint is enabled
  24579. */
  24580. tintColor: Color3;
  24581. /**
  24582. * Defines the distance at which the tint color should be found in the
  24583. * clear coat media.
  24584. * This is only use if tint is enabled
  24585. */
  24586. tintColorAtDistance: number;
  24587. /**
  24588. * Defines the clear coat layer thickness.
  24589. * This is only use if tint is enabled
  24590. */
  24591. tintThickness: number;
  24592. private _tintTexture;
  24593. /**
  24594. * Stores the clear tint values in a texture.
  24595. * rgb is tint
  24596. * a is a thickness factor
  24597. */
  24598. tintTexture: Nullable<BaseTexture>;
  24599. /** @hidden */
  24600. private _internalMarkAllSubMeshesAsTexturesDirty;
  24601. /** @hidden */
  24602. _markAllSubMeshesAsTexturesDirty(): void;
  24603. /**
  24604. * Instantiate a new istance of clear coat configuration.
  24605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24606. */
  24607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24608. /**
  24609. * Gets wehter the submesh is ready to be used or not.
  24610. * @param defines the list of "defines" to update.
  24611. * @param scene defines the scene the material belongs to.
  24612. * @param engine defines the engine the material belongs to.
  24613. * @param disableBumpMap defines wether the material disables bump or not.
  24614. * @returns - boolean indicating that the submesh is ready or not.
  24615. */
  24616. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24617. /**
  24618. * Checks to see if a texture is used in the material.
  24619. * @param defines the list of "defines" to update.
  24620. * @param scene defines the scene to the material belongs to.
  24621. */
  24622. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24623. /**
  24624. * Binds the material data.
  24625. * @param uniformBuffer defines the Uniform buffer to fill in.
  24626. * @param scene defines the scene the material belongs to.
  24627. * @param engine defines the engine the material belongs to.
  24628. * @param disableBumpMap defines wether the material disables bump or not.
  24629. * @param isFrozen defines wether the material is frozen or not.
  24630. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24631. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24632. * @param subMesh the submesh to bind data for
  24633. */
  24634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24635. /**
  24636. * Checks to see if a texture is used in the material.
  24637. * @param texture - Base texture to use.
  24638. * @returns - Boolean specifying if a texture is used in the material.
  24639. */
  24640. hasTexture(texture: BaseTexture): boolean;
  24641. /**
  24642. * Returns an array of the actively used textures.
  24643. * @param activeTextures Array of BaseTextures
  24644. */
  24645. getActiveTextures(activeTextures: BaseTexture[]): void;
  24646. /**
  24647. * Returns the animatable textures.
  24648. * @param animatables Array of animatable textures.
  24649. */
  24650. getAnimatables(animatables: IAnimatable[]): void;
  24651. /**
  24652. * Disposes the resources of the material.
  24653. * @param forceDisposeTextures - Forces the disposal of all textures.
  24654. */
  24655. dispose(forceDisposeTextures?: boolean): void;
  24656. /**
  24657. * Get the current class name of the texture useful for serialization or dynamic coding.
  24658. * @returns "PBRClearCoatConfiguration"
  24659. */
  24660. getClassName(): string;
  24661. /**
  24662. * Add fallbacks to the effect fallbacks list.
  24663. * @param defines defines the Base texture to use.
  24664. * @param fallbacks defines the current fallback list.
  24665. * @param currentRank defines the current fallback rank.
  24666. * @returns the new fallback rank.
  24667. */
  24668. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24669. /**
  24670. * Add the required uniforms to the current list.
  24671. * @param uniforms defines the current uniform list.
  24672. */
  24673. static AddUniforms(uniforms: string[]): void;
  24674. /**
  24675. * Add the required samplers to the current list.
  24676. * @param samplers defines the current sampler list.
  24677. */
  24678. static AddSamplers(samplers: string[]): void;
  24679. /**
  24680. * Add the required uniforms to the current buffer.
  24681. * @param uniformBuffer defines the current uniform buffer.
  24682. */
  24683. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24684. /**
  24685. * Makes a duplicate of the current configuration into another one.
  24686. * @param clearCoatConfiguration define the config where to copy the info
  24687. */
  24688. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24689. /**
  24690. * Serializes this clear coat configuration.
  24691. * @returns - An object with the serialized config.
  24692. */
  24693. serialize(): any;
  24694. /**
  24695. * Parses a anisotropy Configuration from a serialized object.
  24696. * @param source - Serialized object.
  24697. * @param scene Defines the scene we are parsing for
  24698. * @param rootUrl Defines the rootUrl to load from
  24699. */
  24700. parse(source: any, scene: Scene, rootUrl: string): void;
  24701. }
  24702. }
  24703. declare module BABYLON {
  24704. /**
  24705. * @hidden
  24706. */
  24707. export interface IMaterialAnisotropicDefines {
  24708. ANISOTROPIC: boolean;
  24709. ANISOTROPIC_TEXTURE: boolean;
  24710. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24711. MAINUV1: boolean;
  24712. _areTexturesDirty: boolean;
  24713. _needUVs: boolean;
  24714. }
  24715. /**
  24716. * Define the code related to the anisotropic parameters of the pbr material.
  24717. */
  24718. export class PBRAnisotropicConfiguration {
  24719. private _isEnabled;
  24720. /**
  24721. * Defines if the anisotropy is enabled in the material.
  24722. */
  24723. isEnabled: boolean;
  24724. /**
  24725. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24726. */
  24727. intensity: number;
  24728. /**
  24729. * Defines if the effect is along the tangents, bitangents or in between.
  24730. * By default, the effect is "strectching" the highlights along the tangents.
  24731. */
  24732. direction: Vector2;
  24733. private _texture;
  24734. /**
  24735. * Stores the anisotropy values in a texture.
  24736. * rg is direction (like normal from -1 to 1)
  24737. * b is a intensity
  24738. */
  24739. texture: Nullable<BaseTexture>;
  24740. /** @hidden */
  24741. private _internalMarkAllSubMeshesAsTexturesDirty;
  24742. /** @hidden */
  24743. _markAllSubMeshesAsTexturesDirty(): void;
  24744. /**
  24745. * Instantiate a new istance of anisotropy configuration.
  24746. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24747. */
  24748. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24749. /**
  24750. * Specifies that the submesh is ready to be used.
  24751. * @param defines the list of "defines" to update.
  24752. * @param scene defines the scene the material belongs to.
  24753. * @returns - boolean indicating that the submesh is ready or not.
  24754. */
  24755. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24756. /**
  24757. * Checks to see if a texture is used in the material.
  24758. * @param defines the list of "defines" to update.
  24759. * @param mesh the mesh we are preparing the defines for.
  24760. * @param scene defines the scene the material belongs to.
  24761. */
  24762. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24763. /**
  24764. * Binds the material data.
  24765. * @param uniformBuffer defines the Uniform buffer to fill in.
  24766. * @param scene defines the scene the material belongs to.
  24767. * @param isFrozen defines wether the material is frozen or not.
  24768. */
  24769. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24770. /**
  24771. * Checks to see if a texture is used in the material.
  24772. * @param texture - Base texture to use.
  24773. * @returns - Boolean specifying if a texture is used in the material.
  24774. */
  24775. hasTexture(texture: BaseTexture): boolean;
  24776. /**
  24777. * Returns an array of the actively used textures.
  24778. * @param activeTextures Array of BaseTextures
  24779. */
  24780. getActiveTextures(activeTextures: BaseTexture[]): void;
  24781. /**
  24782. * Returns the animatable textures.
  24783. * @param animatables Array of animatable textures.
  24784. */
  24785. getAnimatables(animatables: IAnimatable[]): void;
  24786. /**
  24787. * Disposes the resources of the material.
  24788. * @param forceDisposeTextures - Forces the disposal of all textures.
  24789. */
  24790. dispose(forceDisposeTextures?: boolean): void;
  24791. /**
  24792. * Get the current class name of the texture useful for serialization or dynamic coding.
  24793. * @returns "PBRAnisotropicConfiguration"
  24794. */
  24795. getClassName(): string;
  24796. /**
  24797. * Add fallbacks to the effect fallbacks list.
  24798. * @param defines defines the Base texture to use.
  24799. * @param fallbacks defines the current fallback list.
  24800. * @param currentRank defines the current fallback rank.
  24801. * @returns the new fallback rank.
  24802. */
  24803. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24804. /**
  24805. * Add the required uniforms to the current list.
  24806. * @param uniforms defines the current uniform list.
  24807. */
  24808. static AddUniforms(uniforms: string[]): void;
  24809. /**
  24810. * Add the required uniforms to the current buffer.
  24811. * @param uniformBuffer defines the current uniform buffer.
  24812. */
  24813. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24814. /**
  24815. * Add the required samplers to the current list.
  24816. * @param samplers defines the current sampler list.
  24817. */
  24818. static AddSamplers(samplers: string[]): void;
  24819. /**
  24820. * Makes a duplicate of the current configuration into another one.
  24821. * @param anisotropicConfiguration define the config where to copy the info
  24822. */
  24823. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24824. /**
  24825. * Serializes this anisotropy configuration.
  24826. * @returns - An object with the serialized config.
  24827. */
  24828. serialize(): any;
  24829. /**
  24830. * Parses a anisotropy Configuration from a serialized object.
  24831. * @param source - Serialized object.
  24832. * @param scene Defines the scene we are parsing for
  24833. * @param rootUrl Defines the rootUrl to load from
  24834. */
  24835. parse(source: any, scene: Scene, rootUrl: string): void;
  24836. }
  24837. }
  24838. declare module BABYLON {
  24839. /**
  24840. * @hidden
  24841. */
  24842. export interface IMaterialBRDFDefines {
  24843. BRDF_V_HEIGHT_CORRELATED: boolean;
  24844. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24845. SPHERICAL_HARMONICS: boolean;
  24846. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24847. /** @hidden */
  24848. _areMiscDirty: boolean;
  24849. }
  24850. /**
  24851. * Define the code related to the BRDF parameters of the pbr material.
  24852. */
  24853. export class PBRBRDFConfiguration {
  24854. /**
  24855. * Default value used for the energy conservation.
  24856. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24857. */
  24858. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24859. /**
  24860. * Default value used for the Smith Visibility Height Correlated mode.
  24861. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24862. */
  24863. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24864. /**
  24865. * Default value used for the IBL diffuse part.
  24866. * This can help switching back to the polynomials mode globally which is a tiny bit
  24867. * less GPU intensive at the drawback of a lower quality.
  24868. */
  24869. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24870. /**
  24871. * Default value used for activating energy conservation for the specular workflow.
  24872. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24873. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24874. */
  24875. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24876. private _useEnergyConservation;
  24877. /**
  24878. * Defines if the material uses energy conservation.
  24879. */
  24880. useEnergyConservation: boolean;
  24881. private _useSmithVisibilityHeightCorrelated;
  24882. /**
  24883. * LEGACY Mode set to false
  24884. * Defines if the material uses height smith correlated visibility term.
  24885. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24886. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24887. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24888. * Not relying on height correlated will also disable energy conservation.
  24889. */
  24890. useSmithVisibilityHeightCorrelated: boolean;
  24891. private _useSphericalHarmonics;
  24892. /**
  24893. * LEGACY Mode set to false
  24894. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24895. * diffuse part of the IBL.
  24896. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24897. * to the ground truth.
  24898. */
  24899. useSphericalHarmonics: boolean;
  24900. private _useSpecularGlossinessInputEnergyConservation;
  24901. /**
  24902. * Defines if the material uses energy conservation, when the specular workflow is active.
  24903. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24904. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24905. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24906. */
  24907. useSpecularGlossinessInputEnergyConservation: boolean;
  24908. /** @hidden */
  24909. private _internalMarkAllSubMeshesAsMiscDirty;
  24910. /** @hidden */
  24911. _markAllSubMeshesAsMiscDirty(): void;
  24912. /**
  24913. * Instantiate a new istance of clear coat configuration.
  24914. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24915. */
  24916. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24917. /**
  24918. * Checks to see if a texture is used in the material.
  24919. * @param defines the list of "defines" to update.
  24920. */
  24921. prepareDefines(defines: IMaterialBRDFDefines): void;
  24922. /**
  24923. * Get the current class name of the texture useful for serialization or dynamic coding.
  24924. * @returns "PBRClearCoatConfiguration"
  24925. */
  24926. getClassName(): string;
  24927. /**
  24928. * Makes a duplicate of the current configuration into another one.
  24929. * @param brdfConfiguration define the config where to copy the info
  24930. */
  24931. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24932. /**
  24933. * Serializes this BRDF configuration.
  24934. * @returns - An object with the serialized config.
  24935. */
  24936. serialize(): any;
  24937. /**
  24938. * Parses a anisotropy Configuration from a serialized object.
  24939. * @param source - Serialized object.
  24940. * @param scene Defines the scene we are parsing for
  24941. * @param rootUrl Defines the rootUrl to load from
  24942. */
  24943. parse(source: any, scene: Scene, rootUrl: string): void;
  24944. }
  24945. }
  24946. declare module BABYLON {
  24947. /**
  24948. * @hidden
  24949. */
  24950. export interface IMaterialSheenDefines {
  24951. SHEEN: boolean;
  24952. SHEEN_TEXTURE: boolean;
  24953. SHEEN_TEXTURE_ROUGHNESS: boolean;
  24954. SHEEN_TEXTUREDIRECTUV: number;
  24955. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  24956. SHEEN_LINKWITHALBEDO: boolean;
  24957. SHEEN_ROUGHNESS: boolean;
  24958. SHEEN_ALBEDOSCALING: boolean;
  24959. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24960. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24961. /** @hidden */
  24962. _areTexturesDirty: boolean;
  24963. }
  24964. /**
  24965. * Define the code related to the Sheen parameters of the pbr material.
  24966. */
  24967. export class PBRSheenConfiguration {
  24968. private _isEnabled;
  24969. /**
  24970. * Defines if the material uses sheen.
  24971. */
  24972. isEnabled: boolean;
  24973. private _linkSheenWithAlbedo;
  24974. /**
  24975. * Defines if the sheen is linked to the sheen color.
  24976. */
  24977. linkSheenWithAlbedo: boolean;
  24978. /**
  24979. * Defines the sheen intensity.
  24980. */
  24981. intensity: number;
  24982. /**
  24983. * Defines the sheen color.
  24984. */
  24985. color: Color3;
  24986. private _texture;
  24987. /**
  24988. * Stores the sheen tint values in a texture.
  24989. * rgb is tint
  24990. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  24991. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  24992. */
  24993. texture: Nullable<BaseTexture>;
  24994. private _useRoughnessFromMainTexture;
  24995. /**
  24996. * Indicates that the alpha channel of the texture property will be used for roughness.
  24997. * Has no effect if the roughness (and texture!) property is not defined
  24998. */
  24999. useRoughnessFromMainTexture: boolean;
  25000. private _roughness;
  25001. /**
  25002. * Defines the sheen roughness.
  25003. * It is not taken into account if linkSheenWithAlbedo is true.
  25004. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25005. */
  25006. roughness: Nullable<number>;
  25007. private _textureRoughness;
  25008. /**
  25009. * Stores the sheen roughness in a texture.
  25010. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25011. */
  25012. textureRoughness: Nullable<BaseTexture>;
  25013. private _albedoScaling;
  25014. /**
  25015. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25016. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25017. * making it easier to setup and tweak the effect
  25018. */
  25019. albedoScaling: boolean;
  25020. /** @hidden */
  25021. private _internalMarkAllSubMeshesAsTexturesDirty;
  25022. /** @hidden */
  25023. _markAllSubMeshesAsTexturesDirty(): void;
  25024. /**
  25025. * Instantiate a new istance of clear coat configuration.
  25026. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25027. */
  25028. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25029. /**
  25030. * Specifies that the submesh is ready to be used.
  25031. * @param defines the list of "defines" to update.
  25032. * @param scene defines the scene the material belongs to.
  25033. * @returns - boolean indicating that the submesh is ready or not.
  25034. */
  25035. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25036. /**
  25037. * Checks to see if a texture is used in the material.
  25038. * @param defines the list of "defines" to update.
  25039. * @param scene defines the scene the material belongs to.
  25040. */
  25041. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25042. /**
  25043. * Binds the material data.
  25044. * @param uniformBuffer defines the Uniform buffer to fill in.
  25045. * @param scene defines the scene the material belongs to.
  25046. * @param isFrozen defines wether the material is frozen or not.
  25047. * @param subMesh the submesh to bind data for
  25048. */
  25049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25050. /**
  25051. * Checks to see if a texture is used in the material.
  25052. * @param texture - Base texture to use.
  25053. * @returns - Boolean specifying if a texture is used in the material.
  25054. */
  25055. hasTexture(texture: BaseTexture): boolean;
  25056. /**
  25057. * Returns an array of the actively used textures.
  25058. * @param activeTextures Array of BaseTextures
  25059. */
  25060. getActiveTextures(activeTextures: BaseTexture[]): void;
  25061. /**
  25062. * Returns the animatable textures.
  25063. * @param animatables Array of animatable textures.
  25064. */
  25065. getAnimatables(animatables: IAnimatable[]): void;
  25066. /**
  25067. * Disposes the resources of the material.
  25068. * @param forceDisposeTextures - Forces the disposal of all textures.
  25069. */
  25070. dispose(forceDisposeTextures?: boolean): void;
  25071. /**
  25072. * Get the current class name of the texture useful for serialization or dynamic coding.
  25073. * @returns "PBRSheenConfiguration"
  25074. */
  25075. getClassName(): string;
  25076. /**
  25077. * Add fallbacks to the effect fallbacks list.
  25078. * @param defines defines the Base texture to use.
  25079. * @param fallbacks defines the current fallback list.
  25080. * @param currentRank defines the current fallback rank.
  25081. * @returns the new fallback rank.
  25082. */
  25083. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25084. /**
  25085. * Add the required uniforms to the current list.
  25086. * @param uniforms defines the current uniform list.
  25087. */
  25088. static AddUniforms(uniforms: string[]): void;
  25089. /**
  25090. * Add the required uniforms to the current buffer.
  25091. * @param uniformBuffer defines the current uniform buffer.
  25092. */
  25093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25094. /**
  25095. * Add the required samplers to the current list.
  25096. * @param samplers defines the current sampler list.
  25097. */
  25098. static AddSamplers(samplers: string[]): void;
  25099. /**
  25100. * Makes a duplicate of the current configuration into another one.
  25101. * @param sheenConfiguration define the config where to copy the info
  25102. */
  25103. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25104. /**
  25105. * Serializes this BRDF configuration.
  25106. * @returns - An object with the serialized config.
  25107. */
  25108. serialize(): any;
  25109. /**
  25110. * Parses a anisotropy Configuration from a serialized object.
  25111. * @param source - Serialized object.
  25112. * @param scene Defines the scene we are parsing for
  25113. * @param rootUrl Defines the rootUrl to load from
  25114. */
  25115. parse(source: any, scene: Scene, rootUrl: string): void;
  25116. }
  25117. }
  25118. declare module BABYLON {
  25119. /**
  25120. * @hidden
  25121. */
  25122. export interface IMaterialSubSurfaceDefines {
  25123. SUBSURFACE: boolean;
  25124. SS_REFRACTION: boolean;
  25125. SS_TRANSLUCENCY: boolean;
  25126. SS_SCATTERING: boolean;
  25127. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25128. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25129. SS_REFRACTIONMAP_3D: boolean;
  25130. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25131. SS_LODINREFRACTIONALPHA: boolean;
  25132. SS_GAMMAREFRACTION: boolean;
  25133. SS_RGBDREFRACTION: boolean;
  25134. SS_LINEARSPECULARREFRACTION: boolean;
  25135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25136. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25137. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25138. /** @hidden */
  25139. _areTexturesDirty: boolean;
  25140. }
  25141. /**
  25142. * Define the code related to the sub surface parameters of the pbr material.
  25143. */
  25144. export class PBRSubSurfaceConfiguration {
  25145. private _isRefractionEnabled;
  25146. /**
  25147. * Defines if the refraction is enabled in the material.
  25148. */
  25149. isRefractionEnabled: boolean;
  25150. private _isTranslucencyEnabled;
  25151. /**
  25152. * Defines if the translucency is enabled in the material.
  25153. */
  25154. isTranslucencyEnabled: boolean;
  25155. private _isScatteringEnabled;
  25156. /**
  25157. * Defines if the sub surface scattering is enabled in the material.
  25158. */
  25159. isScatteringEnabled: boolean;
  25160. private _scatteringDiffusionProfileIndex;
  25161. /**
  25162. * Diffusion profile for subsurface scattering.
  25163. * Useful for better scattering in the skins or foliages.
  25164. */
  25165. get scatteringDiffusionProfile(): Nullable<Color3>;
  25166. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25167. /**
  25168. * Defines the refraction intensity of the material.
  25169. * The refraction when enabled replaces the Diffuse part of the material.
  25170. * The intensity helps transitionning between diffuse and refraction.
  25171. */
  25172. refractionIntensity: number;
  25173. /**
  25174. * Defines the translucency intensity of the material.
  25175. * When translucency has been enabled, this defines how much of the "translucency"
  25176. * is addded to the diffuse part of the material.
  25177. */
  25178. translucencyIntensity: number;
  25179. /**
  25180. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25181. */
  25182. useAlbedoToTintRefraction: boolean;
  25183. private _thicknessTexture;
  25184. /**
  25185. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25186. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25187. * 0 would mean minimumThickness
  25188. * 1 would mean maximumThickness
  25189. * The other channels might be use as a mask to vary the different effects intensity.
  25190. */
  25191. thicknessTexture: Nullable<BaseTexture>;
  25192. private _refractionTexture;
  25193. /**
  25194. * Defines the texture to use for refraction.
  25195. */
  25196. refractionTexture: Nullable<BaseTexture>;
  25197. private _indexOfRefraction;
  25198. /**
  25199. * Index of refraction of the material base layer.
  25200. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25201. *
  25202. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25203. *
  25204. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25205. */
  25206. indexOfRefraction: number;
  25207. private _volumeIndexOfRefraction;
  25208. /**
  25209. * Index of refraction of the material's volume.
  25210. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25211. *
  25212. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25213. * the volume will use the same IOR as the surface.
  25214. */
  25215. get volumeIndexOfRefraction(): number;
  25216. set volumeIndexOfRefraction(value: number);
  25217. private _invertRefractionY;
  25218. /**
  25219. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25220. */
  25221. invertRefractionY: boolean;
  25222. private _linkRefractionWithTransparency;
  25223. /**
  25224. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25225. * Materials half opaque for instance using refraction could benefit from this control.
  25226. */
  25227. linkRefractionWithTransparency: boolean;
  25228. /**
  25229. * Defines the minimum thickness stored in the thickness map.
  25230. * If no thickness map is defined, this value will be used to simulate thickness.
  25231. */
  25232. minimumThickness: number;
  25233. /**
  25234. * Defines the maximum thickness stored in the thickness map.
  25235. */
  25236. maximumThickness: number;
  25237. /**
  25238. * Defines the volume tint of the material.
  25239. * This is used for both translucency and scattering.
  25240. */
  25241. tintColor: Color3;
  25242. /**
  25243. * Defines the distance at which the tint color should be found in the media.
  25244. * This is used for refraction only.
  25245. */
  25246. tintColorAtDistance: number;
  25247. /**
  25248. * Defines how far each channel transmit through the media.
  25249. * It is defined as a color to simplify it selection.
  25250. */
  25251. diffusionDistance: Color3;
  25252. private _useMaskFromThicknessTexture;
  25253. /**
  25254. * Stores the intensity of the different subsurface effects in the thickness texture.
  25255. * * the green channel is the translucency intensity.
  25256. * * the blue channel is the scattering intensity.
  25257. * * the alpha channel is the refraction intensity.
  25258. */
  25259. useMaskFromThicknessTexture: boolean;
  25260. private _scene;
  25261. /** @hidden */
  25262. private _internalMarkAllSubMeshesAsTexturesDirty;
  25263. private _internalMarkScenePrePassDirty;
  25264. /** @hidden */
  25265. _markAllSubMeshesAsTexturesDirty(): void;
  25266. /** @hidden */
  25267. _markScenePrePassDirty(): void;
  25268. /**
  25269. * Instantiate a new istance of sub surface configuration.
  25270. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25271. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25272. * @param scene The scene
  25273. */
  25274. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25275. /**
  25276. * Gets wehter the submesh is ready to be used or not.
  25277. * @param defines the list of "defines" to update.
  25278. * @param scene defines the scene the material belongs to.
  25279. * @returns - boolean indicating that the submesh is ready or not.
  25280. */
  25281. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25282. /**
  25283. * Checks to see if a texture is used in the material.
  25284. * @param defines the list of "defines" to update.
  25285. * @param scene defines the scene to the material belongs to.
  25286. */
  25287. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25288. /**
  25289. * Binds the material data.
  25290. * @param uniformBuffer defines the Uniform buffer to fill in.
  25291. * @param scene defines the scene the material belongs to.
  25292. * @param engine defines the engine the material belongs to.
  25293. * @param isFrozen defines whether the material is frozen or not.
  25294. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25295. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25296. */
  25297. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25298. /**
  25299. * Unbinds the material from the mesh.
  25300. * @param activeEffect defines the effect that should be unbound from.
  25301. * @returns true if unbound, otherwise false
  25302. */
  25303. unbind(activeEffect: Effect): boolean;
  25304. /**
  25305. * Returns the texture used for refraction or null if none is used.
  25306. * @param scene defines the scene the material belongs to.
  25307. * @returns - Refraction texture if present. If no refraction texture and refraction
  25308. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25309. */
  25310. private _getRefractionTexture;
  25311. /**
  25312. * Returns true if alpha blending should be disabled.
  25313. */
  25314. get disableAlphaBlending(): boolean;
  25315. /**
  25316. * Fills the list of render target textures.
  25317. * @param renderTargets the list of render targets to update
  25318. */
  25319. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25320. /**
  25321. * Checks to see if a texture is used in the material.
  25322. * @param texture - Base texture to use.
  25323. * @returns - Boolean specifying if a texture is used in the material.
  25324. */
  25325. hasTexture(texture: BaseTexture): boolean;
  25326. /**
  25327. * Gets a boolean indicating that current material needs to register RTT
  25328. * @returns true if this uses a render target otherwise false.
  25329. */
  25330. hasRenderTargetTextures(): boolean;
  25331. /**
  25332. * Returns an array of the actively used textures.
  25333. * @param activeTextures Array of BaseTextures
  25334. */
  25335. getActiveTextures(activeTextures: BaseTexture[]): void;
  25336. /**
  25337. * Returns the animatable textures.
  25338. * @param animatables Array of animatable textures.
  25339. */
  25340. getAnimatables(animatables: IAnimatable[]): void;
  25341. /**
  25342. * Disposes the resources of the material.
  25343. * @param forceDisposeTextures - Forces the disposal of all textures.
  25344. */
  25345. dispose(forceDisposeTextures?: boolean): void;
  25346. /**
  25347. * Get the current class name of the texture useful for serialization or dynamic coding.
  25348. * @returns "PBRSubSurfaceConfiguration"
  25349. */
  25350. getClassName(): string;
  25351. /**
  25352. * Add fallbacks to the effect fallbacks list.
  25353. * @param defines defines the Base texture to use.
  25354. * @param fallbacks defines the current fallback list.
  25355. * @param currentRank defines the current fallback rank.
  25356. * @returns the new fallback rank.
  25357. */
  25358. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25359. /**
  25360. * Add the required uniforms to the current list.
  25361. * @param uniforms defines the current uniform list.
  25362. */
  25363. static AddUniforms(uniforms: string[]): void;
  25364. /**
  25365. * Add the required samplers to the current list.
  25366. * @param samplers defines the current sampler list.
  25367. */
  25368. static AddSamplers(samplers: string[]): void;
  25369. /**
  25370. * Add the required uniforms to the current buffer.
  25371. * @param uniformBuffer defines the current uniform buffer.
  25372. */
  25373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25374. /**
  25375. * Makes a duplicate of the current configuration into another one.
  25376. * @param configuration define the config where to copy the info
  25377. */
  25378. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25379. /**
  25380. * Serializes this Sub Surface configuration.
  25381. * @returns - An object with the serialized config.
  25382. */
  25383. serialize(): any;
  25384. /**
  25385. * Parses a anisotropy Configuration from a serialized object.
  25386. * @param source - Serialized object.
  25387. * @param scene Defines the scene we are parsing for
  25388. * @param rootUrl Defines the rootUrl to load from
  25389. */
  25390. parse(source: any, scene: Scene, rootUrl: string): void;
  25391. }
  25392. }
  25393. declare module BABYLON {
  25394. /**
  25395. * Class representing spherical harmonics coefficients to the 3rd degree
  25396. */
  25397. export class SphericalHarmonics {
  25398. /**
  25399. * Defines whether or not the harmonics have been prescaled for rendering.
  25400. */
  25401. preScaled: boolean;
  25402. /**
  25403. * The l0,0 coefficients of the spherical harmonics
  25404. */
  25405. l00: Vector3;
  25406. /**
  25407. * The l1,-1 coefficients of the spherical harmonics
  25408. */
  25409. l1_1: Vector3;
  25410. /**
  25411. * The l1,0 coefficients of the spherical harmonics
  25412. */
  25413. l10: Vector3;
  25414. /**
  25415. * The l1,1 coefficients of the spherical harmonics
  25416. */
  25417. l11: Vector3;
  25418. /**
  25419. * The l2,-2 coefficients of the spherical harmonics
  25420. */
  25421. l2_2: Vector3;
  25422. /**
  25423. * The l2,-1 coefficients of the spherical harmonics
  25424. */
  25425. l2_1: Vector3;
  25426. /**
  25427. * The l2,0 coefficients of the spherical harmonics
  25428. */
  25429. l20: Vector3;
  25430. /**
  25431. * The l2,1 coefficients of the spherical harmonics
  25432. */
  25433. l21: Vector3;
  25434. /**
  25435. * The l2,2 coefficients of the spherical harmonics
  25436. */
  25437. l22: Vector3;
  25438. /**
  25439. * Adds a light to the spherical harmonics
  25440. * @param direction the direction of the light
  25441. * @param color the color of the light
  25442. * @param deltaSolidAngle the delta solid angle of the light
  25443. */
  25444. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25445. /**
  25446. * Scales the spherical harmonics by the given amount
  25447. * @param scale the amount to scale
  25448. */
  25449. scaleInPlace(scale: number): void;
  25450. /**
  25451. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25452. *
  25453. * ```
  25454. * E_lm = A_l * L_lm
  25455. * ```
  25456. *
  25457. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25458. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25459. * the scaling factors are given in equation 9.
  25460. */
  25461. convertIncidentRadianceToIrradiance(): void;
  25462. /**
  25463. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25464. *
  25465. * ```
  25466. * L = (1/pi) * E * rho
  25467. * ```
  25468. *
  25469. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25470. */
  25471. convertIrradianceToLambertianRadiance(): void;
  25472. /**
  25473. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25474. * required operations at run time.
  25475. *
  25476. * This is simply done by scaling back the SH with Ylm constants parameter.
  25477. * The trigonometric part being applied by the shader at run time.
  25478. */
  25479. preScaleForRendering(): void;
  25480. /**
  25481. * Constructs a spherical harmonics from an array.
  25482. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25483. * @returns the spherical harmonics
  25484. */
  25485. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25486. /**
  25487. * Gets the spherical harmonics from polynomial
  25488. * @param polynomial the spherical polynomial
  25489. * @returns the spherical harmonics
  25490. */
  25491. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25492. }
  25493. /**
  25494. * Class representing spherical polynomial coefficients to the 3rd degree
  25495. */
  25496. export class SphericalPolynomial {
  25497. private _harmonics;
  25498. /**
  25499. * The spherical harmonics used to create the polynomials.
  25500. */
  25501. get preScaledHarmonics(): SphericalHarmonics;
  25502. /**
  25503. * The x coefficients of the spherical polynomial
  25504. */
  25505. x: Vector3;
  25506. /**
  25507. * The y coefficients of the spherical polynomial
  25508. */
  25509. y: Vector3;
  25510. /**
  25511. * The z coefficients of the spherical polynomial
  25512. */
  25513. z: Vector3;
  25514. /**
  25515. * The xx coefficients of the spherical polynomial
  25516. */
  25517. xx: Vector3;
  25518. /**
  25519. * The yy coefficients of the spherical polynomial
  25520. */
  25521. yy: Vector3;
  25522. /**
  25523. * The zz coefficients of the spherical polynomial
  25524. */
  25525. zz: Vector3;
  25526. /**
  25527. * The xy coefficients of the spherical polynomial
  25528. */
  25529. xy: Vector3;
  25530. /**
  25531. * The yz coefficients of the spherical polynomial
  25532. */
  25533. yz: Vector3;
  25534. /**
  25535. * The zx coefficients of the spherical polynomial
  25536. */
  25537. zx: Vector3;
  25538. /**
  25539. * Adds an ambient color to the spherical polynomial
  25540. * @param color the color to add
  25541. */
  25542. addAmbient(color: Color3): void;
  25543. /**
  25544. * Scales the spherical polynomial by the given amount
  25545. * @param scale the amount to scale
  25546. */
  25547. scaleInPlace(scale: number): void;
  25548. /**
  25549. * Gets the spherical polynomial from harmonics
  25550. * @param harmonics the spherical harmonics
  25551. * @returns the spherical polynomial
  25552. */
  25553. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25554. /**
  25555. * Constructs a spherical polynomial from an array.
  25556. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25557. * @returns the spherical polynomial
  25558. */
  25559. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25560. }
  25561. }
  25562. declare module BABYLON {
  25563. /**
  25564. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25565. */
  25566. export interface CubeMapInfo {
  25567. /**
  25568. * The pixel array for the front face.
  25569. * This is stored in format, left to right, up to down format.
  25570. */
  25571. front: Nullable<ArrayBufferView>;
  25572. /**
  25573. * The pixel array for the back face.
  25574. * This is stored in format, left to right, up to down format.
  25575. */
  25576. back: Nullable<ArrayBufferView>;
  25577. /**
  25578. * The pixel array for the left face.
  25579. * This is stored in format, left to right, up to down format.
  25580. */
  25581. left: Nullable<ArrayBufferView>;
  25582. /**
  25583. * The pixel array for the right face.
  25584. * This is stored in format, left to right, up to down format.
  25585. */
  25586. right: Nullable<ArrayBufferView>;
  25587. /**
  25588. * The pixel array for the up face.
  25589. * This is stored in format, left to right, up to down format.
  25590. */
  25591. up: Nullable<ArrayBufferView>;
  25592. /**
  25593. * The pixel array for the down face.
  25594. * This is stored in format, left to right, up to down format.
  25595. */
  25596. down: Nullable<ArrayBufferView>;
  25597. /**
  25598. * The size of the cubemap stored.
  25599. *
  25600. * Each faces will be size * size pixels.
  25601. */
  25602. size: number;
  25603. /**
  25604. * The format of the texture.
  25605. *
  25606. * RGBA, RGB.
  25607. */
  25608. format: number;
  25609. /**
  25610. * The type of the texture data.
  25611. *
  25612. * UNSIGNED_INT, FLOAT.
  25613. */
  25614. type: number;
  25615. /**
  25616. * Specifies whether the texture is in gamma space.
  25617. */
  25618. gammaSpace: boolean;
  25619. }
  25620. /**
  25621. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25622. */
  25623. export class PanoramaToCubeMapTools {
  25624. private static FACE_LEFT;
  25625. private static FACE_RIGHT;
  25626. private static FACE_FRONT;
  25627. private static FACE_BACK;
  25628. private static FACE_DOWN;
  25629. private static FACE_UP;
  25630. /**
  25631. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25632. *
  25633. * @param float32Array The source data.
  25634. * @param inputWidth The width of the input panorama.
  25635. * @param inputHeight The height of the input panorama.
  25636. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25637. * @return The cubemap data
  25638. */
  25639. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25640. private static CreateCubemapTexture;
  25641. private static CalcProjectionSpherical;
  25642. }
  25643. }
  25644. declare module BABYLON {
  25645. /**
  25646. * Helper class dealing with the extraction of spherical polynomial dataArray
  25647. * from a cube map.
  25648. */
  25649. export class CubeMapToSphericalPolynomialTools {
  25650. private static FileFaces;
  25651. /**
  25652. * Converts a texture to the according Spherical Polynomial data.
  25653. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25654. *
  25655. * @param texture The texture to extract the information from.
  25656. * @return The Spherical Polynomial data.
  25657. */
  25658. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25659. /**
  25660. * Converts a cubemap to the according Spherical Polynomial data.
  25661. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25662. *
  25663. * @param cubeInfo The Cube map to extract the information from.
  25664. * @return The Spherical Polynomial data.
  25665. */
  25666. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25667. }
  25668. }
  25669. declare module BABYLON {
  25670. interface BaseTexture {
  25671. /**
  25672. * Get the polynomial representation of the texture data.
  25673. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25674. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25675. */
  25676. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25677. }
  25678. }
  25679. declare module BABYLON {
  25680. /** @hidden */
  25681. export var pbrFragmentDeclaration: {
  25682. name: string;
  25683. shader: string;
  25684. };
  25685. }
  25686. declare module BABYLON {
  25687. /** @hidden */
  25688. export var pbrUboDeclaration: {
  25689. name: string;
  25690. shader: string;
  25691. };
  25692. }
  25693. declare module BABYLON {
  25694. /** @hidden */
  25695. export var pbrFragmentExtraDeclaration: {
  25696. name: string;
  25697. shader: string;
  25698. };
  25699. }
  25700. declare module BABYLON {
  25701. /** @hidden */
  25702. export var pbrFragmentSamplersDeclaration: {
  25703. name: string;
  25704. shader: string;
  25705. };
  25706. }
  25707. declare module BABYLON {
  25708. /** @hidden */
  25709. export var subSurfaceScatteringFunctions: {
  25710. name: string;
  25711. shader: string;
  25712. };
  25713. }
  25714. declare module BABYLON {
  25715. /** @hidden */
  25716. export var importanceSampling: {
  25717. name: string;
  25718. shader: string;
  25719. };
  25720. }
  25721. declare module BABYLON {
  25722. /** @hidden */
  25723. export var pbrHelperFunctions: {
  25724. name: string;
  25725. shader: string;
  25726. };
  25727. }
  25728. declare module BABYLON {
  25729. /** @hidden */
  25730. export var harmonicsFunctions: {
  25731. name: string;
  25732. shader: string;
  25733. };
  25734. }
  25735. declare module BABYLON {
  25736. /** @hidden */
  25737. export var pbrDirectLightingSetupFunctions: {
  25738. name: string;
  25739. shader: string;
  25740. };
  25741. }
  25742. declare module BABYLON {
  25743. /** @hidden */
  25744. export var pbrDirectLightingFalloffFunctions: {
  25745. name: string;
  25746. shader: string;
  25747. };
  25748. }
  25749. declare module BABYLON {
  25750. /** @hidden */
  25751. export var pbrBRDFFunctions: {
  25752. name: string;
  25753. shader: string;
  25754. };
  25755. }
  25756. declare module BABYLON {
  25757. /** @hidden */
  25758. export var hdrFilteringFunctions: {
  25759. name: string;
  25760. shader: string;
  25761. };
  25762. }
  25763. declare module BABYLON {
  25764. /** @hidden */
  25765. export var pbrDirectLightingFunctions: {
  25766. name: string;
  25767. shader: string;
  25768. };
  25769. }
  25770. declare module BABYLON {
  25771. /** @hidden */
  25772. export var pbrIBLFunctions: {
  25773. name: string;
  25774. shader: string;
  25775. };
  25776. }
  25777. declare module BABYLON {
  25778. /** @hidden */
  25779. export var pbrBlockAlbedoOpacity: {
  25780. name: string;
  25781. shader: string;
  25782. };
  25783. }
  25784. declare module BABYLON {
  25785. /** @hidden */
  25786. export var pbrBlockReflectivity: {
  25787. name: string;
  25788. shader: string;
  25789. };
  25790. }
  25791. declare module BABYLON {
  25792. /** @hidden */
  25793. export var pbrBlockAmbientOcclusion: {
  25794. name: string;
  25795. shader: string;
  25796. };
  25797. }
  25798. declare module BABYLON {
  25799. /** @hidden */
  25800. export var pbrBlockAlphaFresnel: {
  25801. name: string;
  25802. shader: string;
  25803. };
  25804. }
  25805. declare module BABYLON {
  25806. /** @hidden */
  25807. export var pbrBlockAnisotropic: {
  25808. name: string;
  25809. shader: string;
  25810. };
  25811. }
  25812. declare module BABYLON {
  25813. /** @hidden */
  25814. export var pbrBlockReflection: {
  25815. name: string;
  25816. shader: string;
  25817. };
  25818. }
  25819. declare module BABYLON {
  25820. /** @hidden */
  25821. export var pbrBlockSheen: {
  25822. name: string;
  25823. shader: string;
  25824. };
  25825. }
  25826. declare module BABYLON {
  25827. /** @hidden */
  25828. export var pbrBlockClearcoat: {
  25829. name: string;
  25830. shader: string;
  25831. };
  25832. }
  25833. declare module BABYLON {
  25834. /** @hidden */
  25835. export var pbrBlockSubSurface: {
  25836. name: string;
  25837. shader: string;
  25838. };
  25839. }
  25840. declare module BABYLON {
  25841. /** @hidden */
  25842. export var pbrBlockNormalGeometric: {
  25843. name: string;
  25844. shader: string;
  25845. };
  25846. }
  25847. declare module BABYLON {
  25848. /** @hidden */
  25849. export var pbrBlockNormalFinal: {
  25850. name: string;
  25851. shader: string;
  25852. };
  25853. }
  25854. declare module BABYLON {
  25855. /** @hidden */
  25856. export var pbrBlockLightmapInit: {
  25857. name: string;
  25858. shader: string;
  25859. };
  25860. }
  25861. declare module BABYLON {
  25862. /** @hidden */
  25863. export var pbrBlockGeometryInfo: {
  25864. name: string;
  25865. shader: string;
  25866. };
  25867. }
  25868. declare module BABYLON {
  25869. /** @hidden */
  25870. export var pbrBlockReflectance0: {
  25871. name: string;
  25872. shader: string;
  25873. };
  25874. }
  25875. declare module BABYLON {
  25876. /** @hidden */
  25877. export var pbrBlockReflectance: {
  25878. name: string;
  25879. shader: string;
  25880. };
  25881. }
  25882. declare module BABYLON {
  25883. /** @hidden */
  25884. export var pbrBlockDirectLighting: {
  25885. name: string;
  25886. shader: string;
  25887. };
  25888. }
  25889. declare module BABYLON {
  25890. /** @hidden */
  25891. export var pbrBlockFinalLitComponents: {
  25892. name: string;
  25893. shader: string;
  25894. };
  25895. }
  25896. declare module BABYLON {
  25897. /** @hidden */
  25898. export var pbrBlockFinalUnlitComponents: {
  25899. name: string;
  25900. shader: string;
  25901. };
  25902. }
  25903. declare module BABYLON {
  25904. /** @hidden */
  25905. export var pbrBlockFinalColorComposition: {
  25906. name: string;
  25907. shader: string;
  25908. };
  25909. }
  25910. declare module BABYLON {
  25911. /** @hidden */
  25912. export var pbrBlockImageProcessing: {
  25913. name: string;
  25914. shader: string;
  25915. };
  25916. }
  25917. declare module BABYLON {
  25918. /** @hidden */
  25919. export var pbrDebug: {
  25920. name: string;
  25921. shader: string;
  25922. };
  25923. }
  25924. declare module BABYLON {
  25925. /** @hidden */
  25926. export var pbrPixelShader: {
  25927. name: string;
  25928. shader: string;
  25929. };
  25930. }
  25931. declare module BABYLON {
  25932. /** @hidden */
  25933. export var pbrVertexDeclaration: {
  25934. name: string;
  25935. shader: string;
  25936. };
  25937. }
  25938. declare module BABYLON {
  25939. /** @hidden */
  25940. export var pbrVertexShader: {
  25941. name: string;
  25942. shader: string;
  25943. };
  25944. }
  25945. declare module BABYLON {
  25946. /**
  25947. * Manages the defines for the PBR Material.
  25948. * @hidden
  25949. */
  25950. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25951. PBR: boolean;
  25952. NUM_SAMPLES: string;
  25953. REALTIME_FILTERING: boolean;
  25954. MAINUV1: boolean;
  25955. MAINUV2: boolean;
  25956. UV1: boolean;
  25957. UV2: boolean;
  25958. ALBEDO: boolean;
  25959. GAMMAALBEDO: boolean;
  25960. ALBEDODIRECTUV: number;
  25961. VERTEXCOLOR: boolean;
  25962. DETAIL: boolean;
  25963. DETAILDIRECTUV: number;
  25964. DETAIL_NORMALBLENDMETHOD: number;
  25965. AMBIENT: boolean;
  25966. AMBIENTDIRECTUV: number;
  25967. AMBIENTINGRAYSCALE: boolean;
  25968. OPACITY: boolean;
  25969. VERTEXALPHA: boolean;
  25970. OPACITYDIRECTUV: number;
  25971. OPACITYRGB: boolean;
  25972. ALPHATEST: boolean;
  25973. DEPTHPREPASS: boolean;
  25974. ALPHABLEND: boolean;
  25975. ALPHAFROMALBEDO: boolean;
  25976. ALPHATESTVALUE: string;
  25977. SPECULAROVERALPHA: boolean;
  25978. RADIANCEOVERALPHA: boolean;
  25979. ALPHAFRESNEL: boolean;
  25980. LINEARALPHAFRESNEL: boolean;
  25981. PREMULTIPLYALPHA: boolean;
  25982. EMISSIVE: boolean;
  25983. EMISSIVEDIRECTUV: number;
  25984. REFLECTIVITY: boolean;
  25985. REFLECTIVITYDIRECTUV: number;
  25986. SPECULARTERM: boolean;
  25987. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25988. MICROSURFACEAUTOMATIC: boolean;
  25989. LODBASEDMICROSFURACE: boolean;
  25990. MICROSURFACEMAP: boolean;
  25991. MICROSURFACEMAPDIRECTUV: number;
  25992. METALLICWORKFLOW: boolean;
  25993. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25994. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25995. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25996. AOSTOREINMETALMAPRED: boolean;
  25997. METALLIC_REFLECTANCE: boolean;
  25998. METALLIC_REFLECTANCEDIRECTUV: number;
  25999. ENVIRONMENTBRDF: boolean;
  26000. ENVIRONMENTBRDF_RGBD: boolean;
  26001. NORMAL: boolean;
  26002. TANGENT: boolean;
  26003. BUMP: boolean;
  26004. BUMPDIRECTUV: number;
  26005. OBJECTSPACE_NORMALMAP: boolean;
  26006. PARALLAX: boolean;
  26007. PARALLAXOCCLUSION: boolean;
  26008. NORMALXYSCALE: boolean;
  26009. LIGHTMAP: boolean;
  26010. LIGHTMAPDIRECTUV: number;
  26011. USELIGHTMAPASSHADOWMAP: boolean;
  26012. GAMMALIGHTMAP: boolean;
  26013. RGBDLIGHTMAP: boolean;
  26014. REFLECTION: boolean;
  26015. REFLECTIONMAP_3D: boolean;
  26016. REFLECTIONMAP_SPHERICAL: boolean;
  26017. REFLECTIONMAP_PLANAR: boolean;
  26018. REFLECTIONMAP_CUBIC: boolean;
  26019. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26020. REFLECTIONMAP_PROJECTION: boolean;
  26021. REFLECTIONMAP_SKYBOX: boolean;
  26022. REFLECTIONMAP_EXPLICIT: boolean;
  26023. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26024. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26025. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26026. INVERTCUBICMAP: boolean;
  26027. USESPHERICALFROMREFLECTIONMAP: boolean;
  26028. USEIRRADIANCEMAP: boolean;
  26029. SPHERICAL_HARMONICS: boolean;
  26030. USESPHERICALINVERTEX: boolean;
  26031. REFLECTIONMAP_OPPOSITEZ: boolean;
  26032. LODINREFLECTIONALPHA: boolean;
  26033. GAMMAREFLECTION: boolean;
  26034. RGBDREFLECTION: boolean;
  26035. LINEARSPECULARREFLECTION: boolean;
  26036. RADIANCEOCCLUSION: boolean;
  26037. HORIZONOCCLUSION: boolean;
  26038. INSTANCES: boolean;
  26039. THIN_INSTANCES: boolean;
  26040. PREPASS: boolean;
  26041. PREPASS_IRRADIANCE: boolean;
  26042. PREPASS_IRRADIANCE_INDEX: number;
  26043. PREPASS_ALBEDO: boolean;
  26044. PREPASS_ALBEDO_INDEX: number;
  26045. PREPASS_DEPTHNORMAL: boolean;
  26046. PREPASS_DEPTHNORMAL_INDEX: number;
  26047. PREPASS_POSITION: boolean;
  26048. PREPASS_POSITION_INDEX: number;
  26049. PREPASS_VELOCITY: boolean;
  26050. PREPASS_VELOCITY_INDEX: number;
  26051. PREPASS_REFLECTIVITY: boolean;
  26052. PREPASS_REFLECTIVITY_INDEX: number;
  26053. SCENE_MRT_COUNT: number;
  26054. NUM_BONE_INFLUENCERS: number;
  26055. BonesPerMesh: number;
  26056. BONETEXTURE: boolean;
  26057. BONES_VELOCITY_ENABLED: boolean;
  26058. NONUNIFORMSCALING: boolean;
  26059. MORPHTARGETS: boolean;
  26060. MORPHTARGETS_NORMAL: boolean;
  26061. MORPHTARGETS_TANGENT: boolean;
  26062. MORPHTARGETS_UV: boolean;
  26063. NUM_MORPH_INFLUENCERS: number;
  26064. IMAGEPROCESSING: boolean;
  26065. VIGNETTE: boolean;
  26066. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26067. VIGNETTEBLENDMODEOPAQUE: boolean;
  26068. TONEMAPPING: boolean;
  26069. TONEMAPPING_ACES: boolean;
  26070. CONTRAST: boolean;
  26071. COLORCURVES: boolean;
  26072. COLORGRADING: boolean;
  26073. COLORGRADING3D: boolean;
  26074. SAMPLER3DGREENDEPTH: boolean;
  26075. SAMPLER3DBGRMAP: boolean;
  26076. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26077. EXPOSURE: boolean;
  26078. MULTIVIEW: boolean;
  26079. USEPHYSICALLIGHTFALLOFF: boolean;
  26080. USEGLTFLIGHTFALLOFF: boolean;
  26081. TWOSIDEDLIGHTING: boolean;
  26082. SHADOWFLOAT: boolean;
  26083. CLIPPLANE: boolean;
  26084. CLIPPLANE2: boolean;
  26085. CLIPPLANE3: boolean;
  26086. CLIPPLANE4: boolean;
  26087. CLIPPLANE5: boolean;
  26088. CLIPPLANE6: boolean;
  26089. POINTSIZE: boolean;
  26090. FOG: boolean;
  26091. LOGARITHMICDEPTH: boolean;
  26092. FORCENORMALFORWARD: boolean;
  26093. SPECULARAA: boolean;
  26094. CLEARCOAT: boolean;
  26095. CLEARCOAT_DEFAULTIOR: boolean;
  26096. CLEARCOAT_TEXTURE: boolean;
  26097. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26098. CLEARCOAT_TEXTUREDIRECTUV: number;
  26099. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26100. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26101. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26102. CLEARCOAT_BUMP: boolean;
  26103. CLEARCOAT_BUMPDIRECTUV: number;
  26104. CLEARCOAT_REMAP_F0: boolean;
  26105. CLEARCOAT_TINT: boolean;
  26106. CLEARCOAT_TINT_TEXTURE: boolean;
  26107. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26108. ANISOTROPIC: boolean;
  26109. ANISOTROPIC_TEXTURE: boolean;
  26110. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26111. BRDF_V_HEIGHT_CORRELATED: boolean;
  26112. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26113. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26114. SHEEN: boolean;
  26115. SHEEN_TEXTURE: boolean;
  26116. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26117. SHEEN_TEXTUREDIRECTUV: number;
  26118. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26119. SHEEN_LINKWITHALBEDO: boolean;
  26120. SHEEN_ROUGHNESS: boolean;
  26121. SHEEN_ALBEDOSCALING: boolean;
  26122. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26123. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26124. SUBSURFACE: boolean;
  26125. SS_REFRACTION: boolean;
  26126. SS_TRANSLUCENCY: boolean;
  26127. SS_SCATTERING: boolean;
  26128. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26129. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26130. SS_REFRACTIONMAP_3D: boolean;
  26131. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26132. SS_LODINREFRACTIONALPHA: boolean;
  26133. SS_GAMMAREFRACTION: boolean;
  26134. SS_RGBDREFRACTION: boolean;
  26135. SS_LINEARSPECULARREFRACTION: boolean;
  26136. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26137. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26138. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26139. UNLIT: boolean;
  26140. DEBUGMODE: number;
  26141. /**
  26142. * Initializes the PBR Material defines.
  26143. */
  26144. constructor();
  26145. /**
  26146. * Resets the PBR Material defines.
  26147. */
  26148. reset(): void;
  26149. }
  26150. /**
  26151. * The Physically based material base class of BJS.
  26152. *
  26153. * This offers the main features of a standard PBR material.
  26154. * For more information, please refer to the documentation :
  26155. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26156. */
  26157. export abstract class PBRBaseMaterial extends PushMaterial {
  26158. /**
  26159. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26160. */
  26161. static readonly PBRMATERIAL_OPAQUE: number;
  26162. /**
  26163. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26164. */
  26165. static readonly PBRMATERIAL_ALPHATEST: number;
  26166. /**
  26167. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26168. */
  26169. static readonly PBRMATERIAL_ALPHABLEND: number;
  26170. /**
  26171. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26172. * They are also discarded below the alpha cutoff threshold to improve performances.
  26173. */
  26174. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26175. /**
  26176. * Defines the default value of how much AO map is occluding the analytical lights
  26177. * (point spot...).
  26178. */
  26179. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26180. /**
  26181. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26182. */
  26183. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26184. /**
  26185. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26186. * to enhance interoperability with other engines.
  26187. */
  26188. static readonly LIGHTFALLOFF_GLTF: number;
  26189. /**
  26190. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26191. * to enhance interoperability with other materials.
  26192. */
  26193. static readonly LIGHTFALLOFF_STANDARD: number;
  26194. /**
  26195. * Intensity of the direct lights e.g. the four lights available in your scene.
  26196. * This impacts both the direct diffuse and specular highlights.
  26197. */
  26198. protected _directIntensity: number;
  26199. /**
  26200. * Intensity of the emissive part of the material.
  26201. * This helps controlling the emissive effect without modifying the emissive color.
  26202. */
  26203. protected _emissiveIntensity: number;
  26204. /**
  26205. * Intensity of the environment e.g. how much the environment will light the object
  26206. * either through harmonics for rough material or through the refelction for shiny ones.
  26207. */
  26208. protected _environmentIntensity: number;
  26209. /**
  26210. * This is a special control allowing the reduction of the specular highlights coming from the
  26211. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26212. */
  26213. protected _specularIntensity: number;
  26214. /**
  26215. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26216. */
  26217. private _lightingInfos;
  26218. /**
  26219. * Debug Control allowing disabling the bump map on this material.
  26220. */
  26221. protected _disableBumpMap: boolean;
  26222. /**
  26223. * AKA Diffuse Texture in standard nomenclature.
  26224. */
  26225. protected _albedoTexture: Nullable<BaseTexture>;
  26226. /**
  26227. * AKA Occlusion Texture in other nomenclature.
  26228. */
  26229. protected _ambientTexture: Nullable<BaseTexture>;
  26230. /**
  26231. * AKA Occlusion Texture Intensity in other nomenclature.
  26232. */
  26233. protected _ambientTextureStrength: number;
  26234. /**
  26235. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26236. * 1 means it completely occludes it
  26237. * 0 mean it has no impact
  26238. */
  26239. protected _ambientTextureImpactOnAnalyticalLights: number;
  26240. /**
  26241. * Stores the alpha values in a texture.
  26242. */
  26243. protected _opacityTexture: Nullable<BaseTexture>;
  26244. /**
  26245. * Stores the reflection values in a texture.
  26246. */
  26247. protected _reflectionTexture: Nullable<BaseTexture>;
  26248. /**
  26249. * Stores the emissive values in a texture.
  26250. */
  26251. protected _emissiveTexture: Nullable<BaseTexture>;
  26252. /**
  26253. * AKA Specular texture in other nomenclature.
  26254. */
  26255. protected _reflectivityTexture: Nullable<BaseTexture>;
  26256. /**
  26257. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26258. */
  26259. protected _metallicTexture: Nullable<BaseTexture>;
  26260. /**
  26261. * Specifies the metallic scalar of the metallic/roughness workflow.
  26262. * Can also be used to scale the metalness values of the metallic texture.
  26263. */
  26264. protected _metallic: Nullable<number>;
  26265. /**
  26266. * Specifies the roughness scalar of the metallic/roughness workflow.
  26267. * Can also be used to scale the roughness values of the metallic texture.
  26268. */
  26269. protected _roughness: Nullable<number>;
  26270. /**
  26271. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26272. * By default the indexOfrefraction is used to compute F0;
  26273. *
  26274. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26275. *
  26276. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26277. * F90 = metallicReflectanceColor;
  26278. */
  26279. protected _metallicF0Factor: number;
  26280. /**
  26281. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26282. * By default the F90 is always 1;
  26283. *
  26284. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26285. *
  26286. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26287. * F90 = metallicReflectanceColor;
  26288. */
  26289. protected _metallicReflectanceColor: Color3;
  26290. /**
  26291. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26292. * This is multiply against the scalar values defined in the material.
  26293. */
  26294. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26295. /**
  26296. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26297. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26298. */
  26299. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26300. /**
  26301. * Stores surface normal data used to displace a mesh in a texture.
  26302. */
  26303. protected _bumpTexture: Nullable<BaseTexture>;
  26304. /**
  26305. * Stores the pre-calculated light information of a mesh in a texture.
  26306. */
  26307. protected _lightmapTexture: Nullable<BaseTexture>;
  26308. /**
  26309. * The color of a material in ambient lighting.
  26310. */
  26311. protected _ambientColor: Color3;
  26312. /**
  26313. * AKA Diffuse Color in other nomenclature.
  26314. */
  26315. protected _albedoColor: Color3;
  26316. /**
  26317. * AKA Specular Color in other nomenclature.
  26318. */
  26319. protected _reflectivityColor: Color3;
  26320. /**
  26321. * The color applied when light is reflected from a material.
  26322. */
  26323. protected _reflectionColor: Color3;
  26324. /**
  26325. * The color applied when light is emitted from a material.
  26326. */
  26327. protected _emissiveColor: Color3;
  26328. /**
  26329. * AKA Glossiness in other nomenclature.
  26330. */
  26331. protected _microSurface: number;
  26332. /**
  26333. * Specifies that the material will use the light map as a show map.
  26334. */
  26335. protected _useLightmapAsShadowmap: boolean;
  26336. /**
  26337. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26338. * makes the reflect vector face the model (under horizon).
  26339. */
  26340. protected _useHorizonOcclusion: boolean;
  26341. /**
  26342. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26343. * too much the area relying on ambient texture to define their ambient occlusion.
  26344. */
  26345. protected _useRadianceOcclusion: boolean;
  26346. /**
  26347. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26348. */
  26349. protected _useAlphaFromAlbedoTexture: boolean;
  26350. /**
  26351. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26352. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26353. */
  26354. protected _useSpecularOverAlpha: boolean;
  26355. /**
  26356. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26357. */
  26358. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26359. /**
  26360. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26361. */
  26362. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26363. /**
  26364. * Specifies if the metallic texture contains the roughness information in its green channel.
  26365. */
  26366. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26367. /**
  26368. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26369. */
  26370. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26371. /**
  26372. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26373. */
  26374. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26375. /**
  26376. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26377. */
  26378. protected _useAmbientInGrayScale: boolean;
  26379. /**
  26380. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26381. * The material will try to infer what glossiness each pixel should be.
  26382. */
  26383. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26384. /**
  26385. * Defines the falloff type used in this material.
  26386. * It by default is Physical.
  26387. */
  26388. protected _lightFalloff: number;
  26389. /**
  26390. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26391. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26392. */
  26393. protected _useRadianceOverAlpha: boolean;
  26394. /**
  26395. * Allows using an object space normal map (instead of tangent space).
  26396. */
  26397. protected _useObjectSpaceNormalMap: boolean;
  26398. /**
  26399. * Allows using the bump map in parallax mode.
  26400. */
  26401. protected _useParallax: boolean;
  26402. /**
  26403. * Allows using the bump map in parallax occlusion mode.
  26404. */
  26405. protected _useParallaxOcclusion: boolean;
  26406. /**
  26407. * Controls the scale bias of the parallax mode.
  26408. */
  26409. protected _parallaxScaleBias: number;
  26410. /**
  26411. * If sets to true, disables all the lights affecting the material.
  26412. */
  26413. protected _disableLighting: boolean;
  26414. /**
  26415. * Number of Simultaneous lights allowed on the material.
  26416. */
  26417. protected _maxSimultaneousLights: number;
  26418. /**
  26419. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26420. */
  26421. protected _invertNormalMapX: boolean;
  26422. /**
  26423. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26424. */
  26425. protected _invertNormalMapY: boolean;
  26426. /**
  26427. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26428. */
  26429. protected _twoSidedLighting: boolean;
  26430. /**
  26431. * Defines the alpha limits in alpha test mode.
  26432. */
  26433. protected _alphaCutOff: number;
  26434. /**
  26435. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26436. */
  26437. protected _forceAlphaTest: boolean;
  26438. /**
  26439. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26440. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26441. */
  26442. protected _useAlphaFresnel: boolean;
  26443. /**
  26444. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26445. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26446. */
  26447. protected _useLinearAlphaFresnel: boolean;
  26448. /**
  26449. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26450. * from cos thetav and roughness:
  26451. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26452. */
  26453. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26454. /**
  26455. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26456. */
  26457. protected _forceIrradianceInFragment: boolean;
  26458. private _realTimeFiltering;
  26459. /**
  26460. * Enables realtime filtering on the texture.
  26461. */
  26462. get realTimeFiltering(): boolean;
  26463. set realTimeFiltering(b: boolean);
  26464. private _realTimeFilteringQuality;
  26465. /**
  26466. * Quality switch for realtime filtering
  26467. */
  26468. get realTimeFilteringQuality(): number;
  26469. set realTimeFilteringQuality(n: number);
  26470. /**
  26471. * Can this material render to several textures at once
  26472. */
  26473. get canRenderToMRT(): boolean;
  26474. /**
  26475. * Force normal to face away from face.
  26476. */
  26477. protected _forceNormalForward: boolean;
  26478. /**
  26479. * Enables specular anti aliasing in the PBR shader.
  26480. * It will both interacts on the Geometry for analytical and IBL lighting.
  26481. * It also prefilter the roughness map based on the bump values.
  26482. */
  26483. protected _enableSpecularAntiAliasing: boolean;
  26484. /**
  26485. * Default configuration related to image processing available in the PBR Material.
  26486. */
  26487. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26488. /**
  26489. * Keep track of the image processing observer to allow dispose and replace.
  26490. */
  26491. private _imageProcessingObserver;
  26492. /**
  26493. * Attaches a new image processing configuration to the PBR Material.
  26494. * @param configuration
  26495. */
  26496. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26497. /**
  26498. * Stores the available render targets.
  26499. */
  26500. private _renderTargets;
  26501. /**
  26502. * Sets the global ambient color for the material used in lighting calculations.
  26503. */
  26504. private _globalAmbientColor;
  26505. /**
  26506. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26507. */
  26508. private _useLogarithmicDepth;
  26509. /**
  26510. * If set to true, no lighting calculations will be applied.
  26511. */
  26512. private _unlit;
  26513. private _debugMode;
  26514. /**
  26515. * @hidden
  26516. * This is reserved for the inspector.
  26517. * Defines the material debug mode.
  26518. * It helps seeing only some components of the material while troubleshooting.
  26519. */
  26520. debugMode: number;
  26521. /**
  26522. * @hidden
  26523. * This is reserved for the inspector.
  26524. * Specify from where on screen the debug mode should start.
  26525. * The value goes from -1 (full screen) to 1 (not visible)
  26526. * It helps with side by side comparison against the final render
  26527. * This defaults to -1
  26528. */
  26529. private debugLimit;
  26530. /**
  26531. * @hidden
  26532. * This is reserved for the inspector.
  26533. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26534. * You can use the factor to better multiply the final value.
  26535. */
  26536. private debugFactor;
  26537. /**
  26538. * Defines the clear coat layer parameters for the material.
  26539. */
  26540. readonly clearCoat: PBRClearCoatConfiguration;
  26541. /**
  26542. * Defines the anisotropic parameters for the material.
  26543. */
  26544. readonly anisotropy: PBRAnisotropicConfiguration;
  26545. /**
  26546. * Defines the BRDF parameters for the material.
  26547. */
  26548. readonly brdf: PBRBRDFConfiguration;
  26549. /**
  26550. * Defines the Sheen parameters for the material.
  26551. */
  26552. readonly sheen: PBRSheenConfiguration;
  26553. /**
  26554. * Defines the SubSurface parameters for the material.
  26555. */
  26556. readonly subSurface: PBRSubSurfaceConfiguration;
  26557. /**
  26558. * Defines additionnal PrePass parameters for the material.
  26559. */
  26560. readonly prePassConfiguration: PrePassConfiguration;
  26561. /**
  26562. * Defines the detail map parameters for the material.
  26563. */
  26564. readonly detailMap: DetailMapConfiguration;
  26565. protected _rebuildInParallel: boolean;
  26566. /**
  26567. * Instantiates a new PBRMaterial instance.
  26568. *
  26569. * @param name The material name
  26570. * @param scene The scene the material will be use in.
  26571. */
  26572. constructor(name: string, scene: Scene);
  26573. /**
  26574. * Gets a boolean indicating that current material needs to register RTT
  26575. */
  26576. get hasRenderTargetTextures(): boolean;
  26577. /**
  26578. * Gets the name of the material class.
  26579. */
  26580. getClassName(): string;
  26581. /**
  26582. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26583. */
  26584. get useLogarithmicDepth(): boolean;
  26585. /**
  26586. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26587. */
  26588. set useLogarithmicDepth(value: boolean);
  26589. /**
  26590. * Returns true if alpha blending should be disabled.
  26591. */
  26592. protected get _disableAlphaBlending(): boolean;
  26593. /**
  26594. * Specifies whether or not this material should be rendered in alpha blend mode.
  26595. */
  26596. needAlphaBlending(): boolean;
  26597. /**
  26598. * Specifies whether or not this material should be rendered in alpha test mode.
  26599. */
  26600. needAlphaTesting(): boolean;
  26601. /**
  26602. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26603. */
  26604. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26605. /**
  26606. * Specifies whether or not there is a usable alpha channel for transparency.
  26607. */
  26608. protected _hasAlphaChannel(): boolean;
  26609. /**
  26610. * Gets the texture used for the alpha test.
  26611. */
  26612. getAlphaTestTexture(): Nullable<BaseTexture>;
  26613. /**
  26614. * Specifies that the submesh is ready to be used.
  26615. * @param mesh - BJS mesh.
  26616. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26617. * @param useInstances - Specifies that instances should be used.
  26618. * @returns - boolean indicating that the submesh is ready or not.
  26619. */
  26620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26621. /**
  26622. * Specifies if the material uses metallic roughness workflow.
  26623. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26624. */
  26625. isMetallicWorkflow(): boolean;
  26626. private _prepareEffect;
  26627. private _prepareDefines;
  26628. /**
  26629. * Force shader compilation
  26630. */
  26631. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26632. /**
  26633. * Initializes the uniform buffer layout for the shader.
  26634. */
  26635. buildUniformLayout(): void;
  26636. /**
  26637. * Unbinds the material from the mesh
  26638. */
  26639. unbind(): void;
  26640. /**
  26641. * Binds the submesh data.
  26642. * @param world - The world matrix.
  26643. * @param mesh - The BJS mesh.
  26644. * @param subMesh - A submesh of the BJS mesh.
  26645. */
  26646. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26647. /**
  26648. * Returns the animatable textures.
  26649. * @returns - Array of animatable textures.
  26650. */
  26651. getAnimatables(): IAnimatable[];
  26652. /**
  26653. * Returns the texture used for reflections.
  26654. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26655. */
  26656. private _getReflectionTexture;
  26657. /**
  26658. * Returns an array of the actively used textures.
  26659. * @returns - Array of BaseTextures
  26660. */
  26661. getActiveTextures(): BaseTexture[];
  26662. /**
  26663. * Checks to see if a texture is used in the material.
  26664. * @param texture - Base texture to use.
  26665. * @returns - Boolean specifying if a texture is used in the material.
  26666. */
  26667. hasTexture(texture: BaseTexture): boolean;
  26668. /**
  26669. * Sets the required values to the prepass renderer.
  26670. * @param prePassRenderer defines the prepass renderer to setup
  26671. */
  26672. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26673. /**
  26674. * Disposes the resources of the material.
  26675. * @param forceDisposeEffect - Forces the disposal of effects.
  26676. * @param forceDisposeTextures - Forces the disposal of all textures.
  26677. */
  26678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26679. }
  26680. }
  26681. declare module BABYLON {
  26682. /**
  26683. * The Physically based material of BJS.
  26684. *
  26685. * This offers the main features of a standard PBR material.
  26686. * For more information, please refer to the documentation :
  26687. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26688. */
  26689. export class PBRMaterial extends PBRBaseMaterial {
  26690. /**
  26691. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26692. */
  26693. static readonly PBRMATERIAL_OPAQUE: number;
  26694. /**
  26695. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26696. */
  26697. static readonly PBRMATERIAL_ALPHATEST: number;
  26698. /**
  26699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26700. */
  26701. static readonly PBRMATERIAL_ALPHABLEND: number;
  26702. /**
  26703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26704. * They are also discarded below the alpha cutoff threshold to improve performances.
  26705. */
  26706. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26707. /**
  26708. * Defines the default value of how much AO map is occluding the analytical lights
  26709. * (point spot...).
  26710. */
  26711. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26712. /**
  26713. * Intensity of the direct lights e.g. the four lights available in your scene.
  26714. * This impacts both the direct diffuse and specular highlights.
  26715. */
  26716. directIntensity: number;
  26717. /**
  26718. * Intensity of the emissive part of the material.
  26719. * This helps controlling the emissive effect without modifying the emissive color.
  26720. */
  26721. emissiveIntensity: number;
  26722. /**
  26723. * Intensity of the environment e.g. how much the environment will light the object
  26724. * either through harmonics for rough material or through the refelction for shiny ones.
  26725. */
  26726. environmentIntensity: number;
  26727. /**
  26728. * This is a special control allowing the reduction of the specular highlights coming from the
  26729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26730. */
  26731. specularIntensity: number;
  26732. /**
  26733. * Debug Control allowing disabling the bump map on this material.
  26734. */
  26735. disableBumpMap: boolean;
  26736. /**
  26737. * AKA Diffuse Texture in standard nomenclature.
  26738. */
  26739. albedoTexture: BaseTexture;
  26740. /**
  26741. * AKA Occlusion Texture in other nomenclature.
  26742. */
  26743. ambientTexture: BaseTexture;
  26744. /**
  26745. * AKA Occlusion Texture Intensity in other nomenclature.
  26746. */
  26747. ambientTextureStrength: number;
  26748. /**
  26749. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26750. * 1 means it completely occludes it
  26751. * 0 mean it has no impact
  26752. */
  26753. ambientTextureImpactOnAnalyticalLights: number;
  26754. /**
  26755. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26756. */
  26757. opacityTexture: BaseTexture;
  26758. /**
  26759. * Stores the reflection values in a texture.
  26760. */
  26761. reflectionTexture: Nullable<BaseTexture>;
  26762. /**
  26763. * Stores the emissive values in a texture.
  26764. */
  26765. emissiveTexture: BaseTexture;
  26766. /**
  26767. * AKA Specular texture in other nomenclature.
  26768. */
  26769. reflectivityTexture: BaseTexture;
  26770. /**
  26771. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26772. */
  26773. metallicTexture: BaseTexture;
  26774. /**
  26775. * Specifies the metallic scalar of the metallic/roughness workflow.
  26776. * Can also be used to scale the metalness values of the metallic texture.
  26777. */
  26778. metallic: Nullable<number>;
  26779. /**
  26780. * Specifies the roughness scalar of the metallic/roughness workflow.
  26781. * Can also be used to scale the roughness values of the metallic texture.
  26782. */
  26783. roughness: Nullable<number>;
  26784. /**
  26785. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26786. * By default the indexOfrefraction is used to compute F0;
  26787. *
  26788. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26789. *
  26790. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26791. * F90 = metallicReflectanceColor;
  26792. */
  26793. metallicF0Factor: number;
  26794. /**
  26795. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26796. * By default the F90 is always 1;
  26797. *
  26798. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26799. *
  26800. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26801. * F90 = metallicReflectanceColor;
  26802. */
  26803. metallicReflectanceColor: Color3;
  26804. /**
  26805. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26806. * This is multiply against the scalar values defined in the material.
  26807. */
  26808. metallicReflectanceTexture: Nullable<BaseTexture>;
  26809. /**
  26810. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26811. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26812. */
  26813. microSurfaceTexture: BaseTexture;
  26814. /**
  26815. * Stores surface normal data used to displace a mesh in a texture.
  26816. */
  26817. bumpTexture: BaseTexture;
  26818. /**
  26819. * Stores the pre-calculated light information of a mesh in a texture.
  26820. */
  26821. lightmapTexture: BaseTexture;
  26822. /**
  26823. * Stores the refracted light information in a texture.
  26824. */
  26825. get refractionTexture(): Nullable<BaseTexture>;
  26826. set refractionTexture(value: Nullable<BaseTexture>);
  26827. /**
  26828. * The color of a material in ambient lighting.
  26829. */
  26830. ambientColor: Color3;
  26831. /**
  26832. * AKA Diffuse Color in other nomenclature.
  26833. */
  26834. albedoColor: Color3;
  26835. /**
  26836. * AKA Specular Color in other nomenclature.
  26837. */
  26838. reflectivityColor: Color3;
  26839. /**
  26840. * The color reflected from the material.
  26841. */
  26842. reflectionColor: Color3;
  26843. /**
  26844. * The color emitted from the material.
  26845. */
  26846. emissiveColor: Color3;
  26847. /**
  26848. * AKA Glossiness in other nomenclature.
  26849. */
  26850. microSurface: number;
  26851. /**
  26852. * Index of refraction of the material base layer.
  26853. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26854. *
  26855. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26856. *
  26857. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26858. */
  26859. get indexOfRefraction(): number;
  26860. set indexOfRefraction(value: number);
  26861. /**
  26862. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26863. */
  26864. get invertRefractionY(): boolean;
  26865. set invertRefractionY(value: boolean);
  26866. /**
  26867. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26868. * Materials half opaque for instance using refraction could benefit from this control.
  26869. */
  26870. get linkRefractionWithTransparency(): boolean;
  26871. set linkRefractionWithTransparency(value: boolean);
  26872. /**
  26873. * If true, the light map contains occlusion information instead of lighting info.
  26874. */
  26875. useLightmapAsShadowmap: boolean;
  26876. /**
  26877. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26878. */
  26879. useAlphaFromAlbedoTexture: boolean;
  26880. /**
  26881. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26882. */
  26883. forceAlphaTest: boolean;
  26884. /**
  26885. * Defines the alpha limits in alpha test mode.
  26886. */
  26887. alphaCutOff: number;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. /**
  26894. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26895. */
  26896. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26897. /**
  26898. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26899. */
  26900. useRoughnessFromMetallicTextureAlpha: boolean;
  26901. /**
  26902. * Specifies if the metallic texture contains the roughness information in its green channel.
  26903. */
  26904. useRoughnessFromMetallicTextureGreen: boolean;
  26905. /**
  26906. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26907. */
  26908. useMetallnessFromMetallicTextureBlue: boolean;
  26909. /**
  26910. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26911. */
  26912. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26913. /**
  26914. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26915. */
  26916. useAmbientInGrayScale: boolean;
  26917. /**
  26918. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26919. * The material will try to infer what glossiness each pixel should be.
  26920. */
  26921. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26922. /**
  26923. * BJS is using an harcoded light falloff based on a manually sets up range.
  26924. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26925. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26926. */
  26927. get usePhysicalLightFalloff(): boolean;
  26928. /**
  26929. * BJS is using an harcoded light falloff based on a manually sets up range.
  26930. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26931. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26932. */
  26933. set usePhysicalLightFalloff(value: boolean);
  26934. /**
  26935. * In order to support the falloff compatibility with gltf, a special mode has been added
  26936. * to reproduce the gltf light falloff.
  26937. */
  26938. get useGLTFLightFalloff(): boolean;
  26939. /**
  26940. * In order to support the falloff compatibility with gltf, a special mode has been added
  26941. * to reproduce the gltf light falloff.
  26942. */
  26943. set useGLTFLightFalloff(value: boolean);
  26944. /**
  26945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26947. */
  26948. useRadianceOverAlpha: boolean;
  26949. /**
  26950. * Allows using an object space normal map (instead of tangent space).
  26951. */
  26952. useObjectSpaceNormalMap: boolean;
  26953. /**
  26954. * Allows using the bump map in parallax mode.
  26955. */
  26956. useParallax: boolean;
  26957. /**
  26958. * Allows using the bump map in parallax occlusion mode.
  26959. */
  26960. useParallaxOcclusion: boolean;
  26961. /**
  26962. * Controls the scale bias of the parallax mode.
  26963. */
  26964. parallaxScaleBias: number;
  26965. /**
  26966. * If sets to true, disables all the lights affecting the material.
  26967. */
  26968. disableLighting: boolean;
  26969. /**
  26970. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26971. */
  26972. forceIrradianceInFragment: boolean;
  26973. /**
  26974. * Number of Simultaneous lights allowed on the material.
  26975. */
  26976. maxSimultaneousLights: number;
  26977. /**
  26978. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26979. */
  26980. invertNormalMapX: boolean;
  26981. /**
  26982. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26983. */
  26984. invertNormalMapY: boolean;
  26985. /**
  26986. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26987. */
  26988. twoSidedLighting: boolean;
  26989. /**
  26990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26991. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26992. */
  26993. useAlphaFresnel: boolean;
  26994. /**
  26995. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26996. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26997. */
  26998. useLinearAlphaFresnel: boolean;
  26999. /**
  27000. * Let user defines the brdf lookup texture used for IBL.
  27001. * A default 8bit version is embedded but you could point at :
  27002. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27003. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27004. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27005. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27006. */
  27007. environmentBRDFTexture: Nullable<BaseTexture>;
  27008. /**
  27009. * Force normal to face away from face.
  27010. */
  27011. forceNormalForward: boolean;
  27012. /**
  27013. * Enables specular anti aliasing in the PBR shader.
  27014. * It will both interacts on the Geometry for analytical and IBL lighting.
  27015. * It also prefilter the roughness map based on the bump values.
  27016. */
  27017. enableSpecularAntiAliasing: boolean;
  27018. /**
  27019. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27020. * makes the reflect vector face the model (under horizon).
  27021. */
  27022. useHorizonOcclusion: boolean;
  27023. /**
  27024. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27025. * too much the area relying on ambient texture to define their ambient occlusion.
  27026. */
  27027. useRadianceOcclusion: boolean;
  27028. /**
  27029. * If set to true, no lighting calculations will be applied.
  27030. */
  27031. unlit: boolean;
  27032. /**
  27033. * Gets the image processing configuration used either in this material.
  27034. */
  27035. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27036. /**
  27037. * Sets the Default image processing configuration used either in the this material.
  27038. *
  27039. * If sets to null, the scene one is in use.
  27040. */
  27041. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27042. /**
  27043. * Gets wether the color curves effect is enabled.
  27044. */
  27045. get cameraColorCurvesEnabled(): boolean;
  27046. /**
  27047. * Sets wether the color curves effect is enabled.
  27048. */
  27049. set cameraColorCurvesEnabled(value: boolean);
  27050. /**
  27051. * Gets wether the color grading effect is enabled.
  27052. */
  27053. get cameraColorGradingEnabled(): boolean;
  27054. /**
  27055. * Gets wether the color grading effect is enabled.
  27056. */
  27057. set cameraColorGradingEnabled(value: boolean);
  27058. /**
  27059. * Gets wether tonemapping is enabled or not.
  27060. */
  27061. get cameraToneMappingEnabled(): boolean;
  27062. /**
  27063. * Sets wether tonemapping is enabled or not
  27064. */
  27065. set cameraToneMappingEnabled(value: boolean);
  27066. /**
  27067. * The camera exposure used on this material.
  27068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27069. * This corresponds to a photographic exposure.
  27070. */
  27071. get cameraExposure(): number;
  27072. /**
  27073. * The camera exposure used on this material.
  27074. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27075. * This corresponds to a photographic exposure.
  27076. */
  27077. set cameraExposure(value: number);
  27078. /**
  27079. * Gets The camera contrast used on this material.
  27080. */
  27081. get cameraContrast(): number;
  27082. /**
  27083. * Sets The camera contrast used on this material.
  27084. */
  27085. set cameraContrast(value: number);
  27086. /**
  27087. * Gets the Color Grading 2D Lookup Texture.
  27088. */
  27089. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27090. /**
  27091. * Sets the Color Grading 2D Lookup Texture.
  27092. */
  27093. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27094. /**
  27095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27097. * 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;
  27098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27099. */
  27100. get cameraColorCurves(): Nullable<ColorCurves>;
  27101. /**
  27102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27104. * 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;
  27105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27106. */
  27107. set cameraColorCurves(value: Nullable<ColorCurves>);
  27108. /**
  27109. * Instantiates a new PBRMaterial instance.
  27110. *
  27111. * @param name The material name
  27112. * @param scene The scene the material will be use in.
  27113. */
  27114. constructor(name: string, scene: Scene);
  27115. /**
  27116. * Returns the name of this material class.
  27117. */
  27118. getClassName(): string;
  27119. /**
  27120. * Makes a duplicate of the current material.
  27121. * @param name - name to use for the new material.
  27122. */
  27123. clone(name: string): PBRMaterial;
  27124. /**
  27125. * Serializes this PBR Material.
  27126. * @returns - An object with the serialized material.
  27127. */
  27128. serialize(): any;
  27129. /**
  27130. * Parses a PBR Material from a serialized object.
  27131. * @param source - Serialized object.
  27132. * @param scene - BJS scene instance.
  27133. * @param rootUrl - url for the scene object
  27134. * @returns - PBRMaterial
  27135. */
  27136. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27137. }
  27138. }
  27139. declare module BABYLON {
  27140. /** @hidden */
  27141. export var mrtFragmentDeclaration: {
  27142. name: string;
  27143. shader: string;
  27144. };
  27145. }
  27146. declare module BABYLON {
  27147. /** @hidden */
  27148. export var geometryPixelShader: {
  27149. name: string;
  27150. shader: string;
  27151. };
  27152. }
  27153. declare module BABYLON {
  27154. /** @hidden */
  27155. export var geometryVertexShader: {
  27156. name: string;
  27157. shader: string;
  27158. };
  27159. }
  27160. declare module BABYLON {
  27161. /** @hidden */
  27162. interface ISavedTransformationMatrix {
  27163. world: Matrix;
  27164. viewProjection: Matrix;
  27165. }
  27166. /**
  27167. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27168. */
  27169. export class GeometryBufferRenderer {
  27170. /**
  27171. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27172. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27173. */
  27174. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27175. /**
  27176. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27177. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27178. */
  27179. static readonly POSITION_TEXTURE_TYPE: number;
  27180. /**
  27181. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27182. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27183. */
  27184. static readonly VELOCITY_TEXTURE_TYPE: number;
  27185. /**
  27186. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27187. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27188. */
  27189. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27190. /**
  27191. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27192. * in order to compute objects velocities when enableVelocity is set to "true"
  27193. * @hidden
  27194. */
  27195. _previousTransformationMatrices: {
  27196. [index: number]: ISavedTransformationMatrix;
  27197. };
  27198. /**
  27199. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27200. * in order to compute objects velocities when enableVelocity is set to "true"
  27201. * @hidden
  27202. */
  27203. _previousBonesTransformationMatrices: {
  27204. [index: number]: Float32Array;
  27205. };
  27206. /**
  27207. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27208. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27209. */
  27210. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27211. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27212. renderTransparentMeshes: boolean;
  27213. private _scene;
  27214. private _resizeObserver;
  27215. private _multiRenderTarget;
  27216. private _ratio;
  27217. private _enablePosition;
  27218. private _enableVelocity;
  27219. private _enableReflectivity;
  27220. private _positionIndex;
  27221. private _velocityIndex;
  27222. private _reflectivityIndex;
  27223. private _depthNormalIndex;
  27224. private _linkedWithPrePass;
  27225. private _prePassRenderer;
  27226. private _attachments;
  27227. protected _effect: Effect;
  27228. protected _cachedDefines: string;
  27229. /**
  27230. * @hidden
  27231. * Sets up internal structures to share outputs with PrePassRenderer
  27232. * This method should only be called by the PrePassRenderer itself
  27233. */
  27234. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27235. /**
  27236. * @hidden
  27237. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27238. * This method should only be called by the PrePassRenderer itself
  27239. */
  27240. _unlinkPrePassRenderer(): void;
  27241. /**
  27242. * @hidden
  27243. * Resets the geometry buffer layout
  27244. */
  27245. _resetLayout(): void;
  27246. /**
  27247. * @hidden
  27248. * Replaces a texture in the geometry buffer renderer
  27249. * Useful when linking textures of the prepass renderer
  27250. */
  27251. _forceTextureType(geometryBufferType: number, index: number): void;
  27252. /**
  27253. * @hidden
  27254. * Sets texture attachments
  27255. * Useful when linking textures of the prepass renderer
  27256. */
  27257. _setAttachments(attachments: number[]): void;
  27258. /**
  27259. * @hidden
  27260. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27261. * Useful when linking textures of the prepass renderer
  27262. */
  27263. _linkInternalTexture(internalTexture: InternalTexture): void;
  27264. /**
  27265. * Gets the render list (meshes to be rendered) used in the G buffer.
  27266. */
  27267. get renderList(): Nullable<AbstractMesh[]>;
  27268. /**
  27269. * Set the render list (meshes to be rendered) used in the G buffer.
  27270. */
  27271. set renderList(meshes: Nullable<AbstractMesh[]>);
  27272. /**
  27273. * Gets wether or not G buffer are supported by the running hardware.
  27274. * This requires draw buffer supports
  27275. */
  27276. get isSupported(): boolean;
  27277. /**
  27278. * Returns the index of the given texture type in the G-Buffer textures array
  27279. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27280. * @returns the index of the given texture type in the G-Buffer textures array
  27281. */
  27282. getTextureIndex(textureType: number): number;
  27283. /**
  27284. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27285. */
  27286. get enablePosition(): boolean;
  27287. /**
  27288. * Sets whether or not objects positions are enabled for the G buffer.
  27289. */
  27290. set enablePosition(enable: boolean);
  27291. /**
  27292. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27293. */
  27294. get enableVelocity(): boolean;
  27295. /**
  27296. * Sets wether or not objects velocities are enabled for the G buffer.
  27297. */
  27298. set enableVelocity(enable: boolean);
  27299. /**
  27300. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27301. */
  27302. get enableReflectivity(): boolean;
  27303. /**
  27304. * Sets wether or not objects roughness are enabled for the G buffer.
  27305. */
  27306. set enableReflectivity(enable: boolean);
  27307. /**
  27308. * Gets the scene associated with the buffer.
  27309. */
  27310. get scene(): Scene;
  27311. /**
  27312. * Gets the ratio used by the buffer during its creation.
  27313. * How big is the buffer related to the main canvas.
  27314. */
  27315. get ratio(): number;
  27316. /** @hidden */
  27317. static _SceneComponentInitialization: (scene: Scene) => void;
  27318. /**
  27319. * Creates a new G Buffer for the scene
  27320. * @param scene The scene the buffer belongs to
  27321. * @param ratio How big is the buffer related to the main canvas.
  27322. */
  27323. constructor(scene: Scene, ratio?: number);
  27324. /**
  27325. * Checks wether everything is ready to render a submesh to the G buffer.
  27326. * @param subMesh the submesh to check readiness for
  27327. * @param useInstances is the mesh drawn using instance or not
  27328. * @returns true if ready otherwise false
  27329. */
  27330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27331. /**
  27332. * Gets the current underlying G Buffer.
  27333. * @returns the buffer
  27334. */
  27335. getGBuffer(): MultiRenderTarget;
  27336. /**
  27337. * Gets the number of samples used to render the buffer (anti aliasing).
  27338. */
  27339. get samples(): number;
  27340. /**
  27341. * Sets the number of samples used to render the buffer (anti aliasing).
  27342. */
  27343. set samples(value: number);
  27344. /**
  27345. * Disposes the renderer and frees up associated resources.
  27346. */
  27347. dispose(): void;
  27348. private _assignRenderTargetIndices;
  27349. protected _createRenderTargets(): void;
  27350. private _copyBonesTransformationMatrices;
  27351. }
  27352. }
  27353. declare module BABYLON {
  27354. /**
  27355. * Renders a pre pass of the scene
  27356. * This means every mesh in the scene will be rendered to a render target texture
  27357. * And then this texture will be composited to the rendering canvas with post processes
  27358. * It is necessary for effects like subsurface scattering or deferred shading
  27359. */
  27360. export class PrePassRenderer {
  27361. /** @hidden */
  27362. static _SceneComponentInitialization: (scene: Scene) => void;
  27363. private _textureFormats;
  27364. /**
  27365. * To save performance, we can excluded skinned meshes from the prepass
  27366. */
  27367. excludedSkinnedMesh: AbstractMesh[];
  27368. /**
  27369. * Force material to be excluded from the prepass
  27370. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27371. * and you don't want a material to show in the effect.
  27372. */
  27373. excludedMaterials: Material[];
  27374. private _textureIndices;
  27375. private _scene;
  27376. private _engine;
  27377. private _isDirty;
  27378. /**
  27379. * Number of textures in the multi render target texture where the scene is directly rendered
  27380. */
  27381. mrtCount: number;
  27382. /**
  27383. * The render target where the scene is directly rendered
  27384. */
  27385. prePassRT: MultiRenderTarget;
  27386. private _multiRenderAttachments;
  27387. private _defaultAttachments;
  27388. private _clearAttachments;
  27389. private _postProcesses;
  27390. private readonly _clearColor;
  27391. /**
  27392. * Image processing post process for composition
  27393. */
  27394. imageProcessingPostProcess: ImageProcessingPostProcess;
  27395. /**
  27396. * Configuration for prepass effects
  27397. */
  27398. private _effectConfigurations;
  27399. private _mrtFormats;
  27400. private _mrtLayout;
  27401. private _enabled;
  27402. /**
  27403. * Indicates if the prepass is enabled
  27404. */
  27405. get enabled(): boolean;
  27406. /**
  27407. * How many samples are used for MSAA of the scene render target
  27408. */
  27409. get samples(): number;
  27410. set samples(n: number);
  27411. private _geometryBuffer;
  27412. private _useGeometryBufferFallback;
  27413. /**
  27414. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27415. */
  27416. get useGeometryBufferFallback(): boolean;
  27417. set useGeometryBufferFallback(value: boolean);
  27418. /**
  27419. * Instanciates a prepass renderer
  27420. * @param scene The scene
  27421. */
  27422. constructor(scene: Scene);
  27423. private _initializeAttachments;
  27424. private _createCompositionEffect;
  27425. /**
  27426. * Indicates if rendering a prepass is supported
  27427. */
  27428. get isSupported(): boolean;
  27429. /**
  27430. * Sets the proper output textures to draw in the engine.
  27431. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27432. * @param subMesh Submesh on which the effect is applied
  27433. */
  27434. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27435. /**
  27436. * @hidden
  27437. */
  27438. _beforeCameraDraw(): void;
  27439. /**
  27440. * @hidden
  27441. */
  27442. _afterCameraDraw(): void;
  27443. private _checkRTSize;
  27444. private _bindFrameBuffer;
  27445. /**
  27446. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27447. */
  27448. clear(): void;
  27449. private _setState;
  27450. private _updateGeometryBufferLayout;
  27451. /**
  27452. * Adds an effect configuration to the prepass.
  27453. * If an effect has already been added, it won't add it twice and will return the configuration
  27454. * already present.
  27455. * @param cfg the effect configuration
  27456. * @return the effect configuration now used by the prepass
  27457. */
  27458. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27459. /**
  27460. * Returns the index of a texture in the multi render target texture array.
  27461. * @param type Texture type
  27462. * @return The index
  27463. */
  27464. getIndex(type: number): number;
  27465. private _enable;
  27466. private _disable;
  27467. private _resetLayout;
  27468. private _resetPostProcessChain;
  27469. private _bindPostProcessChain;
  27470. /**
  27471. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27472. */
  27473. markAsDirty(): void;
  27474. /**
  27475. * Enables a texture on the MultiRenderTarget for prepass
  27476. */
  27477. private _enableTextures;
  27478. private _update;
  27479. private _markAllMaterialsAsPrePassDirty;
  27480. /**
  27481. * Disposes the prepass renderer.
  27482. */
  27483. dispose(): void;
  27484. }
  27485. }
  27486. declare module BABYLON {
  27487. /**
  27488. * Size options for a post process
  27489. */
  27490. export type PostProcessOptions = {
  27491. width: number;
  27492. height: number;
  27493. };
  27494. /**
  27495. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27496. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27497. */
  27498. export class PostProcess {
  27499. /**
  27500. * Gets or sets the unique id of the post process
  27501. */
  27502. uniqueId: number;
  27503. /** Name of the PostProcess. */
  27504. name: string;
  27505. /**
  27506. * Width of the texture to apply the post process on
  27507. */
  27508. width: number;
  27509. /**
  27510. * Height of the texture to apply the post process on
  27511. */
  27512. height: number;
  27513. /**
  27514. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27515. */
  27516. nodeMaterialSource: Nullable<NodeMaterial>;
  27517. /**
  27518. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27519. * @hidden
  27520. */
  27521. _outputTexture: Nullable<InternalTexture>;
  27522. /**
  27523. * Sampling mode used by the shader
  27524. * See https://doc.babylonjs.com/classes/3.1/texture
  27525. */
  27526. renderTargetSamplingMode: number;
  27527. /**
  27528. * Clear color to use when screen clearing
  27529. */
  27530. clearColor: Color4;
  27531. /**
  27532. * If the buffer needs to be cleared before applying the post process. (default: true)
  27533. * Should be set to false if shader will overwrite all previous pixels.
  27534. */
  27535. autoClear: boolean;
  27536. /**
  27537. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27538. */
  27539. alphaMode: number;
  27540. /**
  27541. * Sets the setAlphaBlendConstants of the babylon engine
  27542. */
  27543. alphaConstants: Color4;
  27544. /**
  27545. * Animations to be used for the post processing
  27546. */
  27547. animations: Animation[];
  27548. /**
  27549. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27550. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27551. */
  27552. enablePixelPerfectMode: boolean;
  27553. /**
  27554. * Force the postprocess to be applied without taking in account viewport
  27555. */
  27556. forceFullscreenViewport: boolean;
  27557. /**
  27558. * List of inspectable custom properties (used by the Inspector)
  27559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27560. */
  27561. inspectableCustomProperties: IInspectable[];
  27562. /**
  27563. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27564. *
  27565. * | Value | Type | Description |
  27566. * | ----- | ----------------------------------- | ----------- |
  27567. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27568. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27569. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27570. *
  27571. */
  27572. scaleMode: number;
  27573. /**
  27574. * Force textures to be a power of two (default: false)
  27575. */
  27576. alwaysForcePOT: boolean;
  27577. private _samples;
  27578. /**
  27579. * Number of sample textures (default: 1)
  27580. */
  27581. get samples(): number;
  27582. set samples(n: number);
  27583. /**
  27584. * Modify the scale of the post process to be the same as the viewport (default: false)
  27585. */
  27586. adaptScaleToCurrentViewport: boolean;
  27587. private _camera;
  27588. protected _scene: Scene;
  27589. private _engine;
  27590. private _options;
  27591. private _reusable;
  27592. private _textureType;
  27593. private _textureFormat;
  27594. /**
  27595. * Smart array of input and output textures for the post process.
  27596. * @hidden
  27597. */
  27598. _textures: SmartArray<InternalTexture>;
  27599. /**
  27600. * The index in _textures that corresponds to the output texture.
  27601. * @hidden
  27602. */
  27603. _currentRenderTextureInd: number;
  27604. private _effect;
  27605. private _samplers;
  27606. private _fragmentUrl;
  27607. private _vertexUrl;
  27608. private _parameters;
  27609. private _scaleRatio;
  27610. protected _indexParameters: any;
  27611. private _shareOutputWithPostProcess;
  27612. private _texelSize;
  27613. private _forcedOutputTexture;
  27614. /**
  27615. * Prepass configuration in case this post process needs a texture from prepass
  27616. * @hidden
  27617. */
  27618. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27619. /**
  27620. * Returns the fragment url or shader name used in the post process.
  27621. * @returns the fragment url or name in the shader store.
  27622. */
  27623. getEffectName(): string;
  27624. /**
  27625. * An event triggered when the postprocess is activated.
  27626. */
  27627. onActivateObservable: Observable<Camera>;
  27628. private _onActivateObserver;
  27629. /**
  27630. * A function that is added to the onActivateObservable
  27631. */
  27632. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27633. /**
  27634. * An event triggered when the postprocess changes its size.
  27635. */
  27636. onSizeChangedObservable: Observable<PostProcess>;
  27637. private _onSizeChangedObserver;
  27638. /**
  27639. * A function that is added to the onSizeChangedObservable
  27640. */
  27641. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27642. /**
  27643. * An event triggered when the postprocess applies its effect.
  27644. */
  27645. onApplyObservable: Observable<Effect>;
  27646. private _onApplyObserver;
  27647. /**
  27648. * A function that is added to the onApplyObservable
  27649. */
  27650. set onApply(callback: (effect: Effect) => void);
  27651. /**
  27652. * An event triggered before rendering the postprocess
  27653. */
  27654. onBeforeRenderObservable: Observable<Effect>;
  27655. private _onBeforeRenderObserver;
  27656. /**
  27657. * A function that is added to the onBeforeRenderObservable
  27658. */
  27659. set onBeforeRender(callback: (effect: Effect) => void);
  27660. /**
  27661. * An event triggered after rendering the postprocess
  27662. */
  27663. onAfterRenderObservable: Observable<Effect>;
  27664. private _onAfterRenderObserver;
  27665. /**
  27666. * A function that is added to the onAfterRenderObservable
  27667. */
  27668. set onAfterRender(callback: (efect: Effect) => void);
  27669. /**
  27670. * 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
  27671. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27672. */
  27673. get inputTexture(): InternalTexture;
  27674. set inputTexture(value: InternalTexture);
  27675. /**
  27676. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27677. * the only way to unset it is to use this function to restore its internal state
  27678. */
  27679. restoreDefaultInputTexture(): void;
  27680. /**
  27681. * Gets the camera which post process is applied to.
  27682. * @returns The camera the post process is applied to.
  27683. */
  27684. getCamera(): Camera;
  27685. /**
  27686. * Gets the texel size of the postprocess.
  27687. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27688. */
  27689. get texelSize(): Vector2;
  27690. /**
  27691. * Creates a new instance PostProcess
  27692. * @param name The name of the PostProcess.
  27693. * @param fragmentUrl The url of the fragment shader to be used.
  27694. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27695. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27696. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27697. * @param camera The camera to apply the render pass to.
  27698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27699. * @param engine The engine which the post process will be applied. (default: current engine)
  27700. * @param reusable If the post process can be reused on the same frame. (default: false)
  27701. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27702. * @param textureType Type of textures used when performing the post process. (default: 0)
  27703. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27704. * @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
  27705. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27706. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27707. */
  27708. 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);
  27709. /**
  27710. * Gets a string identifying the name of the class
  27711. * @returns "PostProcess" string
  27712. */
  27713. getClassName(): string;
  27714. /**
  27715. * Gets the engine which this post process belongs to.
  27716. * @returns The engine the post process was enabled with.
  27717. */
  27718. getEngine(): Engine;
  27719. /**
  27720. * The effect that is created when initializing the post process.
  27721. * @returns The created effect corresponding the the postprocess.
  27722. */
  27723. getEffect(): Effect;
  27724. /**
  27725. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27726. * @param postProcess The post process to share the output with.
  27727. * @returns This post process.
  27728. */
  27729. shareOutputWith(postProcess: PostProcess): PostProcess;
  27730. /**
  27731. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27732. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27733. */
  27734. useOwnOutput(): void;
  27735. /**
  27736. * Updates the effect with the current post process compile time values and recompiles the shader.
  27737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27740. * @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
  27741. * @param onCompiled Called when the shader has been compiled.
  27742. * @param onError Called if there is an error when compiling a shader.
  27743. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27744. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27745. */
  27746. 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;
  27747. /**
  27748. * The post process is reusable if it can be used multiple times within one frame.
  27749. * @returns If the post process is reusable
  27750. */
  27751. isReusable(): boolean;
  27752. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27753. markTextureDirty(): void;
  27754. /**
  27755. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27756. * 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.
  27757. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27758. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27759. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27760. * @returns The target texture that was bound to be written to.
  27761. */
  27762. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27763. /**
  27764. * If the post process is supported.
  27765. */
  27766. get isSupported(): boolean;
  27767. /**
  27768. * The aspect ratio of the output texture.
  27769. */
  27770. get aspectRatio(): number;
  27771. /**
  27772. * Get a value indicating if the post-process is ready to be used
  27773. * @returns true if the post-process is ready (shader is compiled)
  27774. */
  27775. isReady(): boolean;
  27776. /**
  27777. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27778. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27779. */
  27780. apply(): Nullable<Effect>;
  27781. private _disposeTextures;
  27782. /**
  27783. * Sets the required values to the prepass renderer.
  27784. * @param prePassRenderer defines the prepass renderer to setup.
  27785. * @returns true if the pre pass is needed.
  27786. */
  27787. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27788. /**
  27789. * Disposes the post process.
  27790. * @param camera The camera to dispose the post process on.
  27791. */
  27792. dispose(camera?: Camera): void;
  27793. /**
  27794. * Serializes the particle system to a JSON object
  27795. * @returns the JSON object
  27796. */
  27797. serialize(): any;
  27798. /**
  27799. * Creates a material from parsed material data
  27800. * @param parsedPostProcess defines parsed post process data
  27801. * @param scene defines the hosting scene
  27802. * @param rootUrl defines the root URL to use to load textures
  27803. * @returns a new post process
  27804. */
  27805. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27806. }
  27807. }
  27808. declare module BABYLON {
  27809. /** @hidden */
  27810. export var kernelBlurVaryingDeclaration: {
  27811. name: string;
  27812. shader: string;
  27813. };
  27814. }
  27815. declare module BABYLON {
  27816. /** @hidden */
  27817. export var kernelBlurFragment: {
  27818. name: string;
  27819. shader: string;
  27820. };
  27821. }
  27822. declare module BABYLON {
  27823. /** @hidden */
  27824. export var kernelBlurFragment2: {
  27825. name: string;
  27826. shader: string;
  27827. };
  27828. }
  27829. declare module BABYLON {
  27830. /** @hidden */
  27831. export var kernelBlurPixelShader: {
  27832. name: string;
  27833. shader: string;
  27834. };
  27835. }
  27836. declare module BABYLON {
  27837. /** @hidden */
  27838. export var kernelBlurVertex: {
  27839. name: string;
  27840. shader: string;
  27841. };
  27842. }
  27843. declare module BABYLON {
  27844. /** @hidden */
  27845. export var kernelBlurVertexShader: {
  27846. name: string;
  27847. shader: string;
  27848. };
  27849. }
  27850. declare module BABYLON {
  27851. /**
  27852. * The Blur Post Process which blurs an image based on a kernel and direction.
  27853. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27854. */
  27855. export class BlurPostProcess extends PostProcess {
  27856. private blockCompilation;
  27857. protected _kernel: number;
  27858. protected _idealKernel: number;
  27859. protected _packedFloat: boolean;
  27860. private _staticDefines;
  27861. /** The direction in which to blur the image. */
  27862. direction: Vector2;
  27863. /**
  27864. * Sets the length in pixels of the blur sample region
  27865. */
  27866. set kernel(v: number);
  27867. /**
  27868. * Gets the length in pixels of the blur sample region
  27869. */
  27870. get kernel(): number;
  27871. /**
  27872. * Sets wether or not the blur needs to unpack/repack floats
  27873. */
  27874. set packedFloat(v: boolean);
  27875. /**
  27876. * Gets wether or not the blur is unpacking/repacking floats
  27877. */
  27878. get packedFloat(): boolean;
  27879. /**
  27880. * Gets a string identifying the name of the class
  27881. * @returns "BlurPostProcess" string
  27882. */
  27883. getClassName(): string;
  27884. /**
  27885. * Creates a new instance BlurPostProcess
  27886. * @param name The name of the effect.
  27887. * @param direction The direction in which to blur the image.
  27888. * @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.
  27889. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27890. * @param camera The camera to apply the render pass to.
  27891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27892. * @param engine The engine which the post process will be applied. (default: current engine)
  27893. * @param reusable If the post process can be reused on the same frame. (default: false)
  27894. * @param textureType Type of textures used when performing the post process. (default: 0)
  27895. * @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)
  27896. */
  27897. 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);
  27898. /**
  27899. * Updates the effect with the current post process compile time values and recompiles the shader.
  27900. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27901. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27902. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27903. * @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
  27904. * @param onCompiled Called when the shader has been compiled.
  27905. * @param onError Called if there is an error when compiling a shader.
  27906. */
  27907. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27908. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27909. /**
  27910. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27911. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27912. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27913. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27914. * The gaps between physical kernels are compensated for in the weighting of the samples
  27915. * @param idealKernel Ideal blur kernel.
  27916. * @return Nearest best kernel.
  27917. */
  27918. protected _nearestBestKernel(idealKernel: number): number;
  27919. /**
  27920. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27921. * @param x The point on the Gaussian distribution to sample.
  27922. * @return the value of the Gaussian function at x.
  27923. */
  27924. protected _gaussianWeight(x: number): number;
  27925. /**
  27926. * Generates a string that can be used as a floating point number in GLSL.
  27927. * @param x Value to print.
  27928. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27929. * @return GLSL float string.
  27930. */
  27931. protected _glslFloat(x: number, decimalFigures?: number): string;
  27932. /** @hidden */
  27933. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27934. }
  27935. }
  27936. declare module BABYLON {
  27937. /**
  27938. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27939. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27940. * You can then easily use it as a reflectionTexture on a flat surface.
  27941. * In case the surface is not a plane, please consider relying on reflection probes.
  27942. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27943. */
  27944. export class MirrorTexture extends RenderTargetTexture {
  27945. private scene;
  27946. /**
  27947. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27948. * 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.
  27949. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27950. */
  27951. mirrorPlane: Plane;
  27952. /**
  27953. * Define the blur ratio used to blur the reflection if needed.
  27954. */
  27955. set blurRatio(value: number);
  27956. get blurRatio(): number;
  27957. /**
  27958. * Define the adaptive blur kernel used to blur the reflection if needed.
  27959. * This will autocompute the closest best match for the `blurKernel`
  27960. */
  27961. set adaptiveBlurKernel(value: number);
  27962. /**
  27963. * Define the blur kernel used to blur the reflection if needed.
  27964. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27965. */
  27966. set blurKernel(value: number);
  27967. /**
  27968. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27969. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27970. */
  27971. set blurKernelX(value: number);
  27972. get blurKernelX(): number;
  27973. /**
  27974. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27975. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27976. */
  27977. set blurKernelY(value: number);
  27978. get blurKernelY(): number;
  27979. private _autoComputeBlurKernel;
  27980. protected _onRatioRescale(): void;
  27981. private _updateGammaSpace;
  27982. private _imageProcessingConfigChangeObserver;
  27983. private _transformMatrix;
  27984. private _mirrorMatrix;
  27985. private _savedViewMatrix;
  27986. private _blurX;
  27987. private _blurY;
  27988. private _adaptiveBlurKernel;
  27989. private _blurKernelX;
  27990. private _blurKernelY;
  27991. private _blurRatio;
  27992. /**
  27993. * Instantiates a Mirror Texture.
  27994. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27995. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27996. * You can then easily use it as a reflectionTexture on a flat surface.
  27997. * In case the surface is not a plane, please consider relying on reflection probes.
  27998. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27999. * @param name
  28000. * @param size
  28001. * @param scene
  28002. * @param generateMipMaps
  28003. * @param type
  28004. * @param samplingMode
  28005. * @param generateDepthBuffer
  28006. */
  28007. constructor(name: string, size: number | {
  28008. width: number;
  28009. height: number;
  28010. } | {
  28011. ratio: number;
  28012. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28013. private _preparePostProcesses;
  28014. /**
  28015. * Clone the mirror texture.
  28016. * @returns the cloned texture
  28017. */
  28018. clone(): MirrorTexture;
  28019. /**
  28020. * Serialize the texture to a JSON representation you could use in Parse later on
  28021. * @returns the serialized JSON representation
  28022. */
  28023. serialize(): any;
  28024. /**
  28025. * Dispose the texture and release its associated resources.
  28026. */
  28027. dispose(): void;
  28028. }
  28029. }
  28030. declare module BABYLON {
  28031. /**
  28032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28033. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28034. */
  28035. export class Texture extends BaseTexture {
  28036. /**
  28037. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28038. */
  28039. static SerializeBuffers: boolean;
  28040. /** @hidden */
  28041. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28042. /** @hidden */
  28043. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28044. /** @hidden */
  28045. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28046. /** nearest is mag = nearest and min = nearest and mip = linear */
  28047. static readonly NEAREST_SAMPLINGMODE: number;
  28048. /** nearest is mag = nearest and min = nearest and mip = linear */
  28049. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28050. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28051. static readonly BILINEAR_SAMPLINGMODE: number;
  28052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28053. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28054. /** Trilinear is mag = linear and min = linear and mip = linear */
  28055. static readonly TRILINEAR_SAMPLINGMODE: number;
  28056. /** Trilinear is mag = linear and min = linear and mip = linear */
  28057. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28058. /** mag = nearest and min = nearest and mip = nearest */
  28059. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28060. /** mag = nearest and min = linear and mip = nearest */
  28061. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28062. /** mag = nearest and min = linear and mip = linear */
  28063. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28064. /** mag = nearest and min = linear and mip = none */
  28065. static readonly NEAREST_LINEAR: number;
  28066. /** mag = nearest and min = nearest and mip = none */
  28067. static readonly NEAREST_NEAREST: number;
  28068. /** mag = linear and min = nearest and mip = nearest */
  28069. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28070. /** mag = linear and min = nearest and mip = linear */
  28071. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28072. /** mag = linear and min = linear and mip = none */
  28073. static readonly LINEAR_LINEAR: number;
  28074. /** mag = linear and min = nearest and mip = none */
  28075. static readonly LINEAR_NEAREST: number;
  28076. /** Explicit coordinates mode */
  28077. static readonly EXPLICIT_MODE: number;
  28078. /** Spherical coordinates mode */
  28079. static readonly SPHERICAL_MODE: number;
  28080. /** Planar coordinates mode */
  28081. static readonly PLANAR_MODE: number;
  28082. /** Cubic coordinates mode */
  28083. static readonly CUBIC_MODE: number;
  28084. /** Projection coordinates mode */
  28085. static readonly PROJECTION_MODE: number;
  28086. /** Inverse Cubic coordinates mode */
  28087. static readonly SKYBOX_MODE: number;
  28088. /** Inverse Cubic coordinates mode */
  28089. static readonly INVCUBIC_MODE: number;
  28090. /** Equirectangular coordinates mode */
  28091. static readonly EQUIRECTANGULAR_MODE: number;
  28092. /** Equirectangular Fixed coordinates mode */
  28093. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28094. /** Equirectangular Fixed Mirrored coordinates mode */
  28095. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28096. /** Texture is not repeating outside of 0..1 UVs */
  28097. static readonly CLAMP_ADDRESSMODE: number;
  28098. /** Texture is repeating outside of 0..1 UVs */
  28099. static readonly WRAP_ADDRESSMODE: number;
  28100. /** Texture is repeating and mirrored */
  28101. static readonly MIRROR_ADDRESSMODE: number;
  28102. /**
  28103. * 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
  28104. */
  28105. static UseSerializedUrlIfAny: boolean;
  28106. /**
  28107. * Define the url of the texture.
  28108. */
  28109. url: Nullable<string>;
  28110. /**
  28111. * Define an offset on the texture to offset the u coordinates of the UVs
  28112. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28113. */
  28114. uOffset: number;
  28115. /**
  28116. * Define an offset on the texture to offset the v coordinates of the UVs
  28117. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28118. */
  28119. vOffset: number;
  28120. /**
  28121. * Define an offset on the texture to scale the u coordinates of the UVs
  28122. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28123. */
  28124. uScale: number;
  28125. /**
  28126. * Define an offset on the texture to scale the v coordinates of the UVs
  28127. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28128. */
  28129. vScale: number;
  28130. /**
  28131. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28132. * @see https://doc.babylonjs.com/how_to/more_materials
  28133. */
  28134. uAng: number;
  28135. /**
  28136. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28137. * @see https://doc.babylonjs.com/how_to/more_materials
  28138. */
  28139. vAng: number;
  28140. /**
  28141. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28142. * @see https://doc.babylonjs.com/how_to/more_materials
  28143. */
  28144. wAng: number;
  28145. /**
  28146. * Defines the center of rotation (U)
  28147. */
  28148. uRotationCenter: number;
  28149. /**
  28150. * Defines the center of rotation (V)
  28151. */
  28152. vRotationCenter: number;
  28153. /**
  28154. * Defines the center of rotation (W)
  28155. */
  28156. wRotationCenter: number;
  28157. /**
  28158. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28159. */
  28160. homogeneousRotationInUVTransform: boolean;
  28161. /**
  28162. * Are mip maps generated for this texture or not.
  28163. */
  28164. get noMipmap(): boolean;
  28165. /**
  28166. * List of inspectable custom properties (used by the Inspector)
  28167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28168. */
  28169. inspectableCustomProperties: Nullable<IInspectable[]>;
  28170. private _noMipmap;
  28171. /** @hidden */
  28172. _invertY: boolean;
  28173. private _rowGenerationMatrix;
  28174. private _cachedTextureMatrix;
  28175. private _projectionModeMatrix;
  28176. private _t0;
  28177. private _t1;
  28178. private _t2;
  28179. private _cachedUOffset;
  28180. private _cachedVOffset;
  28181. private _cachedUScale;
  28182. private _cachedVScale;
  28183. private _cachedUAng;
  28184. private _cachedVAng;
  28185. private _cachedWAng;
  28186. private _cachedProjectionMatrixId;
  28187. private _cachedURotationCenter;
  28188. private _cachedVRotationCenter;
  28189. private _cachedWRotationCenter;
  28190. private _cachedHomogeneousRotationInUVTransform;
  28191. private _cachedCoordinatesMode;
  28192. /** @hidden */
  28193. protected _initialSamplingMode: number;
  28194. /** @hidden */
  28195. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28196. private _deleteBuffer;
  28197. protected _format: Nullable<number>;
  28198. private _delayedOnLoad;
  28199. private _delayedOnError;
  28200. private _mimeType?;
  28201. private _loaderOptions?;
  28202. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28203. get mimeType(): string | undefined;
  28204. /**
  28205. * Observable triggered once the texture has been loaded.
  28206. */
  28207. onLoadObservable: Observable<Texture>;
  28208. protected _isBlocking: boolean;
  28209. /**
  28210. * Is the texture preventing material to render while loading.
  28211. * If false, a default texture will be used instead of the loading one during the preparation step.
  28212. */
  28213. set isBlocking(value: boolean);
  28214. get isBlocking(): boolean;
  28215. /**
  28216. * Get the current sampling mode associated with the texture.
  28217. */
  28218. get samplingMode(): number;
  28219. /**
  28220. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28221. */
  28222. get invertY(): boolean;
  28223. /**
  28224. * Instantiates a new texture.
  28225. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28226. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28227. * @param url defines the url of the picture to load as a texture
  28228. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28229. * @param noMipmap defines if the texture will require mip maps or not
  28230. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28231. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28232. * @param onLoad defines a callback triggered when the texture has been loaded
  28233. * @param onError defines a callback triggered when an error occurred during the loading session
  28234. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28235. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28236. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28237. * @param mimeType defines an optional mime type information
  28238. * @param loaderOptions options to be passed to the loader
  28239. */
  28240. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  28241. /**
  28242. * Update the url (and optional buffer) of this texture if url was null during construction.
  28243. * @param url the url of the texture
  28244. * @param buffer the buffer of the texture (defaults to null)
  28245. * @param onLoad callback called when the texture is loaded (defaults to null)
  28246. */
  28247. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28248. /**
  28249. * Finish the loading sequence of a texture flagged as delayed load.
  28250. * @hidden
  28251. */
  28252. delayLoad(): void;
  28253. private _prepareRowForTextureGeneration;
  28254. /**
  28255. * Checks if the texture has the same transform matrix than another texture
  28256. * @param texture texture to check against
  28257. * @returns true if the transforms are the same, else false
  28258. */
  28259. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28260. /**
  28261. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28262. * @returns the transform matrix of the texture.
  28263. */
  28264. getTextureMatrix(uBase?: number): Matrix;
  28265. /**
  28266. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28267. * @returns The reflection texture transform
  28268. */
  28269. getReflectionTextureMatrix(): Matrix;
  28270. /**
  28271. * Clones the texture.
  28272. * @returns the cloned texture
  28273. */
  28274. clone(): Texture;
  28275. /**
  28276. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28277. * @returns The JSON representation of the texture
  28278. */
  28279. serialize(): any;
  28280. /**
  28281. * Get the current class name of the texture useful for serialization or dynamic coding.
  28282. * @returns "Texture"
  28283. */
  28284. getClassName(): string;
  28285. /**
  28286. * Dispose the texture and release its associated resources.
  28287. */
  28288. dispose(): void;
  28289. /**
  28290. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28291. * @param parsedTexture Define the JSON representation of the texture
  28292. * @param scene Define the scene the parsed texture should be instantiated in
  28293. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28294. * @returns The parsed texture if successful
  28295. */
  28296. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28297. /**
  28298. * Creates a texture from its base 64 representation.
  28299. * @param data Define the base64 payload without the data: prefix
  28300. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28301. * @param scene Define the scene the texture should belong to
  28302. * @param noMipmap Forces the texture to not create mip map information if true
  28303. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28304. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28305. * @param onLoad define a callback triggered when the texture has been loaded
  28306. * @param onError define a callback triggered when an error occurred during the loading session
  28307. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28308. * @returns the created texture
  28309. */
  28310. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28311. /**
  28312. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28313. * @param data Define the base64 payload without the data: prefix
  28314. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28315. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28316. * @param scene Define the scene the texture should belong to
  28317. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28318. * @param noMipmap Forces the texture to not create mip map information if true
  28319. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28320. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28321. * @param onLoad define a callback triggered when the texture has been loaded
  28322. * @param onError define a callback triggered when an error occurred during the loading session
  28323. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28324. * @returns the created texture
  28325. */
  28326. 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;
  28327. }
  28328. }
  28329. declare module BABYLON {
  28330. /**
  28331. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28332. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28333. */
  28334. export class PostProcessManager {
  28335. private _scene;
  28336. private _indexBuffer;
  28337. private _vertexBuffers;
  28338. /**
  28339. * Creates a new instance PostProcess
  28340. * @param scene The scene that the post process is associated with.
  28341. */
  28342. constructor(scene: Scene);
  28343. private _prepareBuffers;
  28344. private _buildIndexBuffer;
  28345. /**
  28346. * Rebuilds the vertex buffers of the manager.
  28347. * @hidden
  28348. */
  28349. _rebuild(): void;
  28350. /**
  28351. * Prepares a frame to be run through a post process.
  28352. * @param sourceTexture The input texture to the post procesess. (default: null)
  28353. * @param postProcesses An array of post processes to be run. (default: null)
  28354. * @returns True if the post processes were able to be run.
  28355. * @hidden
  28356. */
  28357. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28358. /**
  28359. * Manually render a set of post processes to a texture.
  28360. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28361. * @param postProcesses An array of post processes to be run.
  28362. * @param targetTexture The target texture to render to.
  28363. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28364. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28365. * @param lodLevel defines which lod of the texture to render to
  28366. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28367. */
  28368. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28369. /**
  28370. * Finalize the result of the output of the postprocesses.
  28371. * @param doNotPresent If true the result will not be displayed to the screen.
  28372. * @param targetTexture The target texture to render to.
  28373. * @param faceIndex The index of the face to bind the target texture to.
  28374. * @param postProcesses The array of post processes to render.
  28375. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28376. * @hidden
  28377. */
  28378. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28379. /**
  28380. * Disposes of the post process manager.
  28381. */
  28382. dispose(): void;
  28383. }
  28384. }
  28385. declare module BABYLON {
  28386. /**
  28387. * This Helps creating a texture that will be created from a camera in your scene.
  28388. * It is basically a dynamic texture that could be used to create special effects for instance.
  28389. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28390. */
  28391. export class RenderTargetTexture extends Texture {
  28392. /**
  28393. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28394. */
  28395. static readonly REFRESHRATE_RENDER_ONCE: number;
  28396. /**
  28397. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28398. */
  28399. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28400. /**
  28401. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28402. * the central point of your effect and can save a lot of performances.
  28403. */
  28404. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28405. /**
  28406. * Use this predicate to dynamically define the list of mesh you want to render.
  28407. * If set, the renderList property will be overwritten.
  28408. */
  28409. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28410. private _renderList;
  28411. /**
  28412. * Use this list to define the list of mesh you want to render.
  28413. */
  28414. get renderList(): Nullable<Array<AbstractMesh>>;
  28415. set renderList(value: Nullable<Array<AbstractMesh>>);
  28416. /**
  28417. * Use this function to overload the renderList array at rendering time.
  28418. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28419. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28420. * the cube (if the RTT is a cube, else layerOrFace=0).
  28421. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28422. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28423. * hold dummy elements!
  28424. */
  28425. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28426. private _hookArray;
  28427. /**
  28428. * Define if particles should be rendered in your texture.
  28429. */
  28430. renderParticles: boolean;
  28431. /**
  28432. * Define if sprites should be rendered in your texture.
  28433. */
  28434. renderSprites: boolean;
  28435. /**
  28436. * Define the camera used to render the texture.
  28437. */
  28438. activeCamera: Nullable<Camera>;
  28439. /**
  28440. * Override the mesh isReady function with your own one.
  28441. */
  28442. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28443. /**
  28444. * Override the render function of the texture with your own one.
  28445. */
  28446. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28447. /**
  28448. * Define if camera post processes should be use while rendering the texture.
  28449. */
  28450. useCameraPostProcesses: boolean;
  28451. /**
  28452. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28453. */
  28454. ignoreCameraViewport: boolean;
  28455. private _postProcessManager;
  28456. private _postProcesses;
  28457. private _resizeObserver;
  28458. /**
  28459. * An event triggered when the texture is unbind.
  28460. */
  28461. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28462. /**
  28463. * An event triggered when the texture is unbind.
  28464. */
  28465. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28466. private _onAfterUnbindObserver;
  28467. /**
  28468. * Set a after unbind callback in the texture.
  28469. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28470. */
  28471. set onAfterUnbind(callback: () => void);
  28472. /**
  28473. * An event triggered before rendering the texture
  28474. */
  28475. onBeforeRenderObservable: Observable<number>;
  28476. private _onBeforeRenderObserver;
  28477. /**
  28478. * Set a before render callback in the texture.
  28479. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28480. */
  28481. set onBeforeRender(callback: (faceIndex: number) => void);
  28482. /**
  28483. * An event triggered after rendering the texture
  28484. */
  28485. onAfterRenderObservable: Observable<number>;
  28486. private _onAfterRenderObserver;
  28487. /**
  28488. * Set a after render callback in the texture.
  28489. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28490. */
  28491. set onAfterRender(callback: (faceIndex: number) => void);
  28492. /**
  28493. * An event triggered after the texture clear
  28494. */
  28495. onClearObservable: Observable<Engine>;
  28496. private _onClearObserver;
  28497. /**
  28498. * Set a clear callback in the texture.
  28499. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28500. */
  28501. set onClear(callback: (Engine: Engine) => void);
  28502. /**
  28503. * An event triggered when the texture is resized.
  28504. */
  28505. onResizeObservable: Observable<RenderTargetTexture>;
  28506. /**
  28507. * Define the clear color of the Render Target if it should be different from the scene.
  28508. */
  28509. clearColor: Color4;
  28510. protected _size: number | {
  28511. width: number;
  28512. height: number;
  28513. layers?: number;
  28514. };
  28515. protected _initialSizeParameter: number | {
  28516. width: number;
  28517. height: number;
  28518. } | {
  28519. ratio: number;
  28520. };
  28521. protected _sizeRatio: Nullable<number>;
  28522. /** @hidden */
  28523. _generateMipMaps: boolean;
  28524. protected _renderingManager: RenderingManager;
  28525. /** @hidden */
  28526. _waitingRenderList?: string[];
  28527. protected _doNotChangeAspectRatio: boolean;
  28528. protected _currentRefreshId: number;
  28529. protected _refreshRate: number;
  28530. protected _textureMatrix: Matrix;
  28531. protected _samples: number;
  28532. protected _renderTargetOptions: RenderTargetCreationOptions;
  28533. /**
  28534. * Gets render target creation options that were used.
  28535. */
  28536. get renderTargetOptions(): RenderTargetCreationOptions;
  28537. protected _onRatioRescale(): void;
  28538. /**
  28539. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28540. * It must define where the camera used to render the texture is set
  28541. */
  28542. boundingBoxPosition: Vector3;
  28543. private _boundingBoxSize;
  28544. /**
  28545. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28546. * When defined, the cubemap will switch to local mode
  28547. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28548. * @example https://www.babylonjs-playground.com/#RNASML
  28549. */
  28550. set boundingBoxSize(value: Vector3);
  28551. get boundingBoxSize(): Vector3;
  28552. /**
  28553. * In case the RTT has been created with a depth texture, get the associated
  28554. * depth texture.
  28555. * Otherwise, return null.
  28556. */
  28557. get depthStencilTexture(): Nullable<InternalTexture>;
  28558. /**
  28559. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28560. * or used a shadow, depth texture...
  28561. * @param name The friendly name of the texture
  28562. * @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)
  28563. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28564. * @param generateMipMaps True if mip maps need to be generated after render.
  28565. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28566. * @param type The type of the buffer in the RTT (int, half float, float...)
  28567. * @param isCube True if a cube texture needs to be created
  28568. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28569. * @param generateDepthBuffer True to generate a depth buffer
  28570. * @param generateStencilBuffer True to generate a stencil buffer
  28571. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28572. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28573. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28574. */
  28575. constructor(name: string, size: number | {
  28576. width: number;
  28577. height: number;
  28578. layers?: number;
  28579. } | {
  28580. ratio: number;
  28581. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28582. /**
  28583. * Creates a depth stencil texture.
  28584. * This is only available in WebGL 2 or with the depth texture extension available.
  28585. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28586. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28587. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28588. */
  28589. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28590. private _processSizeParameter;
  28591. /**
  28592. * Define the number of samples to use in case of MSAA.
  28593. * It defaults to one meaning no MSAA has been enabled.
  28594. */
  28595. get samples(): number;
  28596. set samples(value: number);
  28597. /**
  28598. * Resets the refresh counter of the texture and start bak from scratch.
  28599. * Could be useful to regenerate the texture if it is setup to render only once.
  28600. */
  28601. resetRefreshCounter(): void;
  28602. /**
  28603. * Define the refresh rate of the texture or the rendering frequency.
  28604. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28605. */
  28606. get refreshRate(): number;
  28607. set refreshRate(value: number);
  28608. /**
  28609. * Adds a post process to the render target rendering passes.
  28610. * @param postProcess define the post process to add
  28611. */
  28612. addPostProcess(postProcess: PostProcess): void;
  28613. /**
  28614. * Clear all the post processes attached to the render target
  28615. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28616. */
  28617. clearPostProcesses(dispose?: boolean): void;
  28618. /**
  28619. * Remove one of the post process from the list of attached post processes to the texture
  28620. * @param postProcess define the post process to remove from the list
  28621. */
  28622. removePostProcess(postProcess: PostProcess): void;
  28623. /** @hidden */
  28624. _shouldRender(): boolean;
  28625. /**
  28626. * Gets the actual render size of the texture.
  28627. * @returns the width of the render size
  28628. */
  28629. getRenderSize(): number;
  28630. /**
  28631. * Gets the actual render width of the texture.
  28632. * @returns the width of the render size
  28633. */
  28634. getRenderWidth(): number;
  28635. /**
  28636. * Gets the actual render height of the texture.
  28637. * @returns the height of the render size
  28638. */
  28639. getRenderHeight(): number;
  28640. /**
  28641. * Gets the actual number of layers of the texture.
  28642. * @returns the number of layers
  28643. */
  28644. getRenderLayers(): number;
  28645. /**
  28646. * Get if the texture can be rescaled or not.
  28647. */
  28648. get canRescale(): boolean;
  28649. /**
  28650. * Resize the texture using a ratio.
  28651. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28652. */
  28653. scale(ratio: number): void;
  28654. /**
  28655. * Get the texture reflection matrix used to rotate/transform the reflection.
  28656. * @returns the reflection matrix
  28657. */
  28658. getReflectionTextureMatrix(): Matrix;
  28659. /**
  28660. * Resize the texture to a new desired size.
  28661. * Be carrefull as it will recreate all the data in the new texture.
  28662. * @param size Define the new size. It can be:
  28663. * - a number for squared texture,
  28664. * - an object containing { width: number, height: number }
  28665. * - or an object containing a ratio { ratio: number }
  28666. */
  28667. resize(size: number | {
  28668. width: number;
  28669. height: number;
  28670. } | {
  28671. ratio: number;
  28672. }): void;
  28673. private _defaultRenderListPrepared;
  28674. /**
  28675. * Renders all the objects from the render list into the texture.
  28676. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28677. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28678. */
  28679. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28680. private _bestReflectionRenderTargetDimension;
  28681. private _prepareRenderingManager;
  28682. /**
  28683. * @hidden
  28684. * @param faceIndex face index to bind to if this is a cubetexture
  28685. * @param layer defines the index of the texture to bind in the array
  28686. */
  28687. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28688. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28689. private renderToTarget;
  28690. /**
  28691. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28692. * This allowed control for front to back rendering or reversly depending of the special needs.
  28693. *
  28694. * @param renderingGroupId The rendering group id corresponding to its index
  28695. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28696. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28697. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28698. */
  28699. 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;
  28700. /**
  28701. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28702. *
  28703. * @param renderingGroupId The rendering group id corresponding to its index
  28704. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28705. */
  28706. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28707. /**
  28708. * Clones the texture.
  28709. * @returns the cloned texture
  28710. */
  28711. clone(): RenderTargetTexture;
  28712. /**
  28713. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28714. * @returns The JSON representation of the texture
  28715. */
  28716. serialize(): any;
  28717. /**
  28718. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28719. */
  28720. disposeFramebufferObjects(): void;
  28721. /**
  28722. * Dispose the texture and release its associated resources.
  28723. */
  28724. dispose(): void;
  28725. /** @hidden */
  28726. _rebuild(): void;
  28727. /**
  28728. * Clear the info related to rendering groups preventing retention point in material dispose.
  28729. */
  28730. freeRenderingGroups(): void;
  28731. /**
  28732. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28733. * @returns the view count
  28734. */
  28735. getViewCount(): number;
  28736. }
  28737. }
  28738. declare module BABYLON {
  28739. /**
  28740. * Class used to manipulate GUIDs
  28741. */
  28742. export class GUID {
  28743. /**
  28744. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28745. * Be aware Math.random() could cause collisions, but:
  28746. * "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"
  28747. * @returns a pseudo random id
  28748. */
  28749. static RandomId(): string;
  28750. }
  28751. }
  28752. declare module BABYLON {
  28753. /**
  28754. * Options to be used when creating a shadow depth material
  28755. */
  28756. export interface IIOptionShadowDepthMaterial {
  28757. /** Variables in the vertex shader code that need to have their names remapped.
  28758. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28759. * "var_name" should be either: worldPos or vNormalW
  28760. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28761. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28762. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28763. */
  28764. remappedVariables?: string[];
  28765. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28766. standalone?: boolean;
  28767. }
  28768. /**
  28769. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28770. */
  28771. export class ShadowDepthWrapper {
  28772. private _scene;
  28773. private _options?;
  28774. private _baseMaterial;
  28775. private _onEffectCreatedObserver;
  28776. private _subMeshToEffect;
  28777. private _subMeshToDepthEffect;
  28778. private _meshes;
  28779. /** @hidden */
  28780. _matriceNames: any;
  28781. /** Gets the standalone status of the wrapper */
  28782. get standalone(): boolean;
  28783. /** Gets the base material the wrapper is built upon */
  28784. get baseMaterial(): Material;
  28785. /**
  28786. * Instantiate a new shadow depth wrapper.
  28787. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28788. * generate the shadow depth map. For more information, please refer to the documentation:
  28789. * https://doc.babylonjs.com/babylon101/shadows
  28790. * @param baseMaterial Material to wrap
  28791. * @param scene Define the scene the material belongs to
  28792. * @param options Options used to create the wrapper
  28793. */
  28794. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28795. /**
  28796. * Gets the effect to use to generate the depth map
  28797. * @param subMesh subMesh to get the effect for
  28798. * @param shadowGenerator shadow generator to get the effect for
  28799. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28800. */
  28801. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28802. /**
  28803. * Specifies that the submesh is ready to be used for depth rendering
  28804. * @param subMesh submesh to check
  28805. * @param defines the list of defines to take into account when checking the effect
  28806. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28807. * @param useInstances specifies that instances should be used
  28808. * @returns a boolean indicating that the submesh is ready or not
  28809. */
  28810. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28811. /**
  28812. * Disposes the resources
  28813. */
  28814. dispose(): void;
  28815. private _makeEffect;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * Options for compiling materials.
  28821. */
  28822. export interface IMaterialCompilationOptions {
  28823. /**
  28824. * Defines whether clip planes are enabled.
  28825. */
  28826. clipPlane: boolean;
  28827. /**
  28828. * Defines whether instances are enabled.
  28829. */
  28830. useInstances: boolean;
  28831. }
  28832. /**
  28833. * Options passed when calling customShaderNameResolve
  28834. */
  28835. export interface ICustomShaderNameResolveOptions {
  28836. /**
  28837. * 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
  28838. */
  28839. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28840. }
  28841. /**
  28842. * Base class for the main features of a material in Babylon.js
  28843. */
  28844. export class Material implements IAnimatable {
  28845. /**
  28846. * Returns the triangle fill mode
  28847. */
  28848. static readonly TriangleFillMode: number;
  28849. /**
  28850. * Returns the wireframe mode
  28851. */
  28852. static readonly WireFrameFillMode: number;
  28853. /**
  28854. * Returns the point fill mode
  28855. */
  28856. static readonly PointFillMode: number;
  28857. /**
  28858. * Returns the point list draw mode
  28859. */
  28860. static readonly PointListDrawMode: number;
  28861. /**
  28862. * Returns the line list draw mode
  28863. */
  28864. static readonly LineListDrawMode: number;
  28865. /**
  28866. * Returns the line loop draw mode
  28867. */
  28868. static readonly LineLoopDrawMode: number;
  28869. /**
  28870. * Returns the line strip draw mode
  28871. */
  28872. static readonly LineStripDrawMode: number;
  28873. /**
  28874. * Returns the triangle strip draw mode
  28875. */
  28876. static readonly TriangleStripDrawMode: number;
  28877. /**
  28878. * Returns the triangle fan draw mode
  28879. */
  28880. static readonly TriangleFanDrawMode: number;
  28881. /**
  28882. * Stores the clock-wise side orientation
  28883. */
  28884. static readonly ClockWiseSideOrientation: number;
  28885. /**
  28886. * Stores the counter clock-wise side orientation
  28887. */
  28888. static readonly CounterClockWiseSideOrientation: number;
  28889. /**
  28890. * The dirty texture flag value
  28891. */
  28892. static readonly TextureDirtyFlag: number;
  28893. /**
  28894. * The dirty light flag value
  28895. */
  28896. static readonly LightDirtyFlag: number;
  28897. /**
  28898. * The dirty fresnel flag value
  28899. */
  28900. static readonly FresnelDirtyFlag: number;
  28901. /**
  28902. * The dirty attribute flag value
  28903. */
  28904. static readonly AttributesDirtyFlag: number;
  28905. /**
  28906. * The dirty misc flag value
  28907. */
  28908. static readonly MiscDirtyFlag: number;
  28909. /**
  28910. * The dirty prepass flag value
  28911. */
  28912. static readonly PrePassDirtyFlag: number;
  28913. /**
  28914. * The all dirty flag value
  28915. */
  28916. static readonly AllDirtyFlag: number;
  28917. /**
  28918. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28919. */
  28920. static readonly MATERIAL_OPAQUE: number;
  28921. /**
  28922. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28923. */
  28924. static readonly MATERIAL_ALPHATEST: number;
  28925. /**
  28926. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28927. */
  28928. static readonly MATERIAL_ALPHABLEND: number;
  28929. /**
  28930. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28931. * They are also discarded below the alpha cutoff threshold to improve performances.
  28932. */
  28933. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28934. /**
  28935. * The Whiteout method is used to blend normals.
  28936. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28937. */
  28938. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28939. /**
  28940. * The Reoriented Normal Mapping method is used to blend normals.
  28941. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28942. */
  28943. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28944. /**
  28945. * Custom callback helping to override the default shader used in the material.
  28946. */
  28947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28948. /**
  28949. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28950. */
  28951. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28952. /**
  28953. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28954. * This means that the material can keep using a previous shader while a new one is being compiled.
  28955. * This is mostly used when shader parallel compilation is supported (true by default)
  28956. */
  28957. allowShaderHotSwapping: boolean;
  28958. /**
  28959. * The ID of the material
  28960. */
  28961. id: string;
  28962. /**
  28963. * Gets or sets the unique id of the material
  28964. */
  28965. uniqueId: number;
  28966. /**
  28967. * The name of the material
  28968. */
  28969. name: string;
  28970. /**
  28971. * Gets or sets user defined metadata
  28972. */
  28973. metadata: any;
  28974. /**
  28975. * For internal use only. Please do not use.
  28976. */
  28977. reservedDataStore: any;
  28978. /**
  28979. * Specifies if the ready state should be checked on each call
  28980. */
  28981. checkReadyOnEveryCall: boolean;
  28982. /**
  28983. * Specifies if the ready state should be checked once
  28984. */
  28985. checkReadyOnlyOnce: boolean;
  28986. /**
  28987. * The state of the material
  28988. */
  28989. state: string;
  28990. /**
  28991. * If the material can be rendered to several textures with MRT extension
  28992. */
  28993. get canRenderToMRT(): boolean;
  28994. /**
  28995. * The alpha value of the material
  28996. */
  28997. protected _alpha: number;
  28998. /**
  28999. * List of inspectable custom properties (used by the Inspector)
  29000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29001. */
  29002. inspectableCustomProperties: IInspectable[];
  29003. /**
  29004. * Sets the alpha value of the material
  29005. */
  29006. set alpha(value: number);
  29007. /**
  29008. * Gets the alpha value of the material
  29009. */
  29010. get alpha(): number;
  29011. /**
  29012. * Specifies if back face culling is enabled
  29013. */
  29014. protected _backFaceCulling: boolean;
  29015. /**
  29016. * Sets the back-face culling state
  29017. */
  29018. set backFaceCulling(value: boolean);
  29019. /**
  29020. * Gets the back-face culling state
  29021. */
  29022. get backFaceCulling(): boolean;
  29023. /**
  29024. * Stores the value for side orientation
  29025. */
  29026. sideOrientation: number;
  29027. /**
  29028. * Callback triggered when the material is compiled
  29029. */
  29030. onCompiled: Nullable<(effect: Effect) => void>;
  29031. /**
  29032. * Callback triggered when an error occurs
  29033. */
  29034. onError: Nullable<(effect: Effect, errors: string) => void>;
  29035. /**
  29036. * Callback triggered to get the render target textures
  29037. */
  29038. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29039. /**
  29040. * Gets a boolean indicating that current material needs to register RTT
  29041. */
  29042. get hasRenderTargetTextures(): boolean;
  29043. /**
  29044. * Specifies if the material should be serialized
  29045. */
  29046. doNotSerialize: boolean;
  29047. /**
  29048. * @hidden
  29049. */
  29050. _storeEffectOnSubMeshes: boolean;
  29051. /**
  29052. * Stores the animations for the material
  29053. */
  29054. animations: Nullable<Array<Animation>>;
  29055. /**
  29056. * An event triggered when the material is disposed
  29057. */
  29058. onDisposeObservable: Observable<Material>;
  29059. /**
  29060. * An observer which watches for dispose events
  29061. */
  29062. private _onDisposeObserver;
  29063. private _onUnBindObservable;
  29064. /**
  29065. * Called during a dispose event
  29066. */
  29067. set onDispose(callback: () => void);
  29068. private _onBindObservable;
  29069. /**
  29070. * An event triggered when the material is bound
  29071. */
  29072. get onBindObservable(): Observable<AbstractMesh>;
  29073. /**
  29074. * An observer which watches for bind events
  29075. */
  29076. private _onBindObserver;
  29077. /**
  29078. * Called during a bind event
  29079. */
  29080. set onBind(callback: (Mesh: AbstractMesh) => void);
  29081. /**
  29082. * An event triggered when the material is unbound
  29083. */
  29084. get onUnBindObservable(): Observable<Material>;
  29085. protected _onEffectCreatedObservable: Nullable<Observable<{
  29086. effect: Effect;
  29087. subMesh: Nullable<SubMesh>;
  29088. }>>;
  29089. /**
  29090. * An event triggered when the effect is (re)created
  29091. */
  29092. get onEffectCreatedObservable(): Observable<{
  29093. effect: Effect;
  29094. subMesh: Nullable<SubMesh>;
  29095. }>;
  29096. /**
  29097. * Stores the value of the alpha mode
  29098. */
  29099. private _alphaMode;
  29100. /**
  29101. * Sets the value of the alpha mode.
  29102. *
  29103. * | Value | Type | Description |
  29104. * | --- | --- | --- |
  29105. * | 0 | ALPHA_DISABLE | |
  29106. * | 1 | ALPHA_ADD | |
  29107. * | 2 | ALPHA_COMBINE | |
  29108. * | 3 | ALPHA_SUBTRACT | |
  29109. * | 4 | ALPHA_MULTIPLY | |
  29110. * | 5 | ALPHA_MAXIMIZED | |
  29111. * | 6 | ALPHA_ONEONE | |
  29112. * | 7 | ALPHA_PREMULTIPLIED | |
  29113. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29114. * | 9 | ALPHA_INTERPOLATE | |
  29115. * | 10 | ALPHA_SCREENMODE | |
  29116. *
  29117. */
  29118. set alphaMode(value: number);
  29119. /**
  29120. * Gets the value of the alpha mode
  29121. */
  29122. get alphaMode(): number;
  29123. /**
  29124. * Stores the state of the need depth pre-pass value
  29125. */
  29126. private _needDepthPrePass;
  29127. /**
  29128. * Sets the need depth pre-pass value
  29129. */
  29130. set needDepthPrePass(value: boolean);
  29131. /**
  29132. * Gets the depth pre-pass value
  29133. */
  29134. get needDepthPrePass(): boolean;
  29135. /**
  29136. * Specifies if depth writing should be disabled
  29137. */
  29138. disableDepthWrite: boolean;
  29139. /**
  29140. * Specifies if color writing should be disabled
  29141. */
  29142. disableColorWrite: boolean;
  29143. /**
  29144. * Specifies if depth writing should be forced
  29145. */
  29146. forceDepthWrite: boolean;
  29147. /**
  29148. * Specifies the depth function that should be used. 0 means the default engine function
  29149. */
  29150. depthFunction: number;
  29151. /**
  29152. * Specifies if there should be a separate pass for culling
  29153. */
  29154. separateCullingPass: boolean;
  29155. /**
  29156. * Stores the state specifing if fog should be enabled
  29157. */
  29158. private _fogEnabled;
  29159. /**
  29160. * Sets the state for enabling fog
  29161. */
  29162. set fogEnabled(value: boolean);
  29163. /**
  29164. * Gets the value of the fog enabled state
  29165. */
  29166. get fogEnabled(): boolean;
  29167. /**
  29168. * Stores the size of points
  29169. */
  29170. pointSize: number;
  29171. /**
  29172. * Stores the z offset value
  29173. */
  29174. zOffset: number;
  29175. get wireframe(): boolean;
  29176. /**
  29177. * Sets the state of wireframe mode
  29178. */
  29179. set wireframe(value: boolean);
  29180. /**
  29181. * Gets the value specifying if point clouds are enabled
  29182. */
  29183. get pointsCloud(): boolean;
  29184. /**
  29185. * Sets the state of point cloud mode
  29186. */
  29187. set pointsCloud(value: boolean);
  29188. /**
  29189. * Gets the material fill mode
  29190. */
  29191. get fillMode(): number;
  29192. /**
  29193. * Sets the material fill mode
  29194. */
  29195. set fillMode(value: number);
  29196. /**
  29197. * @hidden
  29198. * Stores the effects for the material
  29199. */
  29200. _effect: Nullable<Effect>;
  29201. /**
  29202. * Specifies if uniform buffers should be used
  29203. */
  29204. private _useUBO;
  29205. /**
  29206. * Stores a reference to the scene
  29207. */
  29208. private _scene;
  29209. /**
  29210. * Stores the fill mode state
  29211. */
  29212. private _fillMode;
  29213. /**
  29214. * Specifies if the depth write state should be cached
  29215. */
  29216. private _cachedDepthWriteState;
  29217. /**
  29218. * Specifies if the color write state should be cached
  29219. */
  29220. private _cachedColorWriteState;
  29221. /**
  29222. * Specifies if the depth function state should be cached
  29223. */
  29224. private _cachedDepthFunctionState;
  29225. /**
  29226. * Stores the uniform buffer
  29227. */
  29228. protected _uniformBuffer: UniformBuffer;
  29229. /** @hidden */
  29230. _indexInSceneMaterialArray: number;
  29231. /** @hidden */
  29232. meshMap: Nullable<{
  29233. [id: string]: AbstractMesh | undefined;
  29234. }>;
  29235. /**
  29236. * Creates a material instance
  29237. * @param name defines the name of the material
  29238. * @param scene defines the scene to reference
  29239. * @param doNotAdd specifies if the material should be added to the scene
  29240. */
  29241. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29242. /**
  29243. * Returns a string representation of the current material
  29244. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29245. * @returns a string with material information
  29246. */
  29247. toString(fullDetails?: boolean): string;
  29248. /**
  29249. * Gets the class name of the material
  29250. * @returns a string with the class name of the material
  29251. */
  29252. getClassName(): string;
  29253. /**
  29254. * Specifies if updates for the material been locked
  29255. */
  29256. get isFrozen(): boolean;
  29257. /**
  29258. * Locks updates for the material
  29259. */
  29260. freeze(): void;
  29261. /**
  29262. * Unlocks updates for the material
  29263. */
  29264. unfreeze(): void;
  29265. /**
  29266. * Specifies if the material is ready to be used
  29267. * @param mesh defines the mesh to check
  29268. * @param useInstances specifies if instances should be used
  29269. * @returns a boolean indicating if the material is ready to be used
  29270. */
  29271. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29272. /**
  29273. * Specifies that the submesh is ready to be used
  29274. * @param mesh defines the mesh to check
  29275. * @param subMesh defines which submesh to check
  29276. * @param useInstances specifies that instances should be used
  29277. * @returns a boolean indicating that the submesh is ready or not
  29278. */
  29279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29280. /**
  29281. * Returns the material effect
  29282. * @returns the effect associated with the material
  29283. */
  29284. getEffect(): Nullable<Effect>;
  29285. /**
  29286. * Returns the current scene
  29287. * @returns a Scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29292. */
  29293. protected _forceAlphaTest: boolean;
  29294. /**
  29295. * The transparency mode of the material.
  29296. */
  29297. protected _transparencyMode: Nullable<number>;
  29298. /**
  29299. * Gets the current transparency mode.
  29300. */
  29301. get transparencyMode(): Nullable<number>;
  29302. /**
  29303. * Sets the transparency mode of the material.
  29304. *
  29305. * | Value | Type | Description |
  29306. * | ----- | ----------------------------------- | ----------- |
  29307. * | 0 | OPAQUE | |
  29308. * | 1 | ALPHATEST | |
  29309. * | 2 | ALPHABLEND | |
  29310. * | 3 | ALPHATESTANDBLEND | |
  29311. *
  29312. */
  29313. set transparencyMode(value: Nullable<number>);
  29314. /**
  29315. * Returns true if alpha blending should be disabled.
  29316. */
  29317. protected get _disableAlphaBlending(): boolean;
  29318. /**
  29319. * Specifies whether or not this material should be rendered in alpha blend mode.
  29320. * @returns a boolean specifying if alpha blending is needed
  29321. */
  29322. needAlphaBlending(): boolean;
  29323. /**
  29324. * Specifies if the mesh will require alpha blending
  29325. * @param mesh defines the mesh to check
  29326. * @returns a boolean specifying if alpha blending is needed for the mesh
  29327. */
  29328. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29329. /**
  29330. * Specifies whether or not this material should be rendered in alpha test mode.
  29331. * @returns a boolean specifying if an alpha test is needed.
  29332. */
  29333. needAlphaTesting(): boolean;
  29334. /**
  29335. * Specifies if material alpha testing should be turned on for the mesh
  29336. * @param mesh defines the mesh to check
  29337. */
  29338. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29339. /**
  29340. * Gets the texture used for the alpha test
  29341. * @returns the texture to use for alpha testing
  29342. */
  29343. getAlphaTestTexture(): Nullable<BaseTexture>;
  29344. /**
  29345. * Marks the material to indicate that it needs to be re-calculated
  29346. */
  29347. markDirty(): void;
  29348. /** @hidden */
  29349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29350. /**
  29351. * Binds the material to the mesh
  29352. * @param world defines the world transformation matrix
  29353. * @param mesh defines the mesh to bind the material to
  29354. */
  29355. bind(world: Matrix, mesh?: Mesh): void;
  29356. /**
  29357. * Binds the submesh to the material
  29358. * @param world defines the world transformation matrix
  29359. * @param mesh defines the mesh containing the submesh
  29360. * @param subMesh defines the submesh to bind the material to
  29361. */
  29362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29363. /**
  29364. * Binds the world matrix to the material
  29365. * @param world defines the world transformation matrix
  29366. */
  29367. bindOnlyWorldMatrix(world: Matrix): void;
  29368. /**
  29369. * Binds the scene's uniform buffer to the effect.
  29370. * @param effect defines the effect to bind to the scene uniform buffer
  29371. * @param sceneUbo defines the uniform buffer storing scene data
  29372. */
  29373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29374. /**
  29375. * Binds the view matrix to the effect
  29376. * @param effect defines the effect to bind the view matrix to
  29377. */
  29378. bindView(effect: Effect): void;
  29379. /**
  29380. * Binds the view projection matrix to the effect
  29381. * @param effect defines the effect to bind the view projection matrix to
  29382. */
  29383. bindViewProjection(effect: Effect): void;
  29384. /**
  29385. * Processes to execute after binding the material to a mesh
  29386. * @param mesh defines the rendered mesh
  29387. */
  29388. protected _afterBind(mesh?: Mesh): void;
  29389. /**
  29390. * Unbinds the material from the mesh
  29391. */
  29392. unbind(): void;
  29393. /**
  29394. * Gets the active textures from the material
  29395. * @returns an array of textures
  29396. */
  29397. getActiveTextures(): BaseTexture[];
  29398. /**
  29399. * Specifies if the material uses a texture
  29400. * @param texture defines the texture to check against the material
  29401. * @returns a boolean specifying if the material uses the texture
  29402. */
  29403. hasTexture(texture: BaseTexture): boolean;
  29404. /**
  29405. * Makes a duplicate of the material, and gives it a new name
  29406. * @param name defines the new name for the duplicated material
  29407. * @returns the cloned material
  29408. */
  29409. clone(name: string): Nullable<Material>;
  29410. /**
  29411. * Gets the meshes bound to the material
  29412. * @returns an array of meshes bound to the material
  29413. */
  29414. getBindedMeshes(): AbstractMesh[];
  29415. /**
  29416. * Force shader compilation
  29417. * @param mesh defines the mesh associated with this material
  29418. * @param onCompiled defines a function to execute once the material is compiled
  29419. * @param options defines the options to configure the compilation
  29420. * @param onError defines a function to execute if the material fails compiling
  29421. */
  29422. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29423. /**
  29424. * Force shader compilation
  29425. * @param mesh defines the mesh that will use this material
  29426. * @param options defines additional options for compiling the shaders
  29427. * @returns a promise that resolves when the compilation completes
  29428. */
  29429. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29430. private static readonly _AllDirtyCallBack;
  29431. private static readonly _ImageProcessingDirtyCallBack;
  29432. private static readonly _TextureDirtyCallBack;
  29433. private static readonly _FresnelDirtyCallBack;
  29434. private static readonly _MiscDirtyCallBack;
  29435. private static readonly _PrePassDirtyCallBack;
  29436. private static readonly _LightsDirtyCallBack;
  29437. private static readonly _AttributeDirtyCallBack;
  29438. private static _FresnelAndMiscDirtyCallBack;
  29439. private static _TextureAndMiscDirtyCallBack;
  29440. private static readonly _DirtyCallbackArray;
  29441. private static readonly _RunDirtyCallBacks;
  29442. /**
  29443. * Marks a define in the material to indicate that it needs to be re-computed
  29444. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29445. */
  29446. markAsDirty(flag: number): void;
  29447. /**
  29448. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29449. * @param func defines a function which checks material defines against the submeshes
  29450. */
  29451. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29452. /**
  29453. * Indicates that the scene should check if the rendering now needs a prepass
  29454. */
  29455. protected _markScenePrePassDirty(): void;
  29456. /**
  29457. * Indicates that we need to re-calculated for all submeshes
  29458. */
  29459. protected _markAllSubMeshesAsAllDirty(): void;
  29460. /**
  29461. * Indicates that image processing needs to be re-calculated for all submeshes
  29462. */
  29463. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29464. /**
  29465. * Indicates that textures need to be re-calculated for all submeshes
  29466. */
  29467. protected _markAllSubMeshesAsTexturesDirty(): void;
  29468. /**
  29469. * Indicates that fresnel needs to be re-calculated for all submeshes
  29470. */
  29471. protected _markAllSubMeshesAsFresnelDirty(): void;
  29472. /**
  29473. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29474. */
  29475. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29476. /**
  29477. * Indicates that lights need to be re-calculated for all submeshes
  29478. */
  29479. protected _markAllSubMeshesAsLightsDirty(): void;
  29480. /**
  29481. * Indicates that attributes need to be re-calculated for all submeshes
  29482. */
  29483. protected _markAllSubMeshesAsAttributesDirty(): void;
  29484. /**
  29485. * Indicates that misc needs to be re-calculated for all submeshes
  29486. */
  29487. protected _markAllSubMeshesAsMiscDirty(): void;
  29488. /**
  29489. * Indicates that prepass needs to be re-calculated for all submeshes
  29490. */
  29491. protected _markAllSubMeshesAsPrePassDirty(): void;
  29492. /**
  29493. * Indicates that textures and misc need to be re-calculated for all submeshes
  29494. */
  29495. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29496. /**
  29497. * Sets the required values to the prepass renderer.
  29498. * @param prePassRenderer defines the prepass renderer to setup.
  29499. * @returns true if the pre pass is needed.
  29500. */
  29501. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29502. /**
  29503. * Disposes the material
  29504. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29505. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29506. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29507. */
  29508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29509. /** @hidden */
  29510. private releaseVertexArrayObject;
  29511. /**
  29512. * Serializes this material
  29513. * @returns the serialized material object
  29514. */
  29515. serialize(): any;
  29516. /**
  29517. * Creates a material from parsed material data
  29518. * @param parsedMaterial defines parsed material data
  29519. * @param scene defines the hosting scene
  29520. * @param rootUrl defines the root URL to use to load textures
  29521. * @returns a new material
  29522. */
  29523. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29524. }
  29525. }
  29526. declare module BABYLON {
  29527. /**
  29528. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29529. * separate meshes. This can be use to improve performances.
  29530. * @see https://doc.babylonjs.com/how_to/multi_materials
  29531. */
  29532. export class MultiMaterial extends Material {
  29533. private _subMaterials;
  29534. /**
  29535. * Gets or Sets the list of Materials used within the multi material.
  29536. * They need to be ordered according to the submeshes order in the associated mesh
  29537. */
  29538. get subMaterials(): Nullable<Material>[];
  29539. set subMaterials(value: Nullable<Material>[]);
  29540. /**
  29541. * Function used to align with Node.getChildren()
  29542. * @returns the list of Materials used within the multi material
  29543. */
  29544. getChildren(): Nullable<Material>[];
  29545. /**
  29546. * Instantiates a new Multi Material
  29547. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29548. * separate meshes. This can be use to improve performances.
  29549. * @see https://doc.babylonjs.com/how_to/multi_materials
  29550. * @param name Define the name in the scene
  29551. * @param scene Define the scene the material belongs to
  29552. */
  29553. constructor(name: string, scene: Scene);
  29554. private _hookArray;
  29555. /**
  29556. * Get one of the submaterial by its index in the submaterials array
  29557. * @param index The index to look the sub material at
  29558. * @returns The Material if the index has been defined
  29559. */
  29560. getSubMaterial(index: number): Nullable<Material>;
  29561. /**
  29562. * Get the list of active textures for the whole sub materials list.
  29563. * @returns All the textures that will be used during the rendering
  29564. */
  29565. getActiveTextures(): BaseTexture[];
  29566. /**
  29567. * Gets the current class name of the material e.g. "MultiMaterial"
  29568. * Mainly use in serialization.
  29569. * @returns the class name
  29570. */
  29571. getClassName(): string;
  29572. /**
  29573. * Checks if the material is ready to render the requested sub mesh
  29574. * @param mesh Define the mesh the submesh belongs to
  29575. * @param subMesh Define the sub mesh to look readyness for
  29576. * @param useInstances Define whether or not the material is used with instances
  29577. * @returns true if ready, otherwise false
  29578. */
  29579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29580. /**
  29581. * Clones the current material and its related sub materials
  29582. * @param name Define the name of the newly cloned material
  29583. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29584. * @returns the cloned material
  29585. */
  29586. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29587. /**
  29588. * Serializes the materials into a JSON representation.
  29589. * @returns the JSON representation
  29590. */
  29591. serialize(): any;
  29592. /**
  29593. * Dispose the material and release its associated resources
  29594. * @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)
  29595. * @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)
  29596. * @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)
  29597. */
  29598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29599. /**
  29600. * Creates a MultiMaterial from parsed MultiMaterial data.
  29601. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29602. * @param scene defines the hosting scene
  29603. * @returns a new MultiMaterial
  29604. */
  29605. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29606. }
  29607. }
  29608. declare module BABYLON {
  29609. /**
  29610. * Defines a subdivision inside a mesh
  29611. */
  29612. export class SubMesh implements ICullable {
  29613. /** the material index to use */
  29614. materialIndex: number;
  29615. /** vertex index start */
  29616. verticesStart: number;
  29617. /** vertices count */
  29618. verticesCount: number;
  29619. /** index start */
  29620. indexStart: number;
  29621. /** indices count */
  29622. indexCount: number;
  29623. /** @hidden */
  29624. _materialDefines: Nullable<MaterialDefines>;
  29625. /** @hidden */
  29626. _materialEffect: Nullable<Effect>;
  29627. /** @hidden */
  29628. _effectOverride: Nullable<Effect>;
  29629. /**
  29630. * Gets material defines used by the effect associated to the sub mesh
  29631. */
  29632. get materialDefines(): Nullable<MaterialDefines>;
  29633. /**
  29634. * Sets material defines used by the effect associated to the sub mesh
  29635. */
  29636. set materialDefines(defines: Nullable<MaterialDefines>);
  29637. /**
  29638. * Gets associated effect
  29639. */
  29640. get effect(): Nullable<Effect>;
  29641. /**
  29642. * Sets associated effect (effect used to render this submesh)
  29643. * @param effect defines the effect to associate with
  29644. * @param defines defines the set of defines used to compile this effect
  29645. */
  29646. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29647. /** @hidden */
  29648. _linesIndexCount: number;
  29649. private _mesh;
  29650. private _renderingMesh;
  29651. private _boundingInfo;
  29652. private _linesIndexBuffer;
  29653. /** @hidden */
  29654. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29655. /** @hidden */
  29656. _trianglePlanes: Plane[];
  29657. /** @hidden */
  29658. _lastColliderTransformMatrix: Nullable<Matrix>;
  29659. /** @hidden */
  29660. _renderId: number;
  29661. /** @hidden */
  29662. _alphaIndex: number;
  29663. /** @hidden */
  29664. _distanceToCamera: number;
  29665. /** @hidden */
  29666. _id: number;
  29667. private _currentMaterial;
  29668. /**
  29669. * Add a new submesh to a mesh
  29670. * @param materialIndex defines the material index to use
  29671. * @param verticesStart defines vertex index start
  29672. * @param verticesCount defines vertices count
  29673. * @param indexStart defines index start
  29674. * @param indexCount defines indices count
  29675. * @param mesh defines the parent mesh
  29676. * @param renderingMesh defines an optional rendering mesh
  29677. * @param createBoundingBox defines if bounding box should be created for this submesh
  29678. * @returns the new submesh
  29679. */
  29680. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29681. /**
  29682. * Creates a new submesh
  29683. * @param materialIndex defines the material index to use
  29684. * @param verticesStart defines vertex index start
  29685. * @param verticesCount defines vertices count
  29686. * @param indexStart defines index start
  29687. * @param indexCount defines indices count
  29688. * @param mesh defines the parent mesh
  29689. * @param renderingMesh defines an optional rendering mesh
  29690. * @param createBoundingBox defines if bounding box should be created for this submesh
  29691. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29692. */
  29693. constructor(
  29694. /** the material index to use */
  29695. materialIndex: number,
  29696. /** vertex index start */
  29697. verticesStart: number,
  29698. /** vertices count */
  29699. verticesCount: number,
  29700. /** index start */
  29701. indexStart: number,
  29702. /** indices count */
  29703. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29704. /**
  29705. * Returns true if this submesh covers the entire parent mesh
  29706. * @ignorenaming
  29707. */
  29708. get IsGlobal(): boolean;
  29709. /**
  29710. * Returns the submesh BoudingInfo object
  29711. * @returns current bounding info (or mesh's one if the submesh is global)
  29712. */
  29713. getBoundingInfo(): BoundingInfo;
  29714. /**
  29715. * Sets the submesh BoundingInfo
  29716. * @param boundingInfo defines the new bounding info to use
  29717. * @returns the SubMesh
  29718. */
  29719. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29720. /**
  29721. * Returns the mesh of the current submesh
  29722. * @return the parent mesh
  29723. */
  29724. getMesh(): AbstractMesh;
  29725. /**
  29726. * Returns the rendering mesh of the submesh
  29727. * @returns the rendering mesh (could be different from parent mesh)
  29728. */
  29729. getRenderingMesh(): Mesh;
  29730. /**
  29731. * Returns the replacement mesh of the submesh
  29732. * @returns the replacement mesh (could be different from parent mesh)
  29733. */
  29734. getReplacementMesh(): Nullable<AbstractMesh>;
  29735. /**
  29736. * Returns the effective mesh of the submesh
  29737. * @returns the effective mesh (could be different from parent mesh)
  29738. */
  29739. getEffectiveMesh(): AbstractMesh;
  29740. /**
  29741. * Returns the submesh material
  29742. * @returns null or the current material
  29743. */
  29744. getMaterial(): Nullable<Material>;
  29745. private _IsMultiMaterial;
  29746. /**
  29747. * Sets a new updated BoundingInfo object to the submesh
  29748. * @param data defines an optional position array to use to determine the bounding info
  29749. * @returns the SubMesh
  29750. */
  29751. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29752. /** @hidden */
  29753. _checkCollision(collider: Collider): boolean;
  29754. /**
  29755. * Updates the submesh BoundingInfo
  29756. * @param world defines the world matrix to use to update the bounding info
  29757. * @returns the submesh
  29758. */
  29759. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29760. /**
  29761. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29762. * @param frustumPlanes defines the frustum planes
  29763. * @returns true if the submesh is intersecting with the frustum
  29764. */
  29765. isInFrustum(frustumPlanes: Plane[]): boolean;
  29766. /**
  29767. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29768. * @param frustumPlanes defines the frustum planes
  29769. * @returns true if the submesh is inside the frustum
  29770. */
  29771. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29772. /**
  29773. * Renders the submesh
  29774. * @param enableAlphaMode defines if alpha needs to be used
  29775. * @returns the submesh
  29776. */
  29777. render(enableAlphaMode: boolean): SubMesh;
  29778. /**
  29779. * @hidden
  29780. */
  29781. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29782. /**
  29783. * Checks if the submesh intersects with a ray
  29784. * @param ray defines the ray to test
  29785. * @returns true is the passed ray intersects the submesh bounding box
  29786. */
  29787. canIntersects(ray: Ray): boolean;
  29788. /**
  29789. * Intersects current submesh with a ray
  29790. * @param ray defines the ray to test
  29791. * @param positions defines mesh's positions array
  29792. * @param indices defines mesh's indices array
  29793. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29795. * @returns intersection info or null if no intersection
  29796. */
  29797. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29798. /** @hidden */
  29799. private _intersectLines;
  29800. /** @hidden */
  29801. private _intersectUnIndexedLines;
  29802. /** @hidden */
  29803. private _intersectTriangles;
  29804. /** @hidden */
  29805. private _intersectUnIndexedTriangles;
  29806. /** @hidden */
  29807. _rebuild(): void;
  29808. /**
  29809. * Creates a new submesh from the passed mesh
  29810. * @param newMesh defines the new hosting mesh
  29811. * @param newRenderingMesh defines an optional rendering mesh
  29812. * @returns the new submesh
  29813. */
  29814. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29815. /**
  29816. * Release associated resources
  29817. */
  29818. dispose(): void;
  29819. /**
  29820. * Gets the class name
  29821. * @returns the string "SubMesh".
  29822. */
  29823. getClassName(): string;
  29824. /**
  29825. * Creates a new submesh from indices data
  29826. * @param materialIndex the index of the main mesh material
  29827. * @param startIndex the index where to start the copy in the mesh indices array
  29828. * @param indexCount the number of indices to copy then from the startIndex
  29829. * @param mesh the main mesh to create the submesh from
  29830. * @param renderingMesh the optional rendering mesh
  29831. * @returns a new submesh
  29832. */
  29833. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29834. }
  29835. }
  29836. declare module BABYLON {
  29837. /**
  29838. * Class used to represent data loading progression
  29839. */
  29840. export class SceneLoaderFlags {
  29841. private static _ForceFullSceneLoadingForIncremental;
  29842. private static _ShowLoadingScreen;
  29843. private static _CleanBoneMatrixWeights;
  29844. private static _loggingLevel;
  29845. /**
  29846. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29847. */
  29848. static get ForceFullSceneLoadingForIncremental(): boolean;
  29849. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29850. /**
  29851. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29852. */
  29853. static get ShowLoadingScreen(): boolean;
  29854. static set ShowLoadingScreen(value: boolean);
  29855. /**
  29856. * Defines the current logging level (while loading the scene)
  29857. * @ignorenaming
  29858. */
  29859. static get loggingLevel(): number;
  29860. static set loggingLevel(value: number);
  29861. /**
  29862. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29863. */
  29864. static get CleanBoneMatrixWeights(): boolean;
  29865. static set CleanBoneMatrixWeights(value: boolean);
  29866. }
  29867. }
  29868. declare module BABYLON {
  29869. /**
  29870. * Class used to store geometry data (vertex buffers + index buffer)
  29871. */
  29872. export class Geometry implements IGetSetVerticesData {
  29873. /**
  29874. * Gets or sets the ID of the geometry
  29875. */
  29876. id: string;
  29877. /**
  29878. * Gets or sets the unique ID of the geometry
  29879. */
  29880. uniqueId: number;
  29881. /**
  29882. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29883. */
  29884. delayLoadState: number;
  29885. /**
  29886. * Gets the file containing the data to load when running in delay load state
  29887. */
  29888. delayLoadingFile: Nullable<string>;
  29889. /**
  29890. * Callback called when the geometry is updated
  29891. */
  29892. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29893. private _scene;
  29894. private _engine;
  29895. private _meshes;
  29896. private _totalVertices;
  29897. /** @hidden */
  29898. _indices: IndicesArray;
  29899. /** @hidden */
  29900. _vertexBuffers: {
  29901. [key: string]: VertexBuffer;
  29902. };
  29903. private _isDisposed;
  29904. private _extend;
  29905. private _boundingBias;
  29906. /** @hidden */
  29907. _delayInfo: Array<string>;
  29908. private _indexBuffer;
  29909. private _indexBufferIsUpdatable;
  29910. /** @hidden */
  29911. _boundingInfo: Nullable<BoundingInfo>;
  29912. /** @hidden */
  29913. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29914. /** @hidden */
  29915. _softwareSkinningFrameId: number;
  29916. private _vertexArrayObjects;
  29917. private _updatable;
  29918. /** @hidden */
  29919. _positions: Nullable<Vector3[]>;
  29920. /**
  29921. * 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
  29922. */
  29923. get boundingBias(): Vector2;
  29924. /**
  29925. * 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
  29926. */
  29927. set boundingBias(value: Vector2);
  29928. /**
  29929. * Static function used to attach a new empty geometry to a mesh
  29930. * @param mesh defines the mesh to attach the geometry to
  29931. * @returns the new Geometry
  29932. */
  29933. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29934. /** Get the list of meshes using this geometry */
  29935. get meshes(): Mesh[];
  29936. /**
  29937. * 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
  29938. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29939. */
  29940. useBoundingInfoFromGeometry: boolean;
  29941. /**
  29942. * Creates a new geometry
  29943. * @param id defines the unique ID
  29944. * @param scene defines the hosting scene
  29945. * @param vertexData defines the VertexData used to get geometry data
  29946. * @param updatable defines if geometry must be updatable (false by default)
  29947. * @param mesh defines the mesh that will be associated with the geometry
  29948. */
  29949. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29950. /**
  29951. * Gets the current extend of the geometry
  29952. */
  29953. get extend(): {
  29954. minimum: Vector3;
  29955. maximum: Vector3;
  29956. };
  29957. /**
  29958. * Gets the hosting scene
  29959. * @returns the hosting Scene
  29960. */
  29961. getScene(): Scene;
  29962. /**
  29963. * Gets the hosting engine
  29964. * @returns the hosting Engine
  29965. */
  29966. getEngine(): Engine;
  29967. /**
  29968. * Defines if the geometry is ready to use
  29969. * @returns true if the geometry is ready to be used
  29970. */
  29971. isReady(): boolean;
  29972. /**
  29973. * Gets a value indicating that the geometry should not be serialized
  29974. */
  29975. get doNotSerialize(): boolean;
  29976. /** @hidden */
  29977. _rebuild(): void;
  29978. /**
  29979. * Affects all geometry data in one call
  29980. * @param vertexData defines the geometry data
  29981. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29982. */
  29983. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29984. /**
  29985. * Set specific vertex data
  29986. * @param kind defines the data kind (Position, normal, etc...)
  29987. * @param data defines the vertex data to use
  29988. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29989. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29990. */
  29991. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29992. /**
  29993. * Removes a specific vertex data
  29994. * @param kind defines the data kind (Position, normal, etc...)
  29995. */
  29996. removeVerticesData(kind: string): void;
  29997. /**
  29998. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29999. * @param buffer defines the vertex buffer to use
  30000. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30001. */
  30002. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30003. /**
  30004. * Update a specific vertex buffer
  30005. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30006. * It will do nothing if the buffer is not updatable
  30007. * @param kind defines the data kind (Position, normal, etc...)
  30008. * @param data defines the data to use
  30009. * @param offset defines the offset in the target buffer where to store the data
  30010. * @param useBytes set to true if the offset is in bytes
  30011. */
  30012. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30013. /**
  30014. * Update a specific vertex buffer
  30015. * This function will create a new buffer if the current one is not updatable
  30016. * @param kind defines the data kind (Position, normal, etc...)
  30017. * @param data defines the data to use
  30018. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30019. */
  30020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30021. private _updateBoundingInfo;
  30022. /** @hidden */
  30023. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30024. /**
  30025. * Gets total number of vertices
  30026. * @returns the total number of vertices
  30027. */
  30028. getTotalVertices(): number;
  30029. /**
  30030. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30031. * @param kind defines the data kind (Position, normal, etc...)
  30032. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30033. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30034. * @returns a float array containing vertex data
  30035. */
  30036. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30037. /**
  30038. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30039. * @param kind defines the data kind (Position, normal, etc...)
  30040. * @returns true if the vertex buffer with the specified kind is updatable
  30041. */
  30042. isVertexBufferUpdatable(kind: string): boolean;
  30043. /**
  30044. * Gets a specific vertex buffer
  30045. * @param kind defines the data kind (Position, normal, etc...)
  30046. * @returns a VertexBuffer
  30047. */
  30048. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30049. /**
  30050. * Returns all vertex buffers
  30051. * @return an object holding all vertex buffers indexed by kind
  30052. */
  30053. getVertexBuffers(): Nullable<{
  30054. [key: string]: VertexBuffer;
  30055. }>;
  30056. /**
  30057. * Gets a boolean indicating if specific vertex buffer is present
  30058. * @param kind defines the data kind (Position, normal, etc...)
  30059. * @returns true if data is present
  30060. */
  30061. isVerticesDataPresent(kind: string): boolean;
  30062. /**
  30063. * Gets a list of all attached data kinds (Position, normal, etc...)
  30064. * @returns a list of string containing all kinds
  30065. */
  30066. getVerticesDataKinds(): string[];
  30067. /**
  30068. * Update index buffer
  30069. * @param indices defines the indices to store in the index buffer
  30070. * @param offset defines the offset in the target buffer where to store the data
  30071. * @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)
  30072. */
  30073. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30074. /**
  30075. * Creates a new index buffer
  30076. * @param indices defines the indices to store in the index buffer
  30077. * @param totalVertices defines the total number of vertices (could be null)
  30078. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30079. */
  30080. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30081. /**
  30082. * Return the total number of indices
  30083. * @returns the total number of indices
  30084. */
  30085. getTotalIndices(): number;
  30086. /**
  30087. * Gets the index buffer array
  30088. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30089. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30090. * @returns the index buffer array
  30091. */
  30092. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30093. /**
  30094. * Gets the index buffer
  30095. * @return the index buffer
  30096. */
  30097. getIndexBuffer(): Nullable<DataBuffer>;
  30098. /** @hidden */
  30099. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30100. /**
  30101. * Release the associated resources for a specific mesh
  30102. * @param mesh defines the source mesh
  30103. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30104. */
  30105. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30106. /**
  30107. * Apply current geometry to a given mesh
  30108. * @param mesh defines the mesh to apply geometry to
  30109. */
  30110. applyToMesh(mesh: Mesh): void;
  30111. private _updateExtend;
  30112. private _applyToMesh;
  30113. private notifyUpdate;
  30114. /**
  30115. * Load the geometry if it was flagged as delay loaded
  30116. * @param scene defines the hosting scene
  30117. * @param onLoaded defines a callback called when the geometry is loaded
  30118. */
  30119. load(scene: Scene, onLoaded?: () => void): void;
  30120. private _queueLoad;
  30121. /**
  30122. * Invert the geometry to move from a right handed system to a left handed one.
  30123. */
  30124. toLeftHanded(): void;
  30125. /** @hidden */
  30126. _resetPointsArrayCache(): void;
  30127. /** @hidden */
  30128. _generatePointsArray(): boolean;
  30129. /**
  30130. * Gets a value indicating if the geometry is disposed
  30131. * @returns true if the geometry was disposed
  30132. */
  30133. isDisposed(): boolean;
  30134. private _disposeVertexArrayObjects;
  30135. /**
  30136. * Free all associated resources
  30137. */
  30138. dispose(): void;
  30139. /**
  30140. * Clone the current geometry into a new geometry
  30141. * @param id defines the unique ID of the new geometry
  30142. * @returns a new geometry object
  30143. */
  30144. copy(id: string): Geometry;
  30145. /**
  30146. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30147. * @return a JSON representation of the current geometry data (without the vertices data)
  30148. */
  30149. serialize(): any;
  30150. private toNumberArray;
  30151. /**
  30152. * Serialize all vertices data into a JSON oject
  30153. * @returns a JSON representation of the current geometry data
  30154. */
  30155. serializeVerticeData(): any;
  30156. /**
  30157. * Extracts a clone of a mesh geometry
  30158. * @param mesh defines the source mesh
  30159. * @param id defines the unique ID of the new geometry object
  30160. * @returns the new geometry object
  30161. */
  30162. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30163. /**
  30164. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30165. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30166. * Be aware Math.random() could cause collisions, but:
  30167. * "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"
  30168. * @returns a string containing a new GUID
  30169. */
  30170. static RandomId(): string;
  30171. /** @hidden */
  30172. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30173. private static _CleanMatricesWeights;
  30174. /**
  30175. * Create a new geometry from persisted data (Using .babylon file format)
  30176. * @param parsedVertexData defines the persisted data
  30177. * @param scene defines the hosting scene
  30178. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30179. * @returns the new geometry object
  30180. */
  30181. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30182. }
  30183. }
  30184. declare module BABYLON {
  30185. /**
  30186. * Define an interface for all classes that will get and set the data on vertices
  30187. */
  30188. export interface IGetSetVerticesData {
  30189. /**
  30190. * Gets a boolean indicating if specific vertex data is present
  30191. * @param kind defines the vertex data kind to use
  30192. * @returns true is data kind is present
  30193. */
  30194. isVerticesDataPresent(kind: string): boolean;
  30195. /**
  30196. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30197. * @param kind defines the data kind (Position, normal, etc...)
  30198. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30199. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30200. * @returns a float array containing vertex data
  30201. */
  30202. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30203. /**
  30204. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30205. * @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.
  30206. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30207. * @returns the indices array or an empty array if the mesh has no geometry
  30208. */
  30209. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30210. /**
  30211. * Set specific vertex data
  30212. * @param kind defines the data kind (Position, normal, etc...)
  30213. * @param data defines the vertex data to use
  30214. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30215. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30216. */
  30217. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30218. /**
  30219. * Update a specific associated vertex buffer
  30220. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30221. * - VertexBuffer.PositionKind
  30222. * - VertexBuffer.UVKind
  30223. * - VertexBuffer.UV2Kind
  30224. * - VertexBuffer.UV3Kind
  30225. * - VertexBuffer.UV4Kind
  30226. * - VertexBuffer.UV5Kind
  30227. * - VertexBuffer.UV6Kind
  30228. * - VertexBuffer.ColorKind
  30229. * - VertexBuffer.MatricesIndicesKind
  30230. * - VertexBuffer.MatricesIndicesExtraKind
  30231. * - VertexBuffer.MatricesWeightsKind
  30232. * - VertexBuffer.MatricesWeightsExtraKind
  30233. * @param data defines the data source
  30234. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30235. * @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)
  30236. */
  30237. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30238. /**
  30239. * Creates a new index buffer
  30240. * @param indices defines the indices to store in the index buffer
  30241. * @param totalVertices defines the total number of vertices (could be null)
  30242. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30243. */
  30244. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30245. }
  30246. /**
  30247. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30248. */
  30249. export class VertexData {
  30250. /**
  30251. * Mesh side orientation : usually the external or front surface
  30252. */
  30253. static readonly FRONTSIDE: number;
  30254. /**
  30255. * Mesh side orientation : usually the internal or back surface
  30256. */
  30257. static readonly BACKSIDE: number;
  30258. /**
  30259. * Mesh side orientation : both internal and external or front and back surfaces
  30260. */
  30261. static readonly DOUBLESIDE: number;
  30262. /**
  30263. * Mesh side orientation : by default, `FRONTSIDE`
  30264. */
  30265. static readonly DEFAULTSIDE: number;
  30266. /**
  30267. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30268. */
  30269. positions: Nullable<FloatArray>;
  30270. /**
  30271. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30272. */
  30273. normals: Nullable<FloatArray>;
  30274. /**
  30275. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30276. */
  30277. tangents: Nullable<FloatArray>;
  30278. /**
  30279. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30280. */
  30281. uvs: Nullable<FloatArray>;
  30282. /**
  30283. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30284. */
  30285. uvs2: Nullable<FloatArray>;
  30286. /**
  30287. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30288. */
  30289. uvs3: Nullable<FloatArray>;
  30290. /**
  30291. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30292. */
  30293. uvs4: Nullable<FloatArray>;
  30294. /**
  30295. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30296. */
  30297. uvs5: Nullable<FloatArray>;
  30298. /**
  30299. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30300. */
  30301. uvs6: Nullable<FloatArray>;
  30302. /**
  30303. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30304. */
  30305. colors: Nullable<FloatArray>;
  30306. /**
  30307. * 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).
  30308. */
  30309. matricesIndices: Nullable<FloatArray>;
  30310. /**
  30311. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30312. */
  30313. matricesWeights: Nullable<FloatArray>;
  30314. /**
  30315. * An array extending the number of possible indices
  30316. */
  30317. matricesIndicesExtra: Nullable<FloatArray>;
  30318. /**
  30319. * An array extending the number of possible weights when the number of indices is extended
  30320. */
  30321. matricesWeightsExtra: Nullable<FloatArray>;
  30322. /**
  30323. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30324. */
  30325. indices: Nullable<IndicesArray>;
  30326. /**
  30327. * Uses the passed data array to set the set the values for the specified kind of data
  30328. * @param data a linear array of floating numbers
  30329. * @param kind the type of data that is being set, eg positions, colors etc
  30330. */
  30331. set(data: FloatArray, kind: string): void;
  30332. /**
  30333. * Associates the vertexData to the passed Mesh.
  30334. * Sets it as updatable or not (default `false`)
  30335. * @param mesh the mesh the vertexData is applied to
  30336. * @param updatable when used and having the value true allows new data to update the vertexData
  30337. * @returns the VertexData
  30338. */
  30339. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30340. /**
  30341. * Associates the vertexData to the passed Geometry.
  30342. * Sets it as updatable or not (default `false`)
  30343. * @param geometry the geometry the vertexData is applied to
  30344. * @param updatable when used and having the value true allows new data to update the vertexData
  30345. * @returns VertexData
  30346. */
  30347. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30348. /**
  30349. * Updates the associated mesh
  30350. * @param mesh the mesh to be updated
  30351. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30352. * @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
  30353. * @returns VertexData
  30354. */
  30355. updateMesh(mesh: Mesh): VertexData;
  30356. /**
  30357. * Updates the associated geometry
  30358. * @param geometry the geometry to be updated
  30359. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30360. * @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
  30361. * @returns VertexData.
  30362. */
  30363. updateGeometry(geometry: Geometry): VertexData;
  30364. private _applyTo;
  30365. private _update;
  30366. /**
  30367. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30368. * @param matrix the transforming matrix
  30369. * @returns the VertexData
  30370. */
  30371. transform(matrix: Matrix): VertexData;
  30372. /**
  30373. * Merges the passed VertexData into the current one
  30374. * @param other the VertexData to be merged into the current one
  30375. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30376. * @returns the modified VertexData
  30377. */
  30378. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30379. private _mergeElement;
  30380. private _validate;
  30381. /**
  30382. * Serializes the VertexData
  30383. * @returns a serialized object
  30384. */
  30385. serialize(): any;
  30386. /**
  30387. * Extracts the vertexData from a mesh
  30388. * @param mesh the mesh from which to extract the VertexData
  30389. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30390. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30391. * @returns the object VertexData associated to the passed mesh
  30392. */
  30393. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30394. /**
  30395. * Extracts the vertexData from the geometry
  30396. * @param geometry the geometry from which to extract the VertexData
  30397. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30398. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30399. * @returns the object VertexData associated to the passed mesh
  30400. */
  30401. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30402. private static _ExtractFrom;
  30403. /**
  30404. * Creates the VertexData for a Ribbon
  30405. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30406. * * pathArray array of paths, each of which an array of successive Vector3
  30407. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30408. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30409. * * 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
  30410. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30411. * * 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)
  30412. * * 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)
  30413. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30414. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30415. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30416. * @returns the VertexData of the ribbon
  30417. */
  30418. static CreateRibbon(options: {
  30419. pathArray: Vector3[][];
  30420. closeArray?: boolean;
  30421. closePath?: boolean;
  30422. offset?: number;
  30423. sideOrientation?: number;
  30424. frontUVs?: Vector4;
  30425. backUVs?: Vector4;
  30426. invertUV?: boolean;
  30427. uvs?: Vector2[];
  30428. colors?: Color4[];
  30429. }): VertexData;
  30430. /**
  30431. * Creates the VertexData for a box
  30432. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30433. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30434. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30435. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30436. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30437. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30438. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30439. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30440. * * 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)
  30441. * * 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)
  30442. * @returns the VertexData of the box
  30443. */
  30444. static CreateBox(options: {
  30445. size?: number;
  30446. width?: number;
  30447. height?: number;
  30448. depth?: number;
  30449. faceUV?: Vector4[];
  30450. faceColors?: Color4[];
  30451. sideOrientation?: number;
  30452. frontUVs?: Vector4;
  30453. backUVs?: Vector4;
  30454. }): VertexData;
  30455. /**
  30456. * Creates the VertexData for a tiled box
  30457. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30458. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30459. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30460. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30462. * @returns the VertexData of the box
  30463. */
  30464. static CreateTiledBox(options: {
  30465. pattern?: number;
  30466. width?: number;
  30467. height?: number;
  30468. depth?: number;
  30469. tileSize?: number;
  30470. tileWidth?: number;
  30471. tileHeight?: number;
  30472. alignHorizontal?: number;
  30473. alignVertical?: number;
  30474. faceUV?: Vector4[];
  30475. faceColors?: Color4[];
  30476. sideOrientation?: number;
  30477. }): VertexData;
  30478. /**
  30479. * Creates the VertexData for a tiled plane
  30480. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30481. * * pattern a limited pattern arrangement depending on the number
  30482. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30483. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30484. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30486. * * 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)
  30487. * * 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)
  30488. * @returns the VertexData of the tiled plane
  30489. */
  30490. static CreateTiledPlane(options: {
  30491. pattern?: number;
  30492. tileSize?: number;
  30493. tileWidth?: number;
  30494. tileHeight?: number;
  30495. size?: number;
  30496. width?: number;
  30497. height?: number;
  30498. alignHorizontal?: number;
  30499. alignVertical?: number;
  30500. sideOrientation?: number;
  30501. frontUVs?: Vector4;
  30502. backUVs?: Vector4;
  30503. }): VertexData;
  30504. /**
  30505. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30506. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30507. * * segments sets the number of horizontal strips optional, default 32
  30508. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30509. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30510. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30511. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30512. * * 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
  30513. * * 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
  30514. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30515. * * 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)
  30516. * * 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)
  30517. * @returns the VertexData of the ellipsoid
  30518. */
  30519. static CreateSphere(options: {
  30520. segments?: number;
  30521. diameter?: number;
  30522. diameterX?: number;
  30523. diameterY?: number;
  30524. diameterZ?: number;
  30525. arc?: number;
  30526. slice?: number;
  30527. sideOrientation?: number;
  30528. frontUVs?: Vector4;
  30529. backUVs?: Vector4;
  30530. }): VertexData;
  30531. /**
  30532. * Creates the VertexData for a cylinder, cone or prism
  30533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30534. * * height sets the height (y direction) of the cylinder, optional, default 2
  30535. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30536. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30537. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30538. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30539. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30540. * * 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
  30541. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30542. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30543. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30544. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30545. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30546. * * 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)
  30547. * * 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)
  30548. * @returns the VertexData of the cylinder, cone or prism
  30549. */
  30550. static CreateCylinder(options: {
  30551. height?: number;
  30552. diameterTop?: number;
  30553. diameterBottom?: number;
  30554. diameter?: number;
  30555. tessellation?: number;
  30556. subdivisions?: number;
  30557. arc?: number;
  30558. faceColors?: Color4[];
  30559. faceUV?: Vector4[];
  30560. hasRings?: boolean;
  30561. enclose?: boolean;
  30562. sideOrientation?: number;
  30563. frontUVs?: Vector4;
  30564. backUVs?: Vector4;
  30565. }): VertexData;
  30566. /**
  30567. * Creates the VertexData for a torus
  30568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30569. * * diameter the diameter of the torus, optional default 1
  30570. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30571. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30573. * * 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)
  30574. * * 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)
  30575. * @returns the VertexData of the torus
  30576. */
  30577. static CreateTorus(options: {
  30578. diameter?: number;
  30579. thickness?: number;
  30580. tessellation?: number;
  30581. sideOrientation?: number;
  30582. frontUVs?: Vector4;
  30583. backUVs?: Vector4;
  30584. }): VertexData;
  30585. /**
  30586. * Creates the VertexData of the LineSystem
  30587. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30588. * - lines an array of lines, each line being an array of successive Vector3
  30589. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30590. * @returns the VertexData of the LineSystem
  30591. */
  30592. static CreateLineSystem(options: {
  30593. lines: Vector3[][];
  30594. colors?: Nullable<Color4[][]>;
  30595. }): VertexData;
  30596. /**
  30597. * Create the VertexData for a DashedLines
  30598. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30599. * - points an array successive Vector3
  30600. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30601. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30602. * - dashNb the intended total number of dashes, optional, default 200
  30603. * @returns the VertexData for the DashedLines
  30604. */
  30605. static CreateDashedLines(options: {
  30606. points: Vector3[];
  30607. dashSize?: number;
  30608. gapSize?: number;
  30609. dashNb?: number;
  30610. }): VertexData;
  30611. /**
  30612. * Creates the VertexData for a Ground
  30613. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30614. * - width the width (x direction) of the ground, optional, default 1
  30615. * - height the height (z direction) of the ground, optional, default 1
  30616. * - subdivisions the number of subdivisions per side, optional, default 1
  30617. * @returns the VertexData of the Ground
  30618. */
  30619. static CreateGround(options: {
  30620. width?: number;
  30621. height?: number;
  30622. subdivisions?: number;
  30623. subdivisionsX?: number;
  30624. subdivisionsY?: number;
  30625. }): VertexData;
  30626. /**
  30627. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30628. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30629. * * xmin the ground minimum X coordinate, optional, default -1
  30630. * * zmin the ground minimum Z coordinate, optional, default -1
  30631. * * xmax the ground maximum X coordinate, optional, default 1
  30632. * * zmax the ground maximum Z coordinate, optional, default 1
  30633. * * 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}
  30634. * * 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}
  30635. * @returns the VertexData of the TiledGround
  30636. */
  30637. static CreateTiledGround(options: {
  30638. xmin: number;
  30639. zmin: number;
  30640. xmax: number;
  30641. zmax: number;
  30642. subdivisions?: {
  30643. w: number;
  30644. h: number;
  30645. };
  30646. precision?: {
  30647. w: number;
  30648. h: number;
  30649. };
  30650. }): VertexData;
  30651. /**
  30652. * Creates the VertexData of the Ground designed from a heightmap
  30653. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30654. * * width the width (x direction) of the ground
  30655. * * height the height (z direction) of the ground
  30656. * * subdivisions the number of subdivisions per side
  30657. * * minHeight the minimum altitude on the ground, optional, default 0
  30658. * * maxHeight the maximum altitude on the ground, optional default 1
  30659. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30660. * * buffer the array holding the image color data
  30661. * * bufferWidth the width of image
  30662. * * bufferHeight the height of image
  30663. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30664. * @returns the VertexData of the Ground designed from a heightmap
  30665. */
  30666. static CreateGroundFromHeightMap(options: {
  30667. width: number;
  30668. height: number;
  30669. subdivisions: number;
  30670. minHeight: number;
  30671. maxHeight: number;
  30672. colorFilter: Color3;
  30673. buffer: Uint8Array;
  30674. bufferWidth: number;
  30675. bufferHeight: number;
  30676. alphaFilter: number;
  30677. }): VertexData;
  30678. /**
  30679. * Creates the VertexData for a Plane
  30680. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30681. * * size sets the width and height of the plane to the value of size, optional default 1
  30682. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30683. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30685. * * 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)
  30686. * * 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)
  30687. * @returns the VertexData of the box
  30688. */
  30689. static CreatePlane(options: {
  30690. size?: number;
  30691. width?: number;
  30692. height?: number;
  30693. sideOrientation?: number;
  30694. frontUVs?: Vector4;
  30695. backUVs?: Vector4;
  30696. }): VertexData;
  30697. /**
  30698. * Creates the VertexData of the Disc or regular Polygon
  30699. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30700. * * radius the radius of the disc, optional default 0.5
  30701. * * tessellation the number of polygon sides, optional, default 64
  30702. * * 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
  30703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30704. * * 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)
  30705. * * 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)
  30706. * @returns the VertexData of the box
  30707. */
  30708. static CreateDisc(options: {
  30709. radius?: number;
  30710. tessellation?: number;
  30711. arc?: number;
  30712. sideOrientation?: number;
  30713. frontUVs?: Vector4;
  30714. backUVs?: Vector4;
  30715. }): VertexData;
  30716. /**
  30717. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30718. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30719. * @param polygon a mesh built from polygonTriangulation.build()
  30720. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30721. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30722. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30723. * @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)
  30724. * @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)
  30725. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30726. * @returns the VertexData of the Polygon
  30727. */
  30728. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30729. /**
  30730. * Creates the VertexData of the IcoSphere
  30731. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30732. * * radius the radius of the IcoSphere, optional default 1
  30733. * * radiusX allows stretching in the x direction, optional, default radius
  30734. * * radiusY allows stretching in the y direction, optional, default radius
  30735. * * radiusZ allows stretching in the z direction, optional, default radius
  30736. * * flat when true creates a flat shaded mesh, optional, default true
  30737. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30739. * * 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)
  30740. * * 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)
  30741. * @returns the VertexData of the IcoSphere
  30742. */
  30743. static CreateIcoSphere(options: {
  30744. radius?: number;
  30745. radiusX?: number;
  30746. radiusY?: number;
  30747. radiusZ?: number;
  30748. flat?: boolean;
  30749. subdivisions?: number;
  30750. sideOrientation?: number;
  30751. frontUVs?: Vector4;
  30752. backUVs?: Vector4;
  30753. }): VertexData;
  30754. /**
  30755. * Creates the VertexData for a Polyhedron
  30756. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30757. * * type provided types are:
  30758. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30759. * * 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)
  30760. * * size the size of the IcoSphere, optional default 1
  30761. * * sizeX allows stretching in the x direction, optional, default size
  30762. * * sizeY allows stretching in the y direction, optional, default size
  30763. * * sizeZ allows stretching in the z direction, optional, default size
  30764. * * 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
  30765. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30766. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30767. * * flat when true creates a flat shaded mesh, optional, default true
  30768. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30770. * * 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)
  30771. * * 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)
  30772. * @returns the VertexData of the Polyhedron
  30773. */
  30774. static CreatePolyhedron(options: {
  30775. type?: number;
  30776. size?: number;
  30777. sizeX?: number;
  30778. sizeY?: number;
  30779. sizeZ?: number;
  30780. custom?: any;
  30781. faceUV?: Vector4[];
  30782. faceColors?: Color4[];
  30783. flat?: boolean;
  30784. sideOrientation?: number;
  30785. frontUVs?: Vector4;
  30786. backUVs?: Vector4;
  30787. }): VertexData;
  30788. /**
  30789. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30790. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30791. * @returns the VertexData of the Capsule
  30792. */
  30793. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30794. /**
  30795. * Creates the VertexData for a TorusKnot
  30796. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30797. * * radius the radius of the torus knot, optional, default 2
  30798. * * tube the thickness of the tube, optional, default 0.5
  30799. * * radialSegments the number of sides on each tube segments, optional, default 32
  30800. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30801. * * p the number of windings around the z axis, optional, default 2
  30802. * * q the number of windings around the x axis, optional, default 3
  30803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30804. * * 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)
  30805. * * 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)
  30806. * @returns the VertexData of the Torus Knot
  30807. */
  30808. static CreateTorusKnot(options: {
  30809. radius?: number;
  30810. tube?: number;
  30811. radialSegments?: number;
  30812. tubularSegments?: number;
  30813. p?: number;
  30814. q?: number;
  30815. sideOrientation?: number;
  30816. frontUVs?: Vector4;
  30817. backUVs?: Vector4;
  30818. }): VertexData;
  30819. /**
  30820. * Compute normals for given positions and indices
  30821. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30822. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30823. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30824. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30825. * * facetNormals : optional array of facet normals (vector3)
  30826. * * facetPositions : optional array of facet positions (vector3)
  30827. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30828. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30829. * * bInfo : optional bounding info, required for facetPartitioning computation
  30830. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30831. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30832. * * useRightHandedSystem: optional boolean to for right handed system computation
  30833. * * depthSort : optional boolean to enable the facet depth sort computation
  30834. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30835. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30836. */
  30837. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30838. facetNormals?: any;
  30839. facetPositions?: any;
  30840. facetPartitioning?: any;
  30841. ratio?: number;
  30842. bInfo?: any;
  30843. bbSize?: Vector3;
  30844. subDiv?: any;
  30845. useRightHandedSystem?: boolean;
  30846. depthSort?: boolean;
  30847. distanceTo?: Vector3;
  30848. depthSortedFacets?: any;
  30849. }): void;
  30850. /** @hidden */
  30851. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30852. /**
  30853. * Applies VertexData created from the imported parameters to the geometry
  30854. * @param parsedVertexData the parsed data from an imported file
  30855. * @param geometry the geometry to apply the VertexData to
  30856. */
  30857. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30858. }
  30859. }
  30860. declare module BABYLON {
  30861. /**
  30862. * Defines a target to use with MorphTargetManager
  30863. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30864. */
  30865. export class MorphTarget implements IAnimatable {
  30866. /** defines the name of the target */
  30867. name: string;
  30868. /**
  30869. * Gets or sets the list of animations
  30870. */
  30871. animations: Animation[];
  30872. private _scene;
  30873. private _positions;
  30874. private _normals;
  30875. private _tangents;
  30876. private _uvs;
  30877. private _influence;
  30878. private _uniqueId;
  30879. /**
  30880. * Observable raised when the influence changes
  30881. */
  30882. onInfluenceChanged: Observable<boolean>;
  30883. /** @hidden */
  30884. _onDataLayoutChanged: Observable<void>;
  30885. /**
  30886. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30887. */
  30888. get influence(): number;
  30889. set influence(influence: number);
  30890. /**
  30891. * Gets or sets the id of the morph Target
  30892. */
  30893. id: string;
  30894. private _animationPropertiesOverride;
  30895. /**
  30896. * Gets or sets the animation properties override
  30897. */
  30898. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30899. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30900. /**
  30901. * Creates a new MorphTarget
  30902. * @param name defines the name of the target
  30903. * @param influence defines the influence to use
  30904. * @param scene defines the scene the morphtarget belongs to
  30905. */
  30906. constructor(
  30907. /** defines the name of the target */
  30908. name: string, influence?: number, scene?: Nullable<Scene>);
  30909. /**
  30910. * Gets the unique ID of this manager
  30911. */
  30912. get uniqueId(): number;
  30913. /**
  30914. * Gets a boolean defining if the target contains position data
  30915. */
  30916. get hasPositions(): boolean;
  30917. /**
  30918. * Gets a boolean defining if the target contains normal data
  30919. */
  30920. get hasNormals(): boolean;
  30921. /**
  30922. * Gets a boolean defining if the target contains tangent data
  30923. */
  30924. get hasTangents(): boolean;
  30925. /**
  30926. * Gets a boolean defining if the target contains texture coordinates data
  30927. */
  30928. get hasUVs(): boolean;
  30929. /**
  30930. * Affects position data to this target
  30931. * @param data defines the position data to use
  30932. */
  30933. setPositions(data: Nullable<FloatArray>): void;
  30934. /**
  30935. * Gets the position data stored in this target
  30936. * @returns a FloatArray containing the position data (or null if not present)
  30937. */
  30938. getPositions(): Nullable<FloatArray>;
  30939. /**
  30940. * Affects normal data to this target
  30941. * @param data defines the normal data to use
  30942. */
  30943. setNormals(data: Nullable<FloatArray>): void;
  30944. /**
  30945. * Gets the normal data stored in this target
  30946. * @returns a FloatArray containing the normal data (or null if not present)
  30947. */
  30948. getNormals(): Nullable<FloatArray>;
  30949. /**
  30950. * Affects tangent data to this target
  30951. * @param data defines the tangent data to use
  30952. */
  30953. setTangents(data: Nullable<FloatArray>): void;
  30954. /**
  30955. * Gets the tangent data stored in this target
  30956. * @returns a FloatArray containing the tangent data (or null if not present)
  30957. */
  30958. getTangents(): Nullable<FloatArray>;
  30959. /**
  30960. * Affects texture coordinates data to this target
  30961. * @param data defines the texture coordinates data to use
  30962. */
  30963. setUVs(data: Nullable<FloatArray>): void;
  30964. /**
  30965. * Gets the texture coordinates data stored in this target
  30966. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30967. */
  30968. getUVs(): Nullable<FloatArray>;
  30969. /**
  30970. * Clone the current target
  30971. * @returns a new MorphTarget
  30972. */
  30973. clone(): MorphTarget;
  30974. /**
  30975. * Serializes the current target into a Serialization object
  30976. * @returns the serialized object
  30977. */
  30978. serialize(): any;
  30979. /**
  30980. * Returns the string "MorphTarget"
  30981. * @returns "MorphTarget"
  30982. */
  30983. getClassName(): string;
  30984. /**
  30985. * Creates a new target from serialized data
  30986. * @param serializationObject defines the serialized data to use
  30987. * @returns a new MorphTarget
  30988. */
  30989. static Parse(serializationObject: any): MorphTarget;
  30990. /**
  30991. * Creates a MorphTarget from mesh data
  30992. * @param mesh defines the source mesh
  30993. * @param name defines the name to use for the new target
  30994. * @param influence defines the influence to attach to the target
  30995. * @returns a new MorphTarget
  30996. */
  30997. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30998. }
  30999. }
  31000. declare module BABYLON {
  31001. /**
  31002. * This class is used to deform meshes using morphing between different targets
  31003. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31004. */
  31005. export class MorphTargetManager {
  31006. private _targets;
  31007. private _targetInfluenceChangedObservers;
  31008. private _targetDataLayoutChangedObservers;
  31009. private _activeTargets;
  31010. private _scene;
  31011. private _influences;
  31012. private _supportsNormals;
  31013. private _supportsTangents;
  31014. private _supportsUVs;
  31015. private _vertexCount;
  31016. private _uniqueId;
  31017. private _tempInfluences;
  31018. /**
  31019. * Gets or sets a boolean indicating if normals must be morphed
  31020. */
  31021. enableNormalMorphing: boolean;
  31022. /**
  31023. * Gets or sets a boolean indicating if tangents must be morphed
  31024. */
  31025. enableTangentMorphing: boolean;
  31026. /**
  31027. * Gets or sets a boolean indicating if UV must be morphed
  31028. */
  31029. enableUVMorphing: boolean;
  31030. /**
  31031. * Creates a new MorphTargetManager
  31032. * @param scene defines the current scene
  31033. */
  31034. constructor(scene?: Nullable<Scene>);
  31035. /**
  31036. * Gets the unique ID of this manager
  31037. */
  31038. get uniqueId(): number;
  31039. /**
  31040. * Gets the number of vertices handled by this manager
  31041. */
  31042. get vertexCount(): number;
  31043. /**
  31044. * Gets a boolean indicating if this manager supports morphing of normals
  31045. */
  31046. get supportsNormals(): boolean;
  31047. /**
  31048. * Gets a boolean indicating if this manager supports morphing of tangents
  31049. */
  31050. get supportsTangents(): boolean;
  31051. /**
  31052. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31053. */
  31054. get supportsUVs(): boolean;
  31055. /**
  31056. * Gets the number of targets stored in this manager
  31057. */
  31058. get numTargets(): number;
  31059. /**
  31060. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31061. */
  31062. get numInfluencers(): number;
  31063. /**
  31064. * Gets the list of influences (one per target)
  31065. */
  31066. get influences(): Float32Array;
  31067. /**
  31068. * Gets the active target at specified index. An active target is a target with an influence > 0
  31069. * @param index defines the index to check
  31070. * @returns the requested target
  31071. */
  31072. getActiveTarget(index: number): MorphTarget;
  31073. /**
  31074. * Gets the target at specified index
  31075. * @param index defines the index to check
  31076. * @returns the requested target
  31077. */
  31078. getTarget(index: number): MorphTarget;
  31079. /**
  31080. * Add a new target to this manager
  31081. * @param target defines the target to add
  31082. */
  31083. addTarget(target: MorphTarget): void;
  31084. /**
  31085. * Removes a target from the manager
  31086. * @param target defines the target to remove
  31087. */
  31088. removeTarget(target: MorphTarget): void;
  31089. /**
  31090. * Clone the current manager
  31091. * @returns a new MorphTargetManager
  31092. */
  31093. clone(): MorphTargetManager;
  31094. /**
  31095. * Serializes the current manager into a Serialization object
  31096. * @returns the serialized object
  31097. */
  31098. serialize(): any;
  31099. private _syncActiveTargets;
  31100. /**
  31101. * Syncrhonize the targets with all the meshes using this morph target manager
  31102. */
  31103. synchronize(): void;
  31104. /**
  31105. * Creates a new MorphTargetManager from serialized data
  31106. * @param serializationObject defines the serialized data
  31107. * @param scene defines the hosting scene
  31108. * @returns the new MorphTargetManager
  31109. */
  31110. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31111. }
  31112. }
  31113. declare module BABYLON {
  31114. /**
  31115. * Class used to represent a specific level of detail of a mesh
  31116. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31117. */
  31118. export class MeshLODLevel {
  31119. /** Defines the distance where this level should start being displayed */
  31120. distance: number;
  31121. /** Defines the mesh to use to render this level */
  31122. mesh: Nullable<Mesh>;
  31123. /**
  31124. * Creates a new LOD level
  31125. * @param distance defines the distance where this level should star being displayed
  31126. * @param mesh defines the mesh to use to render this level
  31127. */
  31128. constructor(
  31129. /** Defines the distance where this level should start being displayed */
  31130. distance: number,
  31131. /** Defines the mesh to use to render this level */
  31132. mesh: Nullable<Mesh>);
  31133. }
  31134. }
  31135. declare module BABYLON {
  31136. /**
  31137. * Helper class used to generate a canvas to manipulate images
  31138. */
  31139. export class CanvasGenerator {
  31140. /**
  31141. * Create a new canvas (or offscreen canvas depending on the context)
  31142. * @param width defines the expected width
  31143. * @param height defines the expected height
  31144. * @return a new canvas or offscreen canvas
  31145. */
  31146. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31147. }
  31148. }
  31149. declare module BABYLON {
  31150. /**
  31151. * Mesh representing the gorund
  31152. */
  31153. export class GroundMesh extends Mesh {
  31154. /** If octree should be generated */
  31155. generateOctree: boolean;
  31156. private _heightQuads;
  31157. /** @hidden */
  31158. _subdivisionsX: number;
  31159. /** @hidden */
  31160. _subdivisionsY: number;
  31161. /** @hidden */
  31162. _width: number;
  31163. /** @hidden */
  31164. _height: number;
  31165. /** @hidden */
  31166. _minX: number;
  31167. /** @hidden */
  31168. _maxX: number;
  31169. /** @hidden */
  31170. _minZ: number;
  31171. /** @hidden */
  31172. _maxZ: number;
  31173. constructor(name: string, scene: Scene);
  31174. /**
  31175. * "GroundMesh"
  31176. * @returns "GroundMesh"
  31177. */
  31178. getClassName(): string;
  31179. /**
  31180. * The minimum of x and y subdivisions
  31181. */
  31182. get subdivisions(): number;
  31183. /**
  31184. * X subdivisions
  31185. */
  31186. get subdivisionsX(): number;
  31187. /**
  31188. * Y subdivisions
  31189. */
  31190. get subdivisionsY(): number;
  31191. /**
  31192. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31193. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31194. * @param chunksCount the number of subdivisions for x and y
  31195. * @param octreeBlocksSize (Default: 32)
  31196. */
  31197. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31198. /**
  31199. * Returns a height (y) value in the Worl system :
  31200. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31201. * @param x x coordinate
  31202. * @param z z coordinate
  31203. * @returns the ground y position if (x, z) are outside the ground surface.
  31204. */
  31205. getHeightAtCoordinates(x: number, z: number): number;
  31206. /**
  31207. * Returns a normalized vector (Vector3) orthogonal to the ground
  31208. * at the ground coordinates (x, z) expressed in the World system.
  31209. * @param x x coordinate
  31210. * @param z z coordinate
  31211. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31212. */
  31213. getNormalAtCoordinates(x: number, z: number): Vector3;
  31214. /**
  31215. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31216. * at the ground coordinates (x, z) expressed in the World system.
  31217. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31218. * @param x x coordinate
  31219. * @param z z coordinate
  31220. * @param ref vector to store the result
  31221. * @returns the GroundMesh.
  31222. */
  31223. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31224. /**
  31225. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31226. * if the ground has been updated.
  31227. * This can be used in the render loop.
  31228. * @returns the GroundMesh.
  31229. */
  31230. updateCoordinateHeights(): GroundMesh;
  31231. private _getFacetAt;
  31232. private _initHeightQuads;
  31233. private _computeHeightQuads;
  31234. /**
  31235. * Serializes this ground mesh
  31236. * @param serializationObject object to write serialization to
  31237. */
  31238. serialize(serializationObject: any): void;
  31239. /**
  31240. * Parses a serialized ground mesh
  31241. * @param parsedMesh the serialized mesh
  31242. * @param scene the scene to create the ground mesh in
  31243. * @returns the created ground mesh
  31244. */
  31245. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31246. }
  31247. }
  31248. declare module BABYLON {
  31249. /**
  31250. * Interface for Physics-Joint data
  31251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31252. */
  31253. export interface PhysicsJointData {
  31254. /**
  31255. * The main pivot of the joint
  31256. */
  31257. mainPivot?: Vector3;
  31258. /**
  31259. * The connected pivot of the joint
  31260. */
  31261. connectedPivot?: Vector3;
  31262. /**
  31263. * The main axis of the joint
  31264. */
  31265. mainAxis?: Vector3;
  31266. /**
  31267. * The connected axis of the joint
  31268. */
  31269. connectedAxis?: Vector3;
  31270. /**
  31271. * The collision of the joint
  31272. */
  31273. collision?: boolean;
  31274. /**
  31275. * Native Oimo/Cannon/Energy data
  31276. */
  31277. nativeParams?: any;
  31278. }
  31279. /**
  31280. * This is a holder class for the physics joint created by the physics plugin
  31281. * It holds a set of functions to control the underlying joint
  31282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31283. */
  31284. export class PhysicsJoint {
  31285. /**
  31286. * The type of the physics joint
  31287. */
  31288. type: number;
  31289. /**
  31290. * The data for the physics joint
  31291. */
  31292. jointData: PhysicsJointData;
  31293. private _physicsJoint;
  31294. protected _physicsPlugin: IPhysicsEnginePlugin;
  31295. /**
  31296. * Initializes the physics joint
  31297. * @param type The type of the physics joint
  31298. * @param jointData The data for the physics joint
  31299. */
  31300. constructor(
  31301. /**
  31302. * The type of the physics joint
  31303. */
  31304. type: number,
  31305. /**
  31306. * The data for the physics joint
  31307. */
  31308. jointData: PhysicsJointData);
  31309. /**
  31310. * Gets the physics joint
  31311. */
  31312. get physicsJoint(): any;
  31313. /**
  31314. * Sets the physics joint
  31315. */
  31316. set physicsJoint(newJoint: any);
  31317. /**
  31318. * Sets the physics plugin
  31319. */
  31320. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31321. /**
  31322. * Execute a function that is physics-plugin specific.
  31323. * @param {Function} func the function that will be executed.
  31324. * It accepts two parameters: the physics world and the physics joint
  31325. */
  31326. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31327. /**
  31328. * Distance-Joint type
  31329. */
  31330. static DistanceJoint: number;
  31331. /**
  31332. * Hinge-Joint type
  31333. */
  31334. static HingeJoint: number;
  31335. /**
  31336. * Ball-and-Socket joint type
  31337. */
  31338. static BallAndSocketJoint: number;
  31339. /**
  31340. * Wheel-Joint type
  31341. */
  31342. static WheelJoint: number;
  31343. /**
  31344. * Slider-Joint type
  31345. */
  31346. static SliderJoint: number;
  31347. /**
  31348. * Prismatic-Joint type
  31349. */
  31350. static PrismaticJoint: number;
  31351. /**
  31352. * Universal-Joint type
  31353. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31354. */
  31355. static UniversalJoint: number;
  31356. /**
  31357. * Hinge-Joint 2 type
  31358. */
  31359. static Hinge2Joint: number;
  31360. /**
  31361. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31362. */
  31363. static PointToPointJoint: number;
  31364. /**
  31365. * Spring-Joint type
  31366. */
  31367. static SpringJoint: number;
  31368. /**
  31369. * Lock-Joint type
  31370. */
  31371. static LockJoint: number;
  31372. }
  31373. /**
  31374. * A class representing a physics distance joint
  31375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31376. */
  31377. export class DistanceJoint extends PhysicsJoint {
  31378. /**
  31379. *
  31380. * @param jointData The data for the Distance-Joint
  31381. */
  31382. constructor(jointData: DistanceJointData);
  31383. /**
  31384. * Update the predefined distance.
  31385. * @param maxDistance The maximum preferred distance
  31386. * @param minDistance The minimum preferred distance
  31387. */
  31388. updateDistance(maxDistance: number, minDistance?: number): void;
  31389. }
  31390. /**
  31391. * Represents a Motor-Enabled Joint
  31392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31393. */
  31394. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31395. /**
  31396. * Initializes the Motor-Enabled Joint
  31397. * @param type The type of the joint
  31398. * @param jointData The physica joint data for the joint
  31399. */
  31400. constructor(type: number, jointData: PhysicsJointData);
  31401. /**
  31402. * Set the motor values.
  31403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31404. * @param force the force to apply
  31405. * @param maxForce max force for this motor.
  31406. */
  31407. setMotor(force?: number, maxForce?: number): void;
  31408. /**
  31409. * Set the motor's limits.
  31410. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31411. * @param upperLimit The upper limit of the motor
  31412. * @param lowerLimit The lower limit of the motor
  31413. */
  31414. setLimit(upperLimit: number, lowerLimit?: number): void;
  31415. }
  31416. /**
  31417. * This class represents a single physics Hinge-Joint
  31418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31419. */
  31420. export class HingeJoint extends MotorEnabledJoint {
  31421. /**
  31422. * Initializes the Hinge-Joint
  31423. * @param jointData The joint data for the Hinge-Joint
  31424. */
  31425. constructor(jointData: PhysicsJointData);
  31426. /**
  31427. * Set the motor values.
  31428. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31429. * @param {number} force the force to apply
  31430. * @param {number} maxForce max force for this motor.
  31431. */
  31432. setMotor(force?: number, maxForce?: number): void;
  31433. /**
  31434. * Set the motor's limits.
  31435. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31436. * @param upperLimit The upper limit of the motor
  31437. * @param lowerLimit The lower limit of the motor
  31438. */
  31439. setLimit(upperLimit: number, lowerLimit?: number): void;
  31440. }
  31441. /**
  31442. * This class represents a dual hinge physics joint (same as wheel joint)
  31443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31444. */
  31445. export class Hinge2Joint extends MotorEnabledJoint {
  31446. /**
  31447. * Initializes the Hinge2-Joint
  31448. * @param jointData The joint data for the Hinge2-Joint
  31449. */
  31450. constructor(jointData: PhysicsJointData);
  31451. /**
  31452. * Set the motor values.
  31453. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31454. * @param {number} targetSpeed the speed the motor is to reach
  31455. * @param {number} maxForce max force for this motor.
  31456. * @param {motorIndex} the motor's index, 0 or 1.
  31457. */
  31458. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31459. /**
  31460. * Set the motor limits.
  31461. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31462. * @param {number} upperLimit the upper limit
  31463. * @param {number} lowerLimit lower limit
  31464. * @param {motorIndex} the motor's index, 0 or 1.
  31465. */
  31466. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31467. }
  31468. /**
  31469. * Interface for a motor enabled joint
  31470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31471. */
  31472. export interface IMotorEnabledJoint {
  31473. /**
  31474. * Physics joint
  31475. */
  31476. physicsJoint: any;
  31477. /**
  31478. * Sets the motor of the motor-enabled joint
  31479. * @param force The force of the motor
  31480. * @param maxForce The maximum force of the motor
  31481. * @param motorIndex The index of the motor
  31482. */
  31483. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31484. /**
  31485. * Sets the limit of the motor
  31486. * @param upperLimit The upper limit of the motor
  31487. * @param lowerLimit The lower limit of the motor
  31488. * @param motorIndex The index of the motor
  31489. */
  31490. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31491. }
  31492. /**
  31493. * Joint data for a Distance-Joint
  31494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31495. */
  31496. export interface DistanceJointData extends PhysicsJointData {
  31497. /**
  31498. * Max distance the 2 joint objects can be apart
  31499. */
  31500. maxDistance: number;
  31501. }
  31502. /**
  31503. * Joint data from a spring joint
  31504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31505. */
  31506. export interface SpringJointData extends PhysicsJointData {
  31507. /**
  31508. * Length of the spring
  31509. */
  31510. length: number;
  31511. /**
  31512. * Stiffness of the spring
  31513. */
  31514. stiffness: number;
  31515. /**
  31516. * Damping of the spring
  31517. */
  31518. damping: number;
  31519. /** this callback will be called when applying the force to the impostors. */
  31520. forceApplicationCallback: () => void;
  31521. }
  31522. }
  31523. declare module BABYLON {
  31524. /**
  31525. * Holds the data for the raycast result
  31526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31527. */
  31528. export class PhysicsRaycastResult {
  31529. private _hasHit;
  31530. private _hitDistance;
  31531. private _hitNormalWorld;
  31532. private _hitPointWorld;
  31533. private _rayFromWorld;
  31534. private _rayToWorld;
  31535. /**
  31536. * Gets if there was a hit
  31537. */
  31538. get hasHit(): boolean;
  31539. /**
  31540. * Gets the distance from the hit
  31541. */
  31542. get hitDistance(): number;
  31543. /**
  31544. * Gets the hit normal/direction in the world
  31545. */
  31546. get hitNormalWorld(): Vector3;
  31547. /**
  31548. * Gets the hit point in the world
  31549. */
  31550. get hitPointWorld(): Vector3;
  31551. /**
  31552. * Gets the ray "start point" of the ray in the world
  31553. */
  31554. get rayFromWorld(): Vector3;
  31555. /**
  31556. * Gets the ray "end point" of the ray in the world
  31557. */
  31558. get rayToWorld(): Vector3;
  31559. /**
  31560. * Sets the hit data (normal & point in world space)
  31561. * @param hitNormalWorld defines the normal in world space
  31562. * @param hitPointWorld defines the point in world space
  31563. */
  31564. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31565. /**
  31566. * Sets the distance from the start point to the hit point
  31567. * @param distance
  31568. */
  31569. setHitDistance(distance: number): void;
  31570. /**
  31571. * Calculates the distance manually
  31572. */
  31573. calculateHitDistance(): void;
  31574. /**
  31575. * Resets all the values to default
  31576. * @param from The from point on world space
  31577. * @param to The to point on world space
  31578. */
  31579. reset(from?: Vector3, to?: Vector3): void;
  31580. }
  31581. /**
  31582. * Interface for the size containing width and height
  31583. */
  31584. interface IXYZ {
  31585. /**
  31586. * X
  31587. */
  31588. x: number;
  31589. /**
  31590. * Y
  31591. */
  31592. y: number;
  31593. /**
  31594. * Z
  31595. */
  31596. z: number;
  31597. }
  31598. }
  31599. declare module BABYLON {
  31600. /**
  31601. * Interface used to describe a physics joint
  31602. */
  31603. export interface PhysicsImpostorJoint {
  31604. /** Defines the main impostor to which the joint is linked */
  31605. mainImpostor: PhysicsImpostor;
  31606. /** Defines the impostor that is connected to the main impostor using this joint */
  31607. connectedImpostor: PhysicsImpostor;
  31608. /** Defines the joint itself */
  31609. joint: PhysicsJoint;
  31610. }
  31611. /** @hidden */
  31612. export interface IPhysicsEnginePlugin {
  31613. world: any;
  31614. name: string;
  31615. setGravity(gravity: Vector3): void;
  31616. setTimeStep(timeStep: number): void;
  31617. getTimeStep(): number;
  31618. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31619. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31620. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31621. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31622. removePhysicsBody(impostor: PhysicsImpostor): void;
  31623. generateJoint(joint: PhysicsImpostorJoint): void;
  31624. removeJoint(joint: PhysicsImpostorJoint): void;
  31625. isSupported(): boolean;
  31626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31633. getBodyMass(impostor: PhysicsImpostor): number;
  31634. getBodyFriction(impostor: PhysicsImpostor): number;
  31635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31636. getBodyRestitution(impostor: PhysicsImpostor): number;
  31637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31638. getBodyPressure?(impostor: PhysicsImpostor): number;
  31639. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31640. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31641. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31642. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31643. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31644. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31645. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31646. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31647. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31648. sleepBody(impostor: PhysicsImpostor): void;
  31649. wakeUpBody(impostor: PhysicsImpostor): void;
  31650. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31651. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31652. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31654. getRadius(impostor: PhysicsImpostor): number;
  31655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31656. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31657. dispose(): void;
  31658. }
  31659. /**
  31660. * Interface used to define a physics engine
  31661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31662. */
  31663. export interface IPhysicsEngine {
  31664. /**
  31665. * Gets the gravity vector used by the simulation
  31666. */
  31667. gravity: Vector3;
  31668. /**
  31669. * Sets the gravity vector used by the simulation
  31670. * @param gravity defines the gravity vector to use
  31671. */
  31672. setGravity(gravity: Vector3): void;
  31673. /**
  31674. * Set the time step of the physics engine.
  31675. * Default is 1/60.
  31676. * To slow it down, enter 1/600 for example.
  31677. * To speed it up, 1/30
  31678. * @param newTimeStep the new timestep to apply to this world.
  31679. */
  31680. setTimeStep(newTimeStep: number): void;
  31681. /**
  31682. * Get the time step of the physics engine.
  31683. * @returns the current time step
  31684. */
  31685. getTimeStep(): number;
  31686. /**
  31687. * Set the sub time step of the physics engine.
  31688. * Default is 0 meaning there is no sub steps
  31689. * To increase physics resolution precision, set a small value (like 1 ms)
  31690. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31691. */
  31692. setSubTimeStep(subTimeStep: number): void;
  31693. /**
  31694. * Get the sub time step of the physics engine.
  31695. * @returns the current sub time step
  31696. */
  31697. getSubTimeStep(): number;
  31698. /**
  31699. * Release all resources
  31700. */
  31701. dispose(): void;
  31702. /**
  31703. * Gets the name of the current physics plugin
  31704. * @returns the name of the plugin
  31705. */
  31706. getPhysicsPluginName(): string;
  31707. /**
  31708. * Adding a new impostor for the impostor tracking.
  31709. * This will be done by the impostor itself.
  31710. * @param impostor the impostor to add
  31711. */
  31712. addImpostor(impostor: PhysicsImpostor): void;
  31713. /**
  31714. * Remove an impostor from the engine.
  31715. * This impostor and its mesh will not longer be updated by the physics engine.
  31716. * @param impostor the impostor to remove
  31717. */
  31718. removeImpostor(impostor: PhysicsImpostor): void;
  31719. /**
  31720. * Add a joint to the physics engine
  31721. * @param mainImpostor defines the main impostor to which the joint is added.
  31722. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31723. * @param joint defines the joint that will connect both impostors.
  31724. */
  31725. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31726. /**
  31727. * Removes a joint from the simulation
  31728. * @param mainImpostor defines the impostor used with the joint
  31729. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31730. * @param joint defines the joint to remove
  31731. */
  31732. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31733. /**
  31734. * Gets the current plugin used to run the simulation
  31735. * @returns current plugin
  31736. */
  31737. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31738. /**
  31739. * Gets the list of physic impostors
  31740. * @returns an array of PhysicsImpostor
  31741. */
  31742. getImpostors(): Array<PhysicsImpostor>;
  31743. /**
  31744. * Gets the impostor for a physics enabled object
  31745. * @param object defines the object impersonated by the impostor
  31746. * @returns the PhysicsImpostor or null if not found
  31747. */
  31748. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31749. /**
  31750. * Gets the impostor for a physics body object
  31751. * @param body defines physics body used by the impostor
  31752. * @returns the PhysicsImpostor or null if not found
  31753. */
  31754. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31755. /**
  31756. * Does a raycast in the physics world
  31757. * @param from when should the ray start?
  31758. * @param to when should the ray end?
  31759. * @returns PhysicsRaycastResult
  31760. */
  31761. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31762. /**
  31763. * Called by the scene. No need to call it.
  31764. * @param delta defines the timespam between frames
  31765. */
  31766. _step(delta: number): void;
  31767. }
  31768. }
  31769. declare module BABYLON {
  31770. /**
  31771. * The interface for the physics imposter parameters
  31772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31773. */
  31774. export interface PhysicsImpostorParameters {
  31775. /**
  31776. * The mass of the physics imposter
  31777. */
  31778. mass: number;
  31779. /**
  31780. * The friction of the physics imposter
  31781. */
  31782. friction?: number;
  31783. /**
  31784. * The coefficient of restitution of the physics imposter
  31785. */
  31786. restitution?: number;
  31787. /**
  31788. * The native options of the physics imposter
  31789. */
  31790. nativeOptions?: any;
  31791. /**
  31792. * Specifies if the parent should be ignored
  31793. */
  31794. ignoreParent?: boolean;
  31795. /**
  31796. * Specifies if bi-directional transformations should be disabled
  31797. */
  31798. disableBidirectionalTransformation?: boolean;
  31799. /**
  31800. * The pressure inside the physics imposter, soft object only
  31801. */
  31802. pressure?: number;
  31803. /**
  31804. * The stiffness the physics imposter, soft object only
  31805. */
  31806. stiffness?: number;
  31807. /**
  31808. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31809. */
  31810. velocityIterations?: number;
  31811. /**
  31812. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31813. */
  31814. positionIterations?: number;
  31815. /**
  31816. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31817. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31818. * Add to fix multiple points
  31819. */
  31820. fixedPoints?: number;
  31821. /**
  31822. * The collision margin around a soft object
  31823. */
  31824. margin?: number;
  31825. /**
  31826. * The collision margin around a soft object
  31827. */
  31828. damping?: number;
  31829. /**
  31830. * The path for a rope based on an extrusion
  31831. */
  31832. path?: any;
  31833. /**
  31834. * The shape of an extrusion used for a rope based on an extrusion
  31835. */
  31836. shape?: any;
  31837. }
  31838. /**
  31839. * Interface for a physics-enabled object
  31840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31841. */
  31842. export interface IPhysicsEnabledObject {
  31843. /**
  31844. * The position of the physics-enabled object
  31845. */
  31846. position: Vector3;
  31847. /**
  31848. * The rotation of the physics-enabled object
  31849. */
  31850. rotationQuaternion: Nullable<Quaternion>;
  31851. /**
  31852. * The scale of the physics-enabled object
  31853. */
  31854. scaling: Vector3;
  31855. /**
  31856. * The rotation of the physics-enabled object
  31857. */
  31858. rotation?: Vector3;
  31859. /**
  31860. * The parent of the physics-enabled object
  31861. */
  31862. parent?: any;
  31863. /**
  31864. * The bounding info of the physics-enabled object
  31865. * @returns The bounding info of the physics-enabled object
  31866. */
  31867. getBoundingInfo(): BoundingInfo;
  31868. /**
  31869. * Computes the world matrix
  31870. * @param force Specifies if the world matrix should be computed by force
  31871. * @returns A world matrix
  31872. */
  31873. computeWorldMatrix(force: boolean): Matrix;
  31874. /**
  31875. * Gets the world matrix
  31876. * @returns A world matrix
  31877. */
  31878. getWorldMatrix?(): Matrix;
  31879. /**
  31880. * Gets the child meshes
  31881. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31882. * @returns An array of abstract meshes
  31883. */
  31884. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31885. /**
  31886. * Gets the vertex data
  31887. * @param kind The type of vertex data
  31888. * @returns A nullable array of numbers, or a float32 array
  31889. */
  31890. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31891. /**
  31892. * Gets the indices from the mesh
  31893. * @returns A nullable array of index arrays
  31894. */
  31895. getIndices?(): Nullable<IndicesArray>;
  31896. /**
  31897. * Gets the scene from the mesh
  31898. * @returns the indices array or null
  31899. */
  31900. getScene?(): Scene;
  31901. /**
  31902. * Gets the absolute position from the mesh
  31903. * @returns the absolute position
  31904. */
  31905. getAbsolutePosition(): Vector3;
  31906. /**
  31907. * Gets the absolute pivot point from the mesh
  31908. * @returns the absolute pivot point
  31909. */
  31910. getAbsolutePivotPoint(): Vector3;
  31911. /**
  31912. * Rotates the mesh
  31913. * @param axis The axis of rotation
  31914. * @param amount The amount of rotation
  31915. * @param space The space of the rotation
  31916. * @returns The rotation transform node
  31917. */
  31918. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31919. /**
  31920. * Translates the mesh
  31921. * @param axis The axis of translation
  31922. * @param distance The distance of translation
  31923. * @param space The space of the translation
  31924. * @returns The transform node
  31925. */
  31926. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31927. /**
  31928. * Sets the absolute position of the mesh
  31929. * @param absolutePosition The absolute position of the mesh
  31930. * @returns The transform node
  31931. */
  31932. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31933. /**
  31934. * Gets the class name of the mesh
  31935. * @returns The class name
  31936. */
  31937. getClassName(): string;
  31938. }
  31939. /**
  31940. * Represents a physics imposter
  31941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31942. */
  31943. export class PhysicsImpostor {
  31944. /**
  31945. * The physics-enabled object used as the physics imposter
  31946. */
  31947. object: IPhysicsEnabledObject;
  31948. /**
  31949. * The type of the physics imposter
  31950. */
  31951. type: number;
  31952. private _options;
  31953. private _scene?;
  31954. /**
  31955. * The default object size of the imposter
  31956. */
  31957. static DEFAULT_OBJECT_SIZE: Vector3;
  31958. /**
  31959. * The identity quaternion of the imposter
  31960. */
  31961. static IDENTITY_QUATERNION: Quaternion;
  31962. /** @hidden */
  31963. _pluginData: any;
  31964. private _physicsEngine;
  31965. private _physicsBody;
  31966. private _bodyUpdateRequired;
  31967. private _onBeforePhysicsStepCallbacks;
  31968. private _onAfterPhysicsStepCallbacks;
  31969. /** @hidden */
  31970. _onPhysicsCollideCallbacks: Array<{
  31971. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31972. otherImpostors: Array<PhysicsImpostor>;
  31973. }>;
  31974. private _deltaPosition;
  31975. private _deltaRotation;
  31976. private _deltaRotationConjugated;
  31977. /** @hidden */
  31978. _isFromLine: boolean;
  31979. private _parent;
  31980. private _isDisposed;
  31981. private static _tmpVecs;
  31982. private static _tmpQuat;
  31983. /**
  31984. * Specifies if the physics imposter is disposed
  31985. */
  31986. get isDisposed(): boolean;
  31987. /**
  31988. * Gets the mass of the physics imposter
  31989. */
  31990. get mass(): number;
  31991. set mass(value: number);
  31992. /**
  31993. * Gets the coefficient of friction
  31994. */
  31995. get friction(): number;
  31996. /**
  31997. * Sets the coefficient of friction
  31998. */
  31999. set friction(value: number);
  32000. /**
  32001. * Gets the coefficient of restitution
  32002. */
  32003. get restitution(): number;
  32004. /**
  32005. * Sets the coefficient of restitution
  32006. */
  32007. set restitution(value: number);
  32008. /**
  32009. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32010. */
  32011. get pressure(): number;
  32012. /**
  32013. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32014. */
  32015. set pressure(value: number);
  32016. /**
  32017. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32018. */
  32019. get stiffness(): number;
  32020. /**
  32021. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32022. */
  32023. set stiffness(value: number);
  32024. /**
  32025. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32026. */
  32027. get velocityIterations(): number;
  32028. /**
  32029. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32030. */
  32031. set velocityIterations(value: number);
  32032. /**
  32033. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32034. */
  32035. get positionIterations(): number;
  32036. /**
  32037. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32038. */
  32039. set positionIterations(value: number);
  32040. /**
  32041. * The unique id of the physics imposter
  32042. * set by the physics engine when adding this impostor to the array
  32043. */
  32044. uniqueId: number;
  32045. /**
  32046. * @hidden
  32047. */
  32048. soft: boolean;
  32049. /**
  32050. * @hidden
  32051. */
  32052. segments: number;
  32053. private _joints;
  32054. /**
  32055. * Initializes the physics imposter
  32056. * @param object The physics-enabled object used as the physics imposter
  32057. * @param type The type of the physics imposter
  32058. * @param _options The options for the physics imposter
  32059. * @param _scene The Babylon scene
  32060. */
  32061. constructor(
  32062. /**
  32063. * The physics-enabled object used as the physics imposter
  32064. */
  32065. object: IPhysicsEnabledObject,
  32066. /**
  32067. * The type of the physics imposter
  32068. */
  32069. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32070. /**
  32071. * This function will completly initialize this impostor.
  32072. * It will create a new body - but only if this mesh has no parent.
  32073. * If it has, this impostor will not be used other than to define the impostor
  32074. * of the child mesh.
  32075. * @hidden
  32076. */
  32077. _init(): void;
  32078. private _getPhysicsParent;
  32079. /**
  32080. * Should a new body be generated.
  32081. * @returns boolean specifying if body initialization is required
  32082. */
  32083. isBodyInitRequired(): boolean;
  32084. /**
  32085. * Sets the updated scaling
  32086. * @param updated Specifies if the scaling is updated
  32087. */
  32088. setScalingUpdated(): void;
  32089. /**
  32090. * Force a regeneration of this or the parent's impostor's body.
  32091. * Use under cautious - This will remove all joints already implemented.
  32092. */
  32093. forceUpdate(): void;
  32094. /**
  32095. * Gets the body that holds this impostor. Either its own, or its parent.
  32096. */
  32097. get physicsBody(): any;
  32098. /**
  32099. * Get the parent of the physics imposter
  32100. * @returns Physics imposter or null
  32101. */
  32102. get parent(): Nullable<PhysicsImpostor>;
  32103. /**
  32104. * Sets the parent of the physics imposter
  32105. */
  32106. set parent(value: Nullable<PhysicsImpostor>);
  32107. /**
  32108. * Set the physics body. Used mainly by the physics engine/plugin
  32109. */
  32110. set physicsBody(physicsBody: any);
  32111. /**
  32112. * Resets the update flags
  32113. */
  32114. resetUpdateFlags(): void;
  32115. /**
  32116. * Gets the object extend size
  32117. * @returns the object extend size
  32118. */
  32119. getObjectExtendSize(): Vector3;
  32120. /**
  32121. * Gets the object center
  32122. * @returns The object center
  32123. */
  32124. getObjectCenter(): Vector3;
  32125. /**
  32126. * Get a specific parameter from the options parameters
  32127. * @param paramName The object parameter name
  32128. * @returns The object parameter
  32129. */
  32130. getParam(paramName: string): any;
  32131. /**
  32132. * Sets a specific parameter in the options given to the physics plugin
  32133. * @param paramName The parameter name
  32134. * @param value The value of the parameter
  32135. */
  32136. setParam(paramName: string, value: number): void;
  32137. /**
  32138. * Specifically change the body's mass option. Won't recreate the physics body object
  32139. * @param mass The mass of the physics imposter
  32140. */
  32141. setMass(mass: number): void;
  32142. /**
  32143. * Gets the linear velocity
  32144. * @returns linear velocity or null
  32145. */
  32146. getLinearVelocity(): Nullable<Vector3>;
  32147. /**
  32148. * Sets the linear velocity
  32149. * @param velocity linear velocity or null
  32150. */
  32151. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32152. /**
  32153. * Gets the angular velocity
  32154. * @returns angular velocity or null
  32155. */
  32156. getAngularVelocity(): Nullable<Vector3>;
  32157. /**
  32158. * Sets the angular velocity
  32159. * @param velocity The velocity or null
  32160. */
  32161. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32162. /**
  32163. * Execute a function with the physics plugin native code
  32164. * Provide a function the will have two variables - the world object and the physics body object
  32165. * @param func The function to execute with the physics plugin native code
  32166. */
  32167. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32168. /**
  32169. * Register a function that will be executed before the physics world is stepping forward
  32170. * @param func The function to execute before the physics world is stepped forward
  32171. */
  32172. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32173. /**
  32174. * Unregister a function that will be executed before the physics world is stepping forward
  32175. * @param func The function to execute before the physics world is stepped forward
  32176. */
  32177. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32178. /**
  32179. * Register a function that will be executed after the physics step
  32180. * @param func The function to execute after physics step
  32181. */
  32182. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32183. /**
  32184. * Unregisters a function that will be executed after the physics step
  32185. * @param func The function to execute after physics step
  32186. */
  32187. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32188. /**
  32189. * register a function that will be executed when this impostor collides against a different body
  32190. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32191. * @param func Callback that is executed on collision
  32192. */
  32193. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32194. /**
  32195. * Unregisters the physics imposter on contact
  32196. * @param collideAgainst The physics object to collide against
  32197. * @param func Callback to execute on collision
  32198. */
  32199. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32200. private _tmpQuat;
  32201. private _tmpQuat2;
  32202. /**
  32203. * Get the parent rotation
  32204. * @returns The parent rotation
  32205. */
  32206. getParentsRotation(): Quaternion;
  32207. /**
  32208. * this function is executed by the physics engine.
  32209. */
  32210. beforeStep: () => void;
  32211. /**
  32212. * this function is executed by the physics engine
  32213. */
  32214. afterStep: () => void;
  32215. /**
  32216. * Legacy collision detection event support
  32217. */
  32218. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32219. /**
  32220. * event and body object due to cannon's event-based architecture.
  32221. */
  32222. onCollide: (e: {
  32223. body: any;
  32224. point: Nullable<Vector3>;
  32225. }) => void;
  32226. /**
  32227. * Apply a force
  32228. * @param force The force to apply
  32229. * @param contactPoint The contact point for the force
  32230. * @returns The physics imposter
  32231. */
  32232. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32233. /**
  32234. * Apply an impulse
  32235. * @param force The impulse force
  32236. * @param contactPoint The contact point for the impulse force
  32237. * @returns The physics imposter
  32238. */
  32239. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32240. /**
  32241. * A help function to create a joint
  32242. * @param otherImpostor A physics imposter used to create a joint
  32243. * @param jointType The type of joint
  32244. * @param jointData The data for the joint
  32245. * @returns The physics imposter
  32246. */
  32247. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32248. /**
  32249. * Add a joint to this impostor with a different impostor
  32250. * @param otherImpostor A physics imposter used to add a joint
  32251. * @param joint The joint to add
  32252. * @returns The physics imposter
  32253. */
  32254. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32255. /**
  32256. * Add an anchor to a cloth impostor
  32257. * @param otherImpostor rigid impostor to anchor to
  32258. * @param width ratio across width from 0 to 1
  32259. * @param height ratio up height from 0 to 1
  32260. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32261. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32262. * @returns impostor the soft imposter
  32263. */
  32264. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32265. /**
  32266. * Add a hook to a rope impostor
  32267. * @param otherImpostor rigid impostor to anchor to
  32268. * @param length ratio across rope from 0 to 1
  32269. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32270. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32271. * @returns impostor the rope imposter
  32272. */
  32273. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32274. /**
  32275. * Will keep this body still, in a sleep mode.
  32276. * @returns the physics imposter
  32277. */
  32278. sleep(): PhysicsImpostor;
  32279. /**
  32280. * Wake the body up.
  32281. * @returns The physics imposter
  32282. */
  32283. wakeUp(): PhysicsImpostor;
  32284. /**
  32285. * Clones the physics imposter
  32286. * @param newObject The physics imposter clones to this physics-enabled object
  32287. * @returns A nullable physics imposter
  32288. */
  32289. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32290. /**
  32291. * Disposes the physics imposter
  32292. */
  32293. dispose(): void;
  32294. /**
  32295. * Sets the delta position
  32296. * @param position The delta position amount
  32297. */
  32298. setDeltaPosition(position: Vector3): void;
  32299. /**
  32300. * Sets the delta rotation
  32301. * @param rotation The delta rotation amount
  32302. */
  32303. setDeltaRotation(rotation: Quaternion): void;
  32304. /**
  32305. * Gets the box size of the physics imposter and stores the result in the input parameter
  32306. * @param result Stores the box size
  32307. * @returns The physics imposter
  32308. */
  32309. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32310. /**
  32311. * Gets the radius of the physics imposter
  32312. * @returns Radius of the physics imposter
  32313. */
  32314. getRadius(): number;
  32315. /**
  32316. * Sync a bone with this impostor
  32317. * @param bone The bone to sync to the impostor.
  32318. * @param boneMesh The mesh that the bone is influencing.
  32319. * @param jointPivot The pivot of the joint / bone in local space.
  32320. * @param distToJoint Optional distance from the impostor to the joint.
  32321. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32322. */
  32323. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32324. /**
  32325. * Sync impostor to a bone
  32326. * @param bone The bone that the impostor will be synced to.
  32327. * @param boneMesh The mesh that the bone is influencing.
  32328. * @param jointPivot The pivot of the joint / bone in local space.
  32329. * @param distToJoint Optional distance from the impostor to the joint.
  32330. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32331. * @param boneAxis Optional vector3 axis the bone is aligned with
  32332. */
  32333. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32334. /**
  32335. * No-Imposter type
  32336. */
  32337. static NoImpostor: number;
  32338. /**
  32339. * Sphere-Imposter type
  32340. */
  32341. static SphereImpostor: number;
  32342. /**
  32343. * Box-Imposter type
  32344. */
  32345. static BoxImpostor: number;
  32346. /**
  32347. * Plane-Imposter type
  32348. */
  32349. static PlaneImpostor: number;
  32350. /**
  32351. * Mesh-imposter type
  32352. */
  32353. static MeshImpostor: number;
  32354. /**
  32355. * Capsule-Impostor type (Ammo.js plugin only)
  32356. */
  32357. static CapsuleImpostor: number;
  32358. /**
  32359. * Cylinder-Imposter type
  32360. */
  32361. static CylinderImpostor: number;
  32362. /**
  32363. * Particle-Imposter type
  32364. */
  32365. static ParticleImpostor: number;
  32366. /**
  32367. * Heightmap-Imposter type
  32368. */
  32369. static HeightmapImpostor: number;
  32370. /**
  32371. * ConvexHull-Impostor type (Ammo.js plugin only)
  32372. */
  32373. static ConvexHullImpostor: number;
  32374. /**
  32375. * Custom-Imposter type (Ammo.js plugin only)
  32376. */
  32377. static CustomImpostor: number;
  32378. /**
  32379. * Rope-Imposter type
  32380. */
  32381. static RopeImpostor: number;
  32382. /**
  32383. * Cloth-Imposter type
  32384. */
  32385. static ClothImpostor: number;
  32386. /**
  32387. * Softbody-Imposter type
  32388. */
  32389. static SoftbodyImpostor: number;
  32390. }
  32391. }
  32392. declare module BABYLON {
  32393. /**
  32394. * @hidden
  32395. **/
  32396. export class _CreationDataStorage {
  32397. closePath?: boolean;
  32398. closeArray?: boolean;
  32399. idx: number[];
  32400. dashSize: number;
  32401. gapSize: number;
  32402. path3D: Path3D;
  32403. pathArray: Vector3[][];
  32404. arc: number;
  32405. radius: number;
  32406. cap: number;
  32407. tessellation: number;
  32408. }
  32409. /**
  32410. * @hidden
  32411. **/
  32412. class _InstanceDataStorage {
  32413. visibleInstances: any;
  32414. batchCache: _InstancesBatch;
  32415. instancesBufferSize: number;
  32416. instancesBuffer: Nullable<Buffer>;
  32417. instancesData: Float32Array;
  32418. overridenInstanceCount: number;
  32419. isFrozen: boolean;
  32420. previousBatch: Nullable<_InstancesBatch>;
  32421. hardwareInstancedRendering: boolean;
  32422. sideOrientation: number;
  32423. manualUpdate: boolean;
  32424. previousRenderId: number;
  32425. }
  32426. /**
  32427. * @hidden
  32428. **/
  32429. export class _InstancesBatch {
  32430. mustReturn: boolean;
  32431. visibleInstances: Nullable<InstancedMesh[]>[];
  32432. renderSelf: boolean[];
  32433. hardwareInstancedRendering: boolean[];
  32434. }
  32435. /**
  32436. * @hidden
  32437. **/
  32438. class _ThinInstanceDataStorage {
  32439. instancesCount: number;
  32440. matrixBuffer: Nullable<Buffer>;
  32441. matrixBufferSize: number;
  32442. matrixData: Nullable<Float32Array>;
  32443. boundingVectors: Array<Vector3>;
  32444. worldMatrices: Nullable<Matrix[]>;
  32445. }
  32446. /**
  32447. * Class used to represent renderable models
  32448. */
  32449. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32450. /**
  32451. * Mesh side orientation : usually the external or front surface
  32452. */
  32453. static readonly FRONTSIDE: number;
  32454. /**
  32455. * Mesh side orientation : usually the internal or back surface
  32456. */
  32457. static readonly BACKSIDE: number;
  32458. /**
  32459. * Mesh side orientation : both internal and external or front and back surfaces
  32460. */
  32461. static readonly DOUBLESIDE: number;
  32462. /**
  32463. * Mesh side orientation : by default, `FRONTSIDE`
  32464. */
  32465. static readonly DEFAULTSIDE: number;
  32466. /**
  32467. * Mesh cap setting : no cap
  32468. */
  32469. static readonly NO_CAP: number;
  32470. /**
  32471. * Mesh cap setting : one cap at the beginning of the mesh
  32472. */
  32473. static readonly CAP_START: number;
  32474. /**
  32475. * Mesh cap setting : one cap at the end of the mesh
  32476. */
  32477. static readonly CAP_END: number;
  32478. /**
  32479. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32480. */
  32481. static readonly CAP_ALL: number;
  32482. /**
  32483. * Mesh pattern setting : no flip or rotate
  32484. */
  32485. static readonly NO_FLIP: number;
  32486. /**
  32487. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32488. */
  32489. static readonly FLIP_TILE: number;
  32490. /**
  32491. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32492. */
  32493. static readonly ROTATE_TILE: number;
  32494. /**
  32495. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32496. */
  32497. static readonly FLIP_ROW: number;
  32498. /**
  32499. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32500. */
  32501. static readonly ROTATE_ROW: number;
  32502. /**
  32503. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32504. */
  32505. static readonly FLIP_N_ROTATE_TILE: number;
  32506. /**
  32507. * Mesh pattern setting : rotate pattern and rotate
  32508. */
  32509. static readonly FLIP_N_ROTATE_ROW: number;
  32510. /**
  32511. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32512. */
  32513. static readonly CENTER: number;
  32514. /**
  32515. * Mesh tile positioning : part tiles on left
  32516. */
  32517. static readonly LEFT: number;
  32518. /**
  32519. * Mesh tile positioning : part tiles on right
  32520. */
  32521. static readonly RIGHT: number;
  32522. /**
  32523. * Mesh tile positioning : part tiles on top
  32524. */
  32525. static readonly TOP: number;
  32526. /**
  32527. * Mesh tile positioning : part tiles on bottom
  32528. */
  32529. static readonly BOTTOM: number;
  32530. /**
  32531. * Gets the default side orientation.
  32532. * @param orientation the orientation to value to attempt to get
  32533. * @returns the default orientation
  32534. * @hidden
  32535. */
  32536. static _GetDefaultSideOrientation(orientation?: number): number;
  32537. private _internalMeshDataInfo;
  32538. get computeBonesUsingShaders(): boolean;
  32539. set computeBonesUsingShaders(value: boolean);
  32540. /**
  32541. * An event triggered before rendering the mesh
  32542. */
  32543. get onBeforeRenderObservable(): Observable<Mesh>;
  32544. /**
  32545. * An event triggered before binding the mesh
  32546. */
  32547. get onBeforeBindObservable(): Observable<Mesh>;
  32548. /**
  32549. * An event triggered after rendering the mesh
  32550. */
  32551. get onAfterRenderObservable(): Observable<Mesh>;
  32552. /**
  32553. * An event triggered before drawing the mesh
  32554. */
  32555. get onBeforeDrawObservable(): Observable<Mesh>;
  32556. private _onBeforeDrawObserver;
  32557. /**
  32558. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32559. */
  32560. set onBeforeDraw(callback: () => void);
  32561. get hasInstances(): boolean;
  32562. get hasThinInstances(): boolean;
  32563. /**
  32564. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32565. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32566. */
  32567. delayLoadState: number;
  32568. /**
  32569. * Gets the list of instances created from this mesh
  32570. * it is not supposed to be modified manually.
  32571. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32572. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32573. */
  32574. instances: InstancedMesh[];
  32575. /**
  32576. * Gets the file containing delay loading data for this mesh
  32577. */
  32578. delayLoadingFile: string;
  32579. /** @hidden */
  32580. _binaryInfo: any;
  32581. /**
  32582. * User defined function used to change how LOD level selection is done
  32583. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32584. */
  32585. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32586. /**
  32587. * Gets or sets the morph target manager
  32588. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32589. */
  32590. get morphTargetManager(): Nullable<MorphTargetManager>;
  32591. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32592. /** @hidden */
  32593. _creationDataStorage: Nullable<_CreationDataStorage>;
  32594. /** @hidden */
  32595. _geometry: Nullable<Geometry>;
  32596. /** @hidden */
  32597. _delayInfo: Array<string>;
  32598. /** @hidden */
  32599. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32600. /** @hidden */
  32601. _instanceDataStorage: _InstanceDataStorage;
  32602. /** @hidden */
  32603. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32604. private _effectiveMaterial;
  32605. /** @hidden */
  32606. _shouldGenerateFlatShading: boolean;
  32607. /** @hidden */
  32608. _originalBuilderSideOrientation: number;
  32609. /**
  32610. * Use this property to change the original side orientation defined at construction time
  32611. */
  32612. overrideMaterialSideOrientation: Nullable<number>;
  32613. /**
  32614. * Gets the source mesh (the one used to clone this one from)
  32615. */
  32616. get source(): Nullable<Mesh>;
  32617. /**
  32618. * Gets the list of clones of this mesh
  32619. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32620. * Note that useClonedMeshMap=true is the default setting
  32621. */
  32622. get cloneMeshMap(): Nullable<{
  32623. [id: string]: Mesh | undefined;
  32624. }>;
  32625. /**
  32626. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32627. */
  32628. get isUnIndexed(): boolean;
  32629. set isUnIndexed(value: boolean);
  32630. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32631. get worldMatrixInstancedBuffer(): Float32Array;
  32632. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32633. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32634. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32635. /**
  32636. * @constructor
  32637. * @param name The value used by scene.getMeshByName() to do a lookup.
  32638. * @param scene The scene to add this mesh to.
  32639. * @param parent The parent of this mesh, if it has one
  32640. * @param source An optional Mesh from which geometry is shared, cloned.
  32641. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32642. * When false, achieved by calling a clone(), also passing False.
  32643. * This will make creation of children, recursive.
  32644. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32645. */
  32646. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32647. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32648. doNotInstantiate: boolean;
  32649. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32650. /**
  32651. * Gets the class name
  32652. * @returns the string "Mesh".
  32653. */
  32654. getClassName(): string;
  32655. /** @hidden */
  32656. get _isMesh(): boolean;
  32657. /**
  32658. * Returns a description of this mesh
  32659. * @param fullDetails define if full details about this mesh must be used
  32660. * @returns a descriptive string representing this mesh
  32661. */
  32662. toString(fullDetails?: boolean): string;
  32663. /** @hidden */
  32664. _unBindEffect(): void;
  32665. /**
  32666. * Gets a boolean indicating if this mesh has LOD
  32667. */
  32668. get hasLODLevels(): boolean;
  32669. /**
  32670. * Gets the list of MeshLODLevel associated with the current mesh
  32671. * @returns an array of MeshLODLevel
  32672. */
  32673. getLODLevels(): MeshLODLevel[];
  32674. private _sortLODLevels;
  32675. /**
  32676. * Add a mesh as LOD level triggered at the given distance.
  32677. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32678. * @param distance The distance from the center of the object to show this level
  32679. * @param mesh The mesh to be added as LOD level (can be null)
  32680. * @return This mesh (for chaining)
  32681. */
  32682. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32683. /**
  32684. * Returns the LOD level mesh at the passed distance or null if not found.
  32685. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32686. * @param distance The distance from the center of the object to show this level
  32687. * @returns a Mesh or `null`
  32688. */
  32689. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32690. /**
  32691. * Remove a mesh from the LOD array
  32692. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32693. * @param mesh defines the mesh to be removed
  32694. * @return This mesh (for chaining)
  32695. */
  32696. removeLODLevel(mesh: Mesh): Mesh;
  32697. /**
  32698. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32699. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32700. * @param camera defines the camera to use to compute distance
  32701. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32702. * @return This mesh (for chaining)
  32703. */
  32704. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32705. /**
  32706. * Gets the mesh internal Geometry object
  32707. */
  32708. get geometry(): Nullable<Geometry>;
  32709. /**
  32710. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32711. * @returns the total number of vertices
  32712. */
  32713. getTotalVertices(): number;
  32714. /**
  32715. * Returns the content of an associated vertex buffer
  32716. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32717. * - VertexBuffer.PositionKind
  32718. * - VertexBuffer.UVKind
  32719. * - VertexBuffer.UV2Kind
  32720. * - VertexBuffer.UV3Kind
  32721. * - VertexBuffer.UV4Kind
  32722. * - VertexBuffer.UV5Kind
  32723. * - VertexBuffer.UV6Kind
  32724. * - VertexBuffer.ColorKind
  32725. * - VertexBuffer.MatricesIndicesKind
  32726. * - VertexBuffer.MatricesIndicesExtraKind
  32727. * - VertexBuffer.MatricesWeightsKind
  32728. * - VertexBuffer.MatricesWeightsExtraKind
  32729. * @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
  32730. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32731. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32732. */
  32733. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32734. /**
  32735. * Returns the mesh VertexBuffer object from the requested `kind`
  32736. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32737. * - VertexBuffer.PositionKind
  32738. * - VertexBuffer.NormalKind
  32739. * - VertexBuffer.UVKind
  32740. * - VertexBuffer.UV2Kind
  32741. * - VertexBuffer.UV3Kind
  32742. * - VertexBuffer.UV4Kind
  32743. * - VertexBuffer.UV5Kind
  32744. * - VertexBuffer.UV6Kind
  32745. * - VertexBuffer.ColorKind
  32746. * - VertexBuffer.MatricesIndicesKind
  32747. * - VertexBuffer.MatricesIndicesExtraKind
  32748. * - VertexBuffer.MatricesWeightsKind
  32749. * - VertexBuffer.MatricesWeightsExtraKind
  32750. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32751. */
  32752. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32753. /**
  32754. * Tests if a specific vertex buffer is associated with this mesh
  32755. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32756. * - VertexBuffer.PositionKind
  32757. * - VertexBuffer.NormalKind
  32758. * - VertexBuffer.UVKind
  32759. * - VertexBuffer.UV2Kind
  32760. * - VertexBuffer.UV3Kind
  32761. * - VertexBuffer.UV4Kind
  32762. * - VertexBuffer.UV5Kind
  32763. * - VertexBuffer.UV6Kind
  32764. * - VertexBuffer.ColorKind
  32765. * - VertexBuffer.MatricesIndicesKind
  32766. * - VertexBuffer.MatricesIndicesExtraKind
  32767. * - VertexBuffer.MatricesWeightsKind
  32768. * - VertexBuffer.MatricesWeightsExtraKind
  32769. * @returns a boolean
  32770. */
  32771. isVerticesDataPresent(kind: string): boolean;
  32772. /**
  32773. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32774. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32775. * - VertexBuffer.PositionKind
  32776. * - VertexBuffer.UVKind
  32777. * - VertexBuffer.UV2Kind
  32778. * - VertexBuffer.UV3Kind
  32779. * - VertexBuffer.UV4Kind
  32780. * - VertexBuffer.UV5Kind
  32781. * - VertexBuffer.UV6Kind
  32782. * - VertexBuffer.ColorKind
  32783. * - VertexBuffer.MatricesIndicesKind
  32784. * - VertexBuffer.MatricesIndicesExtraKind
  32785. * - VertexBuffer.MatricesWeightsKind
  32786. * - VertexBuffer.MatricesWeightsExtraKind
  32787. * @returns a boolean
  32788. */
  32789. isVertexBufferUpdatable(kind: string): boolean;
  32790. /**
  32791. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32792. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32793. * - VertexBuffer.PositionKind
  32794. * - VertexBuffer.NormalKind
  32795. * - VertexBuffer.UVKind
  32796. * - VertexBuffer.UV2Kind
  32797. * - VertexBuffer.UV3Kind
  32798. * - VertexBuffer.UV4Kind
  32799. * - VertexBuffer.UV5Kind
  32800. * - VertexBuffer.UV6Kind
  32801. * - VertexBuffer.ColorKind
  32802. * - VertexBuffer.MatricesIndicesKind
  32803. * - VertexBuffer.MatricesIndicesExtraKind
  32804. * - VertexBuffer.MatricesWeightsKind
  32805. * - VertexBuffer.MatricesWeightsExtraKind
  32806. * @returns an array of strings
  32807. */
  32808. getVerticesDataKinds(): string[];
  32809. /**
  32810. * Returns a positive integer : the total number of indices in this mesh geometry.
  32811. * @returns the numner of indices or zero if the mesh has no geometry.
  32812. */
  32813. getTotalIndices(): number;
  32814. /**
  32815. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32816. * @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.
  32817. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32818. * @returns the indices array or an empty array if the mesh has no geometry
  32819. */
  32820. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32821. get isBlocked(): boolean;
  32822. /**
  32823. * Determine if the current mesh is ready to be rendered
  32824. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32825. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32826. * @returns true if all associated assets are ready (material, textures, shaders)
  32827. */
  32828. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32829. /**
  32830. * 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.
  32831. */
  32832. get areNormalsFrozen(): boolean;
  32833. /**
  32834. * 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.
  32835. * @returns the current mesh
  32836. */
  32837. freezeNormals(): Mesh;
  32838. /**
  32839. * 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
  32840. * @returns the current mesh
  32841. */
  32842. unfreezeNormals(): Mesh;
  32843. /**
  32844. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32845. */
  32846. set overridenInstanceCount(count: number);
  32847. /** @hidden */
  32848. _preActivate(): Mesh;
  32849. /** @hidden */
  32850. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32851. /** @hidden */
  32852. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32853. protected _afterComputeWorldMatrix(): void;
  32854. /** @hidden */
  32855. _postActivate(): void;
  32856. /**
  32857. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32858. * This means the mesh underlying bounding box and sphere are recomputed.
  32859. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32860. * @returns the current mesh
  32861. */
  32862. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32863. /** @hidden */
  32864. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32865. /**
  32866. * This function will subdivide the mesh into multiple submeshes
  32867. * @param count defines the expected number of submeshes
  32868. */
  32869. subdivide(count: number): void;
  32870. /**
  32871. * Copy a FloatArray into a specific associated vertex buffer
  32872. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32873. * - VertexBuffer.PositionKind
  32874. * - VertexBuffer.UVKind
  32875. * - VertexBuffer.UV2Kind
  32876. * - VertexBuffer.UV3Kind
  32877. * - VertexBuffer.UV4Kind
  32878. * - VertexBuffer.UV5Kind
  32879. * - VertexBuffer.UV6Kind
  32880. * - VertexBuffer.ColorKind
  32881. * - VertexBuffer.MatricesIndicesKind
  32882. * - VertexBuffer.MatricesIndicesExtraKind
  32883. * - VertexBuffer.MatricesWeightsKind
  32884. * - VertexBuffer.MatricesWeightsExtraKind
  32885. * @param data defines the data source
  32886. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32887. * @param stride defines the data stride size (can be null)
  32888. * @returns the current mesh
  32889. */
  32890. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32891. /**
  32892. * Delete a vertex buffer associated with this mesh
  32893. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32894. * - VertexBuffer.PositionKind
  32895. * - VertexBuffer.UVKind
  32896. * - VertexBuffer.UV2Kind
  32897. * - VertexBuffer.UV3Kind
  32898. * - VertexBuffer.UV4Kind
  32899. * - VertexBuffer.UV5Kind
  32900. * - VertexBuffer.UV6Kind
  32901. * - VertexBuffer.ColorKind
  32902. * - VertexBuffer.MatricesIndicesKind
  32903. * - VertexBuffer.MatricesIndicesExtraKind
  32904. * - VertexBuffer.MatricesWeightsKind
  32905. * - VertexBuffer.MatricesWeightsExtraKind
  32906. */
  32907. removeVerticesData(kind: string): void;
  32908. /**
  32909. * Flags an associated vertex buffer as updatable
  32910. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32911. * - VertexBuffer.PositionKind
  32912. * - VertexBuffer.UVKind
  32913. * - VertexBuffer.UV2Kind
  32914. * - VertexBuffer.UV3Kind
  32915. * - VertexBuffer.UV4Kind
  32916. * - VertexBuffer.UV5Kind
  32917. * - VertexBuffer.UV6Kind
  32918. * - VertexBuffer.ColorKind
  32919. * - VertexBuffer.MatricesIndicesKind
  32920. * - VertexBuffer.MatricesIndicesExtraKind
  32921. * - VertexBuffer.MatricesWeightsKind
  32922. * - VertexBuffer.MatricesWeightsExtraKind
  32923. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32924. */
  32925. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32926. /**
  32927. * Sets the mesh global Vertex Buffer
  32928. * @param buffer defines the buffer to use
  32929. * @returns the current mesh
  32930. */
  32931. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32932. /**
  32933. * Update a specific associated vertex buffer
  32934. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32935. * - VertexBuffer.PositionKind
  32936. * - VertexBuffer.UVKind
  32937. * - VertexBuffer.UV2Kind
  32938. * - VertexBuffer.UV3Kind
  32939. * - VertexBuffer.UV4Kind
  32940. * - VertexBuffer.UV5Kind
  32941. * - VertexBuffer.UV6Kind
  32942. * - VertexBuffer.ColorKind
  32943. * - VertexBuffer.MatricesIndicesKind
  32944. * - VertexBuffer.MatricesIndicesExtraKind
  32945. * - VertexBuffer.MatricesWeightsKind
  32946. * - VertexBuffer.MatricesWeightsExtraKind
  32947. * @param data defines the data source
  32948. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32949. * @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)
  32950. * @returns the current mesh
  32951. */
  32952. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32953. /**
  32954. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32955. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32956. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32957. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32958. * @returns the current mesh
  32959. */
  32960. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32961. /**
  32962. * Creates a un-shared specific occurence of the geometry for the mesh.
  32963. * @returns the current mesh
  32964. */
  32965. makeGeometryUnique(): Mesh;
  32966. /**
  32967. * Set the index buffer of this mesh
  32968. * @param indices defines the source data
  32969. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32970. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32971. * @returns the current mesh
  32972. */
  32973. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32974. /**
  32975. * Update the current index buffer
  32976. * @param indices defines the source data
  32977. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32978. * @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)
  32979. * @returns the current mesh
  32980. */
  32981. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32982. /**
  32983. * Invert the geometry to move from a right handed system to a left handed one.
  32984. * @returns the current mesh
  32985. */
  32986. toLeftHanded(): Mesh;
  32987. /** @hidden */
  32988. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32989. /** @hidden */
  32990. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32991. /**
  32992. * Registers for this mesh a javascript function called just before the rendering process
  32993. * @param func defines the function to call before rendering this mesh
  32994. * @returns the current mesh
  32995. */
  32996. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32997. /**
  32998. * Disposes a previously registered javascript function called before the rendering
  32999. * @param func defines the function to remove
  33000. * @returns the current mesh
  33001. */
  33002. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33003. /**
  33004. * Registers for this mesh a javascript function called just after the rendering is complete
  33005. * @param func defines the function to call after rendering this mesh
  33006. * @returns the current mesh
  33007. */
  33008. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33009. /**
  33010. * Disposes a previously registered javascript function called after the rendering.
  33011. * @param func defines the function to remove
  33012. * @returns the current mesh
  33013. */
  33014. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33015. /** @hidden */
  33016. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33017. /** @hidden */
  33018. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33019. /** @hidden */
  33020. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33021. /** @hidden */
  33022. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33023. /** @hidden */
  33024. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33025. /** @hidden */
  33026. _rebuild(): void;
  33027. /** @hidden */
  33028. _freeze(): void;
  33029. /** @hidden */
  33030. _unFreeze(): void;
  33031. /**
  33032. * 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
  33033. * @param subMesh defines the subMesh to render
  33034. * @param enableAlphaMode defines if alpha mode can be changed
  33035. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33036. * @returns the current mesh
  33037. */
  33038. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33039. private _onBeforeDraw;
  33040. /**
  33041. * Renormalize the mesh and patch it up if there are no weights
  33042. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33043. * However in the case of zero weights then we set just a single influence to 1.
  33044. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33045. */
  33046. cleanMatrixWeights(): void;
  33047. private normalizeSkinFourWeights;
  33048. private normalizeSkinWeightsAndExtra;
  33049. /**
  33050. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33051. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33052. * the user know there was an issue with importing the mesh
  33053. * @returns a validation object with skinned, valid and report string
  33054. */
  33055. validateSkinning(): {
  33056. skinned: boolean;
  33057. valid: boolean;
  33058. report: string;
  33059. };
  33060. /** @hidden */
  33061. _checkDelayState(): Mesh;
  33062. private _queueLoad;
  33063. /**
  33064. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33065. * A mesh is in the frustum if its bounding box intersects the frustum
  33066. * @param frustumPlanes defines the frustum to test
  33067. * @returns true if the mesh is in the frustum planes
  33068. */
  33069. isInFrustum(frustumPlanes: Plane[]): boolean;
  33070. /**
  33071. * Sets the mesh material by the material or multiMaterial `id` property
  33072. * @param id is a string identifying the material or the multiMaterial
  33073. * @returns the current mesh
  33074. */
  33075. setMaterialByID(id: string): Mesh;
  33076. /**
  33077. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33078. * @returns an array of IAnimatable
  33079. */
  33080. getAnimatables(): IAnimatable[];
  33081. /**
  33082. * Modifies the mesh geometry according to the passed transformation matrix.
  33083. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33084. * The mesh normals are modified using the same transformation.
  33085. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33086. * @param transform defines the transform matrix to use
  33087. * @see https://doc.babylonjs.com/resources/baking_transformations
  33088. * @returns the current mesh
  33089. */
  33090. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33091. /**
  33092. * Modifies the mesh geometry according to its own current World Matrix.
  33093. * The mesh World Matrix is then reset.
  33094. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33095. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33096. * @see https://doc.babylonjs.com/resources/baking_transformations
  33097. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33098. * @returns the current mesh
  33099. */
  33100. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33101. /** @hidden */
  33102. get _positions(): Nullable<Vector3[]>;
  33103. /** @hidden */
  33104. _resetPointsArrayCache(): Mesh;
  33105. /** @hidden */
  33106. _generatePointsArray(): boolean;
  33107. /**
  33108. * Returns a new Mesh object generated from the current mesh properties.
  33109. * This method must not get confused with createInstance()
  33110. * @param name is a string, the name given to the new mesh
  33111. * @param newParent can be any Node object (default `null`)
  33112. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33113. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33114. * @returns a new mesh
  33115. */
  33116. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33117. /**
  33118. * Releases resources associated with this mesh.
  33119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33121. */
  33122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33123. /** @hidden */
  33124. _disposeInstanceSpecificData(): void;
  33125. /** @hidden */
  33126. _disposeThinInstanceSpecificData(): void;
  33127. /**
  33128. * Modifies the mesh geometry according to a displacement map.
  33129. * 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.
  33130. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33131. * @param url is a string, the URL from the image file is to be downloaded.
  33132. * @param minHeight is the lower limit of the displacement.
  33133. * @param maxHeight is the upper limit of the displacement.
  33134. * @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.
  33135. * @param uvOffset is an optional vector2 used to offset UV.
  33136. * @param uvScale is an optional vector2 used to scale UV.
  33137. * @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.
  33138. * @returns the Mesh.
  33139. */
  33140. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33141. /**
  33142. * Modifies the mesh geometry according to a displacementMap buffer.
  33143. * 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.
  33144. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33145. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33146. * @param heightMapWidth is the width of the buffer image.
  33147. * @param heightMapHeight is the height of the buffer image.
  33148. * @param minHeight is the lower limit of the displacement.
  33149. * @param maxHeight is the upper limit of the displacement.
  33150. * @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.
  33151. * @param uvOffset is an optional vector2 used to offset UV.
  33152. * @param uvScale is an optional vector2 used to scale UV.
  33153. * @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.
  33154. * @returns the Mesh.
  33155. */
  33156. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33157. /**
  33158. * Modify the mesh to get a flat shading rendering.
  33159. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33160. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33161. * @returns current mesh
  33162. */
  33163. convertToFlatShadedMesh(): Mesh;
  33164. /**
  33165. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33166. * In other words, more vertices, no more indices and a single bigger VBO.
  33167. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33168. * @returns current mesh
  33169. */
  33170. convertToUnIndexedMesh(): Mesh;
  33171. /**
  33172. * Inverses facet orientations.
  33173. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33174. * @param flipNormals will also inverts the normals
  33175. * @returns current mesh
  33176. */
  33177. flipFaces(flipNormals?: boolean): Mesh;
  33178. /**
  33179. * Increase the number of facets and hence vertices in a mesh
  33180. * Vertex normals are interpolated from existing vertex normals
  33181. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33182. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33183. */
  33184. increaseVertices(numberPerEdge: number): void;
  33185. /**
  33186. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33187. * This will undo any application of covertToFlatShadedMesh
  33188. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33189. */
  33190. forceSharedVertices(): void;
  33191. /** @hidden */
  33192. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33193. /** @hidden */
  33194. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33195. /**
  33196. * Creates a new InstancedMesh object from the mesh model.
  33197. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33198. * @param name defines the name of the new instance
  33199. * @returns a new InstancedMesh
  33200. */
  33201. createInstance(name: string): InstancedMesh;
  33202. /**
  33203. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33204. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33205. * @returns the current mesh
  33206. */
  33207. synchronizeInstances(): Mesh;
  33208. /**
  33209. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33210. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33211. * This should be used together with the simplification to avoid disappearing triangles.
  33212. * @param successCallback an optional success callback to be called after the optimization finished.
  33213. * @returns the current mesh
  33214. */
  33215. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33216. /**
  33217. * Serialize current mesh
  33218. * @param serializationObject defines the object which will receive the serialization data
  33219. */
  33220. serialize(serializationObject: any): void;
  33221. /** @hidden */
  33222. _syncGeometryWithMorphTargetManager(): void;
  33223. /** @hidden */
  33224. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33225. /**
  33226. * Returns a new Mesh object parsed from the source provided.
  33227. * @param parsedMesh is the source
  33228. * @param scene defines the hosting scene
  33229. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33230. * @returns a new Mesh
  33231. */
  33232. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33233. /**
  33234. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33236. * @param name defines the name of the mesh to create
  33237. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33238. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33239. * @param closePath creates a seam between the first and the last points of each path of the path array
  33240. * @param offset is taken in account only if the `pathArray` is containing a single path
  33241. * @param scene defines the hosting scene
  33242. * @param updatable defines if the mesh must be flagged as updatable
  33243. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33244. * @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)
  33245. * @returns a new Mesh
  33246. */
  33247. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33248. /**
  33249. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33250. * @param name defines the name of the mesh to create
  33251. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33252. * @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
  33253. * @param scene defines the hosting scene
  33254. * @param updatable defines if the mesh must be flagged as updatable
  33255. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33256. * @returns a new Mesh
  33257. */
  33258. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33259. /**
  33260. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33261. * @param name defines the name of the mesh to create
  33262. * @param size sets the size (float) of each box side (default 1)
  33263. * @param scene defines the hosting scene
  33264. * @param updatable defines if the mesh must be flagged as updatable
  33265. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33266. * @returns a new Mesh
  33267. */
  33268. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33269. /**
  33270. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33271. * @param name defines the name of the mesh to create
  33272. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33273. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33274. * @param scene defines the hosting scene
  33275. * @param updatable defines if the mesh must be flagged as updatable
  33276. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33277. * @returns a new Mesh
  33278. */
  33279. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33280. /**
  33281. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33282. * @param name defines the name of the mesh to create
  33283. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33284. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33285. * @param scene defines the hosting scene
  33286. * @returns a new Mesh
  33287. */
  33288. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33289. /**
  33290. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33291. * @param name defines the name of the mesh to create
  33292. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33293. * @param diameterTop set the top cap diameter (floats, default 1)
  33294. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33295. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33296. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33297. * @param scene defines the hosting scene
  33298. * @param updatable defines if the mesh must be flagged as updatable
  33299. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33300. * @returns a new Mesh
  33301. */
  33302. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33303. /**
  33304. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33305. * @param name defines the name of the mesh to create
  33306. * @param diameter sets the diameter size (float) of the torus (default 1)
  33307. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33308. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33309. * @param scene defines the hosting scene
  33310. * @param updatable defines if the mesh must be flagged as updatable
  33311. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33312. * @returns a new Mesh
  33313. */
  33314. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33315. /**
  33316. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33317. * @param name defines the name of the mesh to create
  33318. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33319. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33320. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33321. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33322. * @param p the number of windings on X axis (positive integers, default 2)
  33323. * @param q the number of windings on Y axis (positive integers, default 3)
  33324. * @param scene defines the hosting scene
  33325. * @param updatable defines if the mesh must be flagged as updatable
  33326. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33327. * @returns a new Mesh
  33328. */
  33329. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33330. /**
  33331. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33332. * @param name defines the name of the mesh to create
  33333. * @param points is an array successive Vector3
  33334. * @param scene defines the hosting scene
  33335. * @param updatable defines if the mesh must be flagged as updatable
  33336. * @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).
  33337. * @returns a new Mesh
  33338. */
  33339. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33340. /**
  33341. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33342. * @param name defines the name of the mesh to create
  33343. * @param points is an array successive Vector3
  33344. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33345. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33346. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33347. * @param scene defines the hosting scene
  33348. * @param updatable defines if the mesh must be flagged as updatable
  33349. * @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)
  33350. * @returns a new Mesh
  33351. */
  33352. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33353. /**
  33354. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33355. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33356. * 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.
  33357. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33358. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33359. * Remember you can only change the shape positions, not their number when updating a polygon.
  33360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33361. * @param name defines the name of the mesh to create
  33362. * @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
  33363. * @param scene defines the hosting scene
  33364. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33365. * @param updatable defines if the mesh must be flagged as updatable
  33366. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33367. * @param earcutInjection can be used to inject your own earcut reference
  33368. * @returns a new Mesh
  33369. */
  33370. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33371. /**
  33372. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33374. * @param name defines the name of the mesh to create
  33375. * @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
  33376. * @param depth defines the height of extrusion
  33377. * @param scene defines the hosting scene
  33378. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33379. * @param updatable defines if the mesh must be flagged as updatable
  33380. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33381. * @param earcutInjection can be used to inject your own earcut reference
  33382. * @returns a new Mesh
  33383. */
  33384. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33385. /**
  33386. * Creates an extruded shape mesh.
  33387. * 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
  33388. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33390. * @param name defines the name of the mesh to create
  33391. * @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
  33392. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33393. * @param scale is the value to scale the shape
  33394. * @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
  33395. * @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
  33396. * @param scene defines the hosting scene
  33397. * @param updatable defines if the mesh must be flagged as updatable
  33398. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33399. * @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)
  33400. * @returns a new Mesh
  33401. */
  33402. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33403. /**
  33404. * Creates an custom extruded shape mesh.
  33405. * The custom extrusion is a parametric shape.
  33406. * It has no predefined shape. Its final shape will depend on the input parameters.
  33407. * Please consider using the same method from the MeshBuilder class instead
  33408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33409. * @param name defines the name of the mesh to create
  33410. * @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
  33411. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33412. * @param scaleFunction is a custom Javascript function called on each path point
  33413. * @param rotationFunction is a custom Javascript function called on each path point
  33414. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33415. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33416. * @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
  33417. * @param scene defines the hosting scene
  33418. * @param updatable defines if the mesh must be flagged as updatable
  33419. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33420. * @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)
  33421. * @returns a new Mesh
  33422. */
  33423. 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;
  33424. /**
  33425. * Creates lathe mesh.
  33426. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33427. * Please consider using the same method from the MeshBuilder class instead
  33428. * @param name defines the name of the mesh to create
  33429. * @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
  33430. * @param radius is the radius value of the lathe
  33431. * @param tessellation is the side number of the lathe.
  33432. * @param scene defines the hosting scene
  33433. * @param updatable defines if the mesh must be flagged as updatable
  33434. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33435. * @returns a new Mesh
  33436. */
  33437. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33438. /**
  33439. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33440. * @param name defines the name of the mesh to create
  33441. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33442. * @param scene defines the hosting scene
  33443. * @param updatable defines if the mesh must be flagged as updatable
  33444. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33445. * @returns a new Mesh
  33446. */
  33447. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33448. /**
  33449. * Creates a ground mesh.
  33450. * Please consider using the same method from the MeshBuilder class instead
  33451. * @param name defines the name of the mesh to create
  33452. * @param width set the width of the ground
  33453. * @param height set the height of the ground
  33454. * @param subdivisions sets the number of subdivisions per side
  33455. * @param scene defines the hosting scene
  33456. * @param updatable defines if the mesh must be flagged as updatable
  33457. * @returns a new Mesh
  33458. */
  33459. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33460. /**
  33461. * Creates a tiled ground mesh.
  33462. * Please consider using the same method from the MeshBuilder class instead
  33463. * @param name defines the name of the mesh to create
  33464. * @param xmin set the ground minimum X coordinate
  33465. * @param zmin set the ground minimum Y coordinate
  33466. * @param xmax set the ground maximum X coordinate
  33467. * @param zmax set the ground maximum Z coordinate
  33468. * @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
  33469. * @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
  33470. * @param scene defines the hosting scene
  33471. * @param updatable defines if the mesh must be flagged as updatable
  33472. * @returns a new Mesh
  33473. */
  33474. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33475. w: number;
  33476. h: number;
  33477. }, precision: {
  33478. w: number;
  33479. h: number;
  33480. }, scene: Scene, updatable?: boolean): Mesh;
  33481. /**
  33482. * Creates a ground mesh from a height map.
  33483. * Please consider using the same method from the MeshBuilder class instead
  33484. * @see https://doc.babylonjs.com/babylon101/height_map
  33485. * @param name defines the name of the mesh to create
  33486. * @param url sets the URL of the height map image resource
  33487. * @param width set the ground width size
  33488. * @param height set the ground height size
  33489. * @param subdivisions sets the number of subdivision per side
  33490. * @param minHeight is the minimum altitude on the ground
  33491. * @param maxHeight is the maximum altitude on the ground
  33492. * @param scene defines the hosting scene
  33493. * @param updatable defines if the mesh must be flagged as updatable
  33494. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33495. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33496. * @returns a new Mesh
  33497. */
  33498. 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;
  33499. /**
  33500. * Creates a tube mesh.
  33501. * The tube is a parametric shape.
  33502. * It has no predefined shape. Its final shape will depend on the input parameters.
  33503. * Please consider using the same method from the MeshBuilder class instead
  33504. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33505. * @param name defines the name of the mesh to create
  33506. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33507. * @param radius sets the tube radius size
  33508. * @param tessellation is the number of sides on the tubular surface
  33509. * @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
  33510. * @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
  33511. * @param scene defines the hosting scene
  33512. * @param updatable defines if the mesh must be flagged as updatable
  33513. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33514. * @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)
  33515. * @returns a new Mesh
  33516. */
  33517. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33518. (i: number, distance: number): number;
  33519. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33520. /**
  33521. * Creates a polyhedron mesh.
  33522. * Please consider using the same method from the MeshBuilder class instead.
  33523. * * 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
  33524. * * The parameter `size` (positive float, default 1) sets the polygon size
  33525. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33526. * * 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`
  33527. * * 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
  33528. * * 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)`)
  33529. * * 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
  33530. * * 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
  33531. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33532. * * 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
  33533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33534. * @param name defines the name of the mesh to create
  33535. * @param options defines the options used to create the mesh
  33536. * @param scene defines the hosting scene
  33537. * @returns a new Mesh
  33538. */
  33539. static CreatePolyhedron(name: string, options: {
  33540. type?: number;
  33541. size?: number;
  33542. sizeX?: number;
  33543. sizeY?: number;
  33544. sizeZ?: number;
  33545. custom?: any;
  33546. faceUV?: Vector4[];
  33547. faceColors?: Color4[];
  33548. updatable?: boolean;
  33549. sideOrientation?: number;
  33550. }, scene: Scene): Mesh;
  33551. /**
  33552. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33553. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33554. * * 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`)
  33555. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33556. * * 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
  33557. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33558. * * 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
  33559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33560. * @param name defines the name of the mesh
  33561. * @param options defines the options used to create the mesh
  33562. * @param scene defines the hosting scene
  33563. * @returns a new Mesh
  33564. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33565. */
  33566. static CreateIcoSphere(name: string, options: {
  33567. radius?: number;
  33568. flat?: boolean;
  33569. subdivisions?: number;
  33570. sideOrientation?: number;
  33571. updatable?: boolean;
  33572. }, scene: Scene): Mesh;
  33573. /**
  33574. * Creates a decal mesh.
  33575. * Please consider using the same method from the MeshBuilder class instead.
  33576. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33577. * @param name defines the name of the mesh
  33578. * @param sourceMesh defines the mesh receiving the decal
  33579. * @param position sets the position of the decal in world coordinates
  33580. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33581. * @param size sets the decal scaling
  33582. * @param angle sets the angle to rotate the decal
  33583. * @returns a new Mesh
  33584. */
  33585. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33586. /** Creates a Capsule Mesh
  33587. * @param name defines the name of the mesh.
  33588. * @param options the constructors options used to shape the mesh.
  33589. * @param scene defines the scene the mesh is scoped to.
  33590. * @returns the capsule mesh
  33591. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33592. */
  33593. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33594. /**
  33595. * Prepare internal position array for software CPU skinning
  33596. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33597. */
  33598. setPositionsForCPUSkinning(): Float32Array;
  33599. /**
  33600. * Prepare internal normal array for software CPU skinning
  33601. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33602. */
  33603. setNormalsForCPUSkinning(): Float32Array;
  33604. /**
  33605. * Updates the vertex buffer by applying transformation from the bones
  33606. * @param skeleton defines the skeleton to apply to current mesh
  33607. * @returns the current mesh
  33608. */
  33609. applySkeleton(skeleton: Skeleton): Mesh;
  33610. /**
  33611. * 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
  33612. * @param meshes defines the list of meshes to scan
  33613. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33614. */
  33615. static MinMax(meshes: AbstractMesh[]): {
  33616. min: Vector3;
  33617. max: Vector3;
  33618. };
  33619. /**
  33620. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33621. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33622. * @returns a vector3
  33623. */
  33624. static Center(meshesOrMinMaxVector: {
  33625. min: Vector3;
  33626. max: Vector3;
  33627. } | AbstractMesh[]): Vector3;
  33628. /**
  33629. * Merge the array of meshes into a single mesh for performance reasons.
  33630. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33631. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33632. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33633. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33634. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33635. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33636. * @returns a new mesh
  33637. */
  33638. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33639. /** @hidden */
  33640. addInstance(instance: InstancedMesh): void;
  33641. /** @hidden */
  33642. removeInstance(instance: InstancedMesh): void;
  33643. }
  33644. }
  33645. declare module BABYLON {
  33646. /**
  33647. * This is the base class of all the camera used in the application.
  33648. * @see https://doc.babylonjs.com/features/cameras
  33649. */
  33650. export class Camera extends Node {
  33651. /** @hidden */
  33652. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33653. /**
  33654. * This is the default projection mode used by the cameras.
  33655. * It helps recreating a feeling of perspective and better appreciate depth.
  33656. * This is the best way to simulate real life cameras.
  33657. */
  33658. static readonly PERSPECTIVE_CAMERA: number;
  33659. /**
  33660. * This helps creating camera with an orthographic mode.
  33661. * 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.
  33662. */
  33663. static readonly ORTHOGRAPHIC_CAMERA: number;
  33664. /**
  33665. * This is the default FOV mode for perspective cameras.
  33666. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33667. */
  33668. static readonly FOVMODE_VERTICAL_FIXED: number;
  33669. /**
  33670. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33671. */
  33672. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33673. /**
  33674. * This specifies ther is no need for a camera rig.
  33675. * Basically only one eye is rendered corresponding to the camera.
  33676. */
  33677. static readonly RIG_MODE_NONE: number;
  33678. /**
  33679. * Simulates a camera Rig with one blue eye and one red eye.
  33680. * This can be use with 3d blue and red glasses.
  33681. */
  33682. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33683. /**
  33684. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33685. */
  33686. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33687. /**
  33688. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33689. */
  33690. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33691. /**
  33692. * Defines that both eyes of the camera will be rendered over under each other.
  33693. */
  33694. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33695. /**
  33696. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33697. */
  33698. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33699. /**
  33700. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33701. */
  33702. static readonly RIG_MODE_VR: number;
  33703. /**
  33704. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33705. */
  33706. static readonly RIG_MODE_WEBVR: number;
  33707. /**
  33708. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33709. */
  33710. static readonly RIG_MODE_CUSTOM: number;
  33711. /**
  33712. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33713. */
  33714. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33715. /**
  33716. * Define the input manager associated with the camera.
  33717. */
  33718. inputs: CameraInputsManager<Camera>;
  33719. /** @hidden */
  33720. _position: Vector3;
  33721. /**
  33722. * Define the current local position of the camera in the scene
  33723. */
  33724. get position(): Vector3;
  33725. set position(newPosition: Vector3);
  33726. protected _upVector: Vector3;
  33727. /**
  33728. * The vector the camera should consider as up.
  33729. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33730. */
  33731. set upVector(vec: Vector3);
  33732. get upVector(): Vector3;
  33733. /**
  33734. * Define the current limit on the left side for an orthographic camera
  33735. * In scene unit
  33736. */
  33737. orthoLeft: Nullable<number>;
  33738. /**
  33739. * Define the current limit on the right side for an orthographic camera
  33740. * In scene unit
  33741. */
  33742. orthoRight: Nullable<number>;
  33743. /**
  33744. * Define the current limit on the bottom side for an orthographic camera
  33745. * In scene unit
  33746. */
  33747. orthoBottom: Nullable<number>;
  33748. /**
  33749. * Define the current limit on the top side for an orthographic camera
  33750. * In scene unit
  33751. */
  33752. orthoTop: Nullable<number>;
  33753. /**
  33754. * Field Of View is set in Radians. (default is 0.8)
  33755. */
  33756. fov: number;
  33757. /**
  33758. * Define the minimum distance the camera can see from.
  33759. * This is important to note that the depth buffer are not infinite and the closer it starts
  33760. * the more your scene might encounter depth fighting issue.
  33761. */
  33762. minZ: number;
  33763. /**
  33764. * Define the maximum distance the camera can see to.
  33765. * This is important to note that the depth buffer are not infinite and the further it end
  33766. * the more your scene might encounter depth fighting issue.
  33767. */
  33768. maxZ: number;
  33769. /**
  33770. * Define the default inertia of the camera.
  33771. * This helps giving a smooth feeling to the camera movement.
  33772. */
  33773. inertia: number;
  33774. /**
  33775. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33776. */
  33777. mode: number;
  33778. /**
  33779. * Define whether the camera is intermediate.
  33780. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33781. */
  33782. isIntermediate: boolean;
  33783. /**
  33784. * Define the viewport of the camera.
  33785. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33786. */
  33787. viewport: Viewport;
  33788. /**
  33789. * Restricts the camera to viewing objects with the same layerMask.
  33790. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33791. */
  33792. layerMask: number;
  33793. /**
  33794. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33795. */
  33796. fovMode: number;
  33797. /**
  33798. * Rig mode of the camera.
  33799. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33800. * This is normally controlled byt the camera themselves as internal use.
  33801. */
  33802. cameraRigMode: number;
  33803. /**
  33804. * Defines the distance between both "eyes" in case of a RIG
  33805. */
  33806. interaxialDistance: number;
  33807. /**
  33808. * Defines if stereoscopic rendering is done side by side or over under.
  33809. */
  33810. isStereoscopicSideBySide: boolean;
  33811. /**
  33812. * 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
  33813. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33814. * else in the scene. (Eg. security camera)
  33815. *
  33816. * 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)
  33817. */
  33818. customRenderTargets: RenderTargetTexture[];
  33819. /**
  33820. * When set, the camera will render to this render target instead of the default canvas
  33821. *
  33822. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33823. */
  33824. outputRenderTarget: Nullable<RenderTargetTexture>;
  33825. /**
  33826. * Observable triggered when the camera view matrix has changed.
  33827. */
  33828. onViewMatrixChangedObservable: Observable<Camera>;
  33829. /**
  33830. * Observable triggered when the camera Projection matrix has changed.
  33831. */
  33832. onProjectionMatrixChangedObservable: Observable<Camera>;
  33833. /**
  33834. * Observable triggered when the inputs have been processed.
  33835. */
  33836. onAfterCheckInputsObservable: Observable<Camera>;
  33837. /**
  33838. * Observable triggered when reset has been called and applied to the camera.
  33839. */
  33840. onRestoreStateObservable: Observable<Camera>;
  33841. /**
  33842. * Is this camera a part of a rig system?
  33843. */
  33844. isRigCamera: boolean;
  33845. /**
  33846. * If isRigCamera set to true this will be set with the parent camera.
  33847. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33848. */
  33849. rigParent?: Camera;
  33850. /** @hidden */
  33851. _cameraRigParams: any;
  33852. /** @hidden */
  33853. _rigCameras: Camera[];
  33854. /** @hidden */
  33855. _rigPostProcess: Nullable<PostProcess>;
  33856. protected _webvrViewMatrix: Matrix;
  33857. /** @hidden */
  33858. _skipRendering: boolean;
  33859. /** @hidden */
  33860. _projectionMatrix: Matrix;
  33861. /** @hidden */
  33862. _postProcesses: Nullable<PostProcess>[];
  33863. /** @hidden */
  33864. _activeMeshes: SmartArray<AbstractMesh>;
  33865. protected _globalPosition: Vector3;
  33866. /** @hidden */
  33867. _computedViewMatrix: Matrix;
  33868. private _doNotComputeProjectionMatrix;
  33869. private _transformMatrix;
  33870. private _frustumPlanes;
  33871. private _refreshFrustumPlanes;
  33872. private _storedFov;
  33873. private _stateStored;
  33874. /**
  33875. * Instantiates a new camera object.
  33876. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33877. * @see https://doc.babylonjs.com/features/cameras
  33878. * @param name Defines the name of the camera in the scene
  33879. * @param position Defines the position of the camera
  33880. * @param scene Defines the scene the camera belongs too
  33881. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33882. */
  33883. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33884. /**
  33885. * Store current camera state (fov, position, etc..)
  33886. * @returns the camera
  33887. */
  33888. storeState(): Camera;
  33889. /**
  33890. * Restores the camera state values if it has been stored. You must call storeState() first
  33891. */
  33892. protected _restoreStateValues(): boolean;
  33893. /**
  33894. * Restored camera state. You must call storeState() first.
  33895. * @returns true if restored and false otherwise
  33896. */
  33897. restoreState(): boolean;
  33898. /**
  33899. * Gets the class name of the camera.
  33900. * @returns the class name
  33901. */
  33902. getClassName(): string;
  33903. /** @hidden */
  33904. readonly _isCamera: boolean;
  33905. /**
  33906. * Gets a string representation of the camera useful for debug purpose.
  33907. * @param fullDetails Defines that a more verboe level of logging is required
  33908. * @returns the string representation
  33909. */
  33910. toString(fullDetails?: boolean): string;
  33911. /**
  33912. * Gets the current world space position of the camera.
  33913. */
  33914. get globalPosition(): Vector3;
  33915. /**
  33916. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33917. * @returns the active meshe list
  33918. */
  33919. getActiveMeshes(): SmartArray<AbstractMesh>;
  33920. /**
  33921. * Check whether a mesh is part of the current active mesh list of the camera
  33922. * @param mesh Defines the mesh to check
  33923. * @returns true if active, false otherwise
  33924. */
  33925. isActiveMesh(mesh: Mesh): boolean;
  33926. /**
  33927. * Is this camera ready to be used/rendered
  33928. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33929. * @return true if the camera is ready
  33930. */
  33931. isReady(completeCheck?: boolean): boolean;
  33932. /** @hidden */
  33933. _initCache(): void;
  33934. /** @hidden */
  33935. _updateCache(ignoreParentClass?: boolean): void;
  33936. /** @hidden */
  33937. _isSynchronized(): boolean;
  33938. /** @hidden */
  33939. _isSynchronizedViewMatrix(): boolean;
  33940. /** @hidden */
  33941. _isSynchronizedProjectionMatrix(): boolean;
  33942. /**
  33943. * Attach the input controls to a specific dom element to get the input from.
  33944. * @param element Defines the element the controls should be listened from
  33945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33946. */
  33947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33948. /**
  33949. * Detach the current controls from the specified dom element.
  33950. * @param element Defines the element to stop listening the inputs from
  33951. */
  33952. detachControl(element: HTMLElement): void;
  33953. /**
  33954. * Update the camera state according to the different inputs gathered during the frame.
  33955. */
  33956. update(): void;
  33957. /** @hidden */
  33958. _checkInputs(): void;
  33959. /** @hidden */
  33960. get rigCameras(): Camera[];
  33961. /**
  33962. * Gets the post process used by the rig cameras
  33963. */
  33964. get rigPostProcess(): Nullable<PostProcess>;
  33965. /**
  33966. * Internal, gets the first post proces.
  33967. * @returns the first post process to be run on this camera.
  33968. */
  33969. _getFirstPostProcess(): Nullable<PostProcess>;
  33970. private _cascadePostProcessesToRigCams;
  33971. /**
  33972. * Attach a post process to the camera.
  33973. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33974. * @param postProcess The post process to attach to the camera
  33975. * @param insertAt The position of the post process in case several of them are in use in the scene
  33976. * @returns the position the post process has been inserted at
  33977. */
  33978. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33979. /**
  33980. * Detach a post process to the camera.
  33981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33982. * @param postProcess The post process to detach from the camera
  33983. */
  33984. detachPostProcess(postProcess: PostProcess): void;
  33985. /**
  33986. * Gets the current world matrix of the camera
  33987. */
  33988. getWorldMatrix(): Matrix;
  33989. /** @hidden */
  33990. _getViewMatrix(): Matrix;
  33991. /**
  33992. * Gets the current view matrix of the camera.
  33993. * @param force forces the camera to recompute the matrix without looking at the cached state
  33994. * @returns the view matrix
  33995. */
  33996. getViewMatrix(force?: boolean): Matrix;
  33997. /**
  33998. * Freeze the projection matrix.
  33999. * It will prevent the cache check of the camera projection compute and can speed up perf
  34000. * if no parameter of the camera are meant to change
  34001. * @param projection Defines manually a projection if necessary
  34002. */
  34003. freezeProjectionMatrix(projection?: Matrix): void;
  34004. /**
  34005. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34006. */
  34007. unfreezeProjectionMatrix(): void;
  34008. /**
  34009. * Gets the current projection matrix of the camera.
  34010. * @param force forces the camera to recompute the matrix without looking at the cached state
  34011. * @returns the projection matrix
  34012. */
  34013. getProjectionMatrix(force?: boolean): Matrix;
  34014. /**
  34015. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34016. * @returns a Matrix
  34017. */
  34018. getTransformationMatrix(): Matrix;
  34019. private _updateFrustumPlanes;
  34020. /**
  34021. * Checks if a cullable object (mesh...) is in the camera frustum
  34022. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34023. * @param target The object to check
  34024. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34025. * @returns true if the object is in frustum otherwise false
  34026. */
  34027. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34028. /**
  34029. * Checks if a cullable object (mesh...) is in the camera frustum
  34030. * Unlike isInFrustum this cheks the full bounding box
  34031. * @param target The object to check
  34032. * @returns true if the object is in frustum otherwise false
  34033. */
  34034. isCompletelyInFrustum(target: ICullable): boolean;
  34035. /**
  34036. * Gets a ray in the forward direction from the camera.
  34037. * @param length Defines the length of the ray to create
  34038. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34039. * @param origin Defines the start point of the ray which defaults to the camera position
  34040. * @returns the forward ray
  34041. */
  34042. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34043. /**
  34044. * Gets a ray in the forward direction from the camera.
  34045. * @param refRay the ray to (re)use when setting the values
  34046. * @param length Defines the length of the ray to create
  34047. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34048. * @param origin Defines the start point of the ray which defaults to the camera position
  34049. * @returns the forward ray
  34050. */
  34051. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34052. /**
  34053. * Releases resources associated with this node.
  34054. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34055. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34056. */
  34057. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34058. /** @hidden */
  34059. _isLeftCamera: boolean;
  34060. /**
  34061. * Gets the left camera of a rig setup in case of Rigged Camera
  34062. */
  34063. get isLeftCamera(): boolean;
  34064. /** @hidden */
  34065. _isRightCamera: boolean;
  34066. /**
  34067. * Gets the right camera of a rig setup in case of Rigged Camera
  34068. */
  34069. get isRightCamera(): boolean;
  34070. /**
  34071. * Gets the left camera of a rig setup in case of Rigged Camera
  34072. */
  34073. get leftCamera(): Nullable<FreeCamera>;
  34074. /**
  34075. * Gets the right camera of a rig setup in case of Rigged Camera
  34076. */
  34077. get rightCamera(): Nullable<FreeCamera>;
  34078. /**
  34079. * Gets the left camera target of a rig setup in case of Rigged Camera
  34080. * @returns the target position
  34081. */
  34082. getLeftTarget(): Nullable<Vector3>;
  34083. /**
  34084. * Gets the right camera target of a rig setup in case of Rigged Camera
  34085. * @returns the target position
  34086. */
  34087. getRightTarget(): Nullable<Vector3>;
  34088. /**
  34089. * @hidden
  34090. */
  34091. setCameraRigMode(mode: number, rigParams: any): void;
  34092. /** @hidden */
  34093. static _setStereoscopicRigMode(camera: Camera): void;
  34094. /** @hidden */
  34095. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34096. /** @hidden */
  34097. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34098. /** @hidden */
  34099. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34100. /** @hidden */
  34101. _getVRProjectionMatrix(): Matrix;
  34102. protected _updateCameraRotationMatrix(): void;
  34103. protected _updateWebVRCameraRotationMatrix(): void;
  34104. /**
  34105. * This function MUST be overwritten by the different WebVR cameras available.
  34106. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34107. * @hidden
  34108. */
  34109. _getWebVRProjectionMatrix(): Matrix;
  34110. /**
  34111. * This function MUST be overwritten by the different WebVR cameras available.
  34112. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34113. * @hidden
  34114. */
  34115. _getWebVRViewMatrix(): Matrix;
  34116. /** @hidden */
  34117. setCameraRigParameter(name: string, value: any): void;
  34118. /**
  34119. * needs to be overridden by children so sub has required properties to be copied
  34120. * @hidden
  34121. */
  34122. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34123. /**
  34124. * May need to be overridden by children
  34125. * @hidden
  34126. */
  34127. _updateRigCameras(): void;
  34128. /** @hidden */
  34129. _setupInputs(): void;
  34130. /**
  34131. * Serialiaze the camera setup to a json represention
  34132. * @returns the JSON representation
  34133. */
  34134. serialize(): any;
  34135. /**
  34136. * Clones the current camera.
  34137. * @param name The cloned camera name
  34138. * @returns the cloned camera
  34139. */
  34140. clone(name: string): Camera;
  34141. /**
  34142. * Gets the direction of the camera relative to a given local axis.
  34143. * @param localAxis Defines the reference axis to provide a relative direction.
  34144. * @return the direction
  34145. */
  34146. getDirection(localAxis: Vector3): Vector3;
  34147. /**
  34148. * Returns the current camera absolute rotation
  34149. */
  34150. get absoluteRotation(): Quaternion;
  34151. /**
  34152. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34153. * @param localAxis Defines the reference axis to provide a relative direction.
  34154. * @param result Defines the vector to store the result in
  34155. */
  34156. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34157. /**
  34158. * Gets a camera constructor for a given camera type
  34159. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34160. * @param name The name of the camera the result will be able to instantiate
  34161. * @param scene The scene the result will construct the camera in
  34162. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34163. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34164. * @returns a factory method to construc the camera
  34165. */
  34166. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34167. /**
  34168. * Compute the world matrix of the camera.
  34169. * @returns the camera world matrix
  34170. */
  34171. computeWorldMatrix(): Matrix;
  34172. /**
  34173. * Parse a JSON and creates the camera from the parsed information
  34174. * @param parsedCamera The JSON to parse
  34175. * @param scene The scene to instantiate the camera in
  34176. * @returns the newly constructed camera
  34177. */
  34178. static Parse(parsedCamera: any, scene: Scene): Camera;
  34179. }
  34180. }
  34181. declare module BABYLON {
  34182. /**
  34183. * Class containing static functions to help procedurally build meshes
  34184. */
  34185. export class DiscBuilder {
  34186. /**
  34187. * Creates a plane polygonal mesh. By default, this is a disc
  34188. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34189. * * 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
  34190. * * 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
  34191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34192. * * 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
  34193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34194. * @param name defines the name of the mesh
  34195. * @param options defines the options used to create the mesh
  34196. * @param scene defines the hosting scene
  34197. * @returns the plane polygonal mesh
  34198. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34199. */
  34200. static CreateDisc(name: string, options: {
  34201. radius?: number;
  34202. tessellation?: number;
  34203. arc?: number;
  34204. updatable?: boolean;
  34205. sideOrientation?: number;
  34206. frontUVs?: Vector4;
  34207. backUVs?: Vector4;
  34208. }, scene?: Nullable<Scene>): Mesh;
  34209. }
  34210. }
  34211. declare module BABYLON {
  34212. /**
  34213. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34214. *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.
  34215. * The SPS is also a particle system. It provides some methods to manage the particles.
  34216. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34217. *
  34218. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34219. */
  34220. export class SolidParticleSystem implements IDisposable {
  34221. /**
  34222. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34223. * Example : var p = SPS.particles[i];
  34224. */
  34225. particles: SolidParticle[];
  34226. /**
  34227. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34228. */
  34229. nbParticles: number;
  34230. /**
  34231. * If the particles must ever face the camera (default false). Useful for planar particles.
  34232. */
  34233. billboard: boolean;
  34234. /**
  34235. * Recompute normals when adding a shape
  34236. */
  34237. recomputeNormals: boolean;
  34238. /**
  34239. * This a counter ofr your own usage. It's not set by any SPS functions.
  34240. */
  34241. counter: number;
  34242. /**
  34243. * The SPS name. This name is also given to the underlying mesh.
  34244. */
  34245. name: string;
  34246. /**
  34247. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34248. */
  34249. mesh: Mesh;
  34250. /**
  34251. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34252. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34253. */
  34254. vars: any;
  34255. /**
  34256. * This array is populated when the SPS is set as 'pickable'.
  34257. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34258. * Each element of this array is an object `{idx: int, faceId: int}`.
  34259. * `idx` is the picked particle index in the `SPS.particles` array
  34260. * `faceId` is the picked face index counted within this particle.
  34261. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34262. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34263. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34264. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34265. */
  34266. pickedParticles: {
  34267. idx: number;
  34268. faceId: number;
  34269. }[];
  34270. /**
  34271. * This array is populated when the SPS is set as 'pickable'
  34272. * Each key of this array is a submesh index.
  34273. * Each element of this array is a second array defined like this :
  34274. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34275. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34276. * `idx` is the picked particle index in the `SPS.particles` array
  34277. * `faceId` is the picked face index counted within this particle.
  34278. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34279. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34280. */
  34281. pickedBySubMesh: {
  34282. idx: number;
  34283. faceId: number;
  34284. }[][];
  34285. /**
  34286. * This array is populated when `enableDepthSort` is set to true.
  34287. * Each element of this array is an instance of the class DepthSortedParticle.
  34288. */
  34289. depthSortedParticles: DepthSortedParticle[];
  34290. /**
  34291. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34292. * @hidden
  34293. */
  34294. _bSphereOnly: boolean;
  34295. /**
  34296. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34297. * @hidden
  34298. */
  34299. _bSphereRadiusFactor: number;
  34300. private _scene;
  34301. private _positions;
  34302. private _indices;
  34303. private _normals;
  34304. private _colors;
  34305. private _uvs;
  34306. private _indices32;
  34307. private _positions32;
  34308. private _normals32;
  34309. private _fixedNormal32;
  34310. private _colors32;
  34311. private _uvs32;
  34312. private _index;
  34313. private _updatable;
  34314. private _pickable;
  34315. private _isVisibilityBoxLocked;
  34316. private _alwaysVisible;
  34317. private _depthSort;
  34318. private _expandable;
  34319. private _shapeCounter;
  34320. private _copy;
  34321. private _color;
  34322. private _computeParticleColor;
  34323. private _computeParticleTexture;
  34324. private _computeParticleRotation;
  34325. private _computeParticleVertex;
  34326. private _computeBoundingBox;
  34327. private _depthSortParticles;
  34328. private _camera;
  34329. private _mustUnrotateFixedNormals;
  34330. private _particlesIntersect;
  34331. private _needs32Bits;
  34332. private _isNotBuilt;
  34333. private _lastParticleId;
  34334. private _idxOfId;
  34335. private _multimaterialEnabled;
  34336. private _useModelMaterial;
  34337. private _indicesByMaterial;
  34338. private _materialIndexes;
  34339. private _depthSortFunction;
  34340. private _materialSortFunction;
  34341. private _materials;
  34342. private _multimaterial;
  34343. private _materialIndexesById;
  34344. private _defaultMaterial;
  34345. private _autoUpdateSubMeshes;
  34346. private _tmpVertex;
  34347. /**
  34348. * Creates a SPS (Solid Particle System) object.
  34349. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34350. * @param scene (Scene) is the scene in which the SPS is added.
  34351. * @param options defines the options of the sps e.g.
  34352. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34353. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34354. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34355. * * 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.
  34356. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34357. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34358. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34359. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34360. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34361. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34362. */
  34363. constructor(name: string, scene: Scene, options?: {
  34364. updatable?: boolean;
  34365. isPickable?: boolean;
  34366. enableDepthSort?: boolean;
  34367. particleIntersection?: boolean;
  34368. boundingSphereOnly?: boolean;
  34369. bSphereRadiusFactor?: number;
  34370. expandable?: boolean;
  34371. useModelMaterial?: boolean;
  34372. enableMultiMaterial?: boolean;
  34373. });
  34374. /**
  34375. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34376. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34377. * @returns the created mesh
  34378. */
  34379. buildMesh(): Mesh;
  34380. /**
  34381. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34382. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34383. * Thus the particles generated from `digest()` have their property `position` set yet.
  34384. * @param mesh ( Mesh ) is the mesh to be digested
  34385. * @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
  34386. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34387. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34388. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34389. * @returns the current SPS
  34390. */
  34391. digest(mesh: Mesh, options?: {
  34392. facetNb?: number;
  34393. number?: number;
  34394. delta?: number;
  34395. storage?: [];
  34396. }): SolidParticleSystem;
  34397. /**
  34398. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34399. * @hidden
  34400. */
  34401. private _unrotateFixedNormals;
  34402. /**
  34403. * Resets the temporary working copy particle
  34404. * @hidden
  34405. */
  34406. private _resetCopy;
  34407. /**
  34408. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34409. * @param p the current index in the positions array to be updated
  34410. * @param ind the current index in the indices array
  34411. * @param shape a Vector3 array, the shape geometry
  34412. * @param positions the positions array to be updated
  34413. * @param meshInd the shape indices array
  34414. * @param indices the indices array to be updated
  34415. * @param meshUV the shape uv array
  34416. * @param uvs the uv array to be updated
  34417. * @param meshCol the shape color array
  34418. * @param colors the color array to be updated
  34419. * @param meshNor the shape normals array
  34420. * @param normals the normals array to be updated
  34421. * @param idx the particle index
  34422. * @param idxInShape the particle index in its shape
  34423. * @param options the addShape() method passed options
  34424. * @model the particle model
  34425. * @hidden
  34426. */
  34427. private _meshBuilder;
  34428. /**
  34429. * Returns a shape Vector3 array from positions float array
  34430. * @param positions float array
  34431. * @returns a vector3 array
  34432. * @hidden
  34433. */
  34434. private _posToShape;
  34435. /**
  34436. * Returns a shapeUV array from a float uvs (array deep copy)
  34437. * @param uvs as a float array
  34438. * @returns a shapeUV array
  34439. * @hidden
  34440. */
  34441. private _uvsToShapeUV;
  34442. /**
  34443. * Adds a new particle object in the particles array
  34444. * @param idx particle index in particles array
  34445. * @param id particle id
  34446. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34447. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34448. * @param model particle ModelShape object
  34449. * @param shapeId model shape identifier
  34450. * @param idxInShape index of the particle in the current model
  34451. * @param bInfo model bounding info object
  34452. * @param storage target storage array, if any
  34453. * @hidden
  34454. */
  34455. private _addParticle;
  34456. /**
  34457. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34458. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34459. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34460. * @param nb (positive integer) the number of particles to be created from this model
  34461. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34462. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34463. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34464. * @returns the number of shapes in the system
  34465. */
  34466. addShape(mesh: Mesh, nb: number, options?: {
  34467. positionFunction?: any;
  34468. vertexFunction?: any;
  34469. storage?: [];
  34470. }): number;
  34471. /**
  34472. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34473. * @hidden
  34474. */
  34475. private _rebuildParticle;
  34476. /**
  34477. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34478. * @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.
  34479. * @returns the SPS.
  34480. */
  34481. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34482. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34483. * Returns an array with the removed particles.
  34484. * 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.
  34485. * The SPS can't be empty so at least one particle needs to remain in place.
  34486. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34487. * @param start index of the first particle to remove
  34488. * @param end index of the last particle to remove (included)
  34489. * @returns an array populated with the removed particles
  34490. */
  34491. removeParticles(start: number, end: number): SolidParticle[];
  34492. /**
  34493. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34494. * @param solidParticleArray an array populated with Solid Particles objects
  34495. * @returns the SPS
  34496. */
  34497. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34498. /**
  34499. * Creates a new particle and modifies the SPS mesh geometry :
  34500. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34501. * - calls _addParticle() to populate the particle array
  34502. * factorized code from addShape() and insertParticlesFromArray()
  34503. * @param idx particle index in the particles array
  34504. * @param i particle index in its shape
  34505. * @param modelShape particle ModelShape object
  34506. * @param shape shape vertex array
  34507. * @param meshInd shape indices array
  34508. * @param meshUV shape uv array
  34509. * @param meshCol shape color array
  34510. * @param meshNor shape normals array
  34511. * @param bbInfo shape bounding info
  34512. * @param storage target particle storage
  34513. * @options addShape() passed options
  34514. * @hidden
  34515. */
  34516. private _insertNewParticle;
  34517. /**
  34518. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34519. * This method calls `updateParticle()` for each particle of the SPS.
  34520. * For an animated SPS, it is usually called within the render loop.
  34521. * 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.
  34522. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34523. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34524. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34525. * @returns the SPS.
  34526. */
  34527. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34528. /**
  34529. * Disposes the SPS.
  34530. */
  34531. dispose(): void;
  34532. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34533. * idx is the particle index in the SPS
  34534. * faceId is the picked face index counted within this particle.
  34535. * Returns null if the pickInfo can't identify a picked particle.
  34536. * @param pickingInfo (PickingInfo object)
  34537. * @returns {idx: number, faceId: number} or null
  34538. */
  34539. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34540. idx: number;
  34541. faceId: number;
  34542. }>;
  34543. /**
  34544. * Returns a SolidParticle object from its identifier : particle.id
  34545. * @param id (integer) the particle Id
  34546. * @returns the searched particle or null if not found in the SPS.
  34547. */
  34548. getParticleById(id: number): Nullable<SolidParticle>;
  34549. /**
  34550. * Returns a new array populated with the particles having the passed shapeId.
  34551. * @param shapeId (integer) the shape identifier
  34552. * @returns a new solid particle array
  34553. */
  34554. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34555. /**
  34556. * Populates the passed array "ref" with the particles having the passed shapeId.
  34557. * @param shapeId the shape identifier
  34558. * @returns the SPS
  34559. * @param ref
  34560. */
  34561. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34562. /**
  34563. * Computes the required SubMeshes according the materials assigned to the particles.
  34564. * @returns the solid particle system.
  34565. * Does nothing if called before the SPS mesh is built.
  34566. */
  34567. computeSubMeshes(): SolidParticleSystem;
  34568. /**
  34569. * Sorts the solid particles by material when MultiMaterial is enabled.
  34570. * Updates the indices32 array.
  34571. * Updates the indicesByMaterial array.
  34572. * Updates the mesh indices array.
  34573. * @returns the SPS
  34574. * @hidden
  34575. */
  34576. private _sortParticlesByMaterial;
  34577. /**
  34578. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34579. * @hidden
  34580. */
  34581. private _setMaterialIndexesById;
  34582. /**
  34583. * Returns an array with unique values of Materials from the passed array
  34584. * @param array the material array to be checked and filtered
  34585. * @hidden
  34586. */
  34587. private _filterUniqueMaterialId;
  34588. /**
  34589. * Sets a new Standard Material as _defaultMaterial if not already set.
  34590. * @hidden
  34591. */
  34592. private _setDefaultMaterial;
  34593. /**
  34594. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34595. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34596. * @returns the SPS.
  34597. */
  34598. refreshVisibleSize(): SolidParticleSystem;
  34599. /**
  34600. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34601. * @param size the size (float) of the visibility box
  34602. * note : this doesn't lock the SPS mesh bounding box.
  34603. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34604. */
  34605. setVisibilityBox(size: number): void;
  34606. /**
  34607. * Gets whether the SPS as always visible or not
  34608. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34609. */
  34610. get isAlwaysVisible(): boolean;
  34611. /**
  34612. * Sets the SPS as always visible or not
  34613. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34614. */
  34615. set isAlwaysVisible(val: boolean);
  34616. /**
  34617. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34618. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34619. */
  34620. set isVisibilityBoxLocked(val: boolean);
  34621. /**
  34622. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34623. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34624. */
  34625. get isVisibilityBoxLocked(): boolean;
  34626. /**
  34627. * Tells to `setParticles()` to compute the particle rotations or not.
  34628. * Default value : true. The SPS is faster when it's set to false.
  34629. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34630. */
  34631. set computeParticleRotation(val: boolean);
  34632. /**
  34633. * Tells to `setParticles()` to compute the particle colors or not.
  34634. * Default value : true. The SPS is faster when it's set to false.
  34635. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34636. */
  34637. set computeParticleColor(val: boolean);
  34638. set computeParticleTexture(val: boolean);
  34639. /**
  34640. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34641. * Default value : false. The SPS is faster when it's set to false.
  34642. * Note : the particle custom vertex positions aren't stored values.
  34643. */
  34644. set computeParticleVertex(val: boolean);
  34645. /**
  34646. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34647. */
  34648. set computeBoundingBox(val: boolean);
  34649. /**
  34650. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34651. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34652. * Default : `true`
  34653. */
  34654. set depthSortParticles(val: boolean);
  34655. /**
  34656. * Gets if `setParticles()` computes the particle rotations or not.
  34657. * Default value : true. The SPS is faster when it's set to false.
  34658. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34659. */
  34660. get computeParticleRotation(): boolean;
  34661. /**
  34662. * Gets if `setParticles()` computes the particle colors or not.
  34663. * Default value : true. The SPS is faster when it's set to false.
  34664. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34665. */
  34666. get computeParticleColor(): boolean;
  34667. /**
  34668. * Gets if `setParticles()` computes the particle textures or not.
  34669. * Default value : true. The SPS is faster when it's set to false.
  34670. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34671. */
  34672. get computeParticleTexture(): boolean;
  34673. /**
  34674. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34675. * Default value : false. The SPS is faster when it's set to false.
  34676. * Note : the particle custom vertex positions aren't stored values.
  34677. */
  34678. get computeParticleVertex(): boolean;
  34679. /**
  34680. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34681. */
  34682. get computeBoundingBox(): boolean;
  34683. /**
  34684. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34685. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34686. * Default : `true`
  34687. */
  34688. get depthSortParticles(): boolean;
  34689. /**
  34690. * Gets if the SPS is created as expandable at construction time.
  34691. * Default : `false`
  34692. */
  34693. get expandable(): boolean;
  34694. /**
  34695. * Gets if the SPS supports the Multi Materials
  34696. */
  34697. get multimaterialEnabled(): boolean;
  34698. /**
  34699. * Gets if the SPS uses the model materials for its own multimaterial.
  34700. */
  34701. get useModelMaterial(): boolean;
  34702. /**
  34703. * The SPS used material array.
  34704. */
  34705. get materials(): Material[];
  34706. /**
  34707. * Sets the SPS MultiMaterial from the passed materials.
  34708. * Note : the passed array is internally copied and not used then by reference.
  34709. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34710. */
  34711. setMultiMaterial(materials: Material[]): void;
  34712. /**
  34713. * The SPS computed multimaterial object
  34714. */
  34715. get multimaterial(): MultiMaterial;
  34716. set multimaterial(mm: MultiMaterial);
  34717. /**
  34718. * If the subMeshes must be updated on the next call to setParticles()
  34719. */
  34720. get autoUpdateSubMeshes(): boolean;
  34721. set autoUpdateSubMeshes(val: boolean);
  34722. /**
  34723. * This function does nothing. It may be overwritten to set all the particle first values.
  34724. * The SPS doesn't call this function, you may have to call it by your own.
  34725. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34726. */
  34727. initParticles(): void;
  34728. /**
  34729. * This function does nothing. It may be overwritten to recycle a particle.
  34730. * The SPS doesn't call this function, you may have to call it by your own.
  34731. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34732. * @param particle The particle to recycle
  34733. * @returns the recycled particle
  34734. */
  34735. recycleParticle(particle: SolidParticle): SolidParticle;
  34736. /**
  34737. * Updates a particle : this function should be overwritten by the user.
  34738. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34739. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34740. * @example : just set a particle position or velocity and recycle conditions
  34741. * @param particle The particle to update
  34742. * @returns the updated particle
  34743. */
  34744. updateParticle(particle: SolidParticle): SolidParticle;
  34745. /**
  34746. * Updates a vertex of a particle : it can be overwritten by the user.
  34747. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34748. * @param particle the current particle
  34749. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34750. * @param pt the index of the current vertex in the particle shape
  34751. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34752. * @example : just set a vertex particle position or color
  34753. * @returns the sps
  34754. */
  34755. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34756. /**
  34757. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34758. * This does nothing and may be overwritten by the user.
  34759. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34760. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34761. * @param update the boolean update value actually passed to setParticles()
  34762. */
  34763. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34764. /**
  34765. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34766. * This will be passed three parameters.
  34767. * This does nothing and may be overwritten by the user.
  34768. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34769. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34770. * @param update the boolean update value actually passed to setParticles()
  34771. */
  34772. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34773. }
  34774. }
  34775. declare module BABYLON {
  34776. /**
  34777. * Represents one particle of a solid particle system.
  34778. */
  34779. export class SolidParticle {
  34780. /**
  34781. * particle global index
  34782. */
  34783. idx: number;
  34784. /**
  34785. * particle identifier
  34786. */
  34787. id: number;
  34788. /**
  34789. * The color of the particle
  34790. */
  34791. color: Nullable<Color4>;
  34792. /**
  34793. * The world space position of the particle.
  34794. */
  34795. position: Vector3;
  34796. /**
  34797. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34798. */
  34799. rotation: Vector3;
  34800. /**
  34801. * The world space rotation quaternion of the particle.
  34802. */
  34803. rotationQuaternion: Nullable<Quaternion>;
  34804. /**
  34805. * The scaling of the particle.
  34806. */
  34807. scaling: Vector3;
  34808. /**
  34809. * The uvs of the particle.
  34810. */
  34811. uvs: Vector4;
  34812. /**
  34813. * The current speed of the particle.
  34814. */
  34815. velocity: Vector3;
  34816. /**
  34817. * The pivot point in the particle local space.
  34818. */
  34819. pivot: Vector3;
  34820. /**
  34821. * Must the particle be translated from its pivot point in its local space ?
  34822. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34823. * Default : false
  34824. */
  34825. translateFromPivot: boolean;
  34826. /**
  34827. * Is the particle active or not ?
  34828. */
  34829. alive: boolean;
  34830. /**
  34831. * Is the particle visible or not ?
  34832. */
  34833. isVisible: boolean;
  34834. /**
  34835. * Index of this particle in the global "positions" array (Internal use)
  34836. * @hidden
  34837. */
  34838. _pos: number;
  34839. /**
  34840. * @hidden Index of this particle in the global "indices" array (Internal use)
  34841. */
  34842. _ind: number;
  34843. /**
  34844. * @hidden ModelShape of this particle (Internal use)
  34845. */
  34846. _model: ModelShape;
  34847. /**
  34848. * ModelShape id of this particle
  34849. */
  34850. shapeId: number;
  34851. /**
  34852. * Index of the particle in its shape id
  34853. */
  34854. idxInShape: number;
  34855. /**
  34856. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34857. */
  34858. _modelBoundingInfo: BoundingInfo;
  34859. /**
  34860. * @hidden Particle BoundingInfo object (Internal use)
  34861. */
  34862. _boundingInfo: BoundingInfo;
  34863. /**
  34864. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34865. */
  34866. _sps: SolidParticleSystem;
  34867. /**
  34868. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34869. */
  34870. _stillInvisible: boolean;
  34871. /**
  34872. * @hidden Last computed particle rotation matrix
  34873. */
  34874. _rotationMatrix: number[];
  34875. /**
  34876. * Parent particle Id, if any.
  34877. * Default null.
  34878. */
  34879. parentId: Nullable<number>;
  34880. /**
  34881. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34882. */
  34883. materialIndex: Nullable<number>;
  34884. /**
  34885. * Custom object or properties.
  34886. */
  34887. props: Nullable<any>;
  34888. /**
  34889. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34890. * The possible values are :
  34891. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34892. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34893. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34894. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34895. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34896. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34897. * */
  34898. cullingStrategy: number;
  34899. /**
  34900. * @hidden Internal global position in the SPS.
  34901. */
  34902. _globalPosition: Vector3;
  34903. /**
  34904. * Creates a Solid Particle object.
  34905. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34906. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34907. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34908. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34909. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34910. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34911. * @param shapeId (integer) is the model shape identifier in the SPS.
  34912. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34913. * @param sps defines the sps it is associated to
  34914. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34915. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34916. */
  34917. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34918. /**
  34919. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34920. * @param target the particle target
  34921. * @returns the current particle
  34922. */
  34923. copyToRef(target: SolidParticle): SolidParticle;
  34924. /**
  34925. * Legacy support, changed scale to scaling
  34926. */
  34927. get scale(): Vector3;
  34928. /**
  34929. * Legacy support, changed scale to scaling
  34930. */
  34931. set scale(scale: Vector3);
  34932. /**
  34933. * Legacy support, changed quaternion to rotationQuaternion
  34934. */
  34935. get quaternion(): Nullable<Quaternion>;
  34936. /**
  34937. * Legacy support, changed quaternion to rotationQuaternion
  34938. */
  34939. set quaternion(q: Nullable<Quaternion>);
  34940. /**
  34941. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34942. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34943. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34944. * @returns true if it intersects
  34945. */
  34946. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34947. /**
  34948. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34949. * A particle is in the frustum if its bounding box intersects the frustum
  34950. * @param frustumPlanes defines the frustum to test
  34951. * @returns true if the particle is in the frustum planes
  34952. */
  34953. isInFrustum(frustumPlanes: Plane[]): boolean;
  34954. /**
  34955. * get the rotation matrix of the particle
  34956. * @hidden
  34957. */
  34958. getRotationMatrix(m: Matrix): void;
  34959. }
  34960. /**
  34961. * Represents the shape of the model used by one particle of a solid particle system.
  34962. * SPS internal tool, don't use it manually.
  34963. */
  34964. export class ModelShape {
  34965. /**
  34966. * The shape id
  34967. * @hidden
  34968. */
  34969. shapeID: number;
  34970. /**
  34971. * flat array of model positions (internal use)
  34972. * @hidden
  34973. */
  34974. _shape: Vector3[];
  34975. /**
  34976. * flat array of model UVs (internal use)
  34977. * @hidden
  34978. */
  34979. _shapeUV: number[];
  34980. /**
  34981. * color array of the model
  34982. * @hidden
  34983. */
  34984. _shapeColors: number[];
  34985. /**
  34986. * indices array of the model
  34987. * @hidden
  34988. */
  34989. _indices: number[];
  34990. /**
  34991. * normals array of the model
  34992. * @hidden
  34993. */
  34994. _normals: number[];
  34995. /**
  34996. * length of the shape in the model indices array (internal use)
  34997. * @hidden
  34998. */
  34999. _indicesLength: number;
  35000. /**
  35001. * Custom position function (internal use)
  35002. * @hidden
  35003. */
  35004. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35005. /**
  35006. * Custom vertex function (internal use)
  35007. * @hidden
  35008. */
  35009. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35010. /**
  35011. * Model material (internal use)
  35012. * @hidden
  35013. */
  35014. _material: Nullable<Material>;
  35015. /**
  35016. * 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.
  35017. * SPS internal tool, don't use it manually.
  35018. * @hidden
  35019. */
  35020. 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>);
  35021. }
  35022. /**
  35023. * Represents a Depth Sorted Particle in the solid particle system.
  35024. * @hidden
  35025. */
  35026. export class DepthSortedParticle {
  35027. /**
  35028. * Particle index
  35029. */
  35030. idx: number;
  35031. /**
  35032. * Index of the particle in the "indices" array
  35033. */
  35034. ind: number;
  35035. /**
  35036. * Length of the particle shape in the "indices" array
  35037. */
  35038. indicesLength: number;
  35039. /**
  35040. * Squared distance from the particle to the camera
  35041. */
  35042. sqDistance: number;
  35043. /**
  35044. * Material index when used with MultiMaterials
  35045. */
  35046. materialIndex: number;
  35047. /**
  35048. * Creates a new sorted particle
  35049. * @param materialIndex
  35050. */
  35051. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35052. }
  35053. /**
  35054. * Represents a solid particle vertex
  35055. */
  35056. export class SolidParticleVertex {
  35057. /**
  35058. * Vertex position
  35059. */
  35060. position: Vector3;
  35061. /**
  35062. * Vertex color
  35063. */
  35064. color: Color4;
  35065. /**
  35066. * Vertex UV
  35067. */
  35068. uv: Vector2;
  35069. /**
  35070. * Creates a new solid particle vertex
  35071. */
  35072. constructor();
  35073. /** Vertex x coordinate */
  35074. get x(): number;
  35075. set x(val: number);
  35076. /** Vertex y coordinate */
  35077. get y(): number;
  35078. set y(val: number);
  35079. /** Vertex z coordinate */
  35080. get z(): number;
  35081. set z(val: number);
  35082. }
  35083. }
  35084. declare module BABYLON {
  35085. /**
  35086. * @hidden
  35087. */
  35088. export class _MeshCollisionData {
  35089. _checkCollisions: boolean;
  35090. _collisionMask: number;
  35091. _collisionGroup: number;
  35092. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35093. _collider: Nullable<Collider>;
  35094. _oldPositionForCollisions: Vector3;
  35095. _diffPositionForCollisions: Vector3;
  35096. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35097. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35098. _collisionResponse: boolean;
  35099. }
  35100. }
  35101. declare module BABYLON {
  35102. /** @hidden */
  35103. class _FacetDataStorage {
  35104. facetPositions: Vector3[];
  35105. facetNormals: Vector3[];
  35106. facetPartitioning: number[][];
  35107. facetNb: number;
  35108. partitioningSubdivisions: number;
  35109. partitioningBBoxRatio: number;
  35110. facetDataEnabled: boolean;
  35111. facetParameters: any;
  35112. bbSize: Vector3;
  35113. subDiv: {
  35114. max: number;
  35115. X: number;
  35116. Y: number;
  35117. Z: number;
  35118. };
  35119. facetDepthSort: boolean;
  35120. facetDepthSortEnabled: boolean;
  35121. depthSortedIndices: IndicesArray;
  35122. depthSortedFacets: {
  35123. ind: number;
  35124. sqDistance: number;
  35125. }[];
  35126. facetDepthSortFunction: (f1: {
  35127. ind: number;
  35128. sqDistance: number;
  35129. }, f2: {
  35130. ind: number;
  35131. sqDistance: number;
  35132. }) => number;
  35133. facetDepthSortFrom: Vector3;
  35134. facetDepthSortOrigin: Vector3;
  35135. invertedMatrix: Matrix;
  35136. }
  35137. /**
  35138. * @hidden
  35139. **/
  35140. class _InternalAbstractMeshDataInfo {
  35141. _hasVertexAlpha: boolean;
  35142. _useVertexColors: boolean;
  35143. _numBoneInfluencers: number;
  35144. _applyFog: boolean;
  35145. _receiveShadows: boolean;
  35146. _facetData: _FacetDataStorage;
  35147. _visibility: number;
  35148. _skeleton: Nullable<Skeleton>;
  35149. _layerMask: number;
  35150. _computeBonesUsingShaders: boolean;
  35151. _isActive: boolean;
  35152. _onlyForInstances: boolean;
  35153. _isActiveIntermediate: boolean;
  35154. _onlyForInstancesIntermediate: boolean;
  35155. _actAsRegularMesh: boolean;
  35156. _currentLOD: Nullable<AbstractMesh>;
  35157. }
  35158. /**
  35159. * Class used to store all common mesh properties
  35160. */
  35161. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35162. /** No occlusion */
  35163. static OCCLUSION_TYPE_NONE: number;
  35164. /** Occlusion set to optimisitic */
  35165. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35166. /** Occlusion set to strict */
  35167. static OCCLUSION_TYPE_STRICT: number;
  35168. /** Use an accurante occlusion algorithm */
  35169. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35170. /** Use a conservative occlusion algorithm */
  35171. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35172. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35173. * Test order :
  35174. * Is the bounding sphere outside the frustum ?
  35175. * If not, are the bounding box vertices outside the frustum ?
  35176. * It not, then the cullable object is in the frustum.
  35177. */
  35178. static readonly CULLINGSTRATEGY_STANDARD: number;
  35179. /** Culling strategy : Bounding Sphere Only.
  35180. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35181. * It's also less accurate than the standard because some not visible objects can still be selected.
  35182. * Test : is the bounding sphere outside the frustum ?
  35183. * If not, then the cullable object is in the frustum.
  35184. */
  35185. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35186. /** Culling strategy : Optimistic Inclusion.
  35187. * This in an inclusion test first, then the standard exclusion test.
  35188. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35189. * 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.
  35190. * Anyway, it's as accurate as the standard strategy.
  35191. * Test :
  35192. * Is the cullable object bounding sphere center in the frustum ?
  35193. * If not, apply the default culling strategy.
  35194. */
  35195. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35196. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35197. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35198. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35199. * 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.
  35200. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35201. * Test :
  35202. * Is the cullable object bounding sphere center in the frustum ?
  35203. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35204. */
  35205. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35206. /**
  35207. * No billboard
  35208. */
  35209. static get BILLBOARDMODE_NONE(): number;
  35210. /** Billboard on X axis */
  35211. static get BILLBOARDMODE_X(): number;
  35212. /** Billboard on Y axis */
  35213. static get BILLBOARDMODE_Y(): number;
  35214. /** Billboard on Z axis */
  35215. static get BILLBOARDMODE_Z(): number;
  35216. /** Billboard on all axes */
  35217. static get BILLBOARDMODE_ALL(): number;
  35218. /** Billboard on using position instead of orientation */
  35219. static get BILLBOARDMODE_USE_POSITION(): number;
  35220. /** @hidden */
  35221. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35222. /**
  35223. * The culling strategy to use to check whether the mesh must be rendered or not.
  35224. * This value can be changed at any time and will be used on the next render mesh selection.
  35225. * The possible values are :
  35226. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35227. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35228. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35229. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35230. * Please read each static variable documentation to get details about the culling process.
  35231. * */
  35232. cullingStrategy: number;
  35233. /**
  35234. * Gets the number of facets in the mesh
  35235. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35236. */
  35237. get facetNb(): number;
  35238. /**
  35239. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35240. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35241. */
  35242. get partitioningSubdivisions(): number;
  35243. set partitioningSubdivisions(nb: number);
  35244. /**
  35245. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35246. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35247. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35248. */
  35249. get partitioningBBoxRatio(): number;
  35250. set partitioningBBoxRatio(ratio: number);
  35251. /**
  35252. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35253. * Works only for updatable meshes.
  35254. * Doesn't work with multi-materials
  35255. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35256. */
  35257. get mustDepthSortFacets(): boolean;
  35258. set mustDepthSortFacets(sort: boolean);
  35259. /**
  35260. * The location (Vector3) where the facet depth sort must be computed from.
  35261. * By default, the active camera position.
  35262. * Used only when facet depth sort is enabled
  35263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35264. */
  35265. get facetDepthSortFrom(): Vector3;
  35266. set facetDepthSortFrom(location: Vector3);
  35267. /**
  35268. * gets a boolean indicating if facetData is enabled
  35269. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35270. */
  35271. get isFacetDataEnabled(): boolean;
  35272. /** @hidden */
  35273. _updateNonUniformScalingState(value: boolean): boolean;
  35274. /**
  35275. * An event triggered when this mesh collides with another one
  35276. */
  35277. onCollideObservable: Observable<AbstractMesh>;
  35278. /** Set a function to call when this mesh collides with another one */
  35279. set onCollide(callback: () => void);
  35280. /**
  35281. * An event triggered when the collision's position changes
  35282. */
  35283. onCollisionPositionChangeObservable: Observable<Vector3>;
  35284. /** Set a function to call when the collision's position changes */
  35285. set onCollisionPositionChange(callback: () => void);
  35286. /**
  35287. * An event triggered when material is changed
  35288. */
  35289. onMaterialChangedObservable: Observable<AbstractMesh>;
  35290. /**
  35291. * Gets or sets the orientation for POV movement & rotation
  35292. */
  35293. definedFacingForward: boolean;
  35294. /** @hidden */
  35295. _occlusionQuery: Nullable<WebGLQuery>;
  35296. /** @hidden */
  35297. _renderingGroup: Nullable<RenderingGroup>;
  35298. /**
  35299. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35300. */
  35301. get visibility(): number;
  35302. /**
  35303. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35304. */
  35305. set visibility(value: number);
  35306. /** Gets or sets the alpha index used to sort transparent meshes
  35307. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35308. */
  35309. alphaIndex: number;
  35310. /**
  35311. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35312. */
  35313. isVisible: boolean;
  35314. /**
  35315. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35316. */
  35317. isPickable: boolean;
  35318. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35319. showSubMeshesBoundingBox: boolean;
  35320. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35321. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35322. */
  35323. isBlocker: boolean;
  35324. /**
  35325. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35326. */
  35327. enablePointerMoveEvents: boolean;
  35328. private _renderingGroupId;
  35329. /**
  35330. * Specifies the rendering group id for this mesh (0 by default)
  35331. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35332. */
  35333. get renderingGroupId(): number;
  35334. set renderingGroupId(value: number);
  35335. private _material;
  35336. /** Gets or sets current material */
  35337. get material(): Nullable<Material>;
  35338. set material(value: Nullable<Material>);
  35339. /**
  35340. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35341. * @see https://doc.babylonjs.com/babylon101/shadows
  35342. */
  35343. get receiveShadows(): boolean;
  35344. set receiveShadows(value: boolean);
  35345. /** Defines color to use when rendering outline */
  35346. outlineColor: Color3;
  35347. /** Define width to use when rendering outline */
  35348. outlineWidth: number;
  35349. /** Defines color to use when rendering overlay */
  35350. overlayColor: Color3;
  35351. /** Defines alpha to use when rendering overlay */
  35352. overlayAlpha: number;
  35353. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35354. get hasVertexAlpha(): boolean;
  35355. set hasVertexAlpha(value: boolean);
  35356. /** 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) */
  35357. get useVertexColors(): boolean;
  35358. set useVertexColors(value: boolean);
  35359. /**
  35360. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35361. */
  35362. get computeBonesUsingShaders(): boolean;
  35363. set computeBonesUsingShaders(value: boolean);
  35364. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35365. get numBoneInfluencers(): number;
  35366. set numBoneInfluencers(value: number);
  35367. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35368. get applyFog(): boolean;
  35369. set applyFog(value: boolean);
  35370. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35371. useOctreeForRenderingSelection: boolean;
  35372. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35373. useOctreeForPicking: boolean;
  35374. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35375. useOctreeForCollisions: boolean;
  35376. /**
  35377. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35378. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35379. */
  35380. get layerMask(): number;
  35381. set layerMask(value: number);
  35382. /**
  35383. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35384. */
  35385. alwaysSelectAsActiveMesh: boolean;
  35386. /**
  35387. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35388. */
  35389. doNotSyncBoundingInfo: boolean;
  35390. /**
  35391. * Gets or sets the current action manager
  35392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35393. */
  35394. actionManager: Nullable<AbstractActionManager>;
  35395. private _meshCollisionData;
  35396. /**
  35397. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35398. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35399. */
  35400. ellipsoid: Vector3;
  35401. /**
  35402. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35403. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35404. */
  35405. ellipsoidOffset: Vector3;
  35406. /**
  35407. * Gets or sets a collision mask used to mask collisions (default is -1).
  35408. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35409. */
  35410. get collisionMask(): number;
  35411. set collisionMask(mask: number);
  35412. /**
  35413. * Gets or sets a collision response flag (default is true).
  35414. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35415. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35416. * to respond to the collision.
  35417. */
  35418. get collisionResponse(): boolean;
  35419. set collisionResponse(response: boolean);
  35420. /**
  35421. * Gets or sets the current collision group mask (-1 by default).
  35422. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35423. */
  35424. get collisionGroup(): number;
  35425. set collisionGroup(mask: number);
  35426. /**
  35427. * Gets or sets current surrounding meshes (null by default).
  35428. *
  35429. * By default collision detection is tested against every mesh in the scene.
  35430. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35431. * meshes will be tested for the collision.
  35432. *
  35433. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35434. */
  35435. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35436. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35437. /**
  35438. * Defines edge width used when edgesRenderer is enabled
  35439. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35440. */
  35441. edgesWidth: number;
  35442. /**
  35443. * Defines edge color used when edgesRenderer is enabled
  35444. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35445. */
  35446. edgesColor: Color4;
  35447. /** @hidden */
  35448. _edgesRenderer: Nullable<IEdgesRenderer>;
  35449. /** @hidden */
  35450. _masterMesh: Nullable<AbstractMesh>;
  35451. /** @hidden */
  35452. _boundingInfo: Nullable<BoundingInfo>;
  35453. /** @hidden */
  35454. _renderId: number;
  35455. /**
  35456. * Gets or sets the list of subMeshes
  35457. * @see https://doc.babylonjs.com/how_to/multi_materials
  35458. */
  35459. subMeshes: SubMesh[];
  35460. /** @hidden */
  35461. _intersectionsInProgress: AbstractMesh[];
  35462. /** @hidden */
  35463. _unIndexed: boolean;
  35464. /** @hidden */
  35465. _lightSources: Light[];
  35466. /** Gets the list of lights affecting that mesh */
  35467. get lightSources(): Light[];
  35468. /** @hidden */
  35469. get _positions(): Nullable<Vector3[]>;
  35470. /** @hidden */
  35471. _waitingData: {
  35472. lods: Nullable<any>;
  35473. actions: Nullable<any>;
  35474. freezeWorldMatrix: Nullable<boolean>;
  35475. };
  35476. /** @hidden */
  35477. _bonesTransformMatrices: Nullable<Float32Array>;
  35478. /** @hidden */
  35479. _transformMatrixTexture: Nullable<RawTexture>;
  35480. /**
  35481. * Gets or sets a skeleton to apply skining transformations
  35482. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35483. */
  35484. set skeleton(value: Nullable<Skeleton>);
  35485. get skeleton(): Nullable<Skeleton>;
  35486. /**
  35487. * An event triggered when the mesh is rebuilt.
  35488. */
  35489. onRebuildObservable: Observable<AbstractMesh>;
  35490. /**
  35491. * Creates a new AbstractMesh
  35492. * @param name defines the name of the mesh
  35493. * @param scene defines the hosting scene
  35494. */
  35495. constructor(name: string, scene?: Nullable<Scene>);
  35496. /**
  35497. * Returns the string "AbstractMesh"
  35498. * @returns "AbstractMesh"
  35499. */
  35500. getClassName(): string;
  35501. /**
  35502. * Gets a string representation of the current mesh
  35503. * @param fullDetails defines a boolean indicating if full details must be included
  35504. * @returns a string representation of the current mesh
  35505. */
  35506. toString(fullDetails?: boolean): string;
  35507. /**
  35508. * @hidden
  35509. */
  35510. protected _getEffectiveParent(): Nullable<Node>;
  35511. /** @hidden */
  35512. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35513. /** @hidden */
  35514. _rebuild(): void;
  35515. /** @hidden */
  35516. _resyncLightSources(): void;
  35517. /** @hidden */
  35518. _resyncLightSource(light: Light): void;
  35519. /** @hidden */
  35520. _unBindEffect(): void;
  35521. /** @hidden */
  35522. _removeLightSource(light: Light, dispose: boolean): void;
  35523. private _markSubMeshesAsDirty;
  35524. /** @hidden */
  35525. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35526. /** @hidden */
  35527. _markSubMeshesAsAttributesDirty(): void;
  35528. /** @hidden */
  35529. _markSubMeshesAsMiscDirty(): void;
  35530. /**
  35531. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35532. */
  35533. get scaling(): Vector3;
  35534. set scaling(newScaling: Vector3);
  35535. /**
  35536. * Returns true if the mesh is blocked. Implemented by child classes
  35537. */
  35538. get isBlocked(): boolean;
  35539. /**
  35540. * Returns the mesh itself by default. Implemented by child classes
  35541. * @param camera defines the camera to use to pick the right LOD level
  35542. * @returns the currentAbstractMesh
  35543. */
  35544. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35545. /**
  35546. * Returns 0 by default. Implemented by child classes
  35547. * @returns an integer
  35548. */
  35549. getTotalVertices(): number;
  35550. /**
  35551. * Returns a positive integer : the total number of indices in this mesh geometry.
  35552. * @returns the numner of indices or zero if the mesh has no geometry.
  35553. */
  35554. getTotalIndices(): number;
  35555. /**
  35556. * Returns null by default. Implemented by child classes
  35557. * @returns null
  35558. */
  35559. getIndices(): Nullable<IndicesArray>;
  35560. /**
  35561. * Returns the array of the requested vertex data kind. Implemented by child classes
  35562. * @param kind defines the vertex data kind to use
  35563. * @returns null
  35564. */
  35565. getVerticesData(kind: string): Nullable<FloatArray>;
  35566. /**
  35567. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35568. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35569. * Note that a new underlying VertexBuffer object is created each call.
  35570. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35571. * @param kind defines vertex data kind:
  35572. * * VertexBuffer.PositionKind
  35573. * * VertexBuffer.UVKind
  35574. * * VertexBuffer.UV2Kind
  35575. * * VertexBuffer.UV3Kind
  35576. * * VertexBuffer.UV4Kind
  35577. * * VertexBuffer.UV5Kind
  35578. * * VertexBuffer.UV6Kind
  35579. * * VertexBuffer.ColorKind
  35580. * * VertexBuffer.MatricesIndicesKind
  35581. * * VertexBuffer.MatricesIndicesExtraKind
  35582. * * VertexBuffer.MatricesWeightsKind
  35583. * * VertexBuffer.MatricesWeightsExtraKind
  35584. * @param data defines the data source
  35585. * @param updatable defines if the data must be flagged as updatable (or static)
  35586. * @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
  35587. * @returns the current mesh
  35588. */
  35589. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35590. /**
  35591. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35592. * If the mesh has no geometry, it is simply returned as it is.
  35593. * @param kind defines vertex data kind:
  35594. * * VertexBuffer.PositionKind
  35595. * * VertexBuffer.UVKind
  35596. * * VertexBuffer.UV2Kind
  35597. * * VertexBuffer.UV3Kind
  35598. * * VertexBuffer.UV4Kind
  35599. * * VertexBuffer.UV5Kind
  35600. * * VertexBuffer.UV6Kind
  35601. * * VertexBuffer.ColorKind
  35602. * * VertexBuffer.MatricesIndicesKind
  35603. * * VertexBuffer.MatricesIndicesExtraKind
  35604. * * VertexBuffer.MatricesWeightsKind
  35605. * * VertexBuffer.MatricesWeightsExtraKind
  35606. * @param data defines the data source
  35607. * @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
  35608. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35609. * @returns the current mesh
  35610. */
  35611. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35612. /**
  35613. * Sets the mesh indices,
  35614. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35615. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35616. * @param totalVertices Defines the total number of vertices
  35617. * @returns the current mesh
  35618. */
  35619. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35620. /**
  35621. * Gets a boolean indicating if specific vertex data is present
  35622. * @param kind defines the vertex data kind to use
  35623. * @returns true is data kind is present
  35624. */
  35625. isVerticesDataPresent(kind: string): boolean;
  35626. /**
  35627. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35628. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35629. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35630. * @returns a BoundingInfo
  35631. */
  35632. getBoundingInfo(): BoundingInfo;
  35633. /**
  35634. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35635. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35636. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35637. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35638. * @returns the current mesh
  35639. */
  35640. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35641. /**
  35642. * Overwrite the current bounding info
  35643. * @param boundingInfo defines the new bounding info
  35644. * @returns the current mesh
  35645. */
  35646. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35647. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35648. get useBones(): boolean;
  35649. /** @hidden */
  35650. _preActivate(): void;
  35651. /** @hidden */
  35652. _preActivateForIntermediateRendering(renderId: number): void;
  35653. /** @hidden */
  35654. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35655. /** @hidden */
  35656. _postActivate(): void;
  35657. /** @hidden */
  35658. _freeze(): void;
  35659. /** @hidden */
  35660. _unFreeze(): void;
  35661. /**
  35662. * Gets the current world matrix
  35663. * @returns a Matrix
  35664. */
  35665. getWorldMatrix(): Matrix;
  35666. /** @hidden */
  35667. _getWorldMatrixDeterminant(): number;
  35668. /**
  35669. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35670. */
  35671. get isAnInstance(): boolean;
  35672. /**
  35673. * Gets a boolean indicating if this mesh has instances
  35674. */
  35675. get hasInstances(): boolean;
  35676. /**
  35677. * Gets a boolean indicating if this mesh has thin instances
  35678. */
  35679. get hasThinInstances(): boolean;
  35680. /**
  35681. * Perform relative position change from the point of view of behind the front of the mesh.
  35682. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35683. * Supports definition of mesh facing forward or backward
  35684. * @param amountRight defines the distance on the right axis
  35685. * @param amountUp defines the distance on the up axis
  35686. * @param amountForward defines the distance on the forward axis
  35687. * @returns the current mesh
  35688. */
  35689. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35690. /**
  35691. * Calculate relative position change from the point of view of behind the front of the mesh.
  35692. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35693. * Supports definition of mesh facing forward or backward
  35694. * @param amountRight defines the distance on the right axis
  35695. * @param amountUp defines the distance on the up axis
  35696. * @param amountForward defines the distance on the forward axis
  35697. * @returns the new displacement vector
  35698. */
  35699. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35700. /**
  35701. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35702. * Supports definition of mesh facing forward or backward
  35703. * @param flipBack defines the flip
  35704. * @param twirlClockwise defines the twirl
  35705. * @param tiltRight defines the tilt
  35706. * @returns the current mesh
  35707. */
  35708. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35709. /**
  35710. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35711. * Supports definition of mesh facing forward or backward.
  35712. * @param flipBack defines the flip
  35713. * @param twirlClockwise defines the twirl
  35714. * @param tiltRight defines the tilt
  35715. * @returns the new rotation vector
  35716. */
  35717. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35718. /**
  35719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35720. * This means the mesh underlying bounding box and sphere are recomputed.
  35721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35722. * @returns the current mesh
  35723. */
  35724. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35725. /** @hidden */
  35726. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35727. /** @hidden */
  35728. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35729. /** @hidden */
  35730. _updateBoundingInfo(): AbstractMesh;
  35731. /** @hidden */
  35732. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35733. /** @hidden */
  35734. protected _afterComputeWorldMatrix(): void;
  35735. /** @hidden */
  35736. get _effectiveMesh(): AbstractMesh;
  35737. /**
  35738. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35739. * A mesh is in the frustum if its bounding box intersects the frustum
  35740. * @param frustumPlanes defines the frustum to test
  35741. * @returns true if the mesh is in the frustum planes
  35742. */
  35743. isInFrustum(frustumPlanes: Plane[]): boolean;
  35744. /**
  35745. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35746. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35747. * @param frustumPlanes defines the frustum to test
  35748. * @returns true if the mesh is completely in the frustum planes
  35749. */
  35750. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35751. /**
  35752. * True if the mesh intersects another mesh or a SolidParticle object
  35753. * @param mesh defines a target mesh or SolidParticle to test
  35754. * @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)
  35755. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35756. * @returns true if there is an intersection
  35757. */
  35758. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35759. /**
  35760. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35761. * @param point defines the point to test
  35762. * @returns true if there is an intersection
  35763. */
  35764. intersectsPoint(point: Vector3): boolean;
  35765. /**
  35766. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35767. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35768. */
  35769. get checkCollisions(): boolean;
  35770. set checkCollisions(collisionEnabled: boolean);
  35771. /**
  35772. * Gets Collider object used to compute collisions (not physics)
  35773. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35774. */
  35775. get collider(): Nullable<Collider>;
  35776. /**
  35777. * Move the mesh using collision engine
  35778. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35779. * @param displacement defines the requested displacement vector
  35780. * @returns the current mesh
  35781. */
  35782. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35783. private _onCollisionPositionChange;
  35784. /** @hidden */
  35785. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35786. /** @hidden */
  35787. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35788. /** @hidden */
  35789. _checkCollision(collider: Collider): AbstractMesh;
  35790. /** @hidden */
  35791. _generatePointsArray(): boolean;
  35792. /**
  35793. * Checks if the passed Ray intersects with the mesh
  35794. * @param ray defines the ray to use
  35795. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35796. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35797. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35798. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35799. * @returns the picking info
  35800. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35801. */
  35802. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35803. /**
  35804. * Clones the current mesh
  35805. * @param name defines the mesh name
  35806. * @param newParent defines the new mesh parent
  35807. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35808. * @returns the new mesh
  35809. */
  35810. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35811. /**
  35812. * Disposes all the submeshes of the current meshnp
  35813. * @returns the current mesh
  35814. */
  35815. releaseSubMeshes(): AbstractMesh;
  35816. /**
  35817. * Releases resources associated with this abstract mesh.
  35818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35820. */
  35821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35822. /**
  35823. * Adds the passed mesh as a child to the current mesh
  35824. * @param mesh defines the child mesh
  35825. * @returns the current mesh
  35826. */
  35827. addChild(mesh: AbstractMesh): AbstractMesh;
  35828. /**
  35829. * Removes the passed mesh from the current mesh children list
  35830. * @param mesh defines the child mesh
  35831. * @returns the current mesh
  35832. */
  35833. removeChild(mesh: AbstractMesh): AbstractMesh;
  35834. /** @hidden */
  35835. private _initFacetData;
  35836. /**
  35837. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35838. * This method can be called within the render loop.
  35839. * 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
  35840. * @returns the current mesh
  35841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35842. */
  35843. updateFacetData(): AbstractMesh;
  35844. /**
  35845. * Returns the facetLocalNormals array.
  35846. * The normals are expressed in the mesh local spac
  35847. * @returns an array of Vector3
  35848. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35849. */
  35850. getFacetLocalNormals(): Vector3[];
  35851. /**
  35852. * Returns the facetLocalPositions array.
  35853. * The facet positions are expressed in the mesh local space
  35854. * @returns an array of Vector3
  35855. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35856. */
  35857. getFacetLocalPositions(): Vector3[];
  35858. /**
  35859. * Returns the facetLocalPartioning array
  35860. * @returns an array of array of numbers
  35861. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35862. */
  35863. getFacetLocalPartitioning(): number[][];
  35864. /**
  35865. * Returns the i-th facet position in the world system.
  35866. * This method allocates a new Vector3 per call
  35867. * @param i defines the facet index
  35868. * @returns a new Vector3
  35869. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35870. */
  35871. getFacetPosition(i: number): Vector3;
  35872. /**
  35873. * Sets the reference Vector3 with the i-th facet position in the world system
  35874. * @param i defines the facet index
  35875. * @param ref defines the target vector
  35876. * @returns the current mesh
  35877. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35878. */
  35879. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35880. /**
  35881. * Returns the i-th facet normal in the world system.
  35882. * This method allocates a new Vector3 per call
  35883. * @param i defines the facet index
  35884. * @returns a new Vector3
  35885. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35886. */
  35887. getFacetNormal(i: number): Vector3;
  35888. /**
  35889. * Sets the reference Vector3 with the i-th facet normal in the world system
  35890. * @param i defines the facet index
  35891. * @param ref defines the target vector
  35892. * @returns the current mesh
  35893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35894. */
  35895. getFacetNormalToRef(i: number, ref: Vector3): this;
  35896. /**
  35897. * 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)
  35898. * @param x defines x coordinate
  35899. * @param y defines y coordinate
  35900. * @param z defines z coordinate
  35901. * @returns the array of facet indexes
  35902. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35903. */
  35904. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35905. /**
  35906. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35907. * @param projected sets as the (x,y,z) world projection on the facet
  35908. * @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
  35909. * @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
  35910. * @param x defines x coordinate
  35911. * @param y defines y coordinate
  35912. * @param z defines z coordinate
  35913. * @returns the face index if found (or null instead)
  35914. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35915. */
  35916. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35917. /**
  35918. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35919. * @param projected sets as the (x,y,z) local projection on the facet
  35920. * @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
  35921. * @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
  35922. * @param x defines x coordinate
  35923. * @param y defines y coordinate
  35924. * @param z defines z coordinate
  35925. * @returns the face index if found (or null instead)
  35926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35927. */
  35928. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35929. /**
  35930. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35931. * @returns the parameters
  35932. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35933. */
  35934. getFacetDataParameters(): any;
  35935. /**
  35936. * Disables the feature FacetData and frees the related memory
  35937. * @returns the current mesh
  35938. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35939. */
  35940. disableFacetData(): AbstractMesh;
  35941. /**
  35942. * Updates the AbstractMesh indices array
  35943. * @param indices defines the data source
  35944. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35945. * @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)
  35946. * @returns the current mesh
  35947. */
  35948. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35949. /**
  35950. * Creates new normals data for the mesh
  35951. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35952. * @returns the current mesh
  35953. */
  35954. createNormals(updatable: boolean): AbstractMesh;
  35955. /**
  35956. * Align the mesh with a normal
  35957. * @param normal defines the normal to use
  35958. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35959. * @returns the current mesh
  35960. */
  35961. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35962. /** @hidden */
  35963. _checkOcclusionQuery(): boolean;
  35964. /**
  35965. * Disables the mesh edge rendering mode
  35966. * @returns the currentAbstractMesh
  35967. */
  35968. disableEdgesRendering(): AbstractMesh;
  35969. /**
  35970. * Enables the edge rendering mode on the mesh.
  35971. * This mode makes the mesh edges visible
  35972. * @param epsilon defines the maximal distance between two angles to detect a face
  35973. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35974. * @returns the currentAbstractMesh
  35975. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35976. */
  35977. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35978. /**
  35979. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35980. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35981. */
  35982. getConnectedParticleSystems(): IParticleSystem[];
  35983. }
  35984. }
  35985. declare module BABYLON {
  35986. /**
  35987. * Interface used to define ActionEvent
  35988. */
  35989. export interface IActionEvent {
  35990. /** The mesh or sprite that triggered the action */
  35991. source: any;
  35992. /** The X mouse cursor position at the time of the event */
  35993. pointerX: number;
  35994. /** The Y mouse cursor position at the time of the event */
  35995. pointerY: number;
  35996. /** The mesh that is currently pointed at (can be null) */
  35997. meshUnderPointer: Nullable<AbstractMesh>;
  35998. /** the original (browser) event that triggered the ActionEvent */
  35999. sourceEvent?: any;
  36000. /** additional data for the event */
  36001. additionalData?: any;
  36002. }
  36003. /**
  36004. * ActionEvent is the event being sent when an action is triggered.
  36005. */
  36006. export class ActionEvent implements IActionEvent {
  36007. /** The mesh or sprite that triggered the action */
  36008. source: any;
  36009. /** The X mouse cursor position at the time of the event */
  36010. pointerX: number;
  36011. /** The Y mouse cursor position at the time of the event */
  36012. pointerY: number;
  36013. /** The mesh that is currently pointed at (can be null) */
  36014. meshUnderPointer: Nullable<AbstractMesh>;
  36015. /** the original (browser) event that triggered the ActionEvent */
  36016. sourceEvent?: any;
  36017. /** additional data for the event */
  36018. additionalData?: any;
  36019. /**
  36020. * Creates a new ActionEvent
  36021. * @param source The mesh or sprite that triggered the action
  36022. * @param pointerX The X mouse cursor position at the time of the event
  36023. * @param pointerY The Y mouse cursor position at the time of the event
  36024. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36025. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36026. * @param additionalData additional data for the event
  36027. */
  36028. constructor(
  36029. /** The mesh or sprite that triggered the action */
  36030. source: any,
  36031. /** The X mouse cursor position at the time of the event */
  36032. pointerX: number,
  36033. /** The Y mouse cursor position at the time of the event */
  36034. pointerY: number,
  36035. /** The mesh that is currently pointed at (can be null) */
  36036. meshUnderPointer: Nullable<AbstractMesh>,
  36037. /** the original (browser) event that triggered the ActionEvent */
  36038. sourceEvent?: any,
  36039. /** additional data for the event */
  36040. additionalData?: any);
  36041. /**
  36042. * Helper function to auto-create an ActionEvent from a source mesh.
  36043. * @param source The source mesh that triggered the event
  36044. * @param evt The original (browser) event
  36045. * @param additionalData additional data for the event
  36046. * @returns the new ActionEvent
  36047. */
  36048. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36049. /**
  36050. * Helper function to auto-create an ActionEvent from a source sprite
  36051. * @param source The source sprite that triggered the event
  36052. * @param scene Scene associated with the sprite
  36053. * @param evt The original (browser) event
  36054. * @param additionalData additional data for the event
  36055. * @returns the new ActionEvent
  36056. */
  36057. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36058. /**
  36059. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36060. * @param scene the scene where the event occurred
  36061. * @param evt The original (browser) event
  36062. * @returns the new ActionEvent
  36063. */
  36064. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36065. /**
  36066. * Helper function to auto-create an ActionEvent from a primitive
  36067. * @param prim defines the target primitive
  36068. * @param pointerPos defines the pointer position
  36069. * @param evt The original (browser) event
  36070. * @param additionalData additional data for the event
  36071. * @returns the new ActionEvent
  36072. */
  36073. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36074. }
  36075. }
  36076. declare module BABYLON {
  36077. /**
  36078. * Abstract class used to decouple action Manager from scene and meshes.
  36079. * Do not instantiate.
  36080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36081. */
  36082. export abstract class AbstractActionManager implements IDisposable {
  36083. /** Gets the list of active triggers */
  36084. static Triggers: {
  36085. [key: string]: number;
  36086. };
  36087. /** Gets the cursor to use when hovering items */
  36088. hoverCursor: string;
  36089. /** Gets the list of actions */
  36090. actions: IAction[];
  36091. /**
  36092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36093. */
  36094. isRecursive: boolean;
  36095. /**
  36096. * Releases all associated resources
  36097. */
  36098. abstract dispose(): void;
  36099. /**
  36100. * Does this action manager has pointer triggers
  36101. */
  36102. abstract get hasPointerTriggers(): boolean;
  36103. /**
  36104. * Does this action manager has pick triggers
  36105. */
  36106. abstract get hasPickTriggers(): boolean;
  36107. /**
  36108. * Process a specific trigger
  36109. * @param trigger defines the trigger to process
  36110. * @param evt defines the event details to be processed
  36111. */
  36112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36113. /**
  36114. * Does this action manager handles actions of any of the given triggers
  36115. * @param triggers defines the triggers to be tested
  36116. * @return a boolean indicating whether one (or more) of the triggers is handled
  36117. */
  36118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36119. /**
  36120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36121. * speed.
  36122. * @param triggerA defines the trigger to be tested
  36123. * @param triggerB defines the trigger to be tested
  36124. * @return a boolean indicating whether one (or more) of the triggers is handled
  36125. */
  36126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36127. /**
  36128. * Does this action manager handles actions of a given trigger
  36129. * @param trigger defines the trigger to be tested
  36130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36131. * @return whether the trigger is handled
  36132. */
  36133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36134. /**
  36135. * Serialize this manager to a JSON object
  36136. * @param name defines the property name to store this manager
  36137. * @returns a JSON representation of this manager
  36138. */
  36139. abstract serialize(name: string): any;
  36140. /**
  36141. * Registers an action to this action manager
  36142. * @param action defines the action to be registered
  36143. * @return the action amended (prepared) after registration
  36144. */
  36145. abstract registerAction(action: IAction): Nullable<IAction>;
  36146. /**
  36147. * Unregisters an action to this action manager
  36148. * @param action defines the action to be unregistered
  36149. * @return a boolean indicating whether the action has been unregistered
  36150. */
  36151. abstract unregisterAction(action: IAction): Boolean;
  36152. /**
  36153. * Does exist one action manager with at least one trigger
  36154. **/
  36155. static get HasTriggers(): boolean;
  36156. /**
  36157. * Does exist one action manager with at least one pick trigger
  36158. **/
  36159. static get HasPickTriggers(): boolean;
  36160. /**
  36161. * Does exist one action manager that handles actions of a given trigger
  36162. * @param trigger defines the trigger to be tested
  36163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36164. **/
  36165. static HasSpecificTrigger(trigger: number): boolean;
  36166. }
  36167. }
  36168. declare module BABYLON {
  36169. /**
  36170. * Defines how a node can be built from a string name.
  36171. */
  36172. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36173. /**
  36174. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36175. */
  36176. export class Node implements IBehaviorAware<Node> {
  36177. /** @hidden */
  36178. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36179. private static _NodeConstructors;
  36180. /**
  36181. * Add a new node constructor
  36182. * @param type defines the type name of the node to construct
  36183. * @param constructorFunc defines the constructor function
  36184. */
  36185. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36186. /**
  36187. * Returns a node constructor based on type name
  36188. * @param type defines the type name
  36189. * @param name defines the new node name
  36190. * @param scene defines the hosting scene
  36191. * @param options defines optional options to transmit to constructors
  36192. * @returns the new constructor or null
  36193. */
  36194. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36195. /**
  36196. * Gets or sets the name of the node
  36197. */
  36198. name: string;
  36199. /**
  36200. * Gets or sets the id of the node
  36201. */
  36202. id: string;
  36203. /**
  36204. * Gets or sets the unique id of the node
  36205. */
  36206. uniqueId: number;
  36207. /**
  36208. * Gets or sets a string used to store user defined state for the node
  36209. */
  36210. state: string;
  36211. /**
  36212. * Gets or sets an object used to store user defined information for the node
  36213. */
  36214. metadata: any;
  36215. /**
  36216. * For internal use only. Please do not use.
  36217. */
  36218. reservedDataStore: any;
  36219. /**
  36220. * List of inspectable custom properties (used by the Inspector)
  36221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36222. */
  36223. inspectableCustomProperties: IInspectable[];
  36224. private _doNotSerialize;
  36225. /**
  36226. * Gets or sets a boolean used to define if the node must be serialized
  36227. */
  36228. get doNotSerialize(): boolean;
  36229. set doNotSerialize(value: boolean);
  36230. /** @hidden */
  36231. _isDisposed: boolean;
  36232. /**
  36233. * Gets a list of Animations associated with the node
  36234. */
  36235. animations: Animation[];
  36236. protected _ranges: {
  36237. [name: string]: Nullable<AnimationRange>;
  36238. };
  36239. /**
  36240. * Callback raised when the node is ready to be used
  36241. */
  36242. onReady: Nullable<(node: Node) => void>;
  36243. private _isEnabled;
  36244. private _isParentEnabled;
  36245. private _isReady;
  36246. /** @hidden */
  36247. _currentRenderId: number;
  36248. private _parentUpdateId;
  36249. /** @hidden */
  36250. _childUpdateId: number;
  36251. /** @hidden */
  36252. _waitingParentId: Nullable<string>;
  36253. /** @hidden */
  36254. _scene: Scene;
  36255. /** @hidden */
  36256. _cache: any;
  36257. private _parentNode;
  36258. private _children;
  36259. /** @hidden */
  36260. _worldMatrix: Matrix;
  36261. /** @hidden */
  36262. _worldMatrixDeterminant: number;
  36263. /** @hidden */
  36264. _worldMatrixDeterminantIsDirty: boolean;
  36265. /** @hidden */
  36266. private _sceneRootNodesIndex;
  36267. /**
  36268. * Gets a boolean indicating if the node has been disposed
  36269. * @returns true if the node was disposed
  36270. */
  36271. isDisposed(): boolean;
  36272. /**
  36273. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36274. * @see https://doc.babylonjs.com/how_to/parenting
  36275. */
  36276. set parent(parent: Nullable<Node>);
  36277. get parent(): Nullable<Node>;
  36278. /** @hidden */
  36279. _addToSceneRootNodes(): void;
  36280. /** @hidden */
  36281. _removeFromSceneRootNodes(): void;
  36282. private _animationPropertiesOverride;
  36283. /**
  36284. * Gets or sets the animation properties override
  36285. */
  36286. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36287. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36288. /**
  36289. * Gets a string identifying the name of the class
  36290. * @returns "Node" string
  36291. */
  36292. getClassName(): string;
  36293. /** @hidden */
  36294. readonly _isNode: boolean;
  36295. /**
  36296. * An event triggered when the mesh is disposed
  36297. */
  36298. onDisposeObservable: Observable<Node>;
  36299. private _onDisposeObserver;
  36300. /**
  36301. * Sets a callback that will be raised when the node will be disposed
  36302. */
  36303. set onDispose(callback: () => void);
  36304. /**
  36305. * Creates a new Node
  36306. * @param name the name and id to be given to this node
  36307. * @param scene the scene this node will be added to
  36308. */
  36309. constructor(name: string, scene?: Nullable<Scene>);
  36310. /**
  36311. * Gets the scene of the node
  36312. * @returns a scene
  36313. */
  36314. getScene(): Scene;
  36315. /**
  36316. * Gets the engine of the node
  36317. * @returns a Engine
  36318. */
  36319. getEngine(): Engine;
  36320. private _behaviors;
  36321. /**
  36322. * Attach a behavior to the node
  36323. * @see https://doc.babylonjs.com/features/behaviour
  36324. * @param behavior defines the behavior to attach
  36325. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36326. * @returns the current Node
  36327. */
  36328. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36329. /**
  36330. * Remove an attached behavior
  36331. * @see https://doc.babylonjs.com/features/behaviour
  36332. * @param behavior defines the behavior to attach
  36333. * @returns the current Node
  36334. */
  36335. removeBehavior(behavior: Behavior<Node>): Node;
  36336. /**
  36337. * Gets the list of attached behaviors
  36338. * @see https://doc.babylonjs.com/features/behaviour
  36339. */
  36340. get behaviors(): Behavior<Node>[];
  36341. /**
  36342. * Gets an attached behavior by name
  36343. * @param name defines the name of the behavior to look for
  36344. * @see https://doc.babylonjs.com/features/behaviour
  36345. * @returns null if behavior was not found else the requested behavior
  36346. */
  36347. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36348. /**
  36349. * Returns the latest update of the World matrix
  36350. * @returns a Matrix
  36351. */
  36352. getWorldMatrix(): Matrix;
  36353. /** @hidden */
  36354. _getWorldMatrixDeterminant(): number;
  36355. /**
  36356. * Returns directly the latest state of the mesh World matrix.
  36357. * A Matrix is returned.
  36358. */
  36359. get worldMatrixFromCache(): Matrix;
  36360. /** @hidden */
  36361. _initCache(): void;
  36362. /** @hidden */
  36363. updateCache(force?: boolean): void;
  36364. /** @hidden */
  36365. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36366. /** @hidden */
  36367. _updateCache(ignoreParentClass?: boolean): void;
  36368. /** @hidden */
  36369. _isSynchronized(): boolean;
  36370. /** @hidden */
  36371. _markSyncedWithParent(): void;
  36372. /** @hidden */
  36373. isSynchronizedWithParent(): boolean;
  36374. /** @hidden */
  36375. isSynchronized(): boolean;
  36376. /**
  36377. * Is this node ready to be used/rendered
  36378. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36379. * @return true if the node is ready
  36380. */
  36381. isReady(completeCheck?: boolean): boolean;
  36382. /**
  36383. * Is this node enabled?
  36384. * 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
  36385. * @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
  36386. * @return whether this node (and its parent) is enabled
  36387. */
  36388. isEnabled(checkAncestors?: boolean): boolean;
  36389. /** @hidden */
  36390. protected _syncParentEnabledState(): void;
  36391. /**
  36392. * Set the enabled state of this node
  36393. * @param value defines the new enabled state
  36394. */
  36395. setEnabled(value: boolean): void;
  36396. /**
  36397. * Is this node a descendant of the given node?
  36398. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36399. * @param ancestor defines the parent node to inspect
  36400. * @returns a boolean indicating if this node is a descendant of the given node
  36401. */
  36402. isDescendantOf(ancestor: Node): boolean;
  36403. /** @hidden */
  36404. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36405. /**
  36406. * Will return all nodes that have this node as ascendant
  36407. * @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
  36408. * @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
  36409. * @return all children nodes of all types
  36410. */
  36411. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36412. /**
  36413. * Get all child-meshes of this node
  36414. * @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)
  36415. * @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
  36416. * @returns an array of AbstractMesh
  36417. */
  36418. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36419. /**
  36420. * Get all direct children of this node
  36421. * @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
  36422. * @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)
  36423. * @returns an array of Node
  36424. */
  36425. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36426. /** @hidden */
  36427. _setReady(state: boolean): void;
  36428. /**
  36429. * Get an animation by name
  36430. * @param name defines the name of the animation to look for
  36431. * @returns null if not found else the requested animation
  36432. */
  36433. getAnimationByName(name: string): Nullable<Animation>;
  36434. /**
  36435. * Creates an animation range for this node
  36436. * @param name defines the name of the range
  36437. * @param from defines the starting key
  36438. * @param to defines the end key
  36439. */
  36440. createAnimationRange(name: string, from: number, to: number): void;
  36441. /**
  36442. * Delete a specific animation range
  36443. * @param name defines the name of the range to delete
  36444. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36445. */
  36446. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36447. /**
  36448. * Get an animation range by name
  36449. * @param name defines the name of the animation range to look for
  36450. * @returns null if not found else the requested animation range
  36451. */
  36452. getAnimationRange(name: string): Nullable<AnimationRange>;
  36453. /**
  36454. * Gets the list of all animation ranges defined on this node
  36455. * @returns an array
  36456. */
  36457. getAnimationRanges(): Nullable<AnimationRange>[];
  36458. /**
  36459. * Will start the animation sequence
  36460. * @param name defines the range frames for animation sequence
  36461. * @param loop defines if the animation should loop (false by default)
  36462. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36463. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36464. * @returns the object created for this animation. If range does not exist, it will return null
  36465. */
  36466. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36467. /**
  36468. * Serialize animation ranges into a JSON compatible object
  36469. * @returns serialization object
  36470. */
  36471. serializeAnimationRanges(): any;
  36472. /**
  36473. * Computes the world matrix of the node
  36474. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36475. * @returns the world matrix
  36476. */
  36477. computeWorldMatrix(force?: boolean): Matrix;
  36478. /**
  36479. * Releases resources associated with this node.
  36480. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36481. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36482. */
  36483. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36484. /**
  36485. * Parse animation range data from a serialization object and store them into a given node
  36486. * @param node defines where to store the animation ranges
  36487. * @param parsedNode defines the serialization object to read data from
  36488. * @param scene defines the hosting scene
  36489. */
  36490. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36491. /**
  36492. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36493. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36494. * @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
  36495. * @returns the new bounding vectors
  36496. */
  36497. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36498. min: Vector3;
  36499. max: Vector3;
  36500. };
  36501. }
  36502. }
  36503. declare module BABYLON {
  36504. /**
  36505. * @hidden
  36506. */
  36507. export class _IAnimationState {
  36508. key: number;
  36509. repeatCount: number;
  36510. workValue?: any;
  36511. loopMode?: number;
  36512. offsetValue?: any;
  36513. highLimitValue?: any;
  36514. }
  36515. /**
  36516. * Class used to store any kind of animation
  36517. */
  36518. export class Animation {
  36519. /**Name of the animation */
  36520. name: string;
  36521. /**Property to animate */
  36522. targetProperty: string;
  36523. /**The frames per second of the animation */
  36524. framePerSecond: number;
  36525. /**The data type of the animation */
  36526. dataType: number;
  36527. /**The loop mode of the animation */
  36528. loopMode?: number | undefined;
  36529. /**Specifies if blending should be enabled */
  36530. enableBlending?: boolean | undefined;
  36531. /**
  36532. * Use matrix interpolation instead of using direct key value when animating matrices
  36533. */
  36534. static AllowMatricesInterpolation: boolean;
  36535. /**
  36536. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36537. */
  36538. static AllowMatrixDecomposeForInterpolation: boolean;
  36539. /** Define the Url to load snippets */
  36540. static SnippetUrl: string;
  36541. /** Snippet ID if the animation was created from the snippet server */
  36542. snippetId: string;
  36543. /**
  36544. * Stores the key frames of the animation
  36545. */
  36546. private _keys;
  36547. /**
  36548. * Stores the easing function of the animation
  36549. */
  36550. private _easingFunction;
  36551. /**
  36552. * @hidden Internal use only
  36553. */
  36554. _runtimeAnimations: RuntimeAnimation[];
  36555. /**
  36556. * The set of event that will be linked to this animation
  36557. */
  36558. private _events;
  36559. /**
  36560. * Stores an array of target property paths
  36561. */
  36562. targetPropertyPath: string[];
  36563. /**
  36564. * Stores the blending speed of the animation
  36565. */
  36566. blendingSpeed: number;
  36567. /**
  36568. * Stores the animation ranges for the animation
  36569. */
  36570. private _ranges;
  36571. /**
  36572. * @hidden Internal use
  36573. */
  36574. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36575. /**
  36576. * Sets up an animation
  36577. * @param property The property to animate
  36578. * @param animationType The animation type to apply
  36579. * @param framePerSecond The frames per second of the animation
  36580. * @param easingFunction The easing function used in the animation
  36581. * @returns The created animation
  36582. */
  36583. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36584. /**
  36585. * Create and start an animation on a node
  36586. * @param name defines the name of the global animation that will be run on all nodes
  36587. * @param node defines the root node where the animation will take place
  36588. * @param targetProperty defines property to animate
  36589. * @param framePerSecond defines the number of frame per second yo use
  36590. * @param totalFrame defines the number of frames in total
  36591. * @param from defines the initial value
  36592. * @param to defines the final value
  36593. * @param loopMode defines which loop mode you want to use (off by default)
  36594. * @param easingFunction defines the easing function to use (linear by default)
  36595. * @param onAnimationEnd defines the callback to call when animation end
  36596. * @returns the animatable created for this animation
  36597. */
  36598. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36599. /**
  36600. * Create and start an animation on a node and its descendants
  36601. * @param name defines the name of the global animation that will be run on all nodes
  36602. * @param node defines the root node where the animation will take place
  36603. * @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
  36604. * @param targetProperty defines property to animate
  36605. * @param framePerSecond defines the number of frame per second to use
  36606. * @param totalFrame defines the number of frames in total
  36607. * @param from defines the initial value
  36608. * @param to defines the final value
  36609. * @param loopMode defines which loop mode you want to use (off by default)
  36610. * @param easingFunction defines the easing function to use (linear by default)
  36611. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36612. * @returns the list of animatables created for all nodes
  36613. * @example https://www.babylonjs-playground.com/#MH0VLI
  36614. */
  36615. 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[]>;
  36616. /**
  36617. * Creates a new animation, merges it with the existing animations and starts it
  36618. * @param name Name of the animation
  36619. * @param node Node which contains the scene that begins the animations
  36620. * @param targetProperty Specifies which property to animate
  36621. * @param framePerSecond The frames per second of the animation
  36622. * @param totalFrame The total number of frames
  36623. * @param from The frame at the beginning of the animation
  36624. * @param to The frame at the end of the animation
  36625. * @param loopMode Specifies the loop mode of the animation
  36626. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36627. * @param onAnimationEnd Callback to run once the animation is complete
  36628. * @returns Nullable animation
  36629. */
  36630. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36631. /**
  36632. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36633. * @param sourceAnimation defines the Animation containing keyframes to convert
  36634. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36635. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36636. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36637. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36638. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36639. */
  36640. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36641. /**
  36642. * Transition property of an host to the target Value
  36643. * @param property The property to transition
  36644. * @param targetValue The target Value of the property
  36645. * @param host The object where the property to animate belongs
  36646. * @param scene Scene used to run the animation
  36647. * @param frameRate Framerate (in frame/s) to use
  36648. * @param transition The transition type we want to use
  36649. * @param duration The duration of the animation, in milliseconds
  36650. * @param onAnimationEnd Callback trigger at the end of the animation
  36651. * @returns Nullable animation
  36652. */
  36653. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36654. /**
  36655. * Return the array of runtime animations currently using this animation
  36656. */
  36657. get runtimeAnimations(): RuntimeAnimation[];
  36658. /**
  36659. * Specifies if any of the runtime animations are currently running
  36660. */
  36661. get hasRunningRuntimeAnimations(): boolean;
  36662. /**
  36663. * Initializes the animation
  36664. * @param name Name of the animation
  36665. * @param targetProperty Property to animate
  36666. * @param framePerSecond The frames per second of the animation
  36667. * @param dataType The data type of the animation
  36668. * @param loopMode The loop mode of the animation
  36669. * @param enableBlending Specifies if blending should be enabled
  36670. */
  36671. constructor(
  36672. /**Name of the animation */
  36673. name: string,
  36674. /**Property to animate */
  36675. targetProperty: string,
  36676. /**The frames per second of the animation */
  36677. framePerSecond: number,
  36678. /**The data type of the animation */
  36679. dataType: number,
  36680. /**The loop mode of the animation */
  36681. loopMode?: number | undefined,
  36682. /**Specifies if blending should be enabled */
  36683. enableBlending?: boolean | undefined);
  36684. /**
  36685. * Converts the animation to a string
  36686. * @param fullDetails support for multiple levels of logging within scene loading
  36687. * @returns String form of the animation
  36688. */
  36689. toString(fullDetails?: boolean): string;
  36690. /**
  36691. * Add an event to this animation
  36692. * @param event Event to add
  36693. */
  36694. addEvent(event: AnimationEvent): void;
  36695. /**
  36696. * Remove all events found at the given frame
  36697. * @param frame The frame to remove events from
  36698. */
  36699. removeEvents(frame: number): void;
  36700. /**
  36701. * Retrieves all the events from the animation
  36702. * @returns Events from the animation
  36703. */
  36704. getEvents(): AnimationEvent[];
  36705. /**
  36706. * Creates an animation range
  36707. * @param name Name of the animation range
  36708. * @param from Starting frame of the animation range
  36709. * @param to Ending frame of the animation
  36710. */
  36711. createRange(name: string, from: number, to: number): void;
  36712. /**
  36713. * Deletes an animation range by name
  36714. * @param name Name of the animation range to delete
  36715. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36716. */
  36717. deleteRange(name: string, deleteFrames?: boolean): void;
  36718. /**
  36719. * Gets the animation range by name, or null if not defined
  36720. * @param name Name of the animation range
  36721. * @returns Nullable animation range
  36722. */
  36723. getRange(name: string): Nullable<AnimationRange>;
  36724. /**
  36725. * Gets the key frames from the animation
  36726. * @returns The key frames of the animation
  36727. */
  36728. getKeys(): Array<IAnimationKey>;
  36729. /**
  36730. * Gets the highest frame rate of the animation
  36731. * @returns Highest frame rate of the animation
  36732. */
  36733. getHighestFrame(): number;
  36734. /**
  36735. * Gets the easing function of the animation
  36736. * @returns Easing function of the animation
  36737. */
  36738. getEasingFunction(): IEasingFunction;
  36739. /**
  36740. * Sets the easing function of the animation
  36741. * @param easingFunction A custom mathematical formula for animation
  36742. */
  36743. setEasingFunction(easingFunction: EasingFunction): void;
  36744. /**
  36745. * Interpolates a scalar linearly
  36746. * @param startValue Start value of the animation curve
  36747. * @param endValue End value of the animation curve
  36748. * @param gradient Scalar amount to interpolate
  36749. * @returns Interpolated scalar value
  36750. */
  36751. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36752. /**
  36753. * Interpolates a scalar cubically
  36754. * @param startValue Start value of the animation curve
  36755. * @param outTangent End tangent of the animation
  36756. * @param endValue End value of the animation curve
  36757. * @param inTangent Start tangent of the animation curve
  36758. * @param gradient Scalar amount to interpolate
  36759. * @returns Interpolated scalar value
  36760. */
  36761. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36762. /**
  36763. * Interpolates a quaternion using a spherical linear interpolation
  36764. * @param startValue Start value of the animation curve
  36765. * @param endValue End value of the animation curve
  36766. * @param gradient Scalar amount to interpolate
  36767. * @returns Interpolated quaternion value
  36768. */
  36769. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36770. /**
  36771. * Interpolates a quaternion cubically
  36772. * @param startValue Start value of the animation curve
  36773. * @param outTangent End tangent of the animation curve
  36774. * @param endValue End value of the animation curve
  36775. * @param inTangent Start tangent of the animation curve
  36776. * @param gradient Scalar amount to interpolate
  36777. * @returns Interpolated quaternion value
  36778. */
  36779. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36780. /**
  36781. * Interpolates a Vector3 linearl
  36782. * @param startValue Start value of the animation curve
  36783. * @param endValue End value of the animation curve
  36784. * @param gradient Scalar amount to interpolate
  36785. * @returns Interpolated scalar value
  36786. */
  36787. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36788. /**
  36789. * Interpolates a Vector3 cubically
  36790. * @param startValue Start value of the animation curve
  36791. * @param outTangent End tangent of the animation
  36792. * @param endValue End value of the animation curve
  36793. * @param inTangent Start tangent of the animation curve
  36794. * @param gradient Scalar amount to interpolate
  36795. * @returns InterpolatedVector3 value
  36796. */
  36797. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36798. /**
  36799. * Interpolates a Vector2 linearly
  36800. * @param startValue Start value of the animation curve
  36801. * @param endValue End value of the animation curve
  36802. * @param gradient Scalar amount to interpolate
  36803. * @returns Interpolated Vector2 value
  36804. */
  36805. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36806. /**
  36807. * Interpolates a Vector2 cubically
  36808. * @param startValue Start value of the animation curve
  36809. * @param outTangent End tangent of the animation
  36810. * @param endValue End value of the animation curve
  36811. * @param inTangent Start tangent of the animation curve
  36812. * @param gradient Scalar amount to interpolate
  36813. * @returns Interpolated Vector2 value
  36814. */
  36815. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36816. /**
  36817. * Interpolates a size linearly
  36818. * @param startValue Start value of the animation curve
  36819. * @param endValue End value of the animation curve
  36820. * @param gradient Scalar amount to interpolate
  36821. * @returns Interpolated Size value
  36822. */
  36823. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36824. /**
  36825. * Interpolates a Color3 linearly
  36826. * @param startValue Start value of the animation curve
  36827. * @param endValue End value of the animation curve
  36828. * @param gradient Scalar amount to interpolate
  36829. * @returns Interpolated Color3 value
  36830. */
  36831. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36832. /**
  36833. * Interpolates a Color4 linearly
  36834. * @param startValue Start value of the animation curve
  36835. * @param endValue End value of the animation curve
  36836. * @param gradient Scalar amount to interpolate
  36837. * @returns Interpolated Color3 value
  36838. */
  36839. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36840. /**
  36841. * @hidden Internal use only
  36842. */
  36843. _getKeyValue(value: any): any;
  36844. /**
  36845. * @hidden Internal use only
  36846. */
  36847. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36848. /**
  36849. * Defines the function to use to interpolate matrices
  36850. * @param startValue defines the start matrix
  36851. * @param endValue defines the end matrix
  36852. * @param gradient defines the gradient between both matrices
  36853. * @param result defines an optional target matrix where to store the interpolation
  36854. * @returns the interpolated matrix
  36855. */
  36856. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36857. /**
  36858. * Makes a copy of the animation
  36859. * @returns Cloned animation
  36860. */
  36861. clone(): Animation;
  36862. /**
  36863. * Sets the key frames of the animation
  36864. * @param values The animation key frames to set
  36865. */
  36866. setKeys(values: Array<IAnimationKey>): void;
  36867. /**
  36868. * Serializes the animation to an object
  36869. * @returns Serialized object
  36870. */
  36871. serialize(): any;
  36872. /**
  36873. * Float animation type
  36874. */
  36875. static readonly ANIMATIONTYPE_FLOAT: number;
  36876. /**
  36877. * Vector3 animation type
  36878. */
  36879. static readonly ANIMATIONTYPE_VECTOR3: number;
  36880. /**
  36881. * Quaternion animation type
  36882. */
  36883. static readonly ANIMATIONTYPE_QUATERNION: number;
  36884. /**
  36885. * Matrix animation type
  36886. */
  36887. static readonly ANIMATIONTYPE_MATRIX: number;
  36888. /**
  36889. * Color3 animation type
  36890. */
  36891. static readonly ANIMATIONTYPE_COLOR3: number;
  36892. /**
  36893. * Color3 animation type
  36894. */
  36895. static readonly ANIMATIONTYPE_COLOR4: number;
  36896. /**
  36897. * Vector2 animation type
  36898. */
  36899. static readonly ANIMATIONTYPE_VECTOR2: number;
  36900. /**
  36901. * Size animation type
  36902. */
  36903. static readonly ANIMATIONTYPE_SIZE: number;
  36904. /**
  36905. * Relative Loop Mode
  36906. */
  36907. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36908. /**
  36909. * Cycle Loop Mode
  36910. */
  36911. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36912. /**
  36913. * Constant Loop Mode
  36914. */
  36915. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36916. /** @hidden */
  36917. static _UniversalLerp(left: any, right: any, amount: number): any;
  36918. /**
  36919. * Parses an animation object and creates an animation
  36920. * @param parsedAnimation Parsed animation object
  36921. * @returns Animation object
  36922. */
  36923. static Parse(parsedAnimation: any): Animation;
  36924. /**
  36925. * Appends the serialized animations from the source animations
  36926. * @param source Source containing the animations
  36927. * @param destination Target to store the animations
  36928. */
  36929. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36930. /**
  36931. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36932. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36933. * @param url defines the url to load from
  36934. * @returns a promise that will resolve to the new animation or an array of animations
  36935. */
  36936. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36937. /**
  36938. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36939. * @param snippetId defines the snippet to load
  36940. * @returns a promise that will resolve to the new animation or a new array of animations
  36941. */
  36942. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. /**
  36947. * Interface containing an array of animations
  36948. */
  36949. export interface IAnimatable {
  36950. /**
  36951. * Array of animations
  36952. */
  36953. animations: Nullable<Array<Animation>>;
  36954. }
  36955. }
  36956. declare module BABYLON {
  36957. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36958. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36963. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36965. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36966. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36967. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36968. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36969. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36970. /**
  36971. * Decorator used to define property that can be serialized as reference to a camera
  36972. * @param sourceName defines the name of the property to decorate
  36973. */
  36974. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36975. /**
  36976. * Class used to help serialization objects
  36977. */
  36978. export class SerializationHelper {
  36979. /** @hidden */
  36980. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36981. /** @hidden */
  36982. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36983. /** @hidden */
  36984. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36985. /** @hidden */
  36986. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36987. /**
  36988. * Appends the serialized animations from the source animations
  36989. * @param source Source containing the animations
  36990. * @param destination Target to store the animations
  36991. */
  36992. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36993. /**
  36994. * Static function used to serialized a specific entity
  36995. * @param entity defines the entity to serialize
  36996. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36997. * @returns a JSON compatible object representing the serialization of the entity
  36998. */
  36999. static Serialize<T>(entity: T, serializationObject?: any): any;
  37000. /**
  37001. * Creates a new entity from a serialization data object
  37002. * @param creationFunction defines a function used to instanciated the new entity
  37003. * @param source defines the source serialization data
  37004. * @param scene defines the hosting scene
  37005. * @param rootUrl defines the root url for resources
  37006. * @returns a new entity
  37007. */
  37008. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37009. /**
  37010. * Clones an object
  37011. * @param creationFunction defines the function used to instanciate the new object
  37012. * @param source defines the source object
  37013. * @returns the cloned object
  37014. */
  37015. static Clone<T>(creationFunction: () => T, source: T): T;
  37016. /**
  37017. * Instanciates a new object based on a source one (some data will be shared between both object)
  37018. * @param creationFunction defines the function used to instanciate the new object
  37019. * @param source defines the source object
  37020. * @returns the new object
  37021. */
  37022. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37023. }
  37024. }
  37025. declare module BABYLON {
  37026. /**
  37027. * Base class of all the textures in babylon.
  37028. * It groups all the common properties the materials, post process, lights... might need
  37029. * in order to make a correct use of the texture.
  37030. */
  37031. export class BaseTexture implements IAnimatable {
  37032. /**
  37033. * Default anisotropic filtering level for the application.
  37034. * It is set to 4 as a good tradeoff between perf and quality.
  37035. */
  37036. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37037. /**
  37038. * Gets or sets the unique id of the texture
  37039. */
  37040. uniqueId: number;
  37041. /**
  37042. * Define the name of the texture.
  37043. */
  37044. name: string;
  37045. /**
  37046. * Gets or sets an object used to store user defined information.
  37047. */
  37048. metadata: any;
  37049. /**
  37050. * For internal use only. Please do not use.
  37051. */
  37052. reservedDataStore: any;
  37053. private _hasAlpha;
  37054. /**
  37055. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37056. */
  37057. set hasAlpha(value: boolean);
  37058. get hasAlpha(): boolean;
  37059. /**
  37060. * Defines if the alpha value should be determined via the rgb values.
  37061. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37062. */
  37063. getAlphaFromRGB: boolean;
  37064. /**
  37065. * Intensity or strength of the texture.
  37066. * It is commonly used by materials to fine tune the intensity of the texture
  37067. */
  37068. level: number;
  37069. /**
  37070. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37071. * This is part of the texture as textures usually maps to one uv set.
  37072. */
  37073. coordinatesIndex: number;
  37074. protected _coordinatesMode: number;
  37075. /**
  37076. * How a texture is mapped.
  37077. *
  37078. * | Value | Type | Description |
  37079. * | ----- | ----------------------------------- | ----------- |
  37080. * | 0 | EXPLICIT_MODE | |
  37081. * | 1 | SPHERICAL_MODE | |
  37082. * | 2 | PLANAR_MODE | |
  37083. * | 3 | CUBIC_MODE | |
  37084. * | 4 | PROJECTION_MODE | |
  37085. * | 5 | SKYBOX_MODE | |
  37086. * | 6 | INVCUBIC_MODE | |
  37087. * | 7 | EQUIRECTANGULAR_MODE | |
  37088. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37089. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37090. */
  37091. set coordinatesMode(value: number);
  37092. get coordinatesMode(): number;
  37093. private _wrapU;
  37094. /**
  37095. * | Value | Type | Description |
  37096. * | ----- | ------------------ | ----------- |
  37097. * | 0 | CLAMP_ADDRESSMODE | |
  37098. * | 1 | WRAP_ADDRESSMODE | |
  37099. * | 2 | MIRROR_ADDRESSMODE | |
  37100. */
  37101. get wrapU(): number;
  37102. set wrapU(value: number);
  37103. private _wrapV;
  37104. /**
  37105. * | Value | Type | Description |
  37106. * | ----- | ------------------ | ----------- |
  37107. * | 0 | CLAMP_ADDRESSMODE | |
  37108. * | 1 | WRAP_ADDRESSMODE | |
  37109. * | 2 | MIRROR_ADDRESSMODE | |
  37110. */
  37111. get wrapV(): number;
  37112. set wrapV(value: number);
  37113. /**
  37114. * | Value | Type | Description |
  37115. * | ----- | ------------------ | ----------- |
  37116. * | 0 | CLAMP_ADDRESSMODE | |
  37117. * | 1 | WRAP_ADDRESSMODE | |
  37118. * | 2 | MIRROR_ADDRESSMODE | |
  37119. */
  37120. wrapR: number;
  37121. /**
  37122. * With compliant hardware and browser (supporting anisotropic filtering)
  37123. * this defines the level of anisotropic filtering in the texture.
  37124. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37125. */
  37126. anisotropicFilteringLevel: number;
  37127. /**
  37128. * Define if the texture is a cube texture or if false a 2d texture.
  37129. */
  37130. get isCube(): boolean;
  37131. set isCube(value: boolean);
  37132. /**
  37133. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37134. */
  37135. get is3D(): boolean;
  37136. set is3D(value: boolean);
  37137. /**
  37138. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37139. */
  37140. get is2DArray(): boolean;
  37141. set is2DArray(value: boolean);
  37142. private _gammaSpace;
  37143. /**
  37144. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37145. * HDR texture are usually stored in linear space.
  37146. * This only impacts the PBR and Background materials
  37147. */
  37148. get gammaSpace(): boolean;
  37149. set gammaSpace(gamma: boolean);
  37150. /**
  37151. * Gets or sets whether or not the texture contains RGBD data.
  37152. */
  37153. get isRGBD(): boolean;
  37154. set isRGBD(value: boolean);
  37155. /**
  37156. * Is Z inverted in the texture (useful in a cube texture).
  37157. */
  37158. invertZ: boolean;
  37159. /**
  37160. * Are mip maps generated for this texture or not.
  37161. */
  37162. get noMipmap(): boolean;
  37163. /**
  37164. * @hidden
  37165. */
  37166. lodLevelInAlpha: boolean;
  37167. /**
  37168. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37169. */
  37170. get lodGenerationOffset(): number;
  37171. set lodGenerationOffset(value: number);
  37172. /**
  37173. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37174. */
  37175. get lodGenerationScale(): number;
  37176. set lodGenerationScale(value: number);
  37177. /**
  37178. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37179. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37180. * average roughness values.
  37181. */
  37182. get linearSpecularLOD(): boolean;
  37183. set linearSpecularLOD(value: boolean);
  37184. /**
  37185. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37186. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37187. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37188. */
  37189. get irradianceTexture(): Nullable<BaseTexture>;
  37190. set irradianceTexture(value: Nullable<BaseTexture>);
  37191. /**
  37192. * Define if the texture is a render target.
  37193. */
  37194. isRenderTarget: boolean;
  37195. /**
  37196. * Define the unique id of the texture in the scene.
  37197. */
  37198. get uid(): string;
  37199. /** @hidden */
  37200. _prefiltered: boolean;
  37201. /**
  37202. * Return a string representation of the texture.
  37203. * @returns the texture as a string
  37204. */
  37205. toString(): string;
  37206. /**
  37207. * Get the class name of the texture.
  37208. * @returns "BaseTexture"
  37209. */
  37210. getClassName(): string;
  37211. /**
  37212. * Define the list of animation attached to the texture.
  37213. */
  37214. animations: Animation[];
  37215. /**
  37216. * An event triggered when the texture is disposed.
  37217. */
  37218. onDisposeObservable: Observable<BaseTexture>;
  37219. private _onDisposeObserver;
  37220. /**
  37221. * Callback triggered when the texture has been disposed.
  37222. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37223. */
  37224. set onDispose(callback: () => void);
  37225. /**
  37226. * Define the current state of the loading sequence when in delayed load mode.
  37227. */
  37228. delayLoadState: number;
  37229. protected _scene: Nullable<Scene>;
  37230. protected _engine: Nullable<ThinEngine>;
  37231. /** @hidden */
  37232. _texture: Nullable<InternalTexture>;
  37233. private _uid;
  37234. /**
  37235. * Define if the texture is preventinga material to render or not.
  37236. * If not and the texture is not ready, the engine will use a default black texture instead.
  37237. */
  37238. get isBlocking(): boolean;
  37239. /**
  37240. * Instantiates a new BaseTexture.
  37241. * Base class of all the textures in babylon.
  37242. * It groups all the common properties the materials, post process, lights... might need
  37243. * in order to make a correct use of the texture.
  37244. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37245. */
  37246. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37247. /**
  37248. * Get the scene the texture belongs to.
  37249. * @returns the scene or null if undefined
  37250. */
  37251. getScene(): Nullable<Scene>;
  37252. /** @hidden */
  37253. protected _getEngine(): Nullable<ThinEngine>;
  37254. /**
  37255. * Checks if the texture has the same transform matrix than another texture
  37256. * @param texture texture to check against
  37257. * @returns true if the transforms are the same, else false
  37258. */
  37259. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37260. /**
  37261. * Get the texture transform matrix used to offset tile the texture for istance.
  37262. * @returns the transformation matrix
  37263. */
  37264. getTextureMatrix(): Matrix;
  37265. /**
  37266. * Get the texture reflection matrix used to rotate/transform the reflection.
  37267. * @returns the reflection matrix
  37268. */
  37269. getReflectionTextureMatrix(): Matrix;
  37270. /**
  37271. * Get the underlying lower level texture from Babylon.
  37272. * @returns the insternal texture
  37273. */
  37274. getInternalTexture(): Nullable<InternalTexture>;
  37275. /**
  37276. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37277. * @returns true if ready or not blocking
  37278. */
  37279. isReadyOrNotBlocking(): boolean;
  37280. /**
  37281. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37282. * @returns true if fully ready
  37283. */
  37284. isReady(): boolean;
  37285. private _cachedSize;
  37286. /**
  37287. * Get the size of the texture.
  37288. * @returns the texture size.
  37289. */
  37290. getSize(): ISize;
  37291. /**
  37292. * Get the base size of the texture.
  37293. * It can be different from the size if the texture has been resized for POT for instance
  37294. * @returns the base size
  37295. */
  37296. getBaseSize(): ISize;
  37297. /**
  37298. * Update the sampling mode of the texture.
  37299. * Default is Trilinear mode.
  37300. *
  37301. * | Value | Type | Description |
  37302. * | ----- | ------------------ | ----------- |
  37303. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37304. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37305. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37306. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37307. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37308. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37309. * | 7 | NEAREST_LINEAR | |
  37310. * | 8 | NEAREST_NEAREST | |
  37311. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37312. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37313. * | 11 | LINEAR_LINEAR | |
  37314. * | 12 | LINEAR_NEAREST | |
  37315. *
  37316. * > _mag_: magnification filter (close to the viewer)
  37317. * > _min_: minification filter (far from the viewer)
  37318. * > _mip_: filter used between mip map levels
  37319. *@param samplingMode Define the new sampling mode of the texture
  37320. */
  37321. updateSamplingMode(samplingMode: number): void;
  37322. /**
  37323. * Scales the texture if is `canRescale()`
  37324. * @param ratio the resize factor we want to use to rescale
  37325. */
  37326. scale(ratio: number): void;
  37327. /**
  37328. * Get if the texture can rescale.
  37329. */
  37330. get canRescale(): boolean;
  37331. /** @hidden */
  37332. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37333. /** @hidden */
  37334. _rebuild(): void;
  37335. /**
  37336. * Triggers the load sequence in delayed load mode.
  37337. */
  37338. delayLoad(): void;
  37339. /**
  37340. * Clones the texture.
  37341. * @returns the cloned texture
  37342. */
  37343. clone(): Nullable<BaseTexture>;
  37344. /**
  37345. * Get the texture underlying type (INT, FLOAT...)
  37346. */
  37347. get textureType(): number;
  37348. /**
  37349. * Get the texture underlying format (RGB, RGBA...)
  37350. */
  37351. get textureFormat(): number;
  37352. /**
  37353. * Indicates that textures need to be re-calculated for all materials
  37354. */
  37355. protected _markAllSubMeshesAsTexturesDirty(): void;
  37356. /**
  37357. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37358. * This will returns an RGBA array buffer containing either in values (0-255) or
  37359. * float values (0-1) depending of the underlying buffer type.
  37360. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37361. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37362. * @param buffer defines a user defined buffer to fill with data (can be null)
  37363. * @returns The Array buffer containing the pixels data.
  37364. */
  37365. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37366. /**
  37367. * Release and destroy the underlying lower level texture aka internalTexture.
  37368. */
  37369. releaseInternalTexture(): void;
  37370. /** @hidden */
  37371. get _lodTextureHigh(): Nullable<BaseTexture>;
  37372. /** @hidden */
  37373. get _lodTextureMid(): Nullable<BaseTexture>;
  37374. /** @hidden */
  37375. get _lodTextureLow(): Nullable<BaseTexture>;
  37376. /**
  37377. * Dispose the texture and release its associated resources.
  37378. */
  37379. dispose(): void;
  37380. /**
  37381. * Serialize the texture into a JSON representation that can be parsed later on.
  37382. * @returns the JSON representation of the texture
  37383. */
  37384. serialize(): any;
  37385. /**
  37386. * Helper function to be called back once a list of texture contains only ready textures.
  37387. * @param textures Define the list of textures to wait for
  37388. * @param callback Define the callback triggered once the entire list will be ready
  37389. */
  37390. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37391. private static _isScene;
  37392. }
  37393. }
  37394. declare module BABYLON {
  37395. /**
  37396. * Options to be used when creating an effect.
  37397. */
  37398. export interface IEffectCreationOptions {
  37399. /**
  37400. * Atrributes that will be used in the shader.
  37401. */
  37402. attributes: string[];
  37403. /**
  37404. * Uniform varible names that will be set in the shader.
  37405. */
  37406. uniformsNames: string[];
  37407. /**
  37408. * Uniform buffer variable names that will be set in the shader.
  37409. */
  37410. uniformBuffersNames: string[];
  37411. /**
  37412. * Sampler texture variable names that will be set in the shader.
  37413. */
  37414. samplers: string[];
  37415. /**
  37416. * Define statements that will be set in the shader.
  37417. */
  37418. defines: any;
  37419. /**
  37420. * Possible fallbacks for this effect to improve performance when needed.
  37421. */
  37422. fallbacks: Nullable<IEffectFallbacks>;
  37423. /**
  37424. * Callback that will be called when the shader is compiled.
  37425. */
  37426. onCompiled: Nullable<(effect: Effect) => void>;
  37427. /**
  37428. * Callback that will be called if an error occurs during shader compilation.
  37429. */
  37430. onError: Nullable<(effect: Effect, errors: string) => void>;
  37431. /**
  37432. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37433. */
  37434. indexParameters?: any;
  37435. /**
  37436. * Max number of lights that can be used in the shader.
  37437. */
  37438. maxSimultaneousLights?: number;
  37439. /**
  37440. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37441. */
  37442. transformFeedbackVaryings?: Nullable<string[]>;
  37443. /**
  37444. * 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
  37445. */
  37446. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37447. /**
  37448. * Is this effect rendering to several color attachments ?
  37449. */
  37450. multiTarget?: boolean;
  37451. }
  37452. /**
  37453. * Effect containing vertex and fragment shader that can be executed on an object.
  37454. */
  37455. export class Effect implements IDisposable {
  37456. /**
  37457. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37458. */
  37459. static ShadersRepository: string;
  37460. /**
  37461. * Enable logging of the shader code when a compilation error occurs
  37462. */
  37463. static LogShaderCodeOnCompilationError: boolean;
  37464. /**
  37465. * Name of the effect.
  37466. */
  37467. name: any;
  37468. /**
  37469. * String container all the define statements that should be set on the shader.
  37470. */
  37471. defines: string;
  37472. /**
  37473. * Callback that will be called when the shader is compiled.
  37474. */
  37475. onCompiled: Nullable<(effect: Effect) => void>;
  37476. /**
  37477. * Callback that will be called if an error occurs during shader compilation.
  37478. */
  37479. onError: Nullable<(effect: Effect, errors: string) => void>;
  37480. /**
  37481. * Callback that will be called when effect is bound.
  37482. */
  37483. onBind: Nullable<(effect: Effect) => void>;
  37484. /**
  37485. * Unique ID of the effect.
  37486. */
  37487. uniqueId: number;
  37488. /**
  37489. * Observable that will be called when the shader is compiled.
  37490. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37491. */
  37492. onCompileObservable: Observable<Effect>;
  37493. /**
  37494. * Observable that will be called if an error occurs during shader compilation.
  37495. */
  37496. onErrorObservable: Observable<Effect>;
  37497. /** @hidden */
  37498. _onBindObservable: Nullable<Observable<Effect>>;
  37499. /**
  37500. * @hidden
  37501. * Specifies if the effect was previously ready
  37502. */
  37503. _wasPreviouslyReady: boolean;
  37504. /**
  37505. * Observable that will be called when effect is bound.
  37506. */
  37507. get onBindObservable(): Observable<Effect>;
  37508. /** @hidden */
  37509. _bonesComputationForcedToCPU: boolean;
  37510. /** @hidden */
  37511. _multiTarget: boolean;
  37512. private static _uniqueIdSeed;
  37513. private _engine;
  37514. private _uniformBuffersNames;
  37515. private _uniformBuffersNamesList;
  37516. private _uniformsNames;
  37517. private _samplerList;
  37518. private _samplers;
  37519. private _isReady;
  37520. private _compilationError;
  37521. private _allFallbacksProcessed;
  37522. private _attributesNames;
  37523. private _attributes;
  37524. private _attributeLocationByName;
  37525. private _uniforms;
  37526. /**
  37527. * Key for the effect.
  37528. * @hidden
  37529. */
  37530. _key: string;
  37531. private _indexParameters;
  37532. private _fallbacks;
  37533. private _vertexSourceCode;
  37534. private _fragmentSourceCode;
  37535. private _vertexSourceCodeOverride;
  37536. private _fragmentSourceCodeOverride;
  37537. private _transformFeedbackVaryings;
  37538. /**
  37539. * Compiled shader to webGL program.
  37540. * @hidden
  37541. */
  37542. _pipelineContext: Nullable<IPipelineContext>;
  37543. private _valueCache;
  37544. private static _baseCache;
  37545. /**
  37546. * Instantiates an effect.
  37547. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37548. * @param baseName Name of the effect.
  37549. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37550. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37551. * @param samplers List of sampler variables that will be passed to the shader.
  37552. * @param engine Engine to be used to render the effect
  37553. * @param defines Define statements to be added to the shader.
  37554. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37555. * @param onCompiled Callback that will be called when the shader is compiled.
  37556. * @param onError Callback that will be called if an error occurs during shader compilation.
  37557. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37558. */
  37559. 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);
  37560. private _useFinalCode;
  37561. /**
  37562. * Unique key for this effect
  37563. */
  37564. get key(): string;
  37565. /**
  37566. * If the effect has been compiled and prepared.
  37567. * @returns if the effect is compiled and prepared.
  37568. */
  37569. isReady(): boolean;
  37570. private _isReadyInternal;
  37571. /**
  37572. * The engine the effect was initialized with.
  37573. * @returns the engine.
  37574. */
  37575. getEngine(): Engine;
  37576. /**
  37577. * The pipeline context for this effect
  37578. * @returns the associated pipeline context
  37579. */
  37580. getPipelineContext(): Nullable<IPipelineContext>;
  37581. /**
  37582. * The set of names of attribute variables for the shader.
  37583. * @returns An array of attribute names.
  37584. */
  37585. getAttributesNames(): string[];
  37586. /**
  37587. * Returns the attribute at the given index.
  37588. * @param index The index of the attribute.
  37589. * @returns The location of the attribute.
  37590. */
  37591. getAttributeLocation(index: number): number;
  37592. /**
  37593. * Returns the attribute based on the name of the variable.
  37594. * @param name of the attribute to look up.
  37595. * @returns the attribute location.
  37596. */
  37597. getAttributeLocationByName(name: string): number;
  37598. /**
  37599. * The number of attributes.
  37600. * @returns the numnber of attributes.
  37601. */
  37602. getAttributesCount(): number;
  37603. /**
  37604. * Gets the index of a uniform variable.
  37605. * @param uniformName of the uniform to look up.
  37606. * @returns the index.
  37607. */
  37608. getUniformIndex(uniformName: string): number;
  37609. /**
  37610. * Returns the attribute based on the name of the variable.
  37611. * @param uniformName of the uniform to look up.
  37612. * @returns the location of the uniform.
  37613. */
  37614. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37615. /**
  37616. * Returns an array of sampler variable names
  37617. * @returns The array of sampler variable names.
  37618. */
  37619. getSamplers(): string[];
  37620. /**
  37621. * Returns an array of uniform variable names
  37622. * @returns The array of uniform variable names.
  37623. */
  37624. getUniformNames(): string[];
  37625. /**
  37626. * Returns an array of uniform buffer variable names
  37627. * @returns The array of uniform buffer variable names.
  37628. */
  37629. getUniformBuffersNames(): string[];
  37630. /**
  37631. * Returns the index parameters used to create the effect
  37632. * @returns The index parameters object
  37633. */
  37634. getIndexParameters(): any;
  37635. /**
  37636. * The error from the last compilation.
  37637. * @returns the error string.
  37638. */
  37639. getCompilationError(): string;
  37640. /**
  37641. * Gets a boolean indicating that all fallbacks were used during compilation
  37642. * @returns true if all fallbacks were used
  37643. */
  37644. allFallbacksProcessed(): boolean;
  37645. /**
  37646. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37647. * @param func The callback to be used.
  37648. */
  37649. executeWhenCompiled(func: (effect: Effect) => void): void;
  37650. private _checkIsReady;
  37651. private _loadShader;
  37652. /**
  37653. * Gets the vertex shader source code of this effect
  37654. */
  37655. get vertexSourceCode(): string;
  37656. /**
  37657. * Gets the fragment shader source code of this effect
  37658. */
  37659. get fragmentSourceCode(): string;
  37660. /**
  37661. * Recompiles the webGL program
  37662. * @param vertexSourceCode The source code for the vertex shader.
  37663. * @param fragmentSourceCode The source code for the fragment shader.
  37664. * @param onCompiled Callback called when completed.
  37665. * @param onError Callback called on error.
  37666. * @hidden
  37667. */
  37668. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37669. /**
  37670. * Prepares the effect
  37671. * @hidden
  37672. */
  37673. _prepareEffect(): void;
  37674. private _getShaderCodeAndErrorLine;
  37675. private _processCompilationErrors;
  37676. /**
  37677. * Checks if the effect is supported. (Must be called after compilation)
  37678. */
  37679. get isSupported(): boolean;
  37680. /**
  37681. * Binds a texture to the engine to be used as output of the shader.
  37682. * @param channel Name of the output variable.
  37683. * @param texture Texture to bind.
  37684. * @hidden
  37685. */
  37686. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37687. /**
  37688. * Sets a texture on the engine to be used in the shader.
  37689. * @param channel Name of the sampler variable.
  37690. * @param texture Texture to set.
  37691. */
  37692. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37693. /**
  37694. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37695. * @param channel Name of the sampler variable.
  37696. * @param texture Texture to set.
  37697. */
  37698. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37699. /**
  37700. * Sets an array of textures on the engine to be used in the shader.
  37701. * @param channel Name of the variable.
  37702. * @param textures Textures to set.
  37703. */
  37704. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37705. /**
  37706. * 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)
  37707. * @param channel Name of the sampler variable.
  37708. * @param postProcess Post process to get the input texture from.
  37709. */
  37710. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37711. /**
  37712. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37713. * 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)
  37714. * @param channel Name of the sampler variable.
  37715. * @param postProcess Post process to get the output texture from.
  37716. */
  37717. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37718. /** @hidden */
  37719. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37720. /** @hidden */
  37721. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37722. /** @hidden */
  37723. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37724. /** @hidden */
  37725. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37726. /**
  37727. * Binds a buffer to a uniform.
  37728. * @param buffer Buffer to bind.
  37729. * @param name Name of the uniform variable to bind to.
  37730. */
  37731. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37732. /**
  37733. * Binds block to a uniform.
  37734. * @param blockName Name of the block to bind.
  37735. * @param index Index to bind.
  37736. */
  37737. bindUniformBlock(blockName: string, index: number): void;
  37738. /**
  37739. * Sets an interger value on a uniform variable.
  37740. * @param uniformName Name of the variable.
  37741. * @param value Value to be set.
  37742. * @returns this effect.
  37743. */
  37744. setInt(uniformName: string, value: number): Effect;
  37745. /**
  37746. * Sets an int array on a uniform variable.
  37747. * @param uniformName Name of the variable.
  37748. * @param array array to be set.
  37749. * @returns this effect.
  37750. */
  37751. setIntArray(uniformName: string, array: Int32Array): Effect;
  37752. /**
  37753. * 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)
  37754. * @param uniformName Name of the variable.
  37755. * @param array array to be set.
  37756. * @returns this effect.
  37757. */
  37758. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37759. /**
  37760. * 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)
  37761. * @param uniformName Name of the variable.
  37762. * @param array array to be set.
  37763. * @returns this effect.
  37764. */
  37765. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37766. /**
  37767. * 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)
  37768. * @param uniformName Name of the variable.
  37769. * @param array array to be set.
  37770. * @returns this effect.
  37771. */
  37772. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37773. /**
  37774. * Sets an float array on a uniform variable.
  37775. * @param uniformName Name of the variable.
  37776. * @param array array to be set.
  37777. * @returns this effect.
  37778. */
  37779. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37780. /**
  37781. * 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)
  37782. * @param uniformName Name of the variable.
  37783. * @param array array to be set.
  37784. * @returns this effect.
  37785. */
  37786. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37787. /**
  37788. * 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)
  37789. * @param uniformName Name of the variable.
  37790. * @param array array to be set.
  37791. * @returns this effect.
  37792. */
  37793. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37794. /**
  37795. * 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)
  37796. * @param uniformName Name of the variable.
  37797. * @param array array to be set.
  37798. * @returns this effect.
  37799. */
  37800. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37801. /**
  37802. * Sets an array on a uniform variable.
  37803. * @param uniformName Name of the variable.
  37804. * @param array array to be set.
  37805. * @returns this effect.
  37806. */
  37807. setArray(uniformName: string, array: number[]): Effect;
  37808. /**
  37809. * 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)
  37810. * @param uniformName Name of the variable.
  37811. * @param array array to be set.
  37812. * @returns this effect.
  37813. */
  37814. setArray2(uniformName: string, array: number[]): Effect;
  37815. /**
  37816. * 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)
  37817. * @param uniformName Name of the variable.
  37818. * @param array array to be set.
  37819. * @returns this effect.
  37820. */
  37821. setArray3(uniformName: string, array: number[]): Effect;
  37822. /**
  37823. * 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)
  37824. * @param uniformName Name of the variable.
  37825. * @param array array to be set.
  37826. * @returns this effect.
  37827. */
  37828. setArray4(uniformName: string, array: number[]): Effect;
  37829. /**
  37830. * Sets matrices on a uniform variable.
  37831. * @param uniformName Name of the variable.
  37832. * @param matrices matrices to be set.
  37833. * @returns this effect.
  37834. */
  37835. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37836. /**
  37837. * Sets matrix on a uniform variable.
  37838. * @param uniformName Name of the variable.
  37839. * @param matrix matrix to be set.
  37840. * @returns this effect.
  37841. */
  37842. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37843. /**
  37844. * 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)
  37845. * @param uniformName Name of the variable.
  37846. * @param matrix matrix to be set.
  37847. * @returns this effect.
  37848. */
  37849. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37850. /**
  37851. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37852. * @param uniformName Name of the variable.
  37853. * @param matrix matrix to be set.
  37854. * @returns this effect.
  37855. */
  37856. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37857. /**
  37858. * Sets a float on a uniform variable.
  37859. * @param uniformName Name of the variable.
  37860. * @param value value to be set.
  37861. * @returns this effect.
  37862. */
  37863. setFloat(uniformName: string, value: number): Effect;
  37864. /**
  37865. * Sets a boolean on a uniform variable.
  37866. * @param uniformName Name of the variable.
  37867. * @param bool value to be set.
  37868. * @returns this effect.
  37869. */
  37870. setBool(uniformName: string, bool: boolean): Effect;
  37871. /**
  37872. * Sets a Vector2 on a uniform variable.
  37873. * @param uniformName Name of the variable.
  37874. * @param vector2 vector2 to be set.
  37875. * @returns this effect.
  37876. */
  37877. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37878. /**
  37879. * Sets a float2 on a uniform variable.
  37880. * @param uniformName Name of the variable.
  37881. * @param x First float in float2.
  37882. * @param y Second float in float2.
  37883. * @returns this effect.
  37884. */
  37885. setFloat2(uniformName: string, x: number, y: number): Effect;
  37886. /**
  37887. * Sets a Vector3 on a uniform variable.
  37888. * @param uniformName Name of the variable.
  37889. * @param vector3 Value to be set.
  37890. * @returns this effect.
  37891. */
  37892. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37893. /**
  37894. * Sets a float3 on a uniform variable.
  37895. * @param uniformName Name of the variable.
  37896. * @param x First float in float3.
  37897. * @param y Second float in float3.
  37898. * @param z Third float in float3.
  37899. * @returns this effect.
  37900. */
  37901. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37902. /**
  37903. * Sets a Vector4 on a uniform variable.
  37904. * @param uniformName Name of the variable.
  37905. * @param vector4 Value to be set.
  37906. * @returns this effect.
  37907. */
  37908. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37909. /**
  37910. * Sets a float4 on a uniform variable.
  37911. * @param uniformName Name of the variable.
  37912. * @param x First float in float4.
  37913. * @param y Second float in float4.
  37914. * @param z Third float in float4.
  37915. * @param w Fourth float in float4.
  37916. * @returns this effect.
  37917. */
  37918. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37919. /**
  37920. * Sets a Color3 on a uniform variable.
  37921. * @param uniformName Name of the variable.
  37922. * @param color3 Value to be set.
  37923. * @returns this effect.
  37924. */
  37925. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37926. /**
  37927. * Sets a Color4 on a uniform variable.
  37928. * @param uniformName Name of the variable.
  37929. * @param color3 Value to be set.
  37930. * @param alpha Alpha value to be set.
  37931. * @returns this effect.
  37932. */
  37933. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37934. /**
  37935. * Sets a Color4 on a uniform variable
  37936. * @param uniformName defines the name of the variable
  37937. * @param color4 defines the value to be set
  37938. * @returns this effect.
  37939. */
  37940. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37941. /** Release all associated resources */
  37942. dispose(): void;
  37943. /**
  37944. * This function will add a new shader to the shader store
  37945. * @param name the name of the shader
  37946. * @param pixelShader optional pixel shader content
  37947. * @param vertexShader optional vertex shader content
  37948. */
  37949. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37950. /**
  37951. * Store of each shader (The can be looked up using effect.key)
  37952. */
  37953. static ShadersStore: {
  37954. [key: string]: string;
  37955. };
  37956. /**
  37957. * Store of each included file for a shader (The can be looked up using effect.key)
  37958. */
  37959. static IncludesShadersStore: {
  37960. [key: string]: string;
  37961. };
  37962. /**
  37963. * Resets the cache of effects.
  37964. */
  37965. static ResetCache(): void;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. /**
  37970. * Interface used to describe the capabilities of the engine relatively to the current browser
  37971. */
  37972. export interface EngineCapabilities {
  37973. /** Maximum textures units per fragment shader */
  37974. maxTexturesImageUnits: number;
  37975. /** Maximum texture units per vertex shader */
  37976. maxVertexTextureImageUnits: number;
  37977. /** Maximum textures units in the entire pipeline */
  37978. maxCombinedTexturesImageUnits: number;
  37979. /** Maximum texture size */
  37980. maxTextureSize: number;
  37981. /** Maximum texture samples */
  37982. maxSamples?: number;
  37983. /** Maximum cube texture size */
  37984. maxCubemapTextureSize: number;
  37985. /** Maximum render texture size */
  37986. maxRenderTextureSize: number;
  37987. /** Maximum number of vertex attributes */
  37988. maxVertexAttribs: number;
  37989. /** Maximum number of varyings */
  37990. maxVaryingVectors: number;
  37991. /** Maximum number of uniforms per vertex shader */
  37992. maxVertexUniformVectors: number;
  37993. /** Maximum number of uniforms per fragment shader */
  37994. maxFragmentUniformVectors: number;
  37995. /** Defines if standard derivates (dx/dy) are supported */
  37996. standardDerivatives: boolean;
  37997. /** Defines if s3tc texture compression is supported */
  37998. s3tc?: WEBGL_compressed_texture_s3tc;
  37999. /** Defines if pvrtc texture compression is supported */
  38000. pvrtc: any;
  38001. /** Defines if etc1 texture compression is supported */
  38002. etc1: any;
  38003. /** Defines if etc2 texture compression is supported */
  38004. etc2: any;
  38005. /** Defines if astc texture compression is supported */
  38006. astc: any;
  38007. /** Defines if bptc texture compression is supported */
  38008. bptc: any;
  38009. /** Defines if float textures are supported */
  38010. textureFloat: boolean;
  38011. /** Defines if vertex array objects are supported */
  38012. vertexArrayObject: boolean;
  38013. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38014. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38015. /** Gets the maximum level of anisotropy supported */
  38016. maxAnisotropy: number;
  38017. /** Defines if instancing is supported */
  38018. instancedArrays: boolean;
  38019. /** Defines if 32 bits indices are supported */
  38020. uintIndices: boolean;
  38021. /** Defines if high precision shaders are supported */
  38022. highPrecisionShaderSupported: boolean;
  38023. /** Defines if depth reading in the fragment shader is supported */
  38024. fragmentDepthSupported: boolean;
  38025. /** Defines if float texture linear filtering is supported*/
  38026. textureFloatLinearFiltering: boolean;
  38027. /** Defines if rendering to float textures is supported */
  38028. textureFloatRender: boolean;
  38029. /** Defines if half float textures are supported*/
  38030. textureHalfFloat: boolean;
  38031. /** Defines if half float texture linear filtering is supported*/
  38032. textureHalfFloatLinearFiltering: boolean;
  38033. /** Defines if rendering to half float textures is supported */
  38034. textureHalfFloatRender: boolean;
  38035. /** Defines if textureLOD shader command is supported */
  38036. textureLOD: boolean;
  38037. /** Defines if draw buffers extension is supported */
  38038. drawBuffersExtension: boolean;
  38039. /** Defines if depth textures are supported */
  38040. depthTextureExtension: boolean;
  38041. /** Defines if float color buffer are supported */
  38042. colorBufferFloat: boolean;
  38043. /** Gets disjoint timer query extension (null if not supported) */
  38044. timerQuery?: EXT_disjoint_timer_query;
  38045. /** Defines if timestamp can be used with timer query */
  38046. canUseTimestampForTimerQuery: boolean;
  38047. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38048. multiview?: any;
  38049. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38050. oculusMultiview?: any;
  38051. /** Function used to let the system compiles shaders in background */
  38052. parallelShaderCompile?: {
  38053. COMPLETION_STATUS_KHR: number;
  38054. };
  38055. /** Max number of texture samples for MSAA */
  38056. maxMSAASamples: number;
  38057. /** Defines if the blend min max extension is supported */
  38058. blendMinMax: boolean;
  38059. }
  38060. }
  38061. declare module BABYLON {
  38062. /**
  38063. * @hidden
  38064. **/
  38065. export class DepthCullingState {
  38066. private _isDepthTestDirty;
  38067. private _isDepthMaskDirty;
  38068. private _isDepthFuncDirty;
  38069. private _isCullFaceDirty;
  38070. private _isCullDirty;
  38071. private _isZOffsetDirty;
  38072. private _isFrontFaceDirty;
  38073. private _depthTest;
  38074. private _depthMask;
  38075. private _depthFunc;
  38076. private _cull;
  38077. private _cullFace;
  38078. private _zOffset;
  38079. private _frontFace;
  38080. /**
  38081. * Initializes the state.
  38082. */
  38083. constructor();
  38084. get isDirty(): boolean;
  38085. get zOffset(): number;
  38086. set zOffset(value: number);
  38087. get cullFace(): Nullable<number>;
  38088. set cullFace(value: Nullable<number>);
  38089. get cull(): Nullable<boolean>;
  38090. set cull(value: Nullable<boolean>);
  38091. get depthFunc(): Nullable<number>;
  38092. set depthFunc(value: Nullable<number>);
  38093. get depthMask(): boolean;
  38094. set depthMask(value: boolean);
  38095. get depthTest(): boolean;
  38096. set depthTest(value: boolean);
  38097. get frontFace(): Nullable<number>;
  38098. set frontFace(value: Nullable<number>);
  38099. reset(): void;
  38100. apply(gl: WebGLRenderingContext): void;
  38101. }
  38102. }
  38103. declare module BABYLON {
  38104. /**
  38105. * @hidden
  38106. **/
  38107. export class StencilState {
  38108. /** 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 */
  38109. static readonly ALWAYS: number;
  38110. /** Passed to stencilOperation to specify that stencil value must be kept */
  38111. static readonly KEEP: number;
  38112. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38113. static readonly REPLACE: number;
  38114. private _isStencilTestDirty;
  38115. private _isStencilMaskDirty;
  38116. private _isStencilFuncDirty;
  38117. private _isStencilOpDirty;
  38118. private _stencilTest;
  38119. private _stencilMask;
  38120. private _stencilFunc;
  38121. private _stencilFuncRef;
  38122. private _stencilFuncMask;
  38123. private _stencilOpStencilFail;
  38124. private _stencilOpDepthFail;
  38125. private _stencilOpStencilDepthPass;
  38126. get isDirty(): boolean;
  38127. get stencilFunc(): number;
  38128. set stencilFunc(value: number);
  38129. get stencilFuncRef(): number;
  38130. set stencilFuncRef(value: number);
  38131. get stencilFuncMask(): number;
  38132. set stencilFuncMask(value: number);
  38133. get stencilOpStencilFail(): number;
  38134. set stencilOpStencilFail(value: number);
  38135. get stencilOpDepthFail(): number;
  38136. set stencilOpDepthFail(value: number);
  38137. get stencilOpStencilDepthPass(): number;
  38138. set stencilOpStencilDepthPass(value: number);
  38139. get stencilMask(): number;
  38140. set stencilMask(value: number);
  38141. get stencilTest(): boolean;
  38142. set stencilTest(value: boolean);
  38143. constructor();
  38144. reset(): void;
  38145. apply(gl: WebGLRenderingContext): void;
  38146. }
  38147. }
  38148. declare module BABYLON {
  38149. /**
  38150. * @hidden
  38151. **/
  38152. export class AlphaState {
  38153. private _isAlphaBlendDirty;
  38154. private _isBlendFunctionParametersDirty;
  38155. private _isBlendEquationParametersDirty;
  38156. private _isBlendConstantsDirty;
  38157. private _alphaBlend;
  38158. private _blendFunctionParameters;
  38159. private _blendEquationParameters;
  38160. private _blendConstants;
  38161. /**
  38162. * Initializes the state.
  38163. */
  38164. constructor();
  38165. get isDirty(): boolean;
  38166. get alphaBlend(): boolean;
  38167. set alphaBlend(value: boolean);
  38168. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38169. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38170. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38171. reset(): void;
  38172. apply(gl: WebGLRenderingContext): void;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /** @hidden */
  38177. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38178. attributeProcessor(attribute: string): string;
  38179. varyingProcessor(varying: string, isFragment: boolean): string;
  38180. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38181. }
  38182. }
  38183. declare module BABYLON {
  38184. /**
  38185. * Interface for attribute information associated with buffer instanciation
  38186. */
  38187. export interface InstancingAttributeInfo {
  38188. /**
  38189. * Name of the GLSL attribute
  38190. * if attribute index is not specified, this is used to retrieve the index from the effect
  38191. */
  38192. attributeName: string;
  38193. /**
  38194. * Index/offset of the attribute in the vertex shader
  38195. * if not specified, this will be computes from the name.
  38196. */
  38197. index?: number;
  38198. /**
  38199. * size of the attribute, 1, 2, 3 or 4
  38200. */
  38201. attributeSize: number;
  38202. /**
  38203. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38204. */
  38205. offset: number;
  38206. /**
  38207. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38208. * default to 1
  38209. */
  38210. divisor?: number;
  38211. /**
  38212. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38213. * default is FLOAT
  38214. */
  38215. attributeType?: number;
  38216. /**
  38217. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38218. */
  38219. normalized?: boolean;
  38220. }
  38221. }
  38222. declare module BABYLON {
  38223. interface ThinEngine {
  38224. /**
  38225. * Update a video texture
  38226. * @param texture defines the texture to update
  38227. * @param video defines the video element to use
  38228. * @param invertY defines if data must be stored with Y axis inverted
  38229. */
  38230. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38231. }
  38232. }
  38233. declare module BABYLON {
  38234. interface ThinEngine {
  38235. /**
  38236. * Creates a dynamic texture
  38237. * @param width defines the width of the texture
  38238. * @param height defines the height of the texture
  38239. * @param generateMipMaps defines if the engine should generate the mip levels
  38240. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38241. * @returns the dynamic texture inside an InternalTexture
  38242. */
  38243. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38244. /**
  38245. * Update the content of a dynamic texture
  38246. * @param texture defines the texture to update
  38247. * @param canvas defines the canvas containing the source
  38248. * @param invertY defines if data must be stored with Y axis inverted
  38249. * @param premulAlpha defines if alpha is stored as premultiplied
  38250. * @param format defines the format of the data
  38251. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38252. */
  38253. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38254. }
  38255. }
  38256. declare module BABYLON {
  38257. /**
  38258. * Settings for finer control over video usage
  38259. */
  38260. export interface VideoTextureSettings {
  38261. /**
  38262. * Applies `autoplay` to video, if specified
  38263. */
  38264. autoPlay?: boolean;
  38265. /**
  38266. * Applies `muted` to video, if specified
  38267. */
  38268. muted?: boolean;
  38269. /**
  38270. * Applies `loop` to video, if specified
  38271. */
  38272. loop?: boolean;
  38273. /**
  38274. * Automatically updates internal texture from video at every frame in the render loop
  38275. */
  38276. autoUpdateTexture: boolean;
  38277. /**
  38278. * Image src displayed during the video loading or until the user interacts with the video.
  38279. */
  38280. poster?: string;
  38281. }
  38282. /**
  38283. * If you want to display a video in your scene, this is the special texture for that.
  38284. * This special texture works similar to other textures, with the exception of a few parameters.
  38285. * @see https://doc.babylonjs.com/how_to/video_texture
  38286. */
  38287. export class VideoTexture extends Texture {
  38288. /**
  38289. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38290. */
  38291. readonly autoUpdateTexture: boolean;
  38292. /**
  38293. * The video instance used by the texture internally
  38294. */
  38295. readonly video: HTMLVideoElement;
  38296. private _onUserActionRequestedObservable;
  38297. /**
  38298. * Event triggerd when a dom action is required by the user to play the video.
  38299. * This happens due to recent changes in browser policies preventing video to auto start.
  38300. */
  38301. get onUserActionRequestedObservable(): Observable<Texture>;
  38302. private _generateMipMaps;
  38303. private _stillImageCaptured;
  38304. private _displayingPosterTexture;
  38305. private _settings;
  38306. private _createInternalTextureOnEvent;
  38307. private _frameId;
  38308. private _currentSrc;
  38309. /**
  38310. * Creates a video texture.
  38311. * If you want to display a video in your scene, this is the special texture for that.
  38312. * This special texture works similar to other textures, with the exception of a few parameters.
  38313. * @see https://doc.babylonjs.com/how_to/video_texture
  38314. * @param name optional name, will detect from video source, if not defined
  38315. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38316. * @param scene is obviously the current scene.
  38317. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38318. * @param invertY is false by default but can be used to invert video on Y axis
  38319. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38320. * @param settings allows finer control over video usage
  38321. */
  38322. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38323. private _getName;
  38324. private _getVideo;
  38325. private _createInternalTexture;
  38326. private reset;
  38327. /**
  38328. * @hidden Internal method to initiate `update`.
  38329. */
  38330. _rebuild(): void;
  38331. /**
  38332. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38333. */
  38334. update(): void;
  38335. /**
  38336. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38337. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38338. */
  38339. updateTexture(isVisible: boolean): void;
  38340. protected _updateInternalTexture: () => void;
  38341. /**
  38342. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38343. * @param url New url.
  38344. */
  38345. updateURL(url: string): void;
  38346. /**
  38347. * Clones the texture.
  38348. * @returns the cloned texture
  38349. */
  38350. clone(): VideoTexture;
  38351. /**
  38352. * Dispose the texture and release its associated resources.
  38353. */
  38354. dispose(): void;
  38355. /**
  38356. * Creates a video texture straight from a stream.
  38357. * @param scene Define the scene the texture should be created in
  38358. * @param stream Define the stream the texture should be created from
  38359. * @returns The created video texture as a promise
  38360. */
  38361. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38362. /**
  38363. * Creates a video texture straight from your WebCam video feed.
  38364. * @param scene Define the scene the texture should be created in
  38365. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38366. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38367. * @returns The created video texture as a promise
  38368. */
  38369. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38370. minWidth: number;
  38371. maxWidth: number;
  38372. minHeight: number;
  38373. maxHeight: number;
  38374. deviceId: string;
  38375. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38376. /**
  38377. * Creates a video texture straight from your WebCam video feed.
  38378. * @param scene Define the scene the texture should be created in
  38379. * @param onReady Define a callback to triggered once the texture will be ready
  38380. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38381. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38382. */
  38383. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38384. minWidth: number;
  38385. maxWidth: number;
  38386. minHeight: number;
  38387. maxHeight: number;
  38388. deviceId: string;
  38389. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38390. }
  38391. }
  38392. declare module BABYLON {
  38393. /**
  38394. * Defines the interface used by objects working like Scene
  38395. * @hidden
  38396. */
  38397. export interface ISceneLike {
  38398. _addPendingData(data: any): void;
  38399. _removePendingData(data: any): void;
  38400. offlineProvider: IOfflineProvider;
  38401. }
  38402. /**
  38403. * Information about the current host
  38404. */
  38405. export interface HostInformation {
  38406. /**
  38407. * Defines if the current host is a mobile
  38408. */
  38409. isMobile: boolean;
  38410. }
  38411. /** Interface defining initialization parameters for Engine class */
  38412. export interface EngineOptions extends WebGLContextAttributes {
  38413. /**
  38414. * Defines if the engine should no exceed a specified device ratio
  38415. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38416. */
  38417. limitDeviceRatio?: number;
  38418. /**
  38419. * Defines if webvr should be enabled automatically
  38420. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38421. */
  38422. autoEnableWebVR?: boolean;
  38423. /**
  38424. * Defines if webgl2 should be turned off even if supported
  38425. * @see https://doc.babylonjs.com/features/webgl2
  38426. */
  38427. disableWebGL2Support?: boolean;
  38428. /**
  38429. * Defines if webaudio should be initialized as well
  38430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38431. */
  38432. audioEngine?: boolean;
  38433. /**
  38434. * Defines if animations should run using a deterministic lock step
  38435. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38436. */
  38437. deterministicLockstep?: boolean;
  38438. /** Defines the maximum steps to use with deterministic lock step mode */
  38439. lockstepMaxSteps?: number;
  38440. /** Defines the seconds between each deterministic lock step */
  38441. timeStep?: number;
  38442. /**
  38443. * Defines that engine should ignore context lost events
  38444. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38445. */
  38446. doNotHandleContextLost?: boolean;
  38447. /**
  38448. * Defines that engine should ignore modifying touch action attribute and style
  38449. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38450. */
  38451. doNotHandleTouchAction?: boolean;
  38452. /**
  38453. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38454. */
  38455. useHighPrecisionFloats?: boolean;
  38456. /**
  38457. * Make the canvas XR Compatible for XR sessions
  38458. */
  38459. xrCompatible?: boolean;
  38460. /**
  38461. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38462. */
  38463. useHighPrecisionMatrix?: boolean;
  38464. /**
  38465. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38466. */
  38467. failIfMajorPerformanceCaveat?: boolean;
  38468. }
  38469. /**
  38470. * The base engine class (root of all engines)
  38471. */
  38472. export class ThinEngine {
  38473. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38474. static ExceptionList: ({
  38475. key: string;
  38476. capture: string;
  38477. captureConstraint: number;
  38478. targets: string[];
  38479. } | {
  38480. key: string;
  38481. capture: null;
  38482. captureConstraint: null;
  38483. targets: string[];
  38484. })[];
  38485. /** @hidden */
  38486. static _TextureLoaders: IInternalTextureLoader[];
  38487. /**
  38488. * Returns the current npm package of the sdk
  38489. */
  38490. static get NpmPackage(): string;
  38491. /**
  38492. * Returns the current version of the framework
  38493. */
  38494. static get Version(): string;
  38495. /**
  38496. * Returns a string describing the current engine
  38497. */
  38498. get description(): string;
  38499. /**
  38500. * Gets or sets the epsilon value used by collision engine
  38501. */
  38502. static CollisionsEpsilon: number;
  38503. /**
  38504. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38505. */
  38506. static get ShadersRepository(): string;
  38507. static set ShadersRepository(value: string);
  38508. /** @hidden */
  38509. _shaderProcessor: IShaderProcessor;
  38510. /**
  38511. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38512. */
  38513. forcePOTTextures: boolean;
  38514. /**
  38515. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38516. */
  38517. isFullscreen: boolean;
  38518. /**
  38519. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38520. */
  38521. cullBackFaces: boolean;
  38522. /**
  38523. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38524. */
  38525. renderEvenInBackground: boolean;
  38526. /**
  38527. * Gets or sets a boolean indicating that cache can be kept between frames
  38528. */
  38529. preventCacheWipeBetweenFrames: boolean;
  38530. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38531. validateShaderPrograms: boolean;
  38532. /**
  38533. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38534. * This can provide greater z depth for distant objects.
  38535. */
  38536. useReverseDepthBuffer: boolean;
  38537. /**
  38538. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38539. */
  38540. disableUniformBuffers: boolean;
  38541. /** @hidden */
  38542. _uniformBuffers: UniformBuffer[];
  38543. /**
  38544. * Gets a boolean indicating that the engine supports uniform buffers
  38545. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38546. */
  38547. get supportsUniformBuffers(): boolean;
  38548. /** @hidden */
  38549. _gl: WebGLRenderingContext;
  38550. /** @hidden */
  38551. _webGLVersion: number;
  38552. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38553. protected _windowIsBackground: boolean;
  38554. protected _creationOptions: EngineOptions;
  38555. protected _highPrecisionShadersAllowed: boolean;
  38556. /** @hidden */
  38557. get _shouldUseHighPrecisionShader(): boolean;
  38558. /**
  38559. * Gets a boolean indicating that only power of 2 textures are supported
  38560. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38561. */
  38562. get needPOTTextures(): boolean;
  38563. /** @hidden */
  38564. _badOS: boolean;
  38565. /** @hidden */
  38566. _badDesktopOS: boolean;
  38567. private _hardwareScalingLevel;
  38568. /** @hidden */
  38569. _caps: EngineCapabilities;
  38570. private _isStencilEnable;
  38571. private _glVersion;
  38572. private _glRenderer;
  38573. private _glVendor;
  38574. /** @hidden */
  38575. _videoTextureSupported: boolean;
  38576. protected _renderingQueueLaunched: boolean;
  38577. protected _activeRenderLoops: (() => void)[];
  38578. /**
  38579. * Observable signaled when a context lost event is raised
  38580. */
  38581. onContextLostObservable: Observable<ThinEngine>;
  38582. /**
  38583. * Observable signaled when a context restored event is raised
  38584. */
  38585. onContextRestoredObservable: Observable<ThinEngine>;
  38586. private _onContextLost;
  38587. private _onContextRestored;
  38588. protected _contextWasLost: boolean;
  38589. /** @hidden */
  38590. _doNotHandleContextLost: boolean;
  38591. /**
  38592. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38593. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38594. */
  38595. get doNotHandleContextLost(): boolean;
  38596. set doNotHandleContextLost(value: boolean);
  38597. /**
  38598. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38599. */
  38600. disableVertexArrayObjects: boolean;
  38601. /** @hidden */
  38602. protected _colorWrite: boolean;
  38603. /** @hidden */
  38604. protected _colorWriteChanged: boolean;
  38605. /** @hidden */
  38606. protected _depthCullingState: DepthCullingState;
  38607. /** @hidden */
  38608. protected _stencilState: StencilState;
  38609. /** @hidden */
  38610. _alphaState: AlphaState;
  38611. /** @hidden */
  38612. _alphaMode: number;
  38613. /** @hidden */
  38614. _alphaEquation: number;
  38615. /** @hidden */
  38616. _internalTexturesCache: InternalTexture[];
  38617. /** @hidden */
  38618. protected _activeChannel: number;
  38619. private _currentTextureChannel;
  38620. /** @hidden */
  38621. protected _boundTexturesCache: {
  38622. [key: string]: Nullable<InternalTexture>;
  38623. };
  38624. /** @hidden */
  38625. protected _currentEffect: Nullable<Effect>;
  38626. /** @hidden */
  38627. protected _currentProgram: Nullable<WebGLProgram>;
  38628. private _compiledEffects;
  38629. private _vertexAttribArraysEnabled;
  38630. /** @hidden */
  38631. protected _cachedViewport: Nullable<IViewportLike>;
  38632. private _cachedVertexArrayObject;
  38633. /** @hidden */
  38634. protected _cachedVertexBuffers: any;
  38635. /** @hidden */
  38636. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38637. /** @hidden */
  38638. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38639. /** @hidden */
  38640. _currentRenderTarget: Nullable<InternalTexture>;
  38641. private _uintIndicesCurrentlySet;
  38642. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38643. /** @hidden */
  38644. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38645. /** @hidden */
  38646. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38647. private _currentBufferPointers;
  38648. private _currentInstanceLocations;
  38649. private _currentInstanceBuffers;
  38650. private _textureUnits;
  38651. /** @hidden */
  38652. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38653. /** @hidden */
  38654. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38655. /** @hidden */
  38656. _boundRenderFunction: any;
  38657. private _vaoRecordInProgress;
  38658. private _mustWipeVertexAttributes;
  38659. private _emptyTexture;
  38660. private _emptyCubeTexture;
  38661. private _emptyTexture3D;
  38662. private _emptyTexture2DArray;
  38663. /** @hidden */
  38664. _frameHandler: number;
  38665. private _nextFreeTextureSlots;
  38666. private _maxSimultaneousTextures;
  38667. private _activeRequests;
  38668. /** @hidden */
  38669. _transformTextureUrl: Nullable<(url: string) => string>;
  38670. /**
  38671. * Gets information about the current host
  38672. */
  38673. hostInformation: HostInformation;
  38674. protected get _supportsHardwareTextureRescaling(): boolean;
  38675. private _framebufferDimensionsObject;
  38676. /**
  38677. * sets the object from which width and height will be taken from when getting render width and height
  38678. * Will fallback to the gl object
  38679. * @param dimensions the framebuffer width and height that will be used.
  38680. */
  38681. set framebufferDimensionsObject(dimensions: Nullable<{
  38682. framebufferWidth: number;
  38683. framebufferHeight: number;
  38684. }>);
  38685. /**
  38686. * Gets the current viewport
  38687. */
  38688. get currentViewport(): Nullable<IViewportLike>;
  38689. /**
  38690. * Gets the default empty texture
  38691. */
  38692. get emptyTexture(): InternalTexture;
  38693. /**
  38694. * Gets the default empty 3D texture
  38695. */
  38696. get emptyTexture3D(): InternalTexture;
  38697. /**
  38698. * Gets the default empty 2D array texture
  38699. */
  38700. get emptyTexture2DArray(): InternalTexture;
  38701. /**
  38702. * Gets the default empty cube texture
  38703. */
  38704. get emptyCubeTexture(): InternalTexture;
  38705. /**
  38706. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38707. */
  38708. readonly premultipliedAlpha: boolean;
  38709. /**
  38710. * Observable event triggered before each texture is initialized
  38711. */
  38712. onBeforeTextureInitObservable: Observable<Texture>;
  38713. /**
  38714. * Creates a new engine
  38715. * @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
  38716. * @param antialias defines enable antialiasing (default: false)
  38717. * @param options defines further options to be sent to the getContext() function
  38718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38719. */
  38720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38721. private _rebuildInternalTextures;
  38722. private _rebuildEffects;
  38723. /**
  38724. * Gets a boolean indicating if all created effects are ready
  38725. * @returns true if all effects are ready
  38726. */
  38727. areAllEffectsReady(): boolean;
  38728. protected _rebuildBuffers(): void;
  38729. protected _initGLContext(): void;
  38730. /**
  38731. * Gets version of the current webGL context
  38732. */
  38733. get webGLVersion(): number;
  38734. /**
  38735. * Gets a string identifying the name of the class
  38736. * @returns "Engine" string
  38737. */
  38738. getClassName(): string;
  38739. /**
  38740. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38741. */
  38742. get isStencilEnable(): boolean;
  38743. /** @hidden */
  38744. _prepareWorkingCanvas(): void;
  38745. /**
  38746. * Reset the texture cache to empty state
  38747. */
  38748. resetTextureCache(): void;
  38749. /**
  38750. * Gets an object containing information about the current webGL context
  38751. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38752. */
  38753. getGlInfo(): {
  38754. vendor: string;
  38755. renderer: string;
  38756. version: string;
  38757. };
  38758. /**
  38759. * Defines the hardware scaling level.
  38760. * By default the hardware scaling level is computed from the window device ratio.
  38761. * 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.
  38762. * @param level defines the level to use
  38763. */
  38764. setHardwareScalingLevel(level: number): void;
  38765. /**
  38766. * Gets the current hardware scaling level.
  38767. * By default the hardware scaling level is computed from the window device ratio.
  38768. * 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.
  38769. * @returns a number indicating the current hardware scaling level
  38770. */
  38771. getHardwareScalingLevel(): number;
  38772. /**
  38773. * Gets the list of loaded textures
  38774. * @returns an array containing all loaded textures
  38775. */
  38776. getLoadedTexturesCache(): InternalTexture[];
  38777. /**
  38778. * Gets the object containing all engine capabilities
  38779. * @returns the EngineCapabilities object
  38780. */
  38781. getCaps(): EngineCapabilities;
  38782. /**
  38783. * stop executing a render loop function and remove it from the execution array
  38784. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38785. */
  38786. stopRenderLoop(renderFunction?: () => void): void;
  38787. /** @hidden */
  38788. _renderLoop(): void;
  38789. /**
  38790. * Gets the HTML canvas attached with the current webGL context
  38791. * @returns a HTML canvas
  38792. */
  38793. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38794. /**
  38795. * Gets host window
  38796. * @returns the host window object
  38797. */
  38798. getHostWindow(): Nullable<Window>;
  38799. /**
  38800. * Gets the current render width
  38801. * @param useScreen defines if screen size must be used (or the current render target if any)
  38802. * @returns a number defining the current render width
  38803. */
  38804. getRenderWidth(useScreen?: boolean): number;
  38805. /**
  38806. * Gets the current render height
  38807. * @param useScreen defines if screen size must be used (or the current render target if any)
  38808. * @returns a number defining the current render height
  38809. */
  38810. getRenderHeight(useScreen?: boolean): number;
  38811. /**
  38812. * Can be used to override the current requestAnimationFrame requester.
  38813. * @hidden
  38814. */
  38815. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38816. /**
  38817. * Register and execute a render loop. The engine can have more than one render function
  38818. * @param renderFunction defines the function to continuously execute
  38819. */
  38820. runRenderLoop(renderFunction: () => void): void;
  38821. /**
  38822. * Clear the current render buffer or the current render target (if any is set up)
  38823. * @param color defines the color to use
  38824. * @param backBuffer defines if the back buffer must be cleared
  38825. * @param depth defines if the depth buffer must be cleared
  38826. * @param stencil defines if the stencil buffer must be cleared
  38827. */
  38828. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38829. private _viewportCached;
  38830. /** @hidden */
  38831. _viewport(x: number, y: number, width: number, height: number): void;
  38832. /**
  38833. * Set the WebGL's viewport
  38834. * @param viewport defines the viewport element to be used
  38835. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38836. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38837. */
  38838. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38839. /**
  38840. * Begin a new frame
  38841. */
  38842. beginFrame(): void;
  38843. /**
  38844. * Enf the current frame
  38845. */
  38846. endFrame(): void;
  38847. /**
  38848. * Resize the view according to the canvas' size
  38849. */
  38850. resize(): void;
  38851. /**
  38852. * Force a specific size of the canvas
  38853. * @param width defines the new canvas' width
  38854. * @param height defines the new canvas' height
  38855. * @returns true if the size was changed
  38856. */
  38857. setSize(width: number, height: number): boolean;
  38858. /**
  38859. * Binds the frame buffer to the specified texture.
  38860. * @param texture The texture to render to or null for the default canvas
  38861. * @param faceIndex The face of the texture to render to in case of cube texture
  38862. * @param requiredWidth The width of the target to render to
  38863. * @param requiredHeight The height of the target to render to
  38864. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38865. * @param lodLevel defines the lod level to bind to the frame buffer
  38866. * @param layer defines the 2d array index to bind to frame buffer to
  38867. */
  38868. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38869. /** @hidden */
  38870. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38871. /**
  38872. * Unbind the current render target texture from the webGL context
  38873. * @param texture defines the render target texture to unbind
  38874. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38875. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38876. */
  38877. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38878. /**
  38879. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38880. */
  38881. flushFramebuffer(): void;
  38882. /**
  38883. * Unbind the current render target and bind the default framebuffer
  38884. */
  38885. restoreDefaultFramebuffer(): void;
  38886. /** @hidden */
  38887. protected _resetVertexBufferBinding(): void;
  38888. /**
  38889. * Creates a vertex buffer
  38890. * @param data the data for the vertex buffer
  38891. * @returns the new WebGL static buffer
  38892. */
  38893. createVertexBuffer(data: DataArray): DataBuffer;
  38894. private _createVertexBuffer;
  38895. /**
  38896. * Creates a dynamic vertex buffer
  38897. * @param data the data for the dynamic vertex buffer
  38898. * @returns the new WebGL dynamic buffer
  38899. */
  38900. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38901. protected _resetIndexBufferBinding(): void;
  38902. /**
  38903. * Creates a new index buffer
  38904. * @param indices defines the content of the index buffer
  38905. * @param updatable defines if the index buffer must be updatable
  38906. * @returns a new webGL buffer
  38907. */
  38908. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38909. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38910. /**
  38911. * Bind a webGL buffer to the webGL context
  38912. * @param buffer defines the buffer to bind
  38913. */
  38914. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38915. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38916. private bindBuffer;
  38917. /**
  38918. * update the bound buffer with the given data
  38919. * @param data defines the data to update
  38920. */
  38921. updateArrayBuffer(data: Float32Array): void;
  38922. private _vertexAttribPointer;
  38923. /** @hidden */
  38924. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38925. private _bindVertexBuffersAttributes;
  38926. /**
  38927. * Records a vertex array object
  38928. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38929. * @param vertexBuffers defines the list of vertex buffers to store
  38930. * @param indexBuffer defines the index buffer to store
  38931. * @param effect defines the effect to store
  38932. * @returns the new vertex array object
  38933. */
  38934. recordVertexArrayObject(vertexBuffers: {
  38935. [key: string]: VertexBuffer;
  38936. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38937. /**
  38938. * Bind a specific vertex array object
  38939. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38940. * @param vertexArrayObject defines the vertex array object to bind
  38941. * @param indexBuffer defines the index buffer to bind
  38942. */
  38943. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38944. /**
  38945. * Bind webGl buffers directly to the webGL context
  38946. * @param vertexBuffer defines the vertex buffer to bind
  38947. * @param indexBuffer defines the index buffer to bind
  38948. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38949. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38950. * @param effect defines the effect associated with the vertex buffer
  38951. */
  38952. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38953. private _unbindVertexArrayObject;
  38954. /**
  38955. * Bind a list of vertex buffers to the webGL context
  38956. * @param vertexBuffers defines the list of vertex buffers to bind
  38957. * @param indexBuffer defines the index buffer to bind
  38958. * @param effect defines the effect associated with the vertex buffers
  38959. */
  38960. bindBuffers(vertexBuffers: {
  38961. [key: string]: Nullable<VertexBuffer>;
  38962. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38963. /**
  38964. * Unbind all instance attributes
  38965. */
  38966. unbindInstanceAttributes(): void;
  38967. /**
  38968. * Release and free the memory of a vertex array object
  38969. * @param vao defines the vertex array object to delete
  38970. */
  38971. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38972. /** @hidden */
  38973. _releaseBuffer(buffer: DataBuffer): boolean;
  38974. protected _deleteBuffer(buffer: DataBuffer): void;
  38975. /**
  38976. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38977. * @param instancesBuffer defines the webGL buffer to update and bind
  38978. * @param data defines the data to store in the buffer
  38979. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38980. */
  38981. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38982. /**
  38983. * Bind the content of a webGL buffer used with instantiation
  38984. * @param instancesBuffer defines the webGL buffer to bind
  38985. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38986. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38987. */
  38988. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38989. /**
  38990. * Disable the instance attribute corresponding to the name in parameter
  38991. * @param name defines the name of the attribute to disable
  38992. */
  38993. disableInstanceAttributeByName(name: string): void;
  38994. /**
  38995. * Disable the instance attribute corresponding to the location in parameter
  38996. * @param attributeLocation defines the attribute location of the attribute to disable
  38997. */
  38998. disableInstanceAttribute(attributeLocation: number): void;
  38999. /**
  39000. * Disable the attribute corresponding to the location in parameter
  39001. * @param attributeLocation defines the attribute location of the attribute to disable
  39002. */
  39003. disableAttributeByIndex(attributeLocation: number): void;
  39004. /**
  39005. * Send a draw order
  39006. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39007. * @param indexStart defines the starting index
  39008. * @param indexCount defines the number of index to draw
  39009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39010. */
  39011. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39012. /**
  39013. * Draw a list of points
  39014. * @param verticesStart defines the index of first vertex to draw
  39015. * @param verticesCount defines the count of vertices to draw
  39016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39017. */
  39018. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39019. /**
  39020. * Draw a list of unindexed primitives
  39021. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39022. * @param verticesStart defines the index of first vertex to draw
  39023. * @param verticesCount defines the count of vertices to draw
  39024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39025. */
  39026. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39027. /**
  39028. * Draw a list of indexed primitives
  39029. * @param fillMode defines the primitive to use
  39030. * @param indexStart defines the starting index
  39031. * @param indexCount defines the number of index to draw
  39032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39033. */
  39034. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39035. /**
  39036. * Draw a list of unindexed primitives
  39037. * @param fillMode defines the primitive to use
  39038. * @param verticesStart defines the index of first vertex to draw
  39039. * @param verticesCount defines the count of vertices to draw
  39040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39041. */
  39042. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39043. private _drawMode;
  39044. /** @hidden */
  39045. protected _reportDrawCall(): void;
  39046. /** @hidden */
  39047. _releaseEffect(effect: Effect): void;
  39048. /** @hidden */
  39049. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39050. /**
  39051. * Create a new effect (used to store vertex/fragment shaders)
  39052. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39053. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39054. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39055. * @param samplers defines an array of string used to represent textures
  39056. * @param defines defines the string containing the defines to use to compile the shaders
  39057. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39058. * @param onCompiled defines a function to call when the effect creation is successful
  39059. * @param onError defines a function to call when the effect creation has failed
  39060. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39061. * @returns the new Effect
  39062. */
  39063. 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;
  39064. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39065. private _compileShader;
  39066. private _compileRawShader;
  39067. /** @hidden */
  39068. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39069. /**
  39070. * Directly creates a webGL program
  39071. * @param pipelineContext defines the pipeline context to attach to
  39072. * @param vertexCode defines the vertex shader code to use
  39073. * @param fragmentCode defines the fragment shader code to use
  39074. * @param context defines the webGL context to use (if not set, the current one will be used)
  39075. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39076. * @returns the new webGL program
  39077. */
  39078. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39079. /**
  39080. * Creates a webGL program
  39081. * @param pipelineContext defines the pipeline context to attach to
  39082. * @param vertexCode defines the vertex shader code to use
  39083. * @param fragmentCode defines the fragment shader code to use
  39084. * @param defines defines the string containing the defines to use to compile the shaders
  39085. * @param context defines the webGL context to use (if not set, the current one will be used)
  39086. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39087. * @returns the new webGL program
  39088. */
  39089. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39090. /**
  39091. * Creates a new pipeline context
  39092. * @returns the new pipeline
  39093. */
  39094. createPipelineContext(): IPipelineContext;
  39095. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39096. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39097. /** @hidden */
  39098. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39099. /** @hidden */
  39100. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39101. /** @hidden */
  39102. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39103. /**
  39104. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39105. * @param pipelineContext defines the pipeline context to use
  39106. * @param uniformsNames defines the list of uniform names
  39107. * @returns an array of webGL uniform locations
  39108. */
  39109. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39110. /**
  39111. * Gets the lsit of active attributes for a given webGL program
  39112. * @param pipelineContext defines the pipeline context to use
  39113. * @param attributesNames defines the list of attribute names to get
  39114. * @returns an array of indices indicating the offset of each attribute
  39115. */
  39116. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39117. /**
  39118. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39119. * @param effect defines the effect to activate
  39120. */
  39121. enableEffect(effect: Nullable<Effect>): void;
  39122. /**
  39123. * Set the value of an uniform to a number (int)
  39124. * @param uniform defines the webGL uniform location where to store the value
  39125. * @param value defines the int number to store
  39126. * @returns true if the value was set
  39127. */
  39128. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39129. /**
  39130. * Set the value of an uniform to an array of int32
  39131. * @param uniform defines the webGL uniform location where to store the value
  39132. * @param array defines the array of int32 to store
  39133. * @returns true if the value was set
  39134. */
  39135. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39136. /**
  39137. * Set the value of an uniform to an array of int32 (stored as vec2)
  39138. * @param uniform defines the webGL uniform location where to store the value
  39139. * @param array defines the array of int32 to store
  39140. * @returns true if the value was set
  39141. */
  39142. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39143. /**
  39144. * Set the value of an uniform to an array of int32 (stored as vec3)
  39145. * @param uniform defines the webGL uniform location where to store the value
  39146. * @param array defines the array of int32 to store
  39147. * @returns true if the value was set
  39148. */
  39149. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39150. /**
  39151. * Set the value of an uniform to an array of int32 (stored as vec4)
  39152. * @param uniform defines the webGL uniform location where to store the value
  39153. * @param array defines the array of int32 to store
  39154. * @returns true if the value was set
  39155. */
  39156. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39157. /**
  39158. * Set the value of an uniform to an array of number
  39159. * @param uniform defines the webGL uniform location where to store the value
  39160. * @param array defines the array of number to store
  39161. * @returns true if the value was set
  39162. */
  39163. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39164. /**
  39165. * Set the value of an uniform to an array of number (stored as vec2)
  39166. * @param uniform defines the webGL uniform location where to store the value
  39167. * @param array defines the array of number to store
  39168. * @returns true if the value was set
  39169. */
  39170. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39171. /**
  39172. * Set the value of an uniform to an array of number (stored as vec3)
  39173. * @param uniform defines the webGL uniform location where to store the value
  39174. * @param array defines the array of number to store
  39175. * @returns true if the value was set
  39176. */
  39177. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39178. /**
  39179. * Set the value of an uniform to an array of number (stored as vec4)
  39180. * @param uniform defines the webGL uniform location where to store the value
  39181. * @param array defines the array of number to store
  39182. * @returns true if the value was set
  39183. */
  39184. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39185. /**
  39186. * Set the value of an uniform to an array of float32 (stored as matrices)
  39187. * @param uniform defines the webGL uniform location where to store the value
  39188. * @param matrices defines the array of float32 to store
  39189. * @returns true if the value was set
  39190. */
  39191. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39192. /**
  39193. * Set the value of an uniform to a matrix (3x3)
  39194. * @param uniform defines the webGL uniform location where to store the value
  39195. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39196. * @returns true if the value was set
  39197. */
  39198. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39199. /**
  39200. * Set the value of an uniform to a matrix (2x2)
  39201. * @param uniform defines the webGL uniform location where to store the value
  39202. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39203. * @returns true if the value was set
  39204. */
  39205. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39206. /**
  39207. * Set the value of an uniform to a number (float)
  39208. * @param uniform defines the webGL uniform location where to store the value
  39209. * @param value defines the float number to store
  39210. * @returns true if the value was transfered
  39211. */
  39212. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39213. /**
  39214. * Set the value of an uniform to a vec2
  39215. * @param uniform defines the webGL uniform location where to store the value
  39216. * @param x defines the 1st component of the value
  39217. * @param y defines the 2nd component of the value
  39218. * @returns true if the value was set
  39219. */
  39220. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39221. /**
  39222. * Set the value of an uniform to a vec3
  39223. * @param uniform defines the webGL uniform location where to store the value
  39224. * @param x defines the 1st component of the value
  39225. * @param y defines the 2nd component of the value
  39226. * @param z defines the 3rd component of the value
  39227. * @returns true if the value was set
  39228. */
  39229. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39230. /**
  39231. * Set the value of an uniform to a vec4
  39232. * @param uniform defines the webGL uniform location where to store the value
  39233. * @param x defines the 1st component of the value
  39234. * @param y defines the 2nd component of the value
  39235. * @param z defines the 3rd component of the value
  39236. * @param w defines the 4th component of the value
  39237. * @returns true if the value was set
  39238. */
  39239. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39240. /**
  39241. * Apply all cached states (depth, culling, stencil and alpha)
  39242. */
  39243. applyStates(): void;
  39244. /**
  39245. * Enable or disable color writing
  39246. * @param enable defines the state to set
  39247. */
  39248. setColorWrite(enable: boolean): void;
  39249. /**
  39250. * Gets a boolean indicating if color writing is enabled
  39251. * @returns the current color writing state
  39252. */
  39253. getColorWrite(): boolean;
  39254. /**
  39255. * Gets the depth culling state manager
  39256. */
  39257. get depthCullingState(): DepthCullingState;
  39258. /**
  39259. * Gets the alpha state manager
  39260. */
  39261. get alphaState(): AlphaState;
  39262. /**
  39263. * Gets the stencil state manager
  39264. */
  39265. get stencilState(): StencilState;
  39266. /**
  39267. * Clears the list of texture accessible through engine.
  39268. * This can help preventing texture load conflict due to name collision.
  39269. */
  39270. clearInternalTexturesCache(): void;
  39271. /**
  39272. * Force the entire cache to be cleared
  39273. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39274. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39275. */
  39276. wipeCaches(bruteForce?: boolean): void;
  39277. /** @hidden */
  39278. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39279. min: number;
  39280. mag: number;
  39281. };
  39282. /** @hidden */
  39283. _createTexture(): WebGLTexture;
  39284. /**
  39285. * Usually called from Texture.ts.
  39286. * Passed information to create a WebGLTexture
  39287. * @param url defines a value which contains one of the following:
  39288. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39289. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39290. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39292. * @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)
  39293. * @param scene needed for loading to the correct scene
  39294. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39295. * @param onLoad optional callback to be called upon successful completion
  39296. * @param onError optional callback to be called upon failure
  39297. * @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
  39298. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39299. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39300. * @param forcedExtension defines the extension to use to pick the right loader
  39301. * @param mimeType defines an optional mime type
  39302. * @param loaderOptions options to be passed to the loader
  39303. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39304. */
  39305. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39306. /**
  39307. * Loads an image as an HTMLImageElement.
  39308. * @param input url string, ArrayBuffer, or Blob to load
  39309. * @param onLoad callback called when the image successfully loads
  39310. * @param onError callback called when the image fails to load
  39311. * @param offlineProvider offline provider for caching
  39312. * @param mimeType optional mime type
  39313. * @returns the HTMLImageElement of the loaded image
  39314. * @hidden
  39315. */
  39316. 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>;
  39317. /**
  39318. * @hidden
  39319. */
  39320. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39321. private _unpackFlipYCached;
  39322. /**
  39323. * In case you are sharing the context with other applications, it might
  39324. * be interested to not cache the unpack flip y state to ensure a consistent
  39325. * value would be set.
  39326. */
  39327. enableUnpackFlipYCached: boolean;
  39328. /** @hidden */
  39329. _unpackFlipY(value: boolean): void;
  39330. /** @hidden */
  39331. _getUnpackAlignement(): number;
  39332. private _getTextureTarget;
  39333. /**
  39334. * Update the sampling mode of a given texture
  39335. * @param samplingMode defines the required sampling mode
  39336. * @param texture defines the texture to update
  39337. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39338. */
  39339. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39340. /**
  39341. * Update the sampling mode of a given texture
  39342. * @param texture defines the texture to update
  39343. * @param wrapU defines the texture wrap mode of the u coordinates
  39344. * @param wrapV defines the texture wrap mode of the v coordinates
  39345. * @param wrapR defines the texture wrap mode of the r coordinates
  39346. */
  39347. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39348. /** @hidden */
  39349. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39350. width: number;
  39351. height: number;
  39352. layers?: number;
  39353. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39354. /** @hidden */
  39355. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39356. /** @hidden */
  39357. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39358. /**
  39359. * Update a portion of an internal texture
  39360. * @param texture defines the texture to update
  39361. * @param imageData defines the data to store into the texture
  39362. * @param xOffset defines the x coordinates of the update rectangle
  39363. * @param yOffset defines the y coordinates of the update rectangle
  39364. * @param width defines the width of the update rectangle
  39365. * @param height defines the height of the update rectangle
  39366. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39367. * @param lod defines the lod level to update (0 by default)
  39368. */
  39369. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39370. /** @hidden */
  39371. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39372. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39373. private _prepareWebGLTexture;
  39374. /** @hidden */
  39375. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39376. private _getDepthStencilBuffer;
  39377. /** @hidden */
  39378. _releaseFramebufferObjects(texture: InternalTexture): void;
  39379. /** @hidden */
  39380. _releaseTexture(texture: InternalTexture): void;
  39381. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39382. protected _setProgram(program: WebGLProgram): void;
  39383. protected _boundUniforms: {
  39384. [key: number]: WebGLUniformLocation;
  39385. };
  39386. /**
  39387. * Binds an effect to the webGL context
  39388. * @param effect defines the effect to bind
  39389. */
  39390. bindSamplers(effect: Effect): void;
  39391. private _activateCurrentTexture;
  39392. /** @hidden */
  39393. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39394. /** @hidden */
  39395. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39396. /**
  39397. * Unbind all textures from the webGL context
  39398. */
  39399. unbindAllTextures(): void;
  39400. /**
  39401. * Sets a texture to the according uniform.
  39402. * @param channel The texture channel
  39403. * @param uniform The uniform to set
  39404. * @param texture The texture to apply
  39405. */
  39406. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39407. private _bindSamplerUniformToChannel;
  39408. private _getTextureWrapMode;
  39409. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39410. /**
  39411. * Sets an array of texture to the webGL context
  39412. * @param channel defines the channel where the texture array must be set
  39413. * @param uniform defines the associated uniform location
  39414. * @param textures defines the array of textures to bind
  39415. */
  39416. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39417. /** @hidden */
  39418. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39419. private _setTextureParameterFloat;
  39420. private _setTextureParameterInteger;
  39421. /**
  39422. * Unbind all vertex attributes from the webGL context
  39423. */
  39424. unbindAllAttributes(): void;
  39425. /**
  39426. * 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
  39427. */
  39428. releaseEffects(): void;
  39429. /**
  39430. * Dispose and release all associated resources
  39431. */
  39432. dispose(): void;
  39433. /**
  39434. * Attach a new callback raised when context lost event is fired
  39435. * @param callback defines the callback to call
  39436. */
  39437. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39438. /**
  39439. * Attach a new callback raised when context restored event is fired
  39440. * @param callback defines the callback to call
  39441. */
  39442. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39443. /**
  39444. * Get the current error code of the webGL context
  39445. * @returns the error code
  39446. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39447. */
  39448. getError(): number;
  39449. private _canRenderToFloatFramebuffer;
  39450. private _canRenderToHalfFloatFramebuffer;
  39451. private _canRenderToFramebuffer;
  39452. /** @hidden */
  39453. _getWebGLTextureType(type: number): number;
  39454. /** @hidden */
  39455. _getInternalFormat(format: number): number;
  39456. /** @hidden */
  39457. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39458. /** @hidden */
  39459. _getRGBAMultiSampleBufferFormat(type: number): number;
  39460. /** @hidden */
  39461. _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;
  39462. /**
  39463. * Loads a file from a url
  39464. * @param url url to load
  39465. * @param onSuccess callback called when the file successfully loads
  39466. * @param onProgress callback called while file is loading (if the server supports this mode)
  39467. * @param offlineProvider defines the offline provider for caching
  39468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39469. * @param onError callback called when the file fails to load
  39470. * @returns a file request object
  39471. * @hidden
  39472. */
  39473. 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;
  39474. /**
  39475. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39476. * @param x defines the x coordinate of the rectangle where pixels must be read
  39477. * @param y defines the y coordinate of the rectangle where pixels must be read
  39478. * @param width defines the width of the rectangle where pixels must be read
  39479. * @param height defines the height of the rectangle where pixels must be read
  39480. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39481. * @returns a Uint8Array containing RGBA colors
  39482. */
  39483. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39484. private static _IsSupported;
  39485. private static _HasMajorPerformanceCaveat;
  39486. /**
  39487. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39488. */
  39489. static get IsSupported(): boolean;
  39490. /**
  39491. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39492. * @returns true if the engine can be created
  39493. * @ignorenaming
  39494. */
  39495. static isSupported(): boolean;
  39496. /**
  39497. * 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)
  39498. */
  39499. static get HasMajorPerformanceCaveat(): boolean;
  39500. /**
  39501. * Find the next highest power of two.
  39502. * @param x Number to start search from.
  39503. * @return Next highest power of two.
  39504. */
  39505. static CeilingPOT(x: number): number;
  39506. /**
  39507. * Find the next lowest power of two.
  39508. * @param x Number to start search from.
  39509. * @return Next lowest power of two.
  39510. */
  39511. static FloorPOT(x: number): number;
  39512. /**
  39513. * Find the nearest power of two.
  39514. * @param x Number to start search from.
  39515. * @return Next nearest power of two.
  39516. */
  39517. static NearestPOT(x: number): number;
  39518. /**
  39519. * Get the closest exponent of two
  39520. * @param value defines the value to approximate
  39521. * @param max defines the maximum value to return
  39522. * @param mode defines how to define the closest value
  39523. * @returns closest exponent of two of the given value
  39524. */
  39525. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39526. /**
  39527. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39528. * @param func - the function to be called
  39529. * @param requester - the object that will request the next frame. Falls back to window.
  39530. * @returns frame number
  39531. */
  39532. static QueueNewFrame(func: () => void, requester?: any): number;
  39533. /**
  39534. * Gets host document
  39535. * @returns the host document object
  39536. */
  39537. getHostDocument(): Nullable<Document>;
  39538. }
  39539. }
  39540. declare module BABYLON {
  39541. /**
  39542. * Defines the source of the internal texture
  39543. */
  39544. export enum InternalTextureSource {
  39545. /**
  39546. * The source of the texture data is unknown
  39547. */
  39548. Unknown = 0,
  39549. /**
  39550. * Texture data comes from an URL
  39551. */
  39552. Url = 1,
  39553. /**
  39554. * Texture data is only used for temporary storage
  39555. */
  39556. Temp = 2,
  39557. /**
  39558. * Texture data comes from raw data (ArrayBuffer)
  39559. */
  39560. Raw = 3,
  39561. /**
  39562. * Texture content is dynamic (video or dynamic texture)
  39563. */
  39564. Dynamic = 4,
  39565. /**
  39566. * Texture content is generated by rendering to it
  39567. */
  39568. RenderTarget = 5,
  39569. /**
  39570. * Texture content is part of a multi render target process
  39571. */
  39572. MultiRenderTarget = 6,
  39573. /**
  39574. * Texture data comes from a cube data file
  39575. */
  39576. Cube = 7,
  39577. /**
  39578. * Texture data comes from a raw cube data
  39579. */
  39580. CubeRaw = 8,
  39581. /**
  39582. * Texture data come from a prefiltered cube data file
  39583. */
  39584. CubePrefiltered = 9,
  39585. /**
  39586. * Texture content is raw 3D data
  39587. */
  39588. Raw3D = 10,
  39589. /**
  39590. * Texture content is raw 2D array data
  39591. */
  39592. Raw2DArray = 11,
  39593. /**
  39594. * Texture content is a depth texture
  39595. */
  39596. Depth = 12,
  39597. /**
  39598. * Texture data comes from a raw cube data encoded with RGBD
  39599. */
  39600. CubeRawRGBD = 13
  39601. }
  39602. /**
  39603. * Class used to store data associated with WebGL texture data for the engine
  39604. * This class should not be used directly
  39605. */
  39606. export class InternalTexture {
  39607. /** @hidden */
  39608. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39609. /**
  39610. * Defines if the texture is ready
  39611. */
  39612. isReady: boolean;
  39613. /**
  39614. * Defines if the texture is a cube texture
  39615. */
  39616. isCube: boolean;
  39617. /**
  39618. * Defines if the texture contains 3D data
  39619. */
  39620. is3D: boolean;
  39621. /**
  39622. * Defines if the texture contains 2D array data
  39623. */
  39624. is2DArray: boolean;
  39625. /**
  39626. * Defines if the texture contains multiview data
  39627. */
  39628. isMultiview: boolean;
  39629. /**
  39630. * Gets the URL used to load this texture
  39631. */
  39632. url: string;
  39633. /**
  39634. * Gets the sampling mode of the texture
  39635. */
  39636. samplingMode: number;
  39637. /**
  39638. * Gets a boolean indicating if the texture needs mipmaps generation
  39639. */
  39640. generateMipMaps: boolean;
  39641. /**
  39642. * Gets the number of samples used by the texture (WebGL2+ only)
  39643. */
  39644. samples: number;
  39645. /**
  39646. * Gets the type of the texture (int, float...)
  39647. */
  39648. type: number;
  39649. /**
  39650. * Gets the format of the texture (RGB, RGBA...)
  39651. */
  39652. format: number;
  39653. /**
  39654. * Observable called when the texture is loaded
  39655. */
  39656. onLoadedObservable: Observable<InternalTexture>;
  39657. /**
  39658. * Gets the width of the texture
  39659. */
  39660. width: number;
  39661. /**
  39662. * Gets the height of the texture
  39663. */
  39664. height: number;
  39665. /**
  39666. * Gets the depth of the texture
  39667. */
  39668. depth: number;
  39669. /**
  39670. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39671. */
  39672. baseWidth: number;
  39673. /**
  39674. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39675. */
  39676. baseHeight: number;
  39677. /**
  39678. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39679. */
  39680. baseDepth: number;
  39681. /**
  39682. * Gets a boolean indicating if the texture is inverted on Y axis
  39683. */
  39684. invertY: boolean;
  39685. /** @hidden */
  39686. _invertVScale: boolean;
  39687. /** @hidden */
  39688. _associatedChannel: number;
  39689. /** @hidden */
  39690. _source: InternalTextureSource;
  39691. /** @hidden */
  39692. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39693. /** @hidden */
  39694. _bufferView: Nullable<ArrayBufferView>;
  39695. /** @hidden */
  39696. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39697. /** @hidden */
  39698. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39699. /** @hidden */
  39700. _size: number;
  39701. /** @hidden */
  39702. _extension: string;
  39703. /** @hidden */
  39704. _files: Nullable<string[]>;
  39705. /** @hidden */
  39706. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39707. /** @hidden */
  39708. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39709. /** @hidden */
  39710. _framebuffer: Nullable<WebGLFramebuffer>;
  39711. /** @hidden */
  39712. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39713. /** @hidden */
  39714. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39715. /** @hidden */
  39716. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39717. /** @hidden */
  39718. _attachments: Nullable<number[]>;
  39719. /** @hidden */
  39720. _textureArray: Nullable<InternalTexture[]>;
  39721. /** @hidden */
  39722. _cachedCoordinatesMode: Nullable<number>;
  39723. /** @hidden */
  39724. _cachedWrapU: Nullable<number>;
  39725. /** @hidden */
  39726. _cachedWrapV: Nullable<number>;
  39727. /** @hidden */
  39728. _cachedWrapR: Nullable<number>;
  39729. /** @hidden */
  39730. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39731. /** @hidden */
  39732. _isDisabled: boolean;
  39733. /** @hidden */
  39734. _compression: Nullable<string>;
  39735. /** @hidden */
  39736. _generateStencilBuffer: boolean;
  39737. /** @hidden */
  39738. _generateDepthBuffer: boolean;
  39739. /** @hidden */
  39740. _comparisonFunction: number;
  39741. /** @hidden */
  39742. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39743. /** @hidden */
  39744. _lodGenerationScale: number;
  39745. /** @hidden */
  39746. _lodGenerationOffset: number;
  39747. /** @hidden */
  39748. _depthStencilTexture: Nullable<InternalTexture>;
  39749. /** @hidden */
  39750. _colorTextureArray: Nullable<WebGLTexture>;
  39751. /** @hidden */
  39752. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39753. /** @hidden */
  39754. _lodTextureHigh: Nullable<BaseTexture>;
  39755. /** @hidden */
  39756. _lodTextureMid: Nullable<BaseTexture>;
  39757. /** @hidden */
  39758. _lodTextureLow: Nullable<BaseTexture>;
  39759. /** @hidden */
  39760. _isRGBD: boolean;
  39761. /** @hidden */
  39762. _linearSpecularLOD: boolean;
  39763. /** @hidden */
  39764. _irradianceTexture: Nullable<BaseTexture>;
  39765. /** @hidden */
  39766. _webGLTexture: Nullable<WebGLTexture>;
  39767. /** @hidden */
  39768. _references: number;
  39769. /** @hidden */
  39770. _gammaSpace: Nullable<boolean>;
  39771. private _engine;
  39772. /**
  39773. * Gets the Engine the texture belongs to.
  39774. * @returns The babylon engine
  39775. */
  39776. getEngine(): ThinEngine;
  39777. /**
  39778. * Gets the data source type of the texture
  39779. */
  39780. get source(): InternalTextureSource;
  39781. /**
  39782. * Creates a new InternalTexture
  39783. * @param engine defines the engine to use
  39784. * @param source defines the type of data that will be used
  39785. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39786. */
  39787. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39788. /**
  39789. * Increments the number of references (ie. the number of Texture that point to it)
  39790. */
  39791. incrementReferences(): void;
  39792. /**
  39793. * Change the size of the texture (not the size of the content)
  39794. * @param width defines the new width
  39795. * @param height defines the new height
  39796. * @param depth defines the new depth (1 by default)
  39797. */
  39798. updateSize(width: int, height: int, depth?: int): void;
  39799. /** @hidden */
  39800. _rebuild(): void;
  39801. /** @hidden */
  39802. _swapAndDie(target: InternalTexture): void;
  39803. /**
  39804. * Dispose the current allocated resources
  39805. */
  39806. dispose(): void;
  39807. }
  39808. }
  39809. declare module BABYLON {
  39810. /**
  39811. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39812. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39813. */
  39814. export class Analyser {
  39815. /**
  39816. * Gets or sets the smoothing
  39817. * @ignorenaming
  39818. */
  39819. SMOOTHING: number;
  39820. /**
  39821. * Gets or sets the FFT table size
  39822. * @ignorenaming
  39823. */
  39824. FFT_SIZE: number;
  39825. /**
  39826. * Gets or sets the bar graph amplitude
  39827. * @ignorenaming
  39828. */
  39829. BARGRAPHAMPLITUDE: number;
  39830. /**
  39831. * Gets or sets the position of the debug canvas
  39832. * @ignorenaming
  39833. */
  39834. DEBUGCANVASPOS: {
  39835. x: number;
  39836. y: number;
  39837. };
  39838. /**
  39839. * Gets or sets the debug canvas size
  39840. * @ignorenaming
  39841. */
  39842. DEBUGCANVASSIZE: {
  39843. width: number;
  39844. height: number;
  39845. };
  39846. private _byteFreqs;
  39847. private _byteTime;
  39848. private _floatFreqs;
  39849. private _webAudioAnalyser;
  39850. private _debugCanvas;
  39851. private _debugCanvasContext;
  39852. private _scene;
  39853. private _registerFunc;
  39854. private _audioEngine;
  39855. /**
  39856. * Creates a new analyser
  39857. * @param scene defines hosting scene
  39858. */
  39859. constructor(scene: Scene);
  39860. /**
  39861. * Get the number of data values you will have to play with for the visualization
  39862. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39863. * @returns a number
  39864. */
  39865. getFrequencyBinCount(): number;
  39866. /**
  39867. * Gets the current frequency data as a byte array
  39868. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39869. * @returns a Uint8Array
  39870. */
  39871. getByteFrequencyData(): Uint8Array;
  39872. /**
  39873. * Gets the current waveform as a byte array
  39874. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39875. * @returns a Uint8Array
  39876. */
  39877. getByteTimeDomainData(): Uint8Array;
  39878. /**
  39879. * Gets the current frequency data as a float array
  39880. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39881. * @returns a Float32Array
  39882. */
  39883. getFloatFrequencyData(): Float32Array;
  39884. /**
  39885. * Renders the debug canvas
  39886. */
  39887. drawDebugCanvas(): void;
  39888. /**
  39889. * Stops rendering the debug canvas and removes it
  39890. */
  39891. stopDebugCanvas(): void;
  39892. /**
  39893. * Connects two audio nodes
  39894. * @param inputAudioNode defines first node to connect
  39895. * @param outputAudioNode defines second node to connect
  39896. */
  39897. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39898. /**
  39899. * Releases all associated resources
  39900. */
  39901. dispose(): void;
  39902. }
  39903. }
  39904. declare module BABYLON {
  39905. /**
  39906. * This represents an audio engine and it is responsible
  39907. * to play, synchronize and analyse sounds throughout the application.
  39908. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39909. */
  39910. export interface IAudioEngine extends IDisposable {
  39911. /**
  39912. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39913. */
  39914. readonly canUseWebAudio: boolean;
  39915. /**
  39916. * Gets the current AudioContext if available.
  39917. */
  39918. readonly audioContext: Nullable<AudioContext>;
  39919. /**
  39920. * The master gain node defines the global audio volume of your audio engine.
  39921. */
  39922. readonly masterGain: GainNode;
  39923. /**
  39924. * Gets whether or not mp3 are supported by your browser.
  39925. */
  39926. readonly isMP3supported: boolean;
  39927. /**
  39928. * Gets whether or not ogg are supported by your browser.
  39929. */
  39930. readonly isOGGsupported: boolean;
  39931. /**
  39932. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39933. * @ignoreNaming
  39934. */
  39935. WarnedWebAudioUnsupported: boolean;
  39936. /**
  39937. * Defines if the audio engine relies on a custom unlocked button.
  39938. * In this case, the embedded button will not be displayed.
  39939. */
  39940. useCustomUnlockedButton: boolean;
  39941. /**
  39942. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39943. */
  39944. readonly unlocked: boolean;
  39945. /**
  39946. * Event raised when audio has been unlocked on the browser.
  39947. */
  39948. onAudioUnlockedObservable: Observable<AudioEngine>;
  39949. /**
  39950. * Event raised when audio has been locked on the browser.
  39951. */
  39952. onAudioLockedObservable: Observable<AudioEngine>;
  39953. /**
  39954. * Flags the audio engine in Locked state.
  39955. * This happens due to new browser policies preventing audio to autoplay.
  39956. */
  39957. lock(): void;
  39958. /**
  39959. * Unlocks the audio engine once a user action has been done on the dom.
  39960. * This is helpful to resume play once browser policies have been satisfied.
  39961. */
  39962. unlock(): void;
  39963. /**
  39964. * Gets the global volume sets on the master gain.
  39965. * @returns the global volume if set or -1 otherwise
  39966. */
  39967. getGlobalVolume(): number;
  39968. /**
  39969. * Sets the global volume of your experience (sets on the master gain).
  39970. * @param newVolume Defines the new global volume of the application
  39971. */
  39972. setGlobalVolume(newVolume: number): void;
  39973. /**
  39974. * Connect the audio engine to an audio analyser allowing some amazing
  39975. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39976. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39977. * @param analyser The analyser to connect to the engine
  39978. */
  39979. connectToAnalyser(analyser: Analyser): void;
  39980. }
  39981. /**
  39982. * This represents the default audio engine used in babylon.
  39983. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39984. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39985. */
  39986. export class AudioEngine implements IAudioEngine {
  39987. private _audioContext;
  39988. private _audioContextInitialized;
  39989. private _muteButton;
  39990. private _hostElement;
  39991. /**
  39992. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39993. */
  39994. canUseWebAudio: boolean;
  39995. /**
  39996. * The master gain node defines the global audio volume of your audio engine.
  39997. */
  39998. masterGain: GainNode;
  39999. /**
  40000. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40001. * @ignoreNaming
  40002. */
  40003. WarnedWebAudioUnsupported: boolean;
  40004. /**
  40005. * Gets whether or not mp3 are supported by your browser.
  40006. */
  40007. isMP3supported: boolean;
  40008. /**
  40009. * Gets whether or not ogg are supported by your browser.
  40010. */
  40011. isOGGsupported: boolean;
  40012. /**
  40013. * Gets whether audio has been unlocked on the device.
  40014. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40015. * a user interaction has happened.
  40016. */
  40017. unlocked: boolean;
  40018. /**
  40019. * Defines if the audio engine relies on a custom unlocked button.
  40020. * In this case, the embedded button will not be displayed.
  40021. */
  40022. useCustomUnlockedButton: boolean;
  40023. /**
  40024. * Event raised when audio has been unlocked on the browser.
  40025. */
  40026. onAudioUnlockedObservable: Observable<AudioEngine>;
  40027. /**
  40028. * Event raised when audio has been locked on the browser.
  40029. */
  40030. onAudioLockedObservable: Observable<AudioEngine>;
  40031. /**
  40032. * Gets the current AudioContext if available.
  40033. */
  40034. get audioContext(): Nullable<AudioContext>;
  40035. private _connectedAnalyser;
  40036. /**
  40037. * Instantiates a new audio engine.
  40038. *
  40039. * There should be only one per page as some browsers restrict the number
  40040. * of audio contexts you can create.
  40041. * @param hostElement defines the host element where to display the mute icon if necessary
  40042. */
  40043. constructor(hostElement?: Nullable<HTMLElement>);
  40044. /**
  40045. * Flags the audio engine in Locked state.
  40046. * This happens due to new browser policies preventing audio to autoplay.
  40047. */
  40048. lock(): void;
  40049. /**
  40050. * Unlocks the audio engine once a user action has been done on the dom.
  40051. * This is helpful to resume play once browser policies have been satisfied.
  40052. */
  40053. unlock(): void;
  40054. private _resumeAudioContext;
  40055. private _initializeAudioContext;
  40056. private _tryToRun;
  40057. private _triggerRunningState;
  40058. private _triggerSuspendedState;
  40059. private _displayMuteButton;
  40060. private _moveButtonToTopLeft;
  40061. private _onResize;
  40062. private _hideMuteButton;
  40063. /**
  40064. * Destroy and release the resources associated with the audio ccontext.
  40065. */
  40066. dispose(): void;
  40067. /**
  40068. * Gets the global volume sets on the master gain.
  40069. * @returns the global volume if set or -1 otherwise
  40070. */
  40071. getGlobalVolume(): number;
  40072. /**
  40073. * Sets the global volume of your experience (sets on the master gain).
  40074. * @param newVolume Defines the new global volume of the application
  40075. */
  40076. setGlobalVolume(newVolume: number): void;
  40077. /**
  40078. * Connect the audio engine to an audio analyser allowing some amazing
  40079. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40081. * @param analyser The analyser to connect to the engine
  40082. */
  40083. connectToAnalyser(analyser: Analyser): void;
  40084. }
  40085. }
  40086. declare module BABYLON {
  40087. /**
  40088. * Interface used to present a loading screen while loading a scene
  40089. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40090. */
  40091. export interface ILoadingScreen {
  40092. /**
  40093. * Function called to display the loading screen
  40094. */
  40095. displayLoadingUI: () => void;
  40096. /**
  40097. * Function called to hide the loading screen
  40098. */
  40099. hideLoadingUI: () => void;
  40100. /**
  40101. * Gets or sets the color to use for the background
  40102. */
  40103. loadingUIBackgroundColor: string;
  40104. /**
  40105. * Gets or sets the text to display while loading
  40106. */
  40107. loadingUIText: string;
  40108. }
  40109. /**
  40110. * Class used for the default loading screen
  40111. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40112. */
  40113. export class DefaultLoadingScreen implements ILoadingScreen {
  40114. private _renderingCanvas;
  40115. private _loadingText;
  40116. private _loadingDivBackgroundColor;
  40117. private _loadingDiv;
  40118. private _loadingTextDiv;
  40119. /** Gets or sets the logo url to use for the default loading screen */
  40120. static DefaultLogoUrl: string;
  40121. /** Gets or sets the spinner url to use for the default loading screen */
  40122. static DefaultSpinnerUrl: string;
  40123. /**
  40124. * Creates a new default loading screen
  40125. * @param _renderingCanvas defines the canvas used to render the scene
  40126. * @param _loadingText defines the default text to display
  40127. * @param _loadingDivBackgroundColor defines the default background color
  40128. */
  40129. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40130. /**
  40131. * Function called to display the loading screen
  40132. */
  40133. displayLoadingUI(): void;
  40134. /**
  40135. * Function called to hide the loading screen
  40136. */
  40137. hideLoadingUI(): void;
  40138. /**
  40139. * Gets or sets the text to display while loading
  40140. */
  40141. set loadingUIText(text: string);
  40142. get loadingUIText(): string;
  40143. /**
  40144. * Gets or sets the color to use for the background
  40145. */
  40146. get loadingUIBackgroundColor(): string;
  40147. set loadingUIBackgroundColor(color: string);
  40148. private _resizeLoadingUI;
  40149. }
  40150. }
  40151. declare module BABYLON {
  40152. /**
  40153. * Interface for any object that can request an animation frame
  40154. */
  40155. export interface ICustomAnimationFrameRequester {
  40156. /**
  40157. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40158. */
  40159. renderFunction?: Function;
  40160. /**
  40161. * Called to request the next frame to render to
  40162. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40163. */
  40164. requestAnimationFrame: Function;
  40165. /**
  40166. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40167. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40168. */
  40169. requestID?: number;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40175. */
  40176. export class PerformanceMonitor {
  40177. private _enabled;
  40178. private _rollingFrameTime;
  40179. private _lastFrameTimeMs;
  40180. /**
  40181. * constructor
  40182. * @param frameSampleSize The number of samples required to saturate the sliding window
  40183. */
  40184. constructor(frameSampleSize?: number);
  40185. /**
  40186. * Samples current frame
  40187. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40188. */
  40189. sampleFrame(timeMs?: number): void;
  40190. /**
  40191. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40192. */
  40193. get averageFrameTime(): number;
  40194. /**
  40195. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40196. */
  40197. get averageFrameTimeVariance(): number;
  40198. /**
  40199. * Returns the frame time of the most recent frame
  40200. */
  40201. get instantaneousFrameTime(): number;
  40202. /**
  40203. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40204. */
  40205. get averageFPS(): number;
  40206. /**
  40207. * Returns the average framerate in frames per second using the most recent frame time
  40208. */
  40209. get instantaneousFPS(): number;
  40210. /**
  40211. * Returns true if enough samples have been taken to completely fill the sliding window
  40212. */
  40213. get isSaturated(): boolean;
  40214. /**
  40215. * Enables contributions to the sliding window sample set
  40216. */
  40217. enable(): void;
  40218. /**
  40219. * Disables contributions to the sliding window sample set
  40220. * Samples will not be interpolated over the disabled period
  40221. */
  40222. disable(): void;
  40223. /**
  40224. * Returns true if sampling is enabled
  40225. */
  40226. get isEnabled(): boolean;
  40227. /**
  40228. * Resets performance monitor
  40229. */
  40230. reset(): void;
  40231. }
  40232. /**
  40233. * RollingAverage
  40234. *
  40235. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40236. */
  40237. export class RollingAverage {
  40238. /**
  40239. * Current average
  40240. */
  40241. average: number;
  40242. /**
  40243. * Current variance
  40244. */
  40245. variance: number;
  40246. protected _samples: Array<number>;
  40247. protected _sampleCount: number;
  40248. protected _pos: number;
  40249. protected _m2: number;
  40250. /**
  40251. * constructor
  40252. * @param length The number of samples required to saturate the sliding window
  40253. */
  40254. constructor(length: number);
  40255. /**
  40256. * Adds a sample to the sample set
  40257. * @param v The sample value
  40258. */
  40259. add(v: number): void;
  40260. /**
  40261. * Returns previously added values or null if outside of history or outside the sliding window domain
  40262. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40263. * @return Value previously recorded with add() or null if outside of range
  40264. */
  40265. history(i: number): number;
  40266. /**
  40267. * Returns true if enough samples have been taken to completely fill the sliding window
  40268. * @return true if sample-set saturated
  40269. */
  40270. isSaturated(): boolean;
  40271. /**
  40272. * Resets the rolling average (equivalent to 0 samples taken so far)
  40273. */
  40274. reset(): void;
  40275. /**
  40276. * Wraps a value around the sample range boundaries
  40277. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40278. * @return Wrapped position in sample range
  40279. */
  40280. protected _wrapPosition(i: number): number;
  40281. }
  40282. }
  40283. declare module BABYLON {
  40284. /**
  40285. * This class is used to track a performance counter which is number based.
  40286. * The user has access to many properties which give statistics of different nature.
  40287. *
  40288. * The implementer can track two kinds of Performance Counter: time and count.
  40289. * 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.
  40290. * 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.
  40291. */
  40292. export class PerfCounter {
  40293. /**
  40294. * Gets or sets a global boolean to turn on and off all the counters
  40295. */
  40296. static Enabled: boolean;
  40297. /**
  40298. * Returns the smallest value ever
  40299. */
  40300. get min(): number;
  40301. /**
  40302. * Returns the biggest value ever
  40303. */
  40304. get max(): number;
  40305. /**
  40306. * Returns the average value since the performance counter is running
  40307. */
  40308. get average(): number;
  40309. /**
  40310. * Returns the average value of the last second the counter was monitored
  40311. */
  40312. get lastSecAverage(): number;
  40313. /**
  40314. * Returns the current value
  40315. */
  40316. get current(): number;
  40317. /**
  40318. * Gets the accumulated total
  40319. */
  40320. get total(): number;
  40321. /**
  40322. * Gets the total value count
  40323. */
  40324. get count(): number;
  40325. /**
  40326. * Creates a new counter
  40327. */
  40328. constructor();
  40329. /**
  40330. * Call this method to start monitoring a new frame.
  40331. * 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.
  40332. */
  40333. fetchNewFrame(): void;
  40334. /**
  40335. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40336. * @param newCount the count value to add to the monitored count
  40337. * @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.
  40338. */
  40339. addCount(newCount: number, fetchResult: boolean): void;
  40340. /**
  40341. * Start monitoring this performance counter
  40342. */
  40343. beginMonitoring(): void;
  40344. /**
  40345. * Compute the time lapsed since the previous beginMonitoring() call.
  40346. * @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
  40347. */
  40348. endMonitoring(newFrame?: boolean): void;
  40349. private _fetchResult;
  40350. private _startMonitoringTime;
  40351. private _min;
  40352. private _max;
  40353. private _average;
  40354. private _current;
  40355. private _totalValueCount;
  40356. private _totalAccumulated;
  40357. private _lastSecAverage;
  40358. private _lastSecAccumulated;
  40359. private _lastSecTime;
  40360. private _lastSecValueCount;
  40361. }
  40362. }
  40363. declare module BABYLON {
  40364. interface ThinEngine {
  40365. /** @hidden */
  40366. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40367. }
  40368. }
  40369. declare module BABYLON {
  40370. /**
  40371. * Defines the interface used by display changed events
  40372. */
  40373. export interface IDisplayChangedEventArgs {
  40374. /** Gets the vrDisplay object (if any) */
  40375. vrDisplay: Nullable<any>;
  40376. /** Gets a boolean indicating if webVR is supported */
  40377. vrSupported: boolean;
  40378. }
  40379. /**
  40380. * Defines the interface used by objects containing a viewport (like a camera)
  40381. */
  40382. interface IViewportOwnerLike {
  40383. /**
  40384. * Gets or sets the viewport
  40385. */
  40386. viewport: IViewportLike;
  40387. }
  40388. /**
  40389. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40390. */
  40391. export class Engine extends ThinEngine {
  40392. /** Defines that alpha blending is disabled */
  40393. static readonly ALPHA_DISABLE: number;
  40394. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40395. static readonly ALPHA_ADD: number;
  40396. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40397. static readonly ALPHA_COMBINE: number;
  40398. /** Defines that alpha blending to DEST - SRC * DEST */
  40399. static readonly ALPHA_SUBTRACT: number;
  40400. /** Defines that alpha blending to SRC * DEST */
  40401. static readonly ALPHA_MULTIPLY: number;
  40402. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40403. static readonly ALPHA_MAXIMIZED: number;
  40404. /** Defines that alpha blending to SRC + DEST */
  40405. static readonly ALPHA_ONEONE: number;
  40406. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40407. static readonly ALPHA_PREMULTIPLIED: number;
  40408. /**
  40409. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40410. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40411. */
  40412. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40413. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40414. static readonly ALPHA_INTERPOLATE: number;
  40415. /**
  40416. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40417. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40418. */
  40419. static readonly ALPHA_SCREENMODE: number;
  40420. /** Defines that the ressource is not delayed*/
  40421. static readonly DELAYLOADSTATE_NONE: number;
  40422. /** Defines that the ressource was successfully delay loaded */
  40423. static readonly DELAYLOADSTATE_LOADED: number;
  40424. /** Defines that the ressource is currently delay loading */
  40425. static readonly DELAYLOADSTATE_LOADING: number;
  40426. /** Defines that the ressource is delayed and has not started loading */
  40427. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40429. static readonly NEVER: number;
  40430. /** 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 */
  40431. static readonly ALWAYS: number;
  40432. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40433. static readonly LESS: number;
  40434. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40435. static readonly EQUAL: number;
  40436. /** 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 */
  40437. static readonly LEQUAL: number;
  40438. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40439. static readonly GREATER: number;
  40440. /** 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 */
  40441. static readonly GEQUAL: number;
  40442. /** 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 */
  40443. static readonly NOTEQUAL: number;
  40444. /** Passed to stencilOperation to specify that stencil value must be kept */
  40445. static readonly KEEP: number;
  40446. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40447. static readonly REPLACE: number;
  40448. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40449. static readonly INCR: number;
  40450. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40451. static readonly DECR: number;
  40452. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40453. static readonly INVERT: number;
  40454. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40455. static readonly INCR_WRAP: number;
  40456. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40457. static readonly DECR_WRAP: number;
  40458. /** Texture is not repeating outside of 0..1 UVs */
  40459. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40460. /** Texture is repeating outside of 0..1 UVs */
  40461. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40462. /** Texture is repeating and mirrored */
  40463. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40464. /** ALPHA */
  40465. static readonly TEXTUREFORMAT_ALPHA: number;
  40466. /** LUMINANCE */
  40467. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40468. /** LUMINANCE_ALPHA */
  40469. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40470. /** RGB */
  40471. static readonly TEXTUREFORMAT_RGB: number;
  40472. /** RGBA */
  40473. static readonly TEXTUREFORMAT_RGBA: number;
  40474. /** RED */
  40475. static readonly TEXTUREFORMAT_RED: number;
  40476. /** RED (2nd reference) */
  40477. static readonly TEXTUREFORMAT_R: number;
  40478. /** RG */
  40479. static readonly TEXTUREFORMAT_RG: number;
  40480. /** RED_INTEGER */
  40481. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40482. /** RED_INTEGER (2nd reference) */
  40483. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40484. /** RG_INTEGER */
  40485. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40486. /** RGB_INTEGER */
  40487. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40488. /** RGBA_INTEGER */
  40489. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40490. /** UNSIGNED_BYTE */
  40491. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40492. /** UNSIGNED_BYTE (2nd reference) */
  40493. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40494. /** FLOAT */
  40495. static readonly TEXTURETYPE_FLOAT: number;
  40496. /** HALF_FLOAT */
  40497. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40498. /** BYTE */
  40499. static readonly TEXTURETYPE_BYTE: number;
  40500. /** SHORT */
  40501. static readonly TEXTURETYPE_SHORT: number;
  40502. /** UNSIGNED_SHORT */
  40503. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40504. /** INT */
  40505. static readonly TEXTURETYPE_INT: number;
  40506. /** UNSIGNED_INT */
  40507. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40508. /** UNSIGNED_SHORT_4_4_4_4 */
  40509. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40510. /** UNSIGNED_SHORT_5_5_5_1 */
  40511. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40512. /** UNSIGNED_SHORT_5_6_5 */
  40513. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40514. /** UNSIGNED_INT_2_10_10_10_REV */
  40515. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40516. /** UNSIGNED_INT_24_8 */
  40517. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40518. /** UNSIGNED_INT_10F_11F_11F_REV */
  40519. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40520. /** UNSIGNED_INT_5_9_9_9_REV */
  40521. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40522. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40523. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40524. /** nearest is mag = nearest and min = nearest and mip = linear */
  40525. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40526. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40527. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40528. /** Trilinear is mag = linear and min = linear and mip = linear */
  40529. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40530. /** nearest is mag = nearest and min = nearest and mip = linear */
  40531. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40532. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40533. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40534. /** Trilinear is mag = linear and min = linear and mip = linear */
  40535. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40536. /** mag = nearest and min = nearest and mip = nearest */
  40537. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40538. /** mag = nearest and min = linear and mip = nearest */
  40539. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40540. /** mag = nearest and min = linear and mip = linear */
  40541. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40542. /** mag = nearest and min = linear and mip = none */
  40543. static readonly TEXTURE_NEAREST_LINEAR: number;
  40544. /** mag = nearest and min = nearest and mip = none */
  40545. static readonly TEXTURE_NEAREST_NEAREST: number;
  40546. /** mag = linear and min = nearest and mip = nearest */
  40547. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40548. /** mag = linear and min = nearest and mip = linear */
  40549. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40550. /** mag = linear and min = linear and mip = none */
  40551. static readonly TEXTURE_LINEAR_LINEAR: number;
  40552. /** mag = linear and min = nearest and mip = none */
  40553. static readonly TEXTURE_LINEAR_NEAREST: number;
  40554. /** Explicit coordinates mode */
  40555. static readonly TEXTURE_EXPLICIT_MODE: number;
  40556. /** Spherical coordinates mode */
  40557. static readonly TEXTURE_SPHERICAL_MODE: number;
  40558. /** Planar coordinates mode */
  40559. static readonly TEXTURE_PLANAR_MODE: number;
  40560. /** Cubic coordinates mode */
  40561. static readonly TEXTURE_CUBIC_MODE: number;
  40562. /** Projection coordinates mode */
  40563. static readonly TEXTURE_PROJECTION_MODE: number;
  40564. /** Skybox coordinates mode */
  40565. static readonly TEXTURE_SKYBOX_MODE: number;
  40566. /** Inverse Cubic coordinates mode */
  40567. static readonly TEXTURE_INVCUBIC_MODE: number;
  40568. /** Equirectangular coordinates mode */
  40569. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40570. /** Equirectangular Fixed coordinates mode */
  40571. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40572. /** Equirectangular Fixed Mirrored coordinates mode */
  40573. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40574. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40575. static readonly SCALEMODE_FLOOR: number;
  40576. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40577. static readonly SCALEMODE_NEAREST: number;
  40578. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40579. static readonly SCALEMODE_CEILING: number;
  40580. /**
  40581. * Returns the current npm package of the sdk
  40582. */
  40583. static get NpmPackage(): string;
  40584. /**
  40585. * Returns the current version of the framework
  40586. */
  40587. static get Version(): string;
  40588. /** Gets the list of created engines */
  40589. static get Instances(): Engine[];
  40590. /**
  40591. * Gets the latest created engine
  40592. */
  40593. static get LastCreatedEngine(): Nullable<Engine>;
  40594. /**
  40595. * Gets the latest created scene
  40596. */
  40597. static get LastCreatedScene(): Nullable<Scene>;
  40598. /**
  40599. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40600. * @param flag defines which part of the materials must be marked as dirty
  40601. * @param predicate defines a predicate used to filter which materials should be affected
  40602. */
  40603. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40604. /**
  40605. * Method called to create the default loading screen.
  40606. * This can be overriden in your own app.
  40607. * @param canvas The rendering canvas element
  40608. * @returns The loading screen
  40609. */
  40610. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40611. /**
  40612. * Method called to create the default rescale post process on each engine.
  40613. */
  40614. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40615. /**
  40616. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40617. **/
  40618. enableOfflineSupport: boolean;
  40619. /**
  40620. * 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)
  40621. **/
  40622. disableManifestCheck: boolean;
  40623. /**
  40624. * Gets the list of created scenes
  40625. */
  40626. scenes: Scene[];
  40627. /**
  40628. * Event raised when a new scene is created
  40629. */
  40630. onNewSceneAddedObservable: Observable<Scene>;
  40631. /**
  40632. * Gets the list of created postprocesses
  40633. */
  40634. postProcesses: PostProcess[];
  40635. /**
  40636. * Gets a boolean indicating if the pointer is currently locked
  40637. */
  40638. isPointerLock: boolean;
  40639. /**
  40640. * Observable event triggered each time the rendering canvas is resized
  40641. */
  40642. onResizeObservable: Observable<Engine>;
  40643. /**
  40644. * Observable event triggered each time the canvas loses focus
  40645. */
  40646. onCanvasBlurObservable: Observable<Engine>;
  40647. /**
  40648. * Observable event triggered each time the canvas gains focus
  40649. */
  40650. onCanvasFocusObservable: Observable<Engine>;
  40651. /**
  40652. * Observable event triggered each time the canvas receives pointerout event
  40653. */
  40654. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40655. /**
  40656. * Observable raised when the engine begins a new frame
  40657. */
  40658. onBeginFrameObservable: Observable<Engine>;
  40659. /**
  40660. * If set, will be used to request the next animation frame for the render loop
  40661. */
  40662. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40663. /**
  40664. * Observable raised when the engine ends the current frame
  40665. */
  40666. onEndFrameObservable: Observable<Engine>;
  40667. /**
  40668. * Observable raised when the engine is about to compile a shader
  40669. */
  40670. onBeforeShaderCompilationObservable: Observable<Engine>;
  40671. /**
  40672. * Observable raised when the engine has jsut compiled a shader
  40673. */
  40674. onAfterShaderCompilationObservable: Observable<Engine>;
  40675. /**
  40676. * Gets the audio engine
  40677. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40678. * @ignorenaming
  40679. */
  40680. static audioEngine: IAudioEngine;
  40681. /**
  40682. * Default AudioEngine factory responsible of creating the Audio Engine.
  40683. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40684. */
  40685. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40686. /**
  40687. * Default offline support factory responsible of creating a tool used to store data locally.
  40688. * By default, this will create a Database object if the workload has been embedded.
  40689. */
  40690. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40691. private _loadingScreen;
  40692. private _pointerLockRequested;
  40693. private _rescalePostProcess;
  40694. private _deterministicLockstep;
  40695. private _lockstepMaxSteps;
  40696. private _timeStep;
  40697. protected get _supportsHardwareTextureRescaling(): boolean;
  40698. private _fps;
  40699. private _deltaTime;
  40700. /** @hidden */
  40701. _drawCalls: PerfCounter;
  40702. /** 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 */
  40703. canvasTabIndex: number;
  40704. /**
  40705. * Turn this value on if you want to pause FPS computation when in background
  40706. */
  40707. disablePerformanceMonitorInBackground: boolean;
  40708. private _performanceMonitor;
  40709. /**
  40710. * Gets the performance monitor attached to this engine
  40711. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40712. */
  40713. get performanceMonitor(): PerformanceMonitor;
  40714. private _onFocus;
  40715. private _onBlur;
  40716. private _onCanvasPointerOut;
  40717. private _onCanvasBlur;
  40718. private _onCanvasFocus;
  40719. private _onFullscreenChange;
  40720. private _onPointerLockChange;
  40721. /**
  40722. * Gets the HTML element used to attach event listeners
  40723. * @returns a HTML element
  40724. */
  40725. getInputElement(): Nullable<HTMLElement>;
  40726. /**
  40727. * Creates a new engine
  40728. * @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
  40729. * @param antialias defines enable antialiasing (default: false)
  40730. * @param options defines further options to be sent to the getContext() function
  40731. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40732. */
  40733. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40734. /**
  40735. * Gets current aspect ratio
  40736. * @param viewportOwner defines the camera to use to get the aspect ratio
  40737. * @param useScreen defines if screen size must be used (or the current render target if any)
  40738. * @returns a number defining the aspect ratio
  40739. */
  40740. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40741. /**
  40742. * Gets current screen aspect ratio
  40743. * @returns a number defining the aspect ratio
  40744. */
  40745. getScreenAspectRatio(): number;
  40746. /**
  40747. * Gets the client rect of the HTML canvas attached with the current webGL context
  40748. * @returns a client rectanglee
  40749. */
  40750. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40751. /**
  40752. * Gets the client rect of the HTML element used for events
  40753. * @returns a client rectanglee
  40754. */
  40755. getInputElementClientRect(): Nullable<ClientRect>;
  40756. /**
  40757. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40758. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40759. * @returns true if engine is in deterministic lock step mode
  40760. */
  40761. isDeterministicLockStep(): boolean;
  40762. /**
  40763. * Gets the max steps when engine is running in deterministic lock step
  40764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40765. * @returns the max steps
  40766. */
  40767. getLockstepMaxSteps(): number;
  40768. /**
  40769. * Returns the time in ms between steps when using deterministic lock step.
  40770. * @returns time step in (ms)
  40771. */
  40772. getTimeStep(): number;
  40773. /**
  40774. * Force the mipmap generation for the given render target texture
  40775. * @param texture defines the render target texture to use
  40776. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40777. */
  40778. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40779. /** States */
  40780. /**
  40781. * Set various states to the webGL context
  40782. * @param culling defines backface culling state
  40783. * @param zOffset defines the value to apply to zOffset (0 by default)
  40784. * @param force defines if states must be applied even if cache is up to date
  40785. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40786. */
  40787. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40788. /**
  40789. * Set the z offset to apply to current rendering
  40790. * @param value defines the offset to apply
  40791. */
  40792. setZOffset(value: number): void;
  40793. /**
  40794. * Gets the current value of the zOffset
  40795. * @returns the current zOffset state
  40796. */
  40797. getZOffset(): number;
  40798. /**
  40799. * Enable or disable depth buffering
  40800. * @param enable defines the state to set
  40801. */
  40802. setDepthBuffer(enable: boolean): void;
  40803. /**
  40804. * Gets a boolean indicating if depth writing is enabled
  40805. * @returns the current depth writing state
  40806. */
  40807. getDepthWrite(): boolean;
  40808. /**
  40809. * Enable or disable depth writing
  40810. * @param enable defines the state to set
  40811. */
  40812. setDepthWrite(enable: boolean): void;
  40813. /**
  40814. * Gets a boolean indicating if stencil buffer is enabled
  40815. * @returns the current stencil buffer state
  40816. */
  40817. getStencilBuffer(): boolean;
  40818. /**
  40819. * Enable or disable the stencil buffer
  40820. * @param enable defines if the stencil buffer must be enabled or disabled
  40821. */
  40822. setStencilBuffer(enable: boolean): void;
  40823. /**
  40824. * Gets the current stencil mask
  40825. * @returns a number defining the new stencil mask to use
  40826. */
  40827. getStencilMask(): number;
  40828. /**
  40829. * Sets the current stencil mask
  40830. * @param mask defines the new stencil mask to use
  40831. */
  40832. setStencilMask(mask: number): void;
  40833. /**
  40834. * Gets the current stencil function
  40835. * @returns a number defining the stencil function to use
  40836. */
  40837. getStencilFunction(): number;
  40838. /**
  40839. * Gets the current stencil reference value
  40840. * @returns a number defining the stencil reference value to use
  40841. */
  40842. getStencilFunctionReference(): number;
  40843. /**
  40844. * Gets the current stencil mask
  40845. * @returns a number defining the stencil mask to use
  40846. */
  40847. getStencilFunctionMask(): number;
  40848. /**
  40849. * Sets the current stencil function
  40850. * @param stencilFunc defines the new stencil function to use
  40851. */
  40852. setStencilFunction(stencilFunc: number): void;
  40853. /**
  40854. * Sets the current stencil reference
  40855. * @param reference defines the new stencil reference to use
  40856. */
  40857. setStencilFunctionReference(reference: number): void;
  40858. /**
  40859. * Sets the current stencil mask
  40860. * @param mask defines the new stencil mask to use
  40861. */
  40862. setStencilFunctionMask(mask: number): void;
  40863. /**
  40864. * Gets the current stencil operation when stencil fails
  40865. * @returns a number defining stencil operation to use when stencil fails
  40866. */
  40867. getStencilOperationFail(): number;
  40868. /**
  40869. * Gets the current stencil operation when depth fails
  40870. * @returns a number defining stencil operation to use when depth fails
  40871. */
  40872. getStencilOperationDepthFail(): number;
  40873. /**
  40874. * Gets the current stencil operation when stencil passes
  40875. * @returns a number defining stencil operation to use when stencil passes
  40876. */
  40877. getStencilOperationPass(): number;
  40878. /**
  40879. * Sets the stencil operation to use when stencil fails
  40880. * @param operation defines the stencil operation to use when stencil fails
  40881. */
  40882. setStencilOperationFail(operation: number): void;
  40883. /**
  40884. * Sets the stencil operation to use when depth fails
  40885. * @param operation defines the stencil operation to use when depth fails
  40886. */
  40887. setStencilOperationDepthFail(operation: number): void;
  40888. /**
  40889. * Sets the stencil operation to use when stencil passes
  40890. * @param operation defines the stencil operation to use when stencil passes
  40891. */
  40892. setStencilOperationPass(operation: number): void;
  40893. /**
  40894. * Sets a boolean indicating if the dithering state is enabled or disabled
  40895. * @param value defines the dithering state
  40896. */
  40897. setDitheringState(value: boolean): void;
  40898. /**
  40899. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40900. * @param value defines the rasterizer state
  40901. */
  40902. setRasterizerState(value: boolean): void;
  40903. /**
  40904. * Gets the current depth function
  40905. * @returns a number defining the depth function
  40906. */
  40907. getDepthFunction(): Nullable<number>;
  40908. /**
  40909. * Sets the current depth function
  40910. * @param depthFunc defines the function to use
  40911. */
  40912. setDepthFunction(depthFunc: number): void;
  40913. /**
  40914. * Sets the current depth function to GREATER
  40915. */
  40916. setDepthFunctionToGreater(): void;
  40917. /**
  40918. * Sets the current depth function to GEQUAL
  40919. */
  40920. setDepthFunctionToGreaterOrEqual(): void;
  40921. /**
  40922. * Sets the current depth function to LESS
  40923. */
  40924. setDepthFunctionToLess(): void;
  40925. /**
  40926. * Sets the current depth function to LEQUAL
  40927. */
  40928. setDepthFunctionToLessOrEqual(): void;
  40929. private _cachedStencilBuffer;
  40930. private _cachedStencilFunction;
  40931. private _cachedStencilMask;
  40932. private _cachedStencilOperationPass;
  40933. private _cachedStencilOperationFail;
  40934. private _cachedStencilOperationDepthFail;
  40935. private _cachedStencilReference;
  40936. /**
  40937. * Caches the the state of the stencil buffer
  40938. */
  40939. cacheStencilState(): void;
  40940. /**
  40941. * Restores the state of the stencil buffer
  40942. */
  40943. restoreStencilState(): void;
  40944. /**
  40945. * Directly set the WebGL Viewport
  40946. * @param x defines the x coordinate of the viewport (in screen space)
  40947. * @param y defines the y coordinate of the viewport (in screen space)
  40948. * @param width defines the width of the viewport (in screen space)
  40949. * @param height defines the height of the viewport (in screen space)
  40950. * @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
  40951. */
  40952. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40953. /**
  40954. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40956. * @param y defines the y-coordinate of the corner of the clear rectangle
  40957. * @param width defines the width of the clear rectangle
  40958. * @param height defines the height of the clear rectangle
  40959. * @param clearColor defines the clear color
  40960. */
  40961. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40962. /**
  40963. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40964. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40965. * @param y defines the y-coordinate of the corner of the clear rectangle
  40966. * @param width defines the width of the clear rectangle
  40967. * @param height defines the height of the clear rectangle
  40968. */
  40969. enableScissor(x: number, y: number, width: number, height: number): void;
  40970. /**
  40971. * Disable previously set scissor test rectangle
  40972. */
  40973. disableScissor(): void;
  40974. protected _reportDrawCall(): void;
  40975. /**
  40976. * Initializes a webVR display and starts listening to display change events
  40977. * The onVRDisplayChangedObservable will be notified upon these changes
  40978. * @returns The onVRDisplayChangedObservable
  40979. */
  40980. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40981. /** @hidden */
  40982. _prepareVRComponent(): void;
  40983. /** @hidden */
  40984. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40985. /** @hidden */
  40986. _submitVRFrame(): void;
  40987. /**
  40988. * Call this function to leave webVR mode
  40989. * Will do nothing if webVR is not supported or if there is no webVR device
  40990. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40991. */
  40992. disableVR(): void;
  40993. /**
  40994. * Gets a boolean indicating that the system is in VR mode and is presenting
  40995. * @returns true if VR mode is engaged
  40996. */
  40997. isVRPresenting(): boolean;
  40998. /** @hidden */
  40999. _requestVRFrame(): void;
  41000. /** @hidden */
  41001. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41002. /**
  41003. * Gets the source code of the vertex shader associated with a specific webGL program
  41004. * @param program defines the program to use
  41005. * @returns a string containing the source code of the vertex shader associated with the program
  41006. */
  41007. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41008. /**
  41009. * Gets the source code of the fragment shader associated with a specific webGL program
  41010. * @param program defines the program to use
  41011. * @returns a string containing the source code of the fragment shader associated with the program
  41012. */
  41013. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41014. /**
  41015. * Sets a depth stencil texture from a render target to the according uniform.
  41016. * @param channel The texture channel
  41017. * @param uniform The uniform to set
  41018. * @param texture The render target texture containing the depth stencil texture to apply
  41019. */
  41020. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41021. /**
  41022. * Sets a texture to the webGL context from a postprocess
  41023. * @param channel defines the channel to use
  41024. * @param postProcess defines the source postprocess
  41025. */
  41026. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41027. /**
  41028. * Binds the output of the passed in post process to the texture channel specified
  41029. * @param channel The channel the texture should be bound to
  41030. * @param postProcess The post process which's output should be bound
  41031. */
  41032. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41033. protected _rebuildBuffers(): void;
  41034. /** @hidden */
  41035. _renderFrame(): void;
  41036. _renderLoop(): void;
  41037. /** @hidden */
  41038. _renderViews(): boolean;
  41039. /**
  41040. * Toggle full screen mode
  41041. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41042. */
  41043. switchFullscreen(requestPointerLock: boolean): void;
  41044. /**
  41045. * Enters full screen mode
  41046. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41047. */
  41048. enterFullscreen(requestPointerLock: boolean): void;
  41049. /**
  41050. * Exits full screen mode
  41051. */
  41052. exitFullscreen(): void;
  41053. /**
  41054. * Enters Pointerlock mode
  41055. */
  41056. enterPointerlock(): void;
  41057. /**
  41058. * Exits Pointerlock mode
  41059. */
  41060. exitPointerlock(): void;
  41061. /**
  41062. * Begin a new frame
  41063. */
  41064. beginFrame(): void;
  41065. /**
  41066. * Enf the current frame
  41067. */
  41068. endFrame(): void;
  41069. resize(): void;
  41070. /**
  41071. * Force a specific size of the canvas
  41072. * @param width defines the new canvas' width
  41073. * @param height defines the new canvas' height
  41074. * @returns true if the size was changed
  41075. */
  41076. setSize(width: number, height: number): boolean;
  41077. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41078. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41079. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41080. _releaseTexture(texture: InternalTexture): void;
  41081. /**
  41082. * @hidden
  41083. * Rescales a texture
  41084. * @param source input texutre
  41085. * @param destination destination texture
  41086. * @param scene scene to use to render the resize
  41087. * @param internalFormat format to use when resizing
  41088. * @param onComplete callback to be called when resize has completed
  41089. */
  41090. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41091. /**
  41092. * Gets the current framerate
  41093. * @returns a number representing the framerate
  41094. */
  41095. getFps(): number;
  41096. /**
  41097. * Gets the time spent between current and previous frame
  41098. * @returns a number representing the delta time in ms
  41099. */
  41100. getDeltaTime(): number;
  41101. private _measureFps;
  41102. /** @hidden */
  41103. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41104. /**
  41105. * Updates the sample count of a render target texture
  41106. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41107. * @param texture defines the texture to update
  41108. * @param samples defines the sample count to set
  41109. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41110. */
  41111. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41112. /**
  41113. * Updates a depth texture Comparison Mode and Function.
  41114. * If the comparison Function is equal to 0, the mode will be set to none.
  41115. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41116. * @param texture The texture to set the comparison function for
  41117. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41118. */
  41119. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41120. /**
  41121. * Creates a webGL buffer to use with instanciation
  41122. * @param capacity defines the size of the buffer
  41123. * @returns the webGL buffer
  41124. */
  41125. createInstancesBuffer(capacity: number): DataBuffer;
  41126. /**
  41127. * Delete a webGL buffer used with instanciation
  41128. * @param buffer defines the webGL buffer to delete
  41129. */
  41130. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41131. private _clientWaitAsync;
  41132. /** @hidden */
  41133. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41134. dispose(): void;
  41135. private _disableTouchAction;
  41136. /**
  41137. * Display the loading screen
  41138. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41139. */
  41140. displayLoadingUI(): void;
  41141. /**
  41142. * Hide the loading screen
  41143. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41144. */
  41145. hideLoadingUI(): void;
  41146. /**
  41147. * Gets the current loading screen object
  41148. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41149. */
  41150. get loadingScreen(): ILoadingScreen;
  41151. /**
  41152. * Sets the current loading screen object
  41153. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41154. */
  41155. set loadingScreen(loadingScreen: ILoadingScreen);
  41156. /**
  41157. * Sets the current loading screen text
  41158. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41159. */
  41160. set loadingUIText(text: string);
  41161. /**
  41162. * Sets the current loading screen background color
  41163. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41164. */
  41165. set loadingUIBackgroundColor(color: string);
  41166. /** Pointerlock and fullscreen */
  41167. /**
  41168. * Ask the browser to promote the current element to pointerlock mode
  41169. * @param element defines the DOM element to promote
  41170. */
  41171. static _RequestPointerlock(element: HTMLElement): void;
  41172. /**
  41173. * Asks the browser to exit pointerlock mode
  41174. */
  41175. static _ExitPointerlock(): void;
  41176. /**
  41177. * Ask the browser to promote the current element to fullscreen rendering mode
  41178. * @param element defines the DOM element to promote
  41179. */
  41180. static _RequestFullscreen(element: HTMLElement): void;
  41181. /**
  41182. * Asks the browser to exit fullscreen mode
  41183. */
  41184. static _ExitFullscreen(): void;
  41185. }
  41186. }
  41187. declare module BABYLON {
  41188. /**
  41189. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41190. * during the life time of the application.
  41191. */
  41192. export class EngineStore {
  41193. /** Gets the list of created engines */
  41194. static Instances: Engine[];
  41195. /** @hidden */
  41196. static _LastCreatedScene: Nullable<Scene>;
  41197. /**
  41198. * Gets the latest created engine
  41199. */
  41200. static get LastCreatedEngine(): Nullable<Engine>;
  41201. /**
  41202. * Gets the latest created scene
  41203. */
  41204. static get LastCreatedScene(): Nullable<Scene>;
  41205. /**
  41206. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41207. * @ignorenaming
  41208. */
  41209. static UseFallbackTexture: boolean;
  41210. /**
  41211. * Texture content used if a texture cannot loaded
  41212. * @ignorenaming
  41213. */
  41214. static FallbackTexture: string;
  41215. }
  41216. }
  41217. declare module BABYLON {
  41218. /**
  41219. * Helper class that provides a small promise polyfill
  41220. */
  41221. export class PromisePolyfill {
  41222. /**
  41223. * Static function used to check if the polyfill is required
  41224. * If this is the case then the function will inject the polyfill to window.Promise
  41225. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41226. */
  41227. static Apply(force?: boolean): void;
  41228. }
  41229. }
  41230. declare module BABYLON {
  41231. /**
  41232. * Interface for screenshot methods with describe argument called `size` as object with options
  41233. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41234. */
  41235. export interface IScreenshotSize {
  41236. /**
  41237. * number in pixels for canvas height
  41238. */
  41239. height?: number;
  41240. /**
  41241. * multiplier allowing render at a higher or lower resolution
  41242. * If value is defined then height and width will be ignored and taken from camera
  41243. */
  41244. precision?: number;
  41245. /**
  41246. * number in pixels for canvas width
  41247. */
  41248. width?: number;
  41249. }
  41250. }
  41251. declare module BABYLON {
  41252. interface IColor4Like {
  41253. r: float;
  41254. g: float;
  41255. b: float;
  41256. a: float;
  41257. }
  41258. /**
  41259. * Class containing a set of static utilities functions
  41260. */
  41261. export class Tools {
  41262. /**
  41263. * Gets or sets the base URL to use to load assets
  41264. */
  41265. static get BaseUrl(): string;
  41266. static set BaseUrl(value: string);
  41267. /**
  41268. * Enable/Disable Custom HTTP Request Headers globally.
  41269. * default = false
  41270. * @see CustomRequestHeaders
  41271. */
  41272. static UseCustomRequestHeaders: boolean;
  41273. /**
  41274. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41275. * i.e. when loading files, where the server/service expects an Authorization header
  41276. */
  41277. static CustomRequestHeaders: {
  41278. [key: string]: string;
  41279. };
  41280. /**
  41281. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41282. */
  41283. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41284. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41285. /**
  41286. * Default behaviour for cors in the application.
  41287. * It can be a string if the expected behavior is identical in the entire app.
  41288. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41289. */
  41290. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41291. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41292. /**
  41293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41294. * @ignorenaming
  41295. */
  41296. static get UseFallbackTexture(): boolean;
  41297. static set UseFallbackTexture(value: boolean);
  41298. /**
  41299. * Use this object to register external classes like custom textures or material
  41300. * to allow the laoders to instantiate them
  41301. */
  41302. static get RegisteredExternalClasses(): {
  41303. [key: string]: Object;
  41304. };
  41305. static set RegisteredExternalClasses(classes: {
  41306. [key: string]: Object;
  41307. });
  41308. /**
  41309. * Texture content used if a texture cannot loaded
  41310. * @ignorenaming
  41311. */
  41312. static get fallbackTexture(): string;
  41313. static set fallbackTexture(value: string);
  41314. /**
  41315. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41316. * @param u defines the coordinate on X axis
  41317. * @param v defines the coordinate on Y axis
  41318. * @param width defines the width of the source data
  41319. * @param height defines the height of the source data
  41320. * @param pixels defines the source byte array
  41321. * @param color defines the output color
  41322. */
  41323. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41324. /**
  41325. * Interpolates between a and b via alpha
  41326. * @param a The lower value (returned when alpha = 0)
  41327. * @param b The upper value (returned when alpha = 1)
  41328. * @param alpha The interpolation-factor
  41329. * @return The mixed value
  41330. */
  41331. static Mix(a: number, b: number, alpha: number): number;
  41332. /**
  41333. * Tries to instantiate a new object from a given class name
  41334. * @param className defines the class name to instantiate
  41335. * @returns the new object or null if the system was not able to do the instantiation
  41336. */
  41337. static Instantiate(className: string): any;
  41338. /**
  41339. * Provides a slice function that will work even on IE
  41340. * @param data defines the array to slice
  41341. * @param start defines the start of the data (optional)
  41342. * @param end defines the end of the data (optional)
  41343. * @returns the new sliced array
  41344. */
  41345. static Slice<T>(data: T, start?: number, end?: number): T;
  41346. /**
  41347. * Polyfill for setImmediate
  41348. * @param action defines the action to execute after the current execution block
  41349. */
  41350. static SetImmediate(action: () => void): void;
  41351. /**
  41352. * Function indicating if a number is an exponent of 2
  41353. * @param value defines the value to test
  41354. * @returns true if the value is an exponent of 2
  41355. */
  41356. static IsExponentOfTwo(value: number): boolean;
  41357. private static _tmpFloatArray;
  41358. /**
  41359. * Returns the nearest 32-bit single precision float representation of a Number
  41360. * @param value A Number. If the parameter is of a different type, it will get converted
  41361. * to a number or to NaN if it cannot be converted
  41362. * @returns number
  41363. */
  41364. static FloatRound(value: number): number;
  41365. /**
  41366. * Extracts the filename from a path
  41367. * @param path defines the path to use
  41368. * @returns the filename
  41369. */
  41370. static GetFilename(path: string): string;
  41371. /**
  41372. * Extracts the "folder" part of a path (everything before the filename).
  41373. * @param uri The URI to extract the info from
  41374. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41375. * @returns The "folder" part of the path
  41376. */
  41377. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41378. /**
  41379. * Extracts text content from a DOM element hierarchy
  41380. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41381. */
  41382. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41383. /**
  41384. * Convert an angle in radians to degrees
  41385. * @param angle defines the angle to convert
  41386. * @returns the angle in degrees
  41387. */
  41388. static ToDegrees(angle: number): number;
  41389. /**
  41390. * Convert an angle in degrees to radians
  41391. * @param angle defines the angle to convert
  41392. * @returns the angle in radians
  41393. */
  41394. static ToRadians(angle: number): number;
  41395. /**
  41396. * Returns an array if obj is not an array
  41397. * @param obj defines the object to evaluate as an array
  41398. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41399. * @returns either obj directly if obj is an array or a new array containing obj
  41400. */
  41401. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41402. /**
  41403. * Gets the pointer prefix to use
  41404. * @param engine defines the engine we are finding the prefix for
  41405. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41406. */
  41407. static GetPointerPrefix(engine: Engine): string;
  41408. /**
  41409. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41410. * @param url define the url we are trying
  41411. * @param element define the dom element where to configure the cors policy
  41412. */
  41413. static SetCorsBehavior(url: string | string[], element: {
  41414. crossOrigin: string | null;
  41415. }): void;
  41416. /**
  41417. * Removes unwanted characters from an url
  41418. * @param url defines the url to clean
  41419. * @returns the cleaned url
  41420. */
  41421. static CleanUrl(url: string): string;
  41422. /**
  41423. * Gets or sets a function used to pre-process url before using them to load assets
  41424. */
  41425. static get PreprocessUrl(): (url: string) => string;
  41426. static set PreprocessUrl(processor: (url: string) => string);
  41427. /**
  41428. * Loads an image as an HTMLImageElement.
  41429. * @param input url string, ArrayBuffer, or Blob to load
  41430. * @param onLoad callback called when the image successfully loads
  41431. * @param onError callback called when the image fails to load
  41432. * @param offlineProvider offline provider for caching
  41433. * @param mimeType optional mime type
  41434. * @returns the HTMLImageElement of the loaded image
  41435. */
  41436. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41437. /**
  41438. * Loads a file from a url
  41439. * @param url url string, ArrayBuffer, or Blob to load
  41440. * @param onSuccess callback called when the file successfully loads
  41441. * @param onProgress callback called while file is loading (if the server supports this mode)
  41442. * @param offlineProvider defines the offline provider for caching
  41443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41444. * @param onError callback called when the file fails to load
  41445. * @returns a file request object
  41446. */
  41447. 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;
  41448. /**
  41449. * Loads a file from a url
  41450. * @param url the file url to load
  41451. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41452. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41453. */
  41454. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41455. /**
  41456. * Load a script (identified by an url). When the url returns, the
  41457. * content of this file is added into a new script element, attached to the DOM (body element)
  41458. * @param scriptUrl defines the url of the script to laod
  41459. * @param onSuccess defines the callback called when the script is loaded
  41460. * @param onError defines the callback to call if an error occurs
  41461. * @param scriptId defines the id of the script element
  41462. */
  41463. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41464. /**
  41465. * Load an asynchronous script (identified by an url). When the url returns, the
  41466. * content of this file is added into a new script element, attached to the DOM (body element)
  41467. * @param scriptUrl defines the url of the script to laod
  41468. * @param scriptId defines the id of the script element
  41469. * @returns a promise request object
  41470. */
  41471. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41472. /**
  41473. * Loads a file from a blob
  41474. * @param fileToLoad defines the blob to use
  41475. * @param callback defines the callback to call when data is loaded
  41476. * @param progressCallback defines the callback to call during loading process
  41477. * @returns a file request object
  41478. */
  41479. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41480. /**
  41481. * Reads a file from a File object
  41482. * @param file defines the file to load
  41483. * @param onSuccess defines the callback to call when data is loaded
  41484. * @param onProgress defines the callback to call during loading process
  41485. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41486. * @param onError defines the callback to call when an error occurs
  41487. * @returns a file request object
  41488. */
  41489. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41490. /**
  41491. * Creates a data url from a given string content
  41492. * @param content defines the content to convert
  41493. * @returns the new data url link
  41494. */
  41495. static FileAsURL(content: string): string;
  41496. /**
  41497. * Format the given number to a specific decimal format
  41498. * @param value defines the number to format
  41499. * @param decimals defines the number of decimals to use
  41500. * @returns the formatted string
  41501. */
  41502. static Format(value: number, decimals?: number): string;
  41503. /**
  41504. * Tries to copy an object by duplicating every property
  41505. * @param source defines the source object
  41506. * @param destination defines the target object
  41507. * @param doNotCopyList defines a list of properties to avoid
  41508. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41509. */
  41510. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41511. /**
  41512. * Gets a boolean indicating if the given object has no own property
  41513. * @param obj defines the object to test
  41514. * @returns true if object has no own property
  41515. */
  41516. static IsEmpty(obj: any): boolean;
  41517. /**
  41518. * Function used to register events at window level
  41519. * @param windowElement defines the Window object to use
  41520. * @param events defines the events to register
  41521. */
  41522. static RegisterTopRootEvents(windowElement: Window, events: {
  41523. name: string;
  41524. handler: Nullable<(e: FocusEvent) => any>;
  41525. }[]): void;
  41526. /**
  41527. * Function used to unregister events from window level
  41528. * @param windowElement defines the Window object to use
  41529. * @param events defines the events to unregister
  41530. */
  41531. static UnregisterTopRootEvents(windowElement: Window, events: {
  41532. name: string;
  41533. handler: Nullable<(e: FocusEvent) => any>;
  41534. }[]): void;
  41535. /**
  41536. * @ignore
  41537. */
  41538. static _ScreenshotCanvas: HTMLCanvasElement;
  41539. /**
  41540. * Dumps the current bound framebuffer
  41541. * @param width defines the rendering width
  41542. * @param height defines the rendering height
  41543. * @param engine defines the hosting engine
  41544. * @param successCallback defines the callback triggered once the data are available
  41545. * @param mimeType defines the mime type of the result
  41546. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41547. */
  41548. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41549. /**
  41550. * Converts the canvas data to blob.
  41551. * This acts as a polyfill for browsers not supporting the to blob function.
  41552. * @param canvas Defines the canvas to extract the data from
  41553. * @param successCallback Defines the callback triggered once the data are available
  41554. * @param mimeType Defines the mime type of the result
  41555. */
  41556. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41557. /**
  41558. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41559. * @param successCallback defines the callback triggered once the data are available
  41560. * @param mimeType defines the mime type of the result
  41561. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41562. */
  41563. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41564. /**
  41565. * Downloads a blob in the browser
  41566. * @param blob defines the blob to download
  41567. * @param fileName defines the name of the downloaded file
  41568. */
  41569. static Download(blob: Blob, fileName: string): void;
  41570. /**
  41571. * Captures a screenshot of the current rendering
  41572. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41573. * @param engine defines the rendering engine
  41574. * @param camera defines the source camera
  41575. * @param size This parameter can be set to a single number or to an object with the
  41576. * following (optional) properties: precision, width, height. If a single number is passed,
  41577. * it will be used for both width and height. If an object is passed, the screenshot size
  41578. * will be derived from the parameters. The precision property is a multiplier allowing
  41579. * rendering at a higher or lower resolution
  41580. * @param successCallback defines the callback receives a single parameter which contains the
  41581. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41582. * src parameter of an <img> to display it
  41583. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41584. * Check your browser for supported MIME types
  41585. */
  41586. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41587. /**
  41588. * Captures a screenshot of the current rendering
  41589. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41590. * @param engine defines the rendering engine
  41591. * @param camera defines the source camera
  41592. * @param size This parameter can be set to a single number or to an object with the
  41593. * following (optional) properties: precision, width, height. If a single number is passed,
  41594. * it will be used for both width and height. If an object is passed, the screenshot size
  41595. * will be derived from the parameters. The precision property is a multiplier allowing
  41596. * rendering at a higher or lower resolution
  41597. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41598. * Check your browser for supported MIME types
  41599. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41600. * to the src parameter of an <img> to display it
  41601. */
  41602. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41603. /**
  41604. * Generates an image screenshot from the specified camera.
  41605. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41606. * @param engine The engine to use for rendering
  41607. * @param camera The camera to use for rendering
  41608. * @param size This parameter can be set to a single number or to an object with the
  41609. * following (optional) properties: precision, width, height. If a single number is passed,
  41610. * it will be used for both width and height. If an object is passed, the screenshot size
  41611. * will be derived from the parameters. The precision property is a multiplier allowing
  41612. * rendering at a higher or lower resolution
  41613. * @param successCallback The callback receives a single parameter which contains the
  41614. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41615. * src parameter of an <img> to display it
  41616. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41617. * Check your browser for supported MIME types
  41618. * @param samples Texture samples (default: 1)
  41619. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41620. * @param fileName A name for for the downloaded file.
  41621. */
  41622. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41623. /**
  41624. * Generates an image screenshot from the specified camera.
  41625. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41626. * @param engine The engine to use for rendering
  41627. * @param camera The camera to use for rendering
  41628. * @param size This parameter can be set to a single number or to an object with the
  41629. * following (optional) properties: precision, width, height. If a single number is passed,
  41630. * it will be used for both width and height. If an object is passed, the screenshot size
  41631. * will be derived from the parameters. The precision property is a multiplier allowing
  41632. * rendering at a higher or lower resolution
  41633. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41634. * Check your browser for supported MIME types
  41635. * @param samples Texture samples (default: 1)
  41636. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41637. * @param fileName A name for for the downloaded file.
  41638. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41639. * to the src parameter of an <img> to display it
  41640. */
  41641. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41642. /**
  41643. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41644. * Be aware Math.random() could cause collisions, but:
  41645. * "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"
  41646. * @returns a pseudo random id
  41647. */
  41648. static RandomId(): string;
  41649. /**
  41650. * Test if the given uri is a base64 string
  41651. * @param uri The uri to test
  41652. * @return True if the uri is a base64 string or false otherwise
  41653. */
  41654. static IsBase64(uri: string): boolean;
  41655. /**
  41656. * Decode the given base64 uri.
  41657. * @param uri The uri to decode
  41658. * @return The decoded base64 data.
  41659. */
  41660. static DecodeBase64(uri: string): ArrayBuffer;
  41661. /**
  41662. * Gets the absolute url.
  41663. * @param url the input url
  41664. * @return the absolute url
  41665. */
  41666. static GetAbsoluteUrl(url: string): string;
  41667. /**
  41668. * No log
  41669. */
  41670. static readonly NoneLogLevel: number;
  41671. /**
  41672. * Only message logs
  41673. */
  41674. static readonly MessageLogLevel: number;
  41675. /**
  41676. * Only warning logs
  41677. */
  41678. static readonly WarningLogLevel: number;
  41679. /**
  41680. * Only error logs
  41681. */
  41682. static readonly ErrorLogLevel: number;
  41683. /**
  41684. * All logs
  41685. */
  41686. static readonly AllLogLevel: number;
  41687. /**
  41688. * Gets a value indicating the number of loading errors
  41689. * @ignorenaming
  41690. */
  41691. static get errorsCount(): number;
  41692. /**
  41693. * Callback called when a new log is added
  41694. */
  41695. static OnNewCacheEntry: (entry: string) => void;
  41696. /**
  41697. * Log a message to the console
  41698. * @param message defines the message to log
  41699. */
  41700. static Log(message: string): void;
  41701. /**
  41702. * Write a warning message to the console
  41703. * @param message defines the message to log
  41704. */
  41705. static Warn(message: string): void;
  41706. /**
  41707. * Write an error message to the console
  41708. * @param message defines the message to log
  41709. */
  41710. static Error(message: string): void;
  41711. /**
  41712. * Gets current log cache (list of logs)
  41713. */
  41714. static get LogCache(): string;
  41715. /**
  41716. * Clears the log cache
  41717. */
  41718. static ClearLogCache(): void;
  41719. /**
  41720. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41721. */
  41722. static set LogLevels(level: number);
  41723. /**
  41724. * Checks if the window object exists
  41725. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41726. */
  41727. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41728. /**
  41729. * No performance log
  41730. */
  41731. static readonly PerformanceNoneLogLevel: number;
  41732. /**
  41733. * Use user marks to log performance
  41734. */
  41735. static readonly PerformanceUserMarkLogLevel: number;
  41736. /**
  41737. * Log performance to the console
  41738. */
  41739. static readonly PerformanceConsoleLogLevel: number;
  41740. private static _performance;
  41741. /**
  41742. * Sets the current performance log level
  41743. */
  41744. static set PerformanceLogLevel(level: number);
  41745. private static _StartPerformanceCounterDisabled;
  41746. private static _EndPerformanceCounterDisabled;
  41747. private static _StartUserMark;
  41748. private static _EndUserMark;
  41749. private static _StartPerformanceConsole;
  41750. private static _EndPerformanceConsole;
  41751. /**
  41752. * Starts a performance counter
  41753. */
  41754. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41755. /**
  41756. * Ends a specific performance coutner
  41757. */
  41758. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41759. /**
  41760. * Gets either window.performance.now() if supported or Date.now() else
  41761. */
  41762. static get Now(): number;
  41763. /**
  41764. * This method will return the name of the class used to create the instance of the given object.
  41765. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41766. * @param object the object to get the class name from
  41767. * @param isType defines if the object is actually a type
  41768. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41769. */
  41770. static GetClassName(object: any, isType?: boolean): string;
  41771. /**
  41772. * Gets the first element of an array satisfying a given predicate
  41773. * @param array defines the array to browse
  41774. * @param predicate defines the predicate to use
  41775. * @returns null if not found or the element
  41776. */
  41777. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41778. /**
  41779. * This method will return the name of the full name of the class, including its owning module (if any).
  41780. * 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).
  41781. * @param object the object to get the class name from
  41782. * @param isType defines if the object is actually a type
  41783. * @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.
  41784. * @ignorenaming
  41785. */
  41786. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41787. /**
  41788. * Returns a promise that resolves after the given amount of time.
  41789. * @param delay Number of milliseconds to delay
  41790. * @returns Promise that resolves after the given amount of time
  41791. */
  41792. static DelayAsync(delay: number): Promise<void>;
  41793. /**
  41794. * Utility function to detect if the current user agent is Safari
  41795. * @returns whether or not the current user agent is safari
  41796. */
  41797. static IsSafari(): boolean;
  41798. }
  41799. /**
  41800. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41801. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41802. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41803. * @param name The name of the class, case should be preserved
  41804. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41805. */
  41806. export function className(name: string, module?: string): (target: Object) => void;
  41807. /**
  41808. * An implementation of a loop for asynchronous functions.
  41809. */
  41810. export class AsyncLoop {
  41811. /**
  41812. * Defines the number of iterations for the loop
  41813. */
  41814. iterations: number;
  41815. /**
  41816. * Defines the current index of the loop.
  41817. */
  41818. index: number;
  41819. private _done;
  41820. private _fn;
  41821. private _successCallback;
  41822. /**
  41823. * Constructor.
  41824. * @param iterations the number of iterations.
  41825. * @param func the function to run each iteration
  41826. * @param successCallback the callback that will be called upon succesful execution
  41827. * @param offset starting offset.
  41828. */
  41829. constructor(
  41830. /**
  41831. * Defines the number of iterations for the loop
  41832. */
  41833. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41834. /**
  41835. * Execute the next iteration. Must be called after the last iteration was finished.
  41836. */
  41837. executeNext(): void;
  41838. /**
  41839. * Break the loop and run the success callback.
  41840. */
  41841. breakLoop(): void;
  41842. /**
  41843. * Create and run an async loop.
  41844. * @param iterations the number of iterations.
  41845. * @param fn the function to run each iteration
  41846. * @param successCallback the callback that will be called upon succesful execution
  41847. * @param offset starting offset.
  41848. * @returns the created async loop object
  41849. */
  41850. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41851. /**
  41852. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41853. * @param iterations total number of iterations
  41854. * @param syncedIterations number of synchronous iterations in each async iteration.
  41855. * @param fn the function to call each iteration.
  41856. * @param callback a success call back that will be called when iterating stops.
  41857. * @param breakFunction a break condition (optional)
  41858. * @param timeout timeout settings for the setTimeout function. default - 0.
  41859. * @returns the created async loop object
  41860. */
  41861. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41862. }
  41863. }
  41864. declare module BABYLON {
  41865. /**
  41866. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41867. * The underlying implementation relies on an associative array to ensure the best performances.
  41868. * The value can be anything including 'null' but except 'undefined'
  41869. */
  41870. export class StringDictionary<T> {
  41871. /**
  41872. * This will clear this dictionary and copy the content from the 'source' one.
  41873. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41874. * @param source the dictionary to take the content from and copy to this dictionary
  41875. */
  41876. copyFrom(source: StringDictionary<T>): void;
  41877. /**
  41878. * Get a value based from its key
  41879. * @param key the given key to get the matching value from
  41880. * @return the value if found, otherwise undefined is returned
  41881. */
  41882. get(key: string): T | undefined;
  41883. /**
  41884. * Get a value from its key or add it if it doesn't exist.
  41885. * This method will ensure you that a given key/data will be present in the dictionary.
  41886. * @param key the given key to get the matching value from
  41887. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41888. * The factory will only be invoked if there's no data for the given key.
  41889. * @return the value corresponding to the key.
  41890. */
  41891. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41892. /**
  41893. * Get a value from its key if present in the dictionary otherwise add it
  41894. * @param key the key to get the value from
  41895. * @param val if there's no such key/value pair in the dictionary add it with this value
  41896. * @return the value corresponding to the key
  41897. */
  41898. getOrAdd(key: string, val: T): T;
  41899. /**
  41900. * Check if there's a given key in the dictionary
  41901. * @param key the key to check for
  41902. * @return true if the key is present, false otherwise
  41903. */
  41904. contains(key: string): boolean;
  41905. /**
  41906. * Add a new key and its corresponding value
  41907. * @param key the key to add
  41908. * @param value the value corresponding to the key
  41909. * @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
  41910. */
  41911. add(key: string, value: T): boolean;
  41912. /**
  41913. * Update a specific value associated to a key
  41914. * @param key defines the key to use
  41915. * @param value defines the value to store
  41916. * @returns true if the value was updated (or false if the key was not found)
  41917. */
  41918. set(key: string, value: T): boolean;
  41919. /**
  41920. * Get the element of the given key and remove it from the dictionary
  41921. * @param key defines the key to search
  41922. * @returns the value associated with the key or null if not found
  41923. */
  41924. getAndRemove(key: string): Nullable<T>;
  41925. /**
  41926. * Remove a key/value from the dictionary.
  41927. * @param key the key to remove
  41928. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41929. */
  41930. remove(key: string): boolean;
  41931. /**
  41932. * Clear the whole content of the dictionary
  41933. */
  41934. clear(): void;
  41935. /**
  41936. * Gets the current count
  41937. */
  41938. get count(): number;
  41939. /**
  41940. * Execute a callback on each key/val of the dictionary.
  41941. * Note that you can remove any element in this dictionary in the callback implementation
  41942. * @param callback the callback to execute on a given key/value pair
  41943. */
  41944. forEach(callback: (key: string, val: T) => void): void;
  41945. /**
  41946. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41947. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41948. * Note that you can remove any element in this dictionary in the callback implementation
  41949. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41950. * @returns the first item
  41951. */
  41952. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41953. private _count;
  41954. private _data;
  41955. }
  41956. }
  41957. declare module BABYLON {
  41958. /** @hidden */
  41959. export interface ICollisionCoordinator {
  41960. createCollider(): Collider;
  41961. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41962. init(scene: Scene): void;
  41963. }
  41964. /** @hidden */
  41965. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41966. private _scene;
  41967. private _scaledPosition;
  41968. private _scaledVelocity;
  41969. private _finalPosition;
  41970. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41971. createCollider(): Collider;
  41972. init(scene: Scene): void;
  41973. private _collideWithWorld;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * Class used to manage all inputs for the scene.
  41979. */
  41980. export class InputManager {
  41981. /** The distance in pixel that you have to move to prevent some events */
  41982. static DragMovementThreshold: number;
  41983. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41984. static LongPressDelay: number;
  41985. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41986. static DoubleClickDelay: number;
  41987. /** If you need to check double click without raising a single click at first click, enable this flag */
  41988. static ExclusiveDoubleClickMode: boolean;
  41989. /** 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. */
  41990. private _alreadyAttached;
  41991. private _alreadyAttachedTo;
  41992. private _wheelEventName;
  41993. private _onPointerMove;
  41994. private _onPointerDown;
  41995. private _onPointerUp;
  41996. private _initClickEvent;
  41997. private _initActionManager;
  41998. private _delayedSimpleClick;
  41999. private _delayedSimpleClickTimeout;
  42000. private _previousDelayedSimpleClickTimeout;
  42001. private _meshPickProceed;
  42002. private _previousButtonPressed;
  42003. private _currentPickResult;
  42004. private _previousPickResult;
  42005. private _totalPointersPressed;
  42006. private _doubleClickOccured;
  42007. private _pointerOverMesh;
  42008. private _pickedDownMesh;
  42009. private _pickedUpMesh;
  42010. private _pointerX;
  42011. private _pointerY;
  42012. private _unTranslatedPointerX;
  42013. private _unTranslatedPointerY;
  42014. private _startingPointerPosition;
  42015. private _previousStartingPointerPosition;
  42016. private _startingPointerTime;
  42017. private _previousStartingPointerTime;
  42018. private _pointerCaptures;
  42019. private _meshUnderPointerId;
  42020. private _onKeyDown;
  42021. private _onKeyUp;
  42022. private _keyboardIsAttached;
  42023. private _onCanvasFocusObserver;
  42024. private _onCanvasBlurObserver;
  42025. private _scene;
  42026. /**
  42027. * Creates a new InputManager
  42028. * @param scene defines the hosting scene
  42029. */
  42030. constructor(scene: Scene);
  42031. /**
  42032. * Gets the mesh that is currently under the pointer
  42033. */
  42034. get meshUnderPointer(): Nullable<AbstractMesh>;
  42035. /**
  42036. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42037. * @param pointerId the pointer id to use
  42038. * @returns The mesh under this pointer id or null if not found
  42039. */
  42040. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42041. /**
  42042. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42043. */
  42044. get unTranslatedPointer(): Vector2;
  42045. /**
  42046. * Gets or sets the current on-screen X position of the pointer
  42047. */
  42048. get pointerX(): number;
  42049. set pointerX(value: number);
  42050. /**
  42051. * Gets or sets the current on-screen Y position of the pointer
  42052. */
  42053. get pointerY(): number;
  42054. set pointerY(value: number);
  42055. private _updatePointerPosition;
  42056. private _processPointerMove;
  42057. private _setRayOnPointerInfo;
  42058. private _checkPrePointerObservable;
  42059. /**
  42060. * Use this method to simulate a pointer move on a mesh
  42061. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42062. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42063. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42064. */
  42065. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42066. /**
  42067. * Use this method to simulate a pointer down on a mesh
  42068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42071. */
  42072. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42073. private _processPointerDown;
  42074. /** @hidden */
  42075. _isPointerSwiping(): boolean;
  42076. /**
  42077. * Use this method to simulate a pointer up on a mesh
  42078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42081. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42082. */
  42083. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42084. private _processPointerUp;
  42085. /**
  42086. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42087. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42088. * @returns true if the pointer was captured
  42089. */
  42090. isPointerCaptured(pointerId?: number): boolean;
  42091. /**
  42092. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42093. * @param attachUp defines if you want to attach events to pointerup
  42094. * @param attachDown defines if you want to attach events to pointerdown
  42095. * @param attachMove defines if you want to attach events to pointermove
  42096. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42097. */
  42098. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42099. /**
  42100. * Detaches all event handlers
  42101. */
  42102. detachControl(): void;
  42103. /**
  42104. * Force the value of meshUnderPointer
  42105. * @param mesh defines the mesh to use
  42106. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42107. */
  42108. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42109. /**
  42110. * Gets the mesh under the pointer
  42111. * @returns a Mesh or null if no mesh is under the pointer
  42112. */
  42113. getPointerOverMesh(): Nullable<AbstractMesh>;
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. /**
  42118. * This class defines the direct association between an animation and a target
  42119. */
  42120. export class TargetedAnimation {
  42121. /**
  42122. * Animation to perform
  42123. */
  42124. animation: Animation;
  42125. /**
  42126. * Target to animate
  42127. */
  42128. target: any;
  42129. /**
  42130. * Returns the string "TargetedAnimation"
  42131. * @returns "TargetedAnimation"
  42132. */
  42133. getClassName(): string;
  42134. /**
  42135. * Serialize the object
  42136. * @returns the JSON object representing the current entity
  42137. */
  42138. serialize(): any;
  42139. }
  42140. /**
  42141. * Use this class to create coordinated animations on multiple targets
  42142. */
  42143. export class AnimationGroup implements IDisposable {
  42144. /** The name of the animation group */
  42145. name: string;
  42146. private _scene;
  42147. private _targetedAnimations;
  42148. private _animatables;
  42149. private _from;
  42150. private _to;
  42151. private _isStarted;
  42152. private _isPaused;
  42153. private _speedRatio;
  42154. private _loopAnimation;
  42155. private _isAdditive;
  42156. /**
  42157. * Gets or sets the unique id of the node
  42158. */
  42159. uniqueId: number;
  42160. /**
  42161. * This observable will notify when one animation have ended
  42162. */
  42163. onAnimationEndObservable: Observable<TargetedAnimation>;
  42164. /**
  42165. * Observer raised when one animation loops
  42166. */
  42167. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42168. /**
  42169. * Observer raised when all animations have looped
  42170. */
  42171. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42172. /**
  42173. * This observable will notify when all animations have ended.
  42174. */
  42175. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42176. /**
  42177. * This observable will notify when all animations have paused.
  42178. */
  42179. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42180. /**
  42181. * This observable will notify when all animations are playing.
  42182. */
  42183. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42184. /**
  42185. * Gets the first frame
  42186. */
  42187. get from(): number;
  42188. /**
  42189. * Gets the last frame
  42190. */
  42191. get to(): number;
  42192. /**
  42193. * Define if the animations are started
  42194. */
  42195. get isStarted(): boolean;
  42196. /**
  42197. * Gets a value indicating that the current group is playing
  42198. */
  42199. get isPlaying(): boolean;
  42200. /**
  42201. * Gets or sets the speed ratio to use for all animations
  42202. */
  42203. get speedRatio(): number;
  42204. /**
  42205. * Gets or sets the speed ratio to use for all animations
  42206. */
  42207. set speedRatio(value: number);
  42208. /**
  42209. * Gets or sets if all animations should loop or not
  42210. */
  42211. get loopAnimation(): boolean;
  42212. set loopAnimation(value: boolean);
  42213. /**
  42214. * Gets or sets if all animations should be evaluated additively
  42215. */
  42216. get isAdditive(): boolean;
  42217. set isAdditive(value: boolean);
  42218. /**
  42219. * Gets the targeted animations for this animation group
  42220. */
  42221. get targetedAnimations(): Array<TargetedAnimation>;
  42222. /**
  42223. * returning the list of animatables controlled by this animation group.
  42224. */
  42225. get animatables(): Array<Animatable>;
  42226. /**
  42227. * Gets the list of target animations
  42228. */
  42229. get children(): TargetedAnimation[];
  42230. /**
  42231. * Instantiates a new Animation Group.
  42232. * This helps managing several animations at once.
  42233. * @see https://doc.babylonjs.com/how_to/group
  42234. * @param name Defines the name of the group
  42235. * @param scene Defines the scene the group belongs to
  42236. */
  42237. constructor(
  42238. /** The name of the animation group */
  42239. name: string, scene?: Nullable<Scene>);
  42240. /**
  42241. * Add an animation (with its target) in the group
  42242. * @param animation defines the animation we want to add
  42243. * @param target defines the target of the animation
  42244. * @returns the TargetedAnimation object
  42245. */
  42246. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42247. /**
  42248. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42249. * It can add constant keys at begin or end
  42250. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42251. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42252. * @returns the animation group
  42253. */
  42254. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42255. private _animationLoopCount;
  42256. private _animationLoopFlags;
  42257. private _processLoop;
  42258. /**
  42259. * Start all animations on given targets
  42260. * @param loop defines if animations must loop
  42261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42262. * @param from defines the from key (optional)
  42263. * @param to defines the to key (optional)
  42264. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42265. * @returns the current animation group
  42266. */
  42267. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42268. /**
  42269. * Pause all animations
  42270. * @returns the animation group
  42271. */
  42272. pause(): AnimationGroup;
  42273. /**
  42274. * Play all animations to initial state
  42275. * This function will start() the animations if they were not started or will restart() them if they were paused
  42276. * @param loop defines if animations must loop
  42277. * @returns the animation group
  42278. */
  42279. play(loop?: boolean): AnimationGroup;
  42280. /**
  42281. * Reset all animations to initial state
  42282. * @returns the animation group
  42283. */
  42284. reset(): AnimationGroup;
  42285. /**
  42286. * Restart animations from key 0
  42287. * @returns the animation group
  42288. */
  42289. restart(): AnimationGroup;
  42290. /**
  42291. * Stop all animations
  42292. * @returns the animation group
  42293. */
  42294. stop(): AnimationGroup;
  42295. /**
  42296. * Set animation weight for all animatables
  42297. * @param weight defines the weight to use
  42298. * @return the animationGroup
  42299. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42300. */
  42301. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42302. /**
  42303. * Synchronize and normalize all animatables with a source animatable
  42304. * @param root defines the root animatable to synchronize with
  42305. * @return the animationGroup
  42306. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42307. */
  42308. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42309. /**
  42310. * Goes to a specific frame in this animation group
  42311. * @param frame the frame number to go to
  42312. * @return the animationGroup
  42313. */
  42314. goToFrame(frame: number): AnimationGroup;
  42315. /**
  42316. * Dispose all associated resources
  42317. */
  42318. dispose(): void;
  42319. private _checkAnimationGroupEnded;
  42320. /**
  42321. * Clone the current animation group and returns a copy
  42322. * @param newName defines the name of the new group
  42323. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42324. * @returns the new aniamtion group
  42325. */
  42326. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42327. /**
  42328. * Serializes the animationGroup to an object
  42329. * @returns Serialized object
  42330. */
  42331. serialize(): any;
  42332. /**
  42333. * Returns a new AnimationGroup object parsed from the source provided.
  42334. * @param parsedAnimationGroup defines the source
  42335. * @param scene defines the scene that will receive the animationGroup
  42336. * @returns a new AnimationGroup
  42337. */
  42338. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42339. /**
  42340. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42341. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42342. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42343. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42344. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42345. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42346. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42347. */
  42348. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42349. /**
  42350. * Returns the string "AnimationGroup"
  42351. * @returns "AnimationGroup"
  42352. */
  42353. getClassName(): string;
  42354. /**
  42355. * Creates a detailled string about the object
  42356. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42357. * @returns a string representing the object
  42358. */
  42359. toString(fullDetails?: boolean): string;
  42360. }
  42361. }
  42362. declare module BABYLON {
  42363. /**
  42364. * Define an interface for all classes that will hold resources
  42365. */
  42366. export interface IDisposable {
  42367. /**
  42368. * Releases all held resources
  42369. */
  42370. dispose(): void;
  42371. }
  42372. /** Interface defining initialization parameters for Scene class */
  42373. export interface SceneOptions {
  42374. /**
  42375. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42376. * It will improve performance when the number of geometries becomes important.
  42377. */
  42378. useGeometryUniqueIdsMap?: boolean;
  42379. /**
  42380. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42381. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42382. */
  42383. useMaterialMeshMap?: boolean;
  42384. /**
  42385. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42386. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42387. */
  42388. useClonedMeshMap?: boolean;
  42389. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42390. virtual?: boolean;
  42391. }
  42392. /**
  42393. * Represents a scene to be rendered by the engine.
  42394. * @see https://doc.babylonjs.com/features/scene
  42395. */
  42396. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42397. /** The fog is deactivated */
  42398. static readonly FOGMODE_NONE: number;
  42399. /** The fog density is following an exponential function */
  42400. static readonly FOGMODE_EXP: number;
  42401. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42402. static readonly FOGMODE_EXP2: number;
  42403. /** The fog density is following a linear function. */
  42404. static readonly FOGMODE_LINEAR: number;
  42405. /**
  42406. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42408. */
  42409. static MinDeltaTime: number;
  42410. /**
  42411. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42413. */
  42414. static MaxDeltaTime: number;
  42415. /**
  42416. * Factory used to create the default material.
  42417. * @param name The name of the material to create
  42418. * @param scene The scene to create the material for
  42419. * @returns The default material
  42420. */
  42421. static DefaultMaterialFactory(scene: Scene): Material;
  42422. /**
  42423. * Factory used to create the a collision coordinator.
  42424. * @returns The collision coordinator
  42425. */
  42426. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42427. /** @hidden */
  42428. _inputManager: InputManager;
  42429. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42430. cameraToUseForPointers: Nullable<Camera>;
  42431. /** @hidden */
  42432. readonly _isScene: boolean;
  42433. /** @hidden */
  42434. _blockEntityCollection: boolean;
  42435. /**
  42436. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42437. */
  42438. autoClear: boolean;
  42439. /**
  42440. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42441. */
  42442. autoClearDepthAndStencil: boolean;
  42443. /**
  42444. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42445. */
  42446. clearColor: Color4;
  42447. /**
  42448. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42449. */
  42450. ambientColor: Color3;
  42451. /**
  42452. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42453. * It should only be one of the following (if not the default embedded one):
  42454. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42455. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42456. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42457. * The material properties need to be setup according to the type of texture in use.
  42458. */
  42459. environmentBRDFTexture: BaseTexture;
  42460. /**
  42461. * Texture used in all pbr material as the reflection texture.
  42462. * As in the majority of the scene they are the same (exception for multi room and so on),
  42463. * this is easier to reference from here than from all the materials.
  42464. */
  42465. get environmentTexture(): Nullable<BaseTexture>;
  42466. /**
  42467. * Texture used in all pbr material as the reflection texture.
  42468. * As in the majority of the scene they are the same (exception for multi room and so on),
  42469. * this is easier to set here than in all the materials.
  42470. */
  42471. set environmentTexture(value: Nullable<BaseTexture>);
  42472. /** @hidden */
  42473. protected _environmentIntensity: number;
  42474. /**
  42475. * Intensity of the environment in all pbr material.
  42476. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42477. * As in the majority of the scene they are the same (exception for multi room and so on),
  42478. * this is easier to reference from here than from all the materials.
  42479. */
  42480. get environmentIntensity(): number;
  42481. /**
  42482. * Intensity of the environment in all pbr material.
  42483. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42484. * As in the majority of the scene they are the same (exception for multi room and so on),
  42485. * this is easier to set here than in all the materials.
  42486. */
  42487. set environmentIntensity(value: number);
  42488. /** @hidden */
  42489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42490. /**
  42491. * Default image processing configuration used either in the rendering
  42492. * Forward main pass or through the imageProcessingPostProcess if present.
  42493. * As in the majority of the scene they are the same (exception for multi camera),
  42494. * this is easier to reference from here than from all the materials and post process.
  42495. *
  42496. * No setter as we it is a shared configuration, you can set the values instead.
  42497. */
  42498. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42499. private _forceWireframe;
  42500. /**
  42501. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42502. */
  42503. set forceWireframe(value: boolean);
  42504. get forceWireframe(): boolean;
  42505. private _skipFrustumClipping;
  42506. /**
  42507. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42508. */
  42509. set skipFrustumClipping(value: boolean);
  42510. get skipFrustumClipping(): boolean;
  42511. private _forcePointsCloud;
  42512. /**
  42513. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42514. */
  42515. set forcePointsCloud(value: boolean);
  42516. get forcePointsCloud(): boolean;
  42517. /**
  42518. * Gets or sets the active clipplane 1
  42519. */
  42520. clipPlane: Nullable<Plane>;
  42521. /**
  42522. * Gets or sets the active clipplane 2
  42523. */
  42524. clipPlane2: Nullable<Plane>;
  42525. /**
  42526. * Gets or sets the active clipplane 3
  42527. */
  42528. clipPlane3: Nullable<Plane>;
  42529. /**
  42530. * Gets or sets the active clipplane 4
  42531. */
  42532. clipPlane4: Nullable<Plane>;
  42533. /**
  42534. * Gets or sets the active clipplane 5
  42535. */
  42536. clipPlane5: Nullable<Plane>;
  42537. /**
  42538. * Gets or sets the active clipplane 6
  42539. */
  42540. clipPlane6: Nullable<Plane>;
  42541. /**
  42542. * Gets or sets a boolean indicating if animations are enabled
  42543. */
  42544. animationsEnabled: boolean;
  42545. private _animationPropertiesOverride;
  42546. /**
  42547. * Gets or sets the animation properties override
  42548. */
  42549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42550. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42551. /**
  42552. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42553. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42554. */
  42555. useConstantAnimationDeltaTime: boolean;
  42556. /**
  42557. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42558. * Please note that it requires to run a ray cast through the scene on every frame
  42559. */
  42560. constantlyUpdateMeshUnderPointer: boolean;
  42561. /**
  42562. * Defines the HTML cursor to use when hovering over interactive elements
  42563. */
  42564. hoverCursor: string;
  42565. /**
  42566. * Defines the HTML default cursor to use (empty by default)
  42567. */
  42568. defaultCursor: string;
  42569. /**
  42570. * Defines whether cursors are handled by the scene.
  42571. */
  42572. doNotHandleCursors: boolean;
  42573. /**
  42574. * This is used to call preventDefault() on pointer down
  42575. * in order to block unwanted artifacts like system double clicks
  42576. */
  42577. preventDefaultOnPointerDown: boolean;
  42578. /**
  42579. * This is used to call preventDefault() on pointer up
  42580. * in order to block unwanted artifacts like system double clicks
  42581. */
  42582. preventDefaultOnPointerUp: boolean;
  42583. /**
  42584. * Gets or sets user defined metadata
  42585. */
  42586. metadata: any;
  42587. /**
  42588. * For internal use only. Please do not use.
  42589. */
  42590. reservedDataStore: any;
  42591. /**
  42592. * Gets the name of the plugin used to load this scene (null by default)
  42593. */
  42594. loadingPluginName: string;
  42595. /**
  42596. * Use this array to add regular expressions used to disable offline support for specific urls
  42597. */
  42598. disableOfflineSupportExceptionRules: RegExp[];
  42599. /**
  42600. * An event triggered when the scene is disposed.
  42601. */
  42602. onDisposeObservable: Observable<Scene>;
  42603. private _onDisposeObserver;
  42604. /** Sets a function to be executed when this scene is disposed. */
  42605. set onDispose(callback: () => void);
  42606. /**
  42607. * An event triggered before rendering the scene (right after animations and physics)
  42608. */
  42609. onBeforeRenderObservable: Observable<Scene>;
  42610. private _onBeforeRenderObserver;
  42611. /** Sets a function to be executed before rendering this scene */
  42612. set beforeRender(callback: Nullable<() => void>);
  42613. /**
  42614. * An event triggered after rendering the scene
  42615. */
  42616. onAfterRenderObservable: Observable<Scene>;
  42617. /**
  42618. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42619. */
  42620. onAfterRenderCameraObservable: Observable<Camera>;
  42621. private _onAfterRenderObserver;
  42622. /** Sets a function to be executed after rendering this scene */
  42623. set afterRender(callback: Nullable<() => void>);
  42624. /**
  42625. * An event triggered before animating the scene
  42626. */
  42627. onBeforeAnimationsObservable: Observable<Scene>;
  42628. /**
  42629. * An event triggered after animations processing
  42630. */
  42631. onAfterAnimationsObservable: Observable<Scene>;
  42632. /**
  42633. * An event triggered before draw calls are ready to be sent
  42634. */
  42635. onBeforeDrawPhaseObservable: Observable<Scene>;
  42636. /**
  42637. * An event triggered after draw calls have been sent
  42638. */
  42639. onAfterDrawPhaseObservable: Observable<Scene>;
  42640. /**
  42641. * An event triggered when the scene is ready
  42642. */
  42643. onReadyObservable: Observable<Scene>;
  42644. /**
  42645. * An event triggered before rendering a camera
  42646. */
  42647. onBeforeCameraRenderObservable: Observable<Camera>;
  42648. private _onBeforeCameraRenderObserver;
  42649. /** Sets a function to be executed before rendering a camera*/
  42650. set beforeCameraRender(callback: () => void);
  42651. /**
  42652. * An event triggered after rendering a camera
  42653. */
  42654. onAfterCameraRenderObservable: Observable<Camera>;
  42655. private _onAfterCameraRenderObserver;
  42656. /** Sets a function to be executed after rendering a camera*/
  42657. set afterCameraRender(callback: () => void);
  42658. /**
  42659. * An event triggered when active meshes evaluation is about to start
  42660. */
  42661. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42662. /**
  42663. * An event triggered when active meshes evaluation is done
  42664. */
  42665. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42666. /**
  42667. * An event triggered when particles rendering is about to start
  42668. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42669. */
  42670. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42671. /**
  42672. * An event triggered when particles rendering is done
  42673. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42674. */
  42675. onAfterParticlesRenderingObservable: Observable<Scene>;
  42676. /**
  42677. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42678. */
  42679. onDataLoadedObservable: Observable<Scene>;
  42680. /**
  42681. * An event triggered when a camera is created
  42682. */
  42683. onNewCameraAddedObservable: Observable<Camera>;
  42684. /**
  42685. * An event triggered when a camera is removed
  42686. */
  42687. onCameraRemovedObservable: Observable<Camera>;
  42688. /**
  42689. * An event triggered when a light is created
  42690. */
  42691. onNewLightAddedObservable: Observable<Light>;
  42692. /**
  42693. * An event triggered when a light is removed
  42694. */
  42695. onLightRemovedObservable: Observable<Light>;
  42696. /**
  42697. * An event triggered when a geometry is created
  42698. */
  42699. onNewGeometryAddedObservable: Observable<Geometry>;
  42700. /**
  42701. * An event triggered when a geometry is removed
  42702. */
  42703. onGeometryRemovedObservable: Observable<Geometry>;
  42704. /**
  42705. * An event triggered when a transform node is created
  42706. */
  42707. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42708. /**
  42709. * An event triggered when a transform node is removed
  42710. */
  42711. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42712. /**
  42713. * An event triggered when a mesh is created
  42714. */
  42715. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42716. /**
  42717. * An event triggered when a mesh is removed
  42718. */
  42719. onMeshRemovedObservable: Observable<AbstractMesh>;
  42720. /**
  42721. * An event triggered when a skeleton is created
  42722. */
  42723. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42724. /**
  42725. * An event triggered when a skeleton is removed
  42726. */
  42727. onSkeletonRemovedObservable: Observable<Skeleton>;
  42728. /**
  42729. * An event triggered when a material is created
  42730. */
  42731. onNewMaterialAddedObservable: Observable<Material>;
  42732. /**
  42733. * An event triggered when a material is removed
  42734. */
  42735. onMaterialRemovedObservable: Observable<Material>;
  42736. /**
  42737. * An event triggered when a texture is created
  42738. */
  42739. onNewTextureAddedObservable: Observable<BaseTexture>;
  42740. /**
  42741. * An event triggered when a texture is removed
  42742. */
  42743. onTextureRemovedObservable: Observable<BaseTexture>;
  42744. /**
  42745. * An event triggered when render targets are about to be rendered
  42746. * Can happen multiple times per frame.
  42747. */
  42748. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42749. /**
  42750. * An event triggered when render targets were rendered.
  42751. * Can happen multiple times per frame.
  42752. */
  42753. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42754. /**
  42755. * An event triggered before calculating deterministic simulation step
  42756. */
  42757. onBeforeStepObservable: Observable<Scene>;
  42758. /**
  42759. * An event triggered after calculating deterministic simulation step
  42760. */
  42761. onAfterStepObservable: Observable<Scene>;
  42762. /**
  42763. * An event triggered when the activeCamera property is updated
  42764. */
  42765. onActiveCameraChanged: Observable<Scene>;
  42766. /**
  42767. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42768. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42769. * 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)
  42770. */
  42771. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42772. /**
  42773. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42774. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42775. * 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)
  42776. */
  42777. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42778. /**
  42779. * This Observable will when a mesh has been imported into the scene.
  42780. */
  42781. onMeshImportedObservable: Observable<AbstractMesh>;
  42782. /**
  42783. * This Observable will when an animation file has been imported into the scene.
  42784. */
  42785. onAnimationFileImportedObservable: Observable<Scene>;
  42786. /**
  42787. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42788. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42789. */
  42790. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42791. /** @hidden */
  42792. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42793. /**
  42794. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42795. */
  42796. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42797. /**
  42798. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42799. */
  42800. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42801. /**
  42802. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42803. */
  42804. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42805. /** Callback called when a pointer move is detected */
  42806. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42807. /** Callback called when a pointer down is detected */
  42808. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42809. /** Callback called when a pointer up is detected */
  42810. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42811. /** Callback called when a pointer pick is detected */
  42812. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42813. /**
  42814. * 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).
  42815. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42816. */
  42817. onPrePointerObservable: Observable<PointerInfoPre>;
  42818. /**
  42819. * Observable event triggered each time an input event is received from the rendering canvas
  42820. */
  42821. onPointerObservable: Observable<PointerInfo>;
  42822. /**
  42823. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42824. */
  42825. get unTranslatedPointer(): Vector2;
  42826. /**
  42827. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42828. */
  42829. static get DragMovementThreshold(): number;
  42830. static set DragMovementThreshold(value: number);
  42831. /**
  42832. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42833. */
  42834. static get LongPressDelay(): number;
  42835. static set LongPressDelay(value: number);
  42836. /**
  42837. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42838. */
  42839. static get DoubleClickDelay(): number;
  42840. static set DoubleClickDelay(value: number);
  42841. /** If you need to check double click without raising a single click at first click, enable this flag */
  42842. static get ExclusiveDoubleClickMode(): boolean;
  42843. static set ExclusiveDoubleClickMode(value: boolean);
  42844. /** @hidden */
  42845. _mirroredCameraPosition: Nullable<Vector3>;
  42846. /**
  42847. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42848. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42849. */
  42850. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42851. /**
  42852. * Observable event triggered each time an keyboard event is received from the hosting window
  42853. */
  42854. onKeyboardObservable: Observable<KeyboardInfo>;
  42855. private _useRightHandedSystem;
  42856. /**
  42857. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42858. */
  42859. set useRightHandedSystem(value: boolean);
  42860. get useRightHandedSystem(): boolean;
  42861. private _timeAccumulator;
  42862. private _currentStepId;
  42863. private _currentInternalStep;
  42864. /**
  42865. * Sets the step Id used by deterministic lock step
  42866. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42867. * @param newStepId defines the step Id
  42868. */
  42869. setStepId(newStepId: number): void;
  42870. /**
  42871. * Gets the step Id used by deterministic lock step
  42872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42873. * @returns the step Id
  42874. */
  42875. getStepId(): number;
  42876. /**
  42877. * Gets the internal step used by deterministic lock step
  42878. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42879. * @returns the internal step
  42880. */
  42881. getInternalStep(): number;
  42882. private _fogEnabled;
  42883. /**
  42884. * Gets or sets a boolean indicating if fog is enabled on this scene
  42885. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42886. * (Default is true)
  42887. */
  42888. set fogEnabled(value: boolean);
  42889. get fogEnabled(): boolean;
  42890. private _fogMode;
  42891. /**
  42892. * Gets or sets the fog mode to use
  42893. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42894. * | mode | value |
  42895. * | --- | --- |
  42896. * | FOGMODE_NONE | 0 |
  42897. * | FOGMODE_EXP | 1 |
  42898. * | FOGMODE_EXP2 | 2 |
  42899. * | FOGMODE_LINEAR | 3 |
  42900. */
  42901. set fogMode(value: number);
  42902. get fogMode(): number;
  42903. /**
  42904. * Gets or sets the fog color to use
  42905. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42906. * (Default is Color3(0.2, 0.2, 0.3))
  42907. */
  42908. fogColor: Color3;
  42909. /**
  42910. * Gets or sets the fog density to use
  42911. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42912. * (Default is 0.1)
  42913. */
  42914. fogDensity: number;
  42915. /**
  42916. * Gets or sets the fog start distance to use
  42917. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42918. * (Default is 0)
  42919. */
  42920. fogStart: number;
  42921. /**
  42922. * Gets or sets the fog end distance to use
  42923. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42924. * (Default is 1000)
  42925. */
  42926. fogEnd: number;
  42927. /**
  42928. * Flag indicating that the frame buffer binding is handled by another component
  42929. */
  42930. prePass: boolean;
  42931. private _shadowsEnabled;
  42932. /**
  42933. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42934. */
  42935. set shadowsEnabled(value: boolean);
  42936. get shadowsEnabled(): boolean;
  42937. private _lightsEnabled;
  42938. /**
  42939. * Gets or sets a boolean indicating if lights are enabled on this scene
  42940. */
  42941. set lightsEnabled(value: boolean);
  42942. get lightsEnabled(): boolean;
  42943. /** All of the active cameras added to this scene. */
  42944. activeCameras: Camera[];
  42945. /** @hidden */
  42946. _activeCamera: Nullable<Camera>;
  42947. /** Gets or sets the current active camera */
  42948. get activeCamera(): Nullable<Camera>;
  42949. set activeCamera(value: Nullable<Camera>);
  42950. private _defaultMaterial;
  42951. /** The default material used on meshes when no material is affected */
  42952. get defaultMaterial(): Material;
  42953. /** The default material used on meshes when no material is affected */
  42954. set defaultMaterial(value: Material);
  42955. private _texturesEnabled;
  42956. /**
  42957. * Gets or sets a boolean indicating if textures are enabled on this scene
  42958. */
  42959. set texturesEnabled(value: boolean);
  42960. get texturesEnabled(): boolean;
  42961. /**
  42962. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42963. */
  42964. physicsEnabled: boolean;
  42965. /**
  42966. * Gets or sets a boolean indicating if particles are enabled on this scene
  42967. */
  42968. particlesEnabled: boolean;
  42969. /**
  42970. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42971. */
  42972. spritesEnabled: boolean;
  42973. private _skeletonsEnabled;
  42974. /**
  42975. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42976. */
  42977. set skeletonsEnabled(value: boolean);
  42978. get skeletonsEnabled(): boolean;
  42979. /**
  42980. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42981. */
  42982. lensFlaresEnabled: boolean;
  42983. /**
  42984. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42986. */
  42987. collisionsEnabled: boolean;
  42988. private _collisionCoordinator;
  42989. /** @hidden */
  42990. get collisionCoordinator(): ICollisionCoordinator;
  42991. /**
  42992. * Defines the gravity applied to this scene (used only for collisions)
  42993. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42994. */
  42995. gravity: Vector3;
  42996. /**
  42997. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42998. */
  42999. postProcessesEnabled: boolean;
  43000. /**
  43001. * Gets the current postprocess manager
  43002. */
  43003. postProcessManager: PostProcessManager;
  43004. /**
  43005. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43006. */
  43007. renderTargetsEnabled: boolean;
  43008. /**
  43009. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43010. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43011. */
  43012. dumpNextRenderTargets: boolean;
  43013. /**
  43014. * The list of user defined render targets added to the scene
  43015. */
  43016. customRenderTargets: RenderTargetTexture[];
  43017. /**
  43018. * Defines if texture loading must be delayed
  43019. * If true, textures will only be loaded when they need to be rendered
  43020. */
  43021. useDelayedTextureLoading: boolean;
  43022. /**
  43023. * Gets the list of meshes imported to the scene through SceneLoader
  43024. */
  43025. importedMeshesFiles: String[];
  43026. /**
  43027. * Gets or sets a boolean indicating if probes are enabled on this scene
  43028. */
  43029. probesEnabled: boolean;
  43030. /**
  43031. * Gets or sets the current offline provider to use to store scene data
  43032. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43033. */
  43034. offlineProvider: IOfflineProvider;
  43035. /**
  43036. * Gets or sets the action manager associated with the scene
  43037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43038. */
  43039. actionManager: AbstractActionManager;
  43040. private _meshesForIntersections;
  43041. /**
  43042. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43043. */
  43044. proceduralTexturesEnabled: boolean;
  43045. private _engine;
  43046. private _totalVertices;
  43047. /** @hidden */
  43048. _activeIndices: PerfCounter;
  43049. /** @hidden */
  43050. _activeParticles: PerfCounter;
  43051. /** @hidden */
  43052. _activeBones: PerfCounter;
  43053. private _animationRatio;
  43054. /** @hidden */
  43055. _animationTimeLast: number;
  43056. /** @hidden */
  43057. _animationTime: number;
  43058. /**
  43059. * Gets or sets a general scale for animation speed
  43060. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43061. */
  43062. animationTimeScale: number;
  43063. /** @hidden */
  43064. _cachedMaterial: Nullable<Material>;
  43065. /** @hidden */
  43066. _cachedEffect: Nullable<Effect>;
  43067. /** @hidden */
  43068. _cachedVisibility: Nullable<number>;
  43069. private _renderId;
  43070. private _frameId;
  43071. private _executeWhenReadyTimeoutId;
  43072. private _intermediateRendering;
  43073. private _viewUpdateFlag;
  43074. private _projectionUpdateFlag;
  43075. /** @hidden */
  43076. _toBeDisposed: Nullable<IDisposable>[];
  43077. private _activeRequests;
  43078. /** @hidden */
  43079. _pendingData: any[];
  43080. private _isDisposed;
  43081. /**
  43082. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43083. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43084. */
  43085. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43086. private _activeMeshes;
  43087. private _processedMaterials;
  43088. private _renderTargets;
  43089. /** @hidden */
  43090. _activeParticleSystems: SmartArray<IParticleSystem>;
  43091. private _activeSkeletons;
  43092. private _softwareSkinnedMeshes;
  43093. private _renderingManager;
  43094. /** @hidden */
  43095. _activeAnimatables: Animatable[];
  43096. private _transformMatrix;
  43097. private _sceneUbo;
  43098. /** @hidden */
  43099. _viewMatrix: Matrix;
  43100. private _projectionMatrix;
  43101. /** @hidden */
  43102. _forcedViewPosition: Nullable<Vector3>;
  43103. /** @hidden */
  43104. _frustumPlanes: Plane[];
  43105. /**
  43106. * Gets the list of frustum planes (built from the active camera)
  43107. */
  43108. get frustumPlanes(): Plane[];
  43109. /**
  43110. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43111. * This is useful if there are more lights that the maximum simulteanous authorized
  43112. */
  43113. requireLightSorting: boolean;
  43114. /** @hidden */
  43115. readonly useMaterialMeshMap: boolean;
  43116. /** @hidden */
  43117. readonly useClonedMeshMap: boolean;
  43118. private _externalData;
  43119. private _uid;
  43120. /**
  43121. * @hidden
  43122. * Backing store of defined scene components.
  43123. */
  43124. _components: ISceneComponent[];
  43125. /**
  43126. * @hidden
  43127. * Backing store of defined scene components.
  43128. */
  43129. _serializableComponents: ISceneSerializableComponent[];
  43130. /**
  43131. * List of components to register on the next registration step.
  43132. */
  43133. private _transientComponents;
  43134. /**
  43135. * Registers the transient components if needed.
  43136. */
  43137. private _registerTransientComponents;
  43138. /**
  43139. * @hidden
  43140. * Add a component to the scene.
  43141. * Note that the ccomponent could be registered on th next frame if this is called after
  43142. * the register component stage.
  43143. * @param component Defines the component to add to the scene
  43144. */
  43145. _addComponent(component: ISceneComponent): void;
  43146. /**
  43147. * @hidden
  43148. * Gets a component from the scene.
  43149. * @param name defines the name of the component to retrieve
  43150. * @returns the component or null if not present
  43151. */
  43152. _getComponent(name: string): Nullable<ISceneComponent>;
  43153. /**
  43154. * @hidden
  43155. * Defines the actions happening before camera updates.
  43156. */
  43157. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43158. /**
  43159. * @hidden
  43160. * Defines the actions happening before clear the canvas.
  43161. */
  43162. _beforeClearStage: Stage<SimpleStageAction>;
  43163. /**
  43164. * @hidden
  43165. * Defines the actions when collecting render targets for the frame.
  43166. */
  43167. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43168. /**
  43169. * @hidden
  43170. * Defines the actions happening for one camera in the frame.
  43171. */
  43172. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43173. /**
  43174. * @hidden
  43175. * Defines the actions happening during the per mesh ready checks.
  43176. */
  43177. _isReadyForMeshStage: Stage<MeshStageAction>;
  43178. /**
  43179. * @hidden
  43180. * Defines the actions happening before evaluate active mesh checks.
  43181. */
  43182. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43183. /**
  43184. * @hidden
  43185. * Defines the actions happening during the evaluate sub mesh checks.
  43186. */
  43187. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43188. /**
  43189. * @hidden
  43190. * Defines the actions happening during the active mesh stage.
  43191. */
  43192. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43193. /**
  43194. * @hidden
  43195. * Defines the actions happening during the per camera render target step.
  43196. */
  43197. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43198. /**
  43199. * @hidden
  43200. * Defines the actions happening just before the active camera is drawing.
  43201. */
  43202. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43203. /**
  43204. * @hidden
  43205. * Defines the actions happening just before a render target is drawing.
  43206. */
  43207. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43208. /**
  43209. * @hidden
  43210. * Defines the actions happening just before a rendering group is drawing.
  43211. */
  43212. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43213. /**
  43214. * @hidden
  43215. * Defines the actions happening just before a mesh is drawing.
  43216. */
  43217. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43218. /**
  43219. * @hidden
  43220. * Defines the actions happening just after a mesh has been drawn.
  43221. */
  43222. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43223. /**
  43224. * @hidden
  43225. * Defines the actions happening just after a rendering group has been drawn.
  43226. */
  43227. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43228. /**
  43229. * @hidden
  43230. * Defines the actions happening just after the active camera has been drawn.
  43231. */
  43232. _afterCameraDrawStage: Stage<CameraStageAction>;
  43233. /**
  43234. * @hidden
  43235. * Defines the actions happening just after a render target has been drawn.
  43236. */
  43237. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43238. /**
  43239. * @hidden
  43240. * Defines the actions happening just after rendering all cameras and computing intersections.
  43241. */
  43242. _afterRenderStage: Stage<SimpleStageAction>;
  43243. /**
  43244. * @hidden
  43245. * Defines the actions happening when a pointer move event happens.
  43246. */
  43247. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43248. /**
  43249. * @hidden
  43250. * Defines the actions happening when a pointer down event happens.
  43251. */
  43252. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43253. /**
  43254. * @hidden
  43255. * Defines the actions happening when a pointer up event happens.
  43256. */
  43257. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43258. /**
  43259. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43260. */
  43261. private geometriesByUniqueId;
  43262. /**
  43263. * Creates a new Scene
  43264. * @param engine defines the engine to use to render this scene
  43265. * @param options defines the scene options
  43266. */
  43267. constructor(engine: Engine, options?: SceneOptions);
  43268. /**
  43269. * Gets a string identifying the name of the class
  43270. * @returns "Scene" string
  43271. */
  43272. getClassName(): string;
  43273. private _defaultMeshCandidates;
  43274. /**
  43275. * @hidden
  43276. */
  43277. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43278. private _defaultSubMeshCandidates;
  43279. /**
  43280. * @hidden
  43281. */
  43282. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43283. /**
  43284. * Sets the default candidate providers for the scene.
  43285. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43286. * and getCollidingSubMeshCandidates to their default function
  43287. */
  43288. setDefaultCandidateProviders(): void;
  43289. /**
  43290. * Gets the mesh that is currently under the pointer
  43291. */
  43292. get meshUnderPointer(): Nullable<AbstractMesh>;
  43293. /**
  43294. * Gets or sets the current on-screen X position of the pointer
  43295. */
  43296. get pointerX(): number;
  43297. set pointerX(value: number);
  43298. /**
  43299. * Gets or sets the current on-screen Y position of the pointer
  43300. */
  43301. get pointerY(): number;
  43302. set pointerY(value: number);
  43303. /**
  43304. * Gets the cached material (ie. the latest rendered one)
  43305. * @returns the cached material
  43306. */
  43307. getCachedMaterial(): Nullable<Material>;
  43308. /**
  43309. * Gets the cached effect (ie. the latest rendered one)
  43310. * @returns the cached effect
  43311. */
  43312. getCachedEffect(): Nullable<Effect>;
  43313. /**
  43314. * Gets the cached visibility state (ie. the latest rendered one)
  43315. * @returns the cached visibility state
  43316. */
  43317. getCachedVisibility(): Nullable<number>;
  43318. /**
  43319. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43320. * @param material defines the current material
  43321. * @param effect defines the current effect
  43322. * @param visibility defines the current visibility state
  43323. * @returns true if one parameter is not cached
  43324. */
  43325. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43326. /**
  43327. * Gets the engine associated with the scene
  43328. * @returns an Engine
  43329. */
  43330. getEngine(): Engine;
  43331. /**
  43332. * Gets the total number of vertices rendered per frame
  43333. * @returns the total number of vertices rendered per frame
  43334. */
  43335. getTotalVertices(): number;
  43336. /**
  43337. * Gets the performance counter for total vertices
  43338. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43339. */
  43340. get totalVerticesPerfCounter(): PerfCounter;
  43341. /**
  43342. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43343. * @returns the total number of active indices rendered per frame
  43344. */
  43345. getActiveIndices(): number;
  43346. /**
  43347. * Gets the performance counter for active indices
  43348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43349. */
  43350. get totalActiveIndicesPerfCounter(): PerfCounter;
  43351. /**
  43352. * Gets the total number of active particles rendered per frame
  43353. * @returns the total number of active particles rendered per frame
  43354. */
  43355. getActiveParticles(): number;
  43356. /**
  43357. * Gets the performance counter for active particles
  43358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43359. */
  43360. get activeParticlesPerfCounter(): PerfCounter;
  43361. /**
  43362. * Gets the total number of active bones rendered per frame
  43363. * @returns the total number of active bones rendered per frame
  43364. */
  43365. getActiveBones(): number;
  43366. /**
  43367. * Gets the performance counter for active bones
  43368. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43369. */
  43370. get activeBonesPerfCounter(): PerfCounter;
  43371. /**
  43372. * Gets the array of active meshes
  43373. * @returns an array of AbstractMesh
  43374. */
  43375. getActiveMeshes(): SmartArray<AbstractMesh>;
  43376. /**
  43377. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43378. * @returns a number
  43379. */
  43380. getAnimationRatio(): number;
  43381. /**
  43382. * Gets an unique Id for the current render phase
  43383. * @returns a number
  43384. */
  43385. getRenderId(): number;
  43386. /**
  43387. * Gets an unique Id for the current frame
  43388. * @returns a number
  43389. */
  43390. getFrameId(): number;
  43391. /** Call this function if you want to manually increment the render Id*/
  43392. incrementRenderId(): void;
  43393. private _createUbo;
  43394. /**
  43395. * Use this method to simulate a pointer move on a mesh
  43396. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43397. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43398. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43399. * @returns the current scene
  43400. */
  43401. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43402. /**
  43403. * Use this method to simulate a pointer down on a mesh
  43404. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43405. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43406. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43407. * @returns the current scene
  43408. */
  43409. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43410. /**
  43411. * Use this method to simulate a pointer up on a mesh
  43412. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43413. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43414. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43415. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43416. * @returns the current scene
  43417. */
  43418. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43419. /**
  43420. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43421. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43422. * @returns true if the pointer was captured
  43423. */
  43424. isPointerCaptured(pointerId?: number): boolean;
  43425. /**
  43426. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43427. * @param attachUp defines if you want to attach events to pointerup
  43428. * @param attachDown defines if you want to attach events to pointerdown
  43429. * @param attachMove defines if you want to attach events to pointermove
  43430. */
  43431. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43432. /** Detaches all event handlers*/
  43433. detachControl(): void;
  43434. /**
  43435. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43436. * Delay loaded resources are not taking in account
  43437. * @return true if all required resources are ready
  43438. */
  43439. isReady(): boolean;
  43440. /** Resets all cached information relative to material (including effect and visibility) */
  43441. resetCachedMaterial(): void;
  43442. /**
  43443. * Registers a function to be called before every frame render
  43444. * @param func defines the function to register
  43445. */
  43446. registerBeforeRender(func: () => void): void;
  43447. /**
  43448. * Unregisters a function called before every frame render
  43449. * @param func defines the function to unregister
  43450. */
  43451. unregisterBeforeRender(func: () => void): void;
  43452. /**
  43453. * Registers a function to be called after every frame render
  43454. * @param func defines the function to register
  43455. */
  43456. registerAfterRender(func: () => void): void;
  43457. /**
  43458. * Unregisters a function called after every frame render
  43459. * @param func defines the function to unregister
  43460. */
  43461. unregisterAfterRender(func: () => void): void;
  43462. private _executeOnceBeforeRender;
  43463. /**
  43464. * The provided function will run before render once and will be disposed afterwards.
  43465. * A timeout delay can be provided so that the function will be executed in N ms.
  43466. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43467. * @param func The function to be executed.
  43468. * @param timeout optional delay in ms
  43469. */
  43470. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43471. /** @hidden */
  43472. _addPendingData(data: any): void;
  43473. /** @hidden */
  43474. _removePendingData(data: any): void;
  43475. /**
  43476. * Returns the number of items waiting to be loaded
  43477. * @returns the number of items waiting to be loaded
  43478. */
  43479. getWaitingItemsCount(): number;
  43480. /**
  43481. * Returns a boolean indicating if the scene is still loading data
  43482. */
  43483. get isLoading(): boolean;
  43484. /**
  43485. * Registers a function to be executed when the scene is ready
  43486. * @param {Function} func - the function to be executed
  43487. */
  43488. executeWhenReady(func: () => void): void;
  43489. /**
  43490. * Returns a promise that resolves when the scene is ready
  43491. * @returns A promise that resolves when the scene is ready
  43492. */
  43493. whenReadyAsync(): Promise<void>;
  43494. /** @hidden */
  43495. _checkIsReady(): void;
  43496. /**
  43497. * Gets all animatable attached to the scene
  43498. */
  43499. get animatables(): Animatable[];
  43500. /**
  43501. * Resets the last animation time frame.
  43502. * Useful to override when animations start running when loading a scene for the first time.
  43503. */
  43504. resetLastAnimationTimeFrame(): void;
  43505. /**
  43506. * Gets the current view matrix
  43507. * @returns a Matrix
  43508. */
  43509. getViewMatrix(): Matrix;
  43510. /**
  43511. * Gets the current projection matrix
  43512. * @returns a Matrix
  43513. */
  43514. getProjectionMatrix(): Matrix;
  43515. /**
  43516. * Gets the current transform matrix
  43517. * @returns a Matrix made of View * Projection
  43518. */
  43519. getTransformMatrix(): Matrix;
  43520. /**
  43521. * Sets the current transform matrix
  43522. * @param viewL defines the View matrix to use
  43523. * @param projectionL defines the Projection matrix to use
  43524. * @param viewR defines the right View matrix to use (if provided)
  43525. * @param projectionR defines the right Projection matrix to use (if provided)
  43526. */
  43527. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43528. /**
  43529. * Gets the uniform buffer used to store scene data
  43530. * @returns a UniformBuffer
  43531. */
  43532. getSceneUniformBuffer(): UniformBuffer;
  43533. /**
  43534. * Gets an unique (relatively to the current scene) Id
  43535. * @returns an unique number for the scene
  43536. */
  43537. getUniqueId(): number;
  43538. /**
  43539. * Add a mesh to the list of scene's meshes
  43540. * @param newMesh defines the mesh to add
  43541. * @param recursive if all child meshes should also be added to the scene
  43542. */
  43543. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43544. /**
  43545. * Remove a mesh for the list of scene's meshes
  43546. * @param toRemove defines the mesh to remove
  43547. * @param recursive if all child meshes should also be removed from the scene
  43548. * @returns the index where the mesh was in the mesh list
  43549. */
  43550. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43551. /**
  43552. * Add a transform node to the list of scene's transform nodes
  43553. * @param newTransformNode defines the transform node to add
  43554. */
  43555. addTransformNode(newTransformNode: TransformNode): void;
  43556. /**
  43557. * Remove a transform node for the list of scene's transform nodes
  43558. * @param toRemove defines the transform node to remove
  43559. * @returns the index where the transform node was in the transform node list
  43560. */
  43561. removeTransformNode(toRemove: TransformNode): number;
  43562. /**
  43563. * Remove a skeleton for the list of scene's skeletons
  43564. * @param toRemove defines the skeleton to remove
  43565. * @returns the index where the skeleton was in the skeleton list
  43566. */
  43567. removeSkeleton(toRemove: Skeleton): number;
  43568. /**
  43569. * Remove a morph target for the list of scene's morph targets
  43570. * @param toRemove defines the morph target to remove
  43571. * @returns the index where the morph target was in the morph target list
  43572. */
  43573. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43574. /**
  43575. * Remove a light for the list of scene's lights
  43576. * @param toRemove defines the light to remove
  43577. * @returns the index where the light was in the light list
  43578. */
  43579. removeLight(toRemove: Light): number;
  43580. /**
  43581. * Remove a camera for the list of scene's cameras
  43582. * @param toRemove defines the camera to remove
  43583. * @returns the index where the camera was in the camera list
  43584. */
  43585. removeCamera(toRemove: Camera): number;
  43586. /**
  43587. * Remove a particle system for the list of scene's particle systems
  43588. * @param toRemove defines the particle system to remove
  43589. * @returns the index where the particle system was in the particle system list
  43590. */
  43591. removeParticleSystem(toRemove: IParticleSystem): number;
  43592. /**
  43593. * Remove a animation for the list of scene's animations
  43594. * @param toRemove defines the animation to remove
  43595. * @returns the index where the animation was in the animation list
  43596. */
  43597. removeAnimation(toRemove: Animation): number;
  43598. /**
  43599. * Will stop the animation of the given target
  43600. * @param target - the target
  43601. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43602. * @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)
  43603. */
  43604. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43605. /**
  43606. * Removes the given animation group from this scene.
  43607. * @param toRemove The animation group to remove
  43608. * @returns The index of the removed animation group
  43609. */
  43610. removeAnimationGroup(toRemove: AnimationGroup): number;
  43611. /**
  43612. * Removes the given multi-material from this scene.
  43613. * @param toRemove The multi-material to remove
  43614. * @returns The index of the removed multi-material
  43615. */
  43616. removeMultiMaterial(toRemove: MultiMaterial): number;
  43617. /**
  43618. * Removes the given material from this scene.
  43619. * @param toRemove The material to remove
  43620. * @returns The index of the removed material
  43621. */
  43622. removeMaterial(toRemove: Material): number;
  43623. /**
  43624. * Removes the given action manager from this scene.
  43625. * @param toRemove The action manager to remove
  43626. * @returns The index of the removed action manager
  43627. */
  43628. removeActionManager(toRemove: AbstractActionManager): number;
  43629. /**
  43630. * Removes the given texture from this scene.
  43631. * @param toRemove The texture to remove
  43632. * @returns The index of the removed texture
  43633. */
  43634. removeTexture(toRemove: BaseTexture): number;
  43635. /**
  43636. * Adds the given light to this scene
  43637. * @param newLight The light to add
  43638. */
  43639. addLight(newLight: Light): void;
  43640. /**
  43641. * Sorts the list list based on light priorities
  43642. */
  43643. sortLightsByPriority(): void;
  43644. /**
  43645. * Adds the given camera to this scene
  43646. * @param newCamera The camera to add
  43647. */
  43648. addCamera(newCamera: Camera): void;
  43649. /**
  43650. * Adds the given skeleton to this scene
  43651. * @param newSkeleton The skeleton to add
  43652. */
  43653. addSkeleton(newSkeleton: Skeleton): void;
  43654. /**
  43655. * Adds the given particle system to this scene
  43656. * @param newParticleSystem The particle system to add
  43657. */
  43658. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43659. /**
  43660. * Adds the given animation to this scene
  43661. * @param newAnimation The animation to add
  43662. */
  43663. addAnimation(newAnimation: Animation): void;
  43664. /**
  43665. * Adds the given animation group to this scene.
  43666. * @param newAnimationGroup The animation group to add
  43667. */
  43668. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43669. /**
  43670. * Adds the given multi-material to this scene
  43671. * @param newMultiMaterial The multi-material to add
  43672. */
  43673. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43674. /**
  43675. * Adds the given material to this scene
  43676. * @param newMaterial The material to add
  43677. */
  43678. addMaterial(newMaterial: Material): void;
  43679. /**
  43680. * Adds the given morph target to this scene
  43681. * @param newMorphTargetManager The morph target to add
  43682. */
  43683. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43684. /**
  43685. * Adds the given geometry to this scene
  43686. * @param newGeometry The geometry to add
  43687. */
  43688. addGeometry(newGeometry: Geometry): void;
  43689. /**
  43690. * Adds the given action manager to this scene
  43691. * @param newActionManager The action manager to add
  43692. */
  43693. addActionManager(newActionManager: AbstractActionManager): void;
  43694. /**
  43695. * Adds the given texture to this scene.
  43696. * @param newTexture The texture to add
  43697. */
  43698. addTexture(newTexture: BaseTexture): void;
  43699. /**
  43700. * Switch active camera
  43701. * @param newCamera defines the new active camera
  43702. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43703. */
  43704. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43705. /**
  43706. * sets the active camera of the scene using its ID
  43707. * @param id defines the camera's ID
  43708. * @return the new active camera or null if none found.
  43709. */
  43710. setActiveCameraByID(id: string): Nullable<Camera>;
  43711. /**
  43712. * sets the active camera of the scene using its name
  43713. * @param name defines the camera's name
  43714. * @returns the new active camera or null if none found.
  43715. */
  43716. setActiveCameraByName(name: string): Nullable<Camera>;
  43717. /**
  43718. * get an animation group using its name
  43719. * @param name defines the material's name
  43720. * @return the animation group or null if none found.
  43721. */
  43722. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43723. /**
  43724. * Get a material using its unique id
  43725. * @param uniqueId defines the material's unique id
  43726. * @return the material or null if none found.
  43727. */
  43728. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43729. /**
  43730. * get a material using its id
  43731. * @param id defines the material's ID
  43732. * @return the material or null if none found.
  43733. */
  43734. getMaterialByID(id: string): Nullable<Material>;
  43735. /**
  43736. * Gets a the last added material using a given id
  43737. * @param id defines the material's ID
  43738. * @return the last material with the given id or null if none found.
  43739. */
  43740. getLastMaterialByID(id: string): Nullable<Material>;
  43741. /**
  43742. * Gets a material using its name
  43743. * @param name defines the material's name
  43744. * @return the material or null if none found.
  43745. */
  43746. getMaterialByName(name: string): Nullable<Material>;
  43747. /**
  43748. * Get a texture using its unique id
  43749. * @param uniqueId defines the texture's unique id
  43750. * @return the texture or null if none found.
  43751. */
  43752. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43753. /**
  43754. * Gets a camera using its id
  43755. * @param id defines the id to look for
  43756. * @returns the camera or null if not found
  43757. */
  43758. getCameraByID(id: string): Nullable<Camera>;
  43759. /**
  43760. * Gets a camera using its unique id
  43761. * @param uniqueId defines the unique id to look for
  43762. * @returns the camera or null if not found
  43763. */
  43764. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43765. /**
  43766. * Gets a camera using its name
  43767. * @param name defines the camera's name
  43768. * @return the camera or null if none found.
  43769. */
  43770. getCameraByName(name: string): Nullable<Camera>;
  43771. /**
  43772. * Gets a bone using its id
  43773. * @param id defines the bone's id
  43774. * @return the bone or null if not found
  43775. */
  43776. getBoneByID(id: string): Nullable<Bone>;
  43777. /**
  43778. * Gets a bone using its id
  43779. * @param name defines the bone's name
  43780. * @return the bone or null if not found
  43781. */
  43782. getBoneByName(name: string): Nullable<Bone>;
  43783. /**
  43784. * Gets a light node using its name
  43785. * @param name defines the the light's name
  43786. * @return the light or null if none found.
  43787. */
  43788. getLightByName(name: string): Nullable<Light>;
  43789. /**
  43790. * Gets a light node using its id
  43791. * @param id defines the light's id
  43792. * @return the light or null if none found.
  43793. */
  43794. getLightByID(id: string): Nullable<Light>;
  43795. /**
  43796. * Gets a light node using its scene-generated unique ID
  43797. * @param uniqueId defines the light's unique id
  43798. * @return the light or null if none found.
  43799. */
  43800. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43801. /**
  43802. * Gets a particle system by id
  43803. * @param id defines the particle system id
  43804. * @return the corresponding system or null if none found
  43805. */
  43806. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43807. /**
  43808. * Gets a geometry using its ID
  43809. * @param id defines the geometry's id
  43810. * @return the geometry or null if none found.
  43811. */
  43812. getGeometryByID(id: string): Nullable<Geometry>;
  43813. private _getGeometryByUniqueID;
  43814. /**
  43815. * Add a new geometry to this scene
  43816. * @param geometry defines the geometry to be added to the scene.
  43817. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43818. * @return a boolean defining if the geometry was added or not
  43819. */
  43820. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43821. /**
  43822. * Removes an existing geometry
  43823. * @param geometry defines the geometry to be removed from the scene
  43824. * @return a boolean defining if the geometry was removed or not
  43825. */
  43826. removeGeometry(geometry: Geometry): boolean;
  43827. /**
  43828. * Gets the list of geometries attached to the scene
  43829. * @returns an array of Geometry
  43830. */
  43831. getGeometries(): Geometry[];
  43832. /**
  43833. * Gets the first added mesh found of a given ID
  43834. * @param id defines the id to search for
  43835. * @return the mesh found or null if not found at all
  43836. */
  43837. getMeshByID(id: string): Nullable<AbstractMesh>;
  43838. /**
  43839. * Gets a list of meshes using their id
  43840. * @param id defines the id to search for
  43841. * @returns a list of meshes
  43842. */
  43843. getMeshesByID(id: string): Array<AbstractMesh>;
  43844. /**
  43845. * Gets the first added transform node found of a given ID
  43846. * @param id defines the id to search for
  43847. * @return the found transform node or null if not found at all.
  43848. */
  43849. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43850. /**
  43851. * Gets a transform node with its auto-generated unique id
  43852. * @param uniqueId efines the unique id to search for
  43853. * @return the found transform node or null if not found at all.
  43854. */
  43855. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43856. /**
  43857. * Gets a list of transform nodes using their id
  43858. * @param id defines the id to search for
  43859. * @returns a list of transform nodes
  43860. */
  43861. getTransformNodesByID(id: string): Array<TransformNode>;
  43862. /**
  43863. * Gets a mesh with its auto-generated unique id
  43864. * @param uniqueId defines the unique id to search for
  43865. * @return the found mesh or null if not found at all.
  43866. */
  43867. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43868. /**
  43869. * Gets a the last added mesh using a given id
  43870. * @param id defines the id to search for
  43871. * @return the found mesh or null if not found at all.
  43872. */
  43873. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43874. /**
  43875. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43876. * @param id defines the id to search for
  43877. * @return the found node or null if not found at all
  43878. */
  43879. getLastEntryByID(id: string): Nullable<Node>;
  43880. /**
  43881. * Gets a node (Mesh, Camera, Light) using a given id
  43882. * @param id defines the id to search for
  43883. * @return the found node or null if not found at all
  43884. */
  43885. getNodeByID(id: string): Nullable<Node>;
  43886. /**
  43887. * Gets a node (Mesh, Camera, Light) using a given name
  43888. * @param name defines the name to search for
  43889. * @return the found node or null if not found at all.
  43890. */
  43891. getNodeByName(name: string): Nullable<Node>;
  43892. /**
  43893. * Gets a mesh using a given name
  43894. * @param name defines the name to search for
  43895. * @return the found mesh or null if not found at all.
  43896. */
  43897. getMeshByName(name: string): Nullable<AbstractMesh>;
  43898. /**
  43899. * Gets a transform node using a given name
  43900. * @param name defines the name to search for
  43901. * @return the found transform node or null if not found at all.
  43902. */
  43903. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43904. /**
  43905. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43906. * @param id defines the id to search for
  43907. * @return the found skeleton or null if not found at all.
  43908. */
  43909. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43910. /**
  43911. * Gets a skeleton using a given auto generated unique id
  43912. * @param uniqueId defines the unique id to search for
  43913. * @return the found skeleton or null if not found at all.
  43914. */
  43915. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43916. /**
  43917. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43918. * @param id defines the id to search for
  43919. * @return the found skeleton or null if not found at all.
  43920. */
  43921. getSkeletonById(id: string): Nullable<Skeleton>;
  43922. /**
  43923. * Gets a skeleton using a given name
  43924. * @param name defines the name to search for
  43925. * @return the found skeleton or null if not found at all.
  43926. */
  43927. getSkeletonByName(name: string): Nullable<Skeleton>;
  43928. /**
  43929. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43930. * @param id defines the id to search for
  43931. * @return the found morph target manager or null if not found at all.
  43932. */
  43933. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43934. /**
  43935. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43936. * @param id defines the id to search for
  43937. * @return the found morph target or null if not found at all.
  43938. */
  43939. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43940. /**
  43941. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43942. * @param name defines the name to search for
  43943. * @return the found morph target or null if not found at all.
  43944. */
  43945. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43946. /**
  43947. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43948. * @param name defines the name to search for
  43949. * @return the found post process or null if not found at all.
  43950. */
  43951. getPostProcessByName(name: string): Nullable<PostProcess>;
  43952. /**
  43953. * Gets a boolean indicating if the given mesh is active
  43954. * @param mesh defines the mesh to look for
  43955. * @returns true if the mesh is in the active list
  43956. */
  43957. isActiveMesh(mesh: AbstractMesh): boolean;
  43958. /**
  43959. * Return a unique id as a string which can serve as an identifier for the scene
  43960. */
  43961. get uid(): string;
  43962. /**
  43963. * Add an externaly attached data from its key.
  43964. * This method call will fail and return false, if such key already exists.
  43965. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43966. * @param key the unique key that identifies the data
  43967. * @param data the data object to associate to the key for this Engine instance
  43968. * @return true if no such key were already present and the data was added successfully, false otherwise
  43969. */
  43970. addExternalData<T>(key: string, data: T): boolean;
  43971. /**
  43972. * Get an externaly attached data from its key
  43973. * @param key the unique key that identifies the data
  43974. * @return the associated data, if present (can be null), or undefined if not present
  43975. */
  43976. getExternalData<T>(key: string): Nullable<T>;
  43977. /**
  43978. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43979. * @param key the unique key that identifies the data
  43980. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43981. * @return the associated data, can be null if the factory returned null.
  43982. */
  43983. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43984. /**
  43985. * Remove an externaly attached data from the Engine instance
  43986. * @param key the unique key that identifies the data
  43987. * @return true if the data was successfully removed, false if it doesn't exist
  43988. */
  43989. removeExternalData(key: string): boolean;
  43990. private _evaluateSubMesh;
  43991. /**
  43992. * Clear the processed materials smart array preventing retention point in material dispose.
  43993. */
  43994. freeProcessedMaterials(): void;
  43995. private _preventFreeActiveMeshesAndRenderingGroups;
  43996. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43997. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43998. * when disposing several meshes in a row or a hierarchy of meshes.
  43999. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44000. */
  44001. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44002. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44003. /**
  44004. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44005. */
  44006. freeActiveMeshes(): void;
  44007. /**
  44008. * Clear the info related to rendering groups preventing retention points during dispose.
  44009. */
  44010. freeRenderingGroups(): void;
  44011. /** @hidden */
  44012. _isInIntermediateRendering(): boolean;
  44013. /**
  44014. * Lambda returning the list of potentially active meshes.
  44015. */
  44016. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44017. /**
  44018. * Lambda returning the list of potentially active sub meshes.
  44019. */
  44020. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44021. /**
  44022. * Lambda returning the list of potentially intersecting sub meshes.
  44023. */
  44024. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44025. /**
  44026. * Lambda returning the list of potentially colliding sub meshes.
  44027. */
  44028. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44029. private _activeMeshesFrozen;
  44030. private _skipEvaluateActiveMeshesCompletely;
  44031. /**
  44032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44033. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44034. * @param onSuccess optional success callback
  44035. * @param onError optional error callback
  44036. * @returns the current scene
  44037. */
  44038. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44039. /**
  44040. * Use this function to restart evaluating active meshes on every frame
  44041. * @returns the current scene
  44042. */
  44043. unfreezeActiveMeshes(): Scene;
  44044. private _evaluateActiveMeshes;
  44045. private _activeMesh;
  44046. /**
  44047. * Update the transform matrix to update from the current active camera
  44048. * @param force defines a boolean used to force the update even if cache is up to date
  44049. */
  44050. updateTransformMatrix(force?: boolean): void;
  44051. private _bindFrameBuffer;
  44052. /** @hidden */
  44053. _allowPostProcessClearColor: boolean;
  44054. /** @hidden */
  44055. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44056. private _processSubCameras;
  44057. private _checkIntersections;
  44058. /** @hidden */
  44059. _advancePhysicsEngineStep(step: number): void;
  44060. /**
  44061. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44062. */
  44063. getDeterministicFrameTime: () => number;
  44064. /** @hidden */
  44065. _animate(): void;
  44066. /** Execute all animations (for a frame) */
  44067. animate(): void;
  44068. /**
  44069. * Render the scene
  44070. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44071. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44072. */
  44073. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44074. /**
  44075. * Freeze all materials
  44076. * A frozen material will not be updatable but should be faster to render
  44077. */
  44078. freezeMaterials(): void;
  44079. /**
  44080. * Unfreeze all materials
  44081. * A frozen material will not be updatable but should be faster to render
  44082. */
  44083. unfreezeMaterials(): void;
  44084. /**
  44085. * Releases all held ressources
  44086. */
  44087. dispose(): void;
  44088. /**
  44089. * Gets if the scene is already disposed
  44090. */
  44091. get isDisposed(): boolean;
  44092. /**
  44093. * Call this function to reduce memory footprint of the scene.
  44094. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44095. */
  44096. clearCachedVertexData(): void;
  44097. /**
  44098. * This function will remove the local cached buffer data from texture.
  44099. * It will save memory but will prevent the texture from being rebuilt
  44100. */
  44101. cleanCachedTextureBuffer(): void;
  44102. /**
  44103. * Get the world extend vectors with an optional filter
  44104. *
  44105. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44106. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44107. */
  44108. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44109. min: Vector3;
  44110. max: Vector3;
  44111. };
  44112. /**
  44113. * Creates a ray that can be used to pick in the scene
  44114. * @param x defines the x coordinate of the origin (on-screen)
  44115. * @param y defines the y coordinate of the origin (on-screen)
  44116. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44117. * @param camera defines the camera to use for the picking
  44118. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44119. * @returns a Ray
  44120. */
  44121. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44122. /**
  44123. * Creates a ray that can be used to pick in the scene
  44124. * @param x defines the x coordinate of the origin (on-screen)
  44125. * @param y defines the y coordinate of the origin (on-screen)
  44126. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44127. * @param result defines the ray where to store the picking ray
  44128. * @param camera defines the camera to use for the picking
  44129. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44130. * @returns the current scene
  44131. */
  44132. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44133. /**
  44134. * Creates a ray that can be used to pick in the scene
  44135. * @param x defines the x coordinate of the origin (on-screen)
  44136. * @param y defines the y coordinate of the origin (on-screen)
  44137. * @param camera defines the camera to use for the picking
  44138. * @returns a Ray
  44139. */
  44140. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44141. /**
  44142. * Creates a ray that can be used to pick in the scene
  44143. * @param x defines the x coordinate of the origin (on-screen)
  44144. * @param y defines the y coordinate of the origin (on-screen)
  44145. * @param result defines the ray where to store the picking ray
  44146. * @param camera defines the camera to use for the picking
  44147. * @returns the current scene
  44148. */
  44149. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44150. /** Launch a ray to try to pick a mesh in the scene
  44151. * @param x position on screen
  44152. * @param y position on screen
  44153. * @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
  44154. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44155. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44156. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44157. * @returns a PickingInfo
  44158. */
  44159. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44160. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44161. * @param x position on screen
  44162. * @param y position on screen
  44163. * @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
  44164. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44165. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44166. * @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)
  44167. */
  44168. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44169. /** Use the given ray to pick a mesh in the scene
  44170. * @param ray The ray to use to pick meshes
  44171. * @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
  44172. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44173. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44174. * @returns a PickingInfo
  44175. */
  44176. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44177. /**
  44178. * Launch a ray to try to pick a mesh in the scene
  44179. * @param x X position on screen
  44180. * @param y Y position on screen
  44181. * @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
  44182. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44184. * @returns an array of PickingInfo
  44185. */
  44186. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44187. /**
  44188. * Launch a ray to try to pick a mesh in the scene
  44189. * @param ray Ray to use
  44190. * @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
  44191. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44192. * @returns an array of PickingInfo
  44193. */
  44194. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44195. /**
  44196. * Force the value of meshUnderPointer
  44197. * @param mesh defines the mesh to use
  44198. * @param pointerId optional pointer id when using more than one pointer
  44199. */
  44200. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44201. /**
  44202. * Gets the mesh under the pointer
  44203. * @returns a Mesh or null if no mesh is under the pointer
  44204. */
  44205. getPointerOverMesh(): Nullable<AbstractMesh>;
  44206. /** @hidden */
  44207. _rebuildGeometries(): void;
  44208. /** @hidden */
  44209. _rebuildTextures(): void;
  44210. private _getByTags;
  44211. /**
  44212. * Get a list of meshes by tags
  44213. * @param tagsQuery defines the tags query to use
  44214. * @param forEach defines a predicate used to filter results
  44215. * @returns an array of Mesh
  44216. */
  44217. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44218. /**
  44219. * Get a list of cameras by tags
  44220. * @param tagsQuery defines the tags query to use
  44221. * @param forEach defines a predicate used to filter results
  44222. * @returns an array of Camera
  44223. */
  44224. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44225. /**
  44226. * Get a list of lights by tags
  44227. * @param tagsQuery defines the tags query to use
  44228. * @param forEach defines a predicate used to filter results
  44229. * @returns an array of Light
  44230. */
  44231. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44232. /**
  44233. * Get a list of materials by tags
  44234. * @param tagsQuery defines the tags query to use
  44235. * @param forEach defines a predicate used to filter results
  44236. * @returns an array of Material
  44237. */
  44238. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44239. /**
  44240. * Get a list of transform nodes by tags
  44241. * @param tagsQuery defines the tags query to use
  44242. * @param forEach defines a predicate used to filter results
  44243. * @returns an array of TransformNode
  44244. */
  44245. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44246. /**
  44247. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44248. * This allowed control for front to back rendering or reversly depending of the special needs.
  44249. *
  44250. * @param renderingGroupId The rendering group id corresponding to its index
  44251. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44252. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44253. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44254. */
  44255. 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;
  44256. /**
  44257. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44258. *
  44259. * @param renderingGroupId The rendering group id corresponding to its index
  44260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44261. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44262. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44263. */
  44264. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44265. /**
  44266. * Gets the current auto clear configuration for one rendering group of the rendering
  44267. * manager.
  44268. * @param index the rendering group index to get the information for
  44269. * @returns The auto clear setup for the requested rendering group
  44270. */
  44271. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44272. private _blockMaterialDirtyMechanism;
  44273. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44274. get blockMaterialDirtyMechanism(): boolean;
  44275. set blockMaterialDirtyMechanism(value: boolean);
  44276. /**
  44277. * Will flag all materials as dirty to trigger new shader compilation
  44278. * @param flag defines the flag used to specify which material part must be marked as dirty
  44279. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44280. */
  44281. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44282. /** @hidden */
  44283. _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;
  44284. /** @hidden */
  44285. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44286. /** @hidden */
  44287. _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;
  44288. /** @hidden */
  44289. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44290. /** @hidden */
  44291. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44292. /** @hidden */
  44293. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44294. }
  44295. }
  44296. declare module BABYLON {
  44297. /**
  44298. * Set of assets to keep when moving a scene into an asset container.
  44299. */
  44300. export class KeepAssets extends AbstractScene {
  44301. }
  44302. /**
  44303. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44304. */
  44305. export class InstantiatedEntries {
  44306. /**
  44307. * List of new root nodes (eg. nodes with no parent)
  44308. */
  44309. rootNodes: TransformNode[];
  44310. /**
  44311. * List of new skeletons
  44312. */
  44313. skeletons: Skeleton[];
  44314. /**
  44315. * List of new animation groups
  44316. */
  44317. animationGroups: AnimationGroup[];
  44318. }
  44319. /**
  44320. * Container with a set of assets that can be added or removed from a scene.
  44321. */
  44322. export class AssetContainer extends AbstractScene {
  44323. private _wasAddedToScene;
  44324. /**
  44325. * The scene the AssetContainer belongs to.
  44326. */
  44327. scene: Scene;
  44328. /**
  44329. * Instantiates an AssetContainer.
  44330. * @param scene The scene the AssetContainer belongs to.
  44331. */
  44332. constructor(scene: Scene);
  44333. /**
  44334. * Instantiate or clone all meshes and add the new ones to the scene.
  44335. * Skeletons and animation groups will all be cloned
  44336. * @param nameFunction defines an optional function used to get new names for clones
  44337. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44338. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44339. */
  44340. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44341. /**
  44342. * Adds all the assets from the container to the scene.
  44343. */
  44344. addAllToScene(): void;
  44345. /**
  44346. * Removes all the assets in the container from the scene
  44347. */
  44348. removeAllFromScene(): void;
  44349. /**
  44350. * Disposes all the assets in the container
  44351. */
  44352. dispose(): void;
  44353. private _moveAssets;
  44354. /**
  44355. * Removes all the assets contained in the scene and adds them to the container.
  44356. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44357. */
  44358. moveAllFromScene(keepAssets?: KeepAssets): void;
  44359. /**
  44360. * 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.
  44361. * @returns the root mesh
  44362. */
  44363. createRootMesh(): Mesh;
  44364. /**
  44365. * Merge animations (direct and animation groups) from this asset container into a scene
  44366. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44367. * @param animatables set of animatables to retarget to a node from the scene
  44368. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44369. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44370. */
  44371. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * Defines how the parser contract is defined.
  44377. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44378. */
  44379. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44380. /**
  44381. * Defines how the individual parser contract is defined.
  44382. * These parser can parse an individual asset
  44383. */
  44384. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44385. /**
  44386. * Base class of the scene acting as a container for the different elements composing a scene.
  44387. * This class is dynamically extended by the different components of the scene increasing
  44388. * flexibility and reducing coupling
  44389. */
  44390. export abstract class AbstractScene {
  44391. /**
  44392. * Stores the list of available parsers in the application.
  44393. */
  44394. private static _BabylonFileParsers;
  44395. /**
  44396. * Stores the list of available individual parsers in the application.
  44397. */
  44398. private static _IndividualBabylonFileParsers;
  44399. /**
  44400. * Adds a parser in the list of available ones
  44401. * @param name Defines the name of the parser
  44402. * @param parser Defines the parser to add
  44403. */
  44404. static AddParser(name: string, parser: BabylonFileParser): void;
  44405. /**
  44406. * Gets a general parser from the list of avaialble ones
  44407. * @param name Defines the name of the parser
  44408. * @returns the requested parser or null
  44409. */
  44410. static GetParser(name: string): Nullable<BabylonFileParser>;
  44411. /**
  44412. * Adds n individual parser in the list of available ones
  44413. * @param name Defines the name of the parser
  44414. * @param parser Defines the parser to add
  44415. */
  44416. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44417. /**
  44418. * Gets an individual parser from the list of avaialble ones
  44419. * @param name Defines the name of the parser
  44420. * @returns the requested parser or null
  44421. */
  44422. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44423. /**
  44424. * Parser json data and populate both a scene and its associated container object
  44425. * @param jsonData Defines the data to parse
  44426. * @param scene Defines the scene to parse the data for
  44427. * @param container Defines the container attached to the parsing sequence
  44428. * @param rootUrl Defines the root url of the data
  44429. */
  44430. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44431. /**
  44432. * Gets the list of root nodes (ie. nodes with no parent)
  44433. */
  44434. rootNodes: Node[];
  44435. /** All of the cameras added to this scene
  44436. * @see https://doc.babylonjs.com/babylon101/cameras
  44437. */
  44438. cameras: Camera[];
  44439. /**
  44440. * All of the lights added to this scene
  44441. * @see https://doc.babylonjs.com/babylon101/lights
  44442. */
  44443. lights: Light[];
  44444. /**
  44445. * All of the (abstract) meshes added to this scene
  44446. */
  44447. meshes: AbstractMesh[];
  44448. /**
  44449. * The list of skeletons added to the scene
  44450. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44451. */
  44452. skeletons: Skeleton[];
  44453. /**
  44454. * All of the particle systems added to this scene
  44455. * @see https://doc.babylonjs.com/babylon101/particles
  44456. */
  44457. particleSystems: IParticleSystem[];
  44458. /**
  44459. * Gets a list of Animations associated with the scene
  44460. */
  44461. animations: Animation[];
  44462. /**
  44463. * All of the animation groups added to this scene
  44464. * @see https://doc.babylonjs.com/how_to/group
  44465. */
  44466. animationGroups: AnimationGroup[];
  44467. /**
  44468. * All of the multi-materials added to this scene
  44469. * @see https://doc.babylonjs.com/how_to/multi_materials
  44470. */
  44471. multiMaterials: MultiMaterial[];
  44472. /**
  44473. * All of the materials added to this scene
  44474. * In the context of a Scene, it is not supposed to be modified manually.
  44475. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44476. * Note also that the order of the Material within the array is not significant and might change.
  44477. * @see https://doc.babylonjs.com/babylon101/materials
  44478. */
  44479. materials: Material[];
  44480. /**
  44481. * The list of morph target managers added to the scene
  44482. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44483. */
  44484. morphTargetManagers: MorphTargetManager[];
  44485. /**
  44486. * The list of geometries used in the scene.
  44487. */
  44488. geometries: Geometry[];
  44489. /**
  44490. * All of the tranform nodes added to this scene
  44491. * In the context of a Scene, it is not supposed to be modified manually.
  44492. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44493. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44494. * @see https://doc.babylonjs.com/how_to/transformnode
  44495. */
  44496. transformNodes: TransformNode[];
  44497. /**
  44498. * ActionManagers available on the scene.
  44499. */
  44500. actionManagers: AbstractActionManager[];
  44501. /**
  44502. * Textures to keep.
  44503. */
  44504. textures: BaseTexture[];
  44505. /** @hidden */
  44506. protected _environmentTexture: Nullable<BaseTexture>;
  44507. /**
  44508. * Texture used in all pbr material as the reflection texture.
  44509. * As in the majority of the scene they are the same (exception for multi room and so on),
  44510. * this is easier to reference from here than from all the materials.
  44511. */
  44512. get environmentTexture(): Nullable<BaseTexture>;
  44513. set environmentTexture(value: Nullable<BaseTexture>);
  44514. /**
  44515. * The list of postprocesses added to the scene
  44516. */
  44517. postProcesses: PostProcess[];
  44518. /**
  44519. * @returns all meshes, lights, cameras, transformNodes and bones
  44520. */
  44521. getNodes(): Array<Node>;
  44522. }
  44523. }
  44524. declare module BABYLON {
  44525. /**
  44526. * Interface used to define options for Sound class
  44527. */
  44528. export interface ISoundOptions {
  44529. /**
  44530. * Does the sound autoplay once loaded.
  44531. */
  44532. autoplay?: boolean;
  44533. /**
  44534. * Does the sound loop after it finishes playing once.
  44535. */
  44536. loop?: boolean;
  44537. /**
  44538. * Sound's volume
  44539. */
  44540. volume?: number;
  44541. /**
  44542. * Is it a spatial sound?
  44543. */
  44544. spatialSound?: boolean;
  44545. /**
  44546. * Maximum distance to hear that sound
  44547. */
  44548. maxDistance?: number;
  44549. /**
  44550. * Uses user defined attenuation function
  44551. */
  44552. useCustomAttenuation?: boolean;
  44553. /**
  44554. * Define the roll off factor of spatial sounds.
  44555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44556. */
  44557. rolloffFactor?: number;
  44558. /**
  44559. * Define the reference distance the sound should be heard perfectly.
  44560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44561. */
  44562. refDistance?: number;
  44563. /**
  44564. * Define the distance attenuation model the sound will follow.
  44565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44566. */
  44567. distanceModel?: string;
  44568. /**
  44569. * Defines the playback speed (1 by default)
  44570. */
  44571. playbackRate?: number;
  44572. /**
  44573. * Defines if the sound is from a streaming source
  44574. */
  44575. streaming?: boolean;
  44576. /**
  44577. * Defines an optional length (in seconds) inside the sound file
  44578. */
  44579. length?: number;
  44580. /**
  44581. * Defines an optional offset (in seconds) inside the sound file
  44582. */
  44583. offset?: number;
  44584. /**
  44585. * If true, URLs will not be required to state the audio file codec to use.
  44586. */
  44587. skipCodecCheck?: boolean;
  44588. }
  44589. /**
  44590. * Defines a sound that can be played in the application.
  44591. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44592. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44593. */
  44594. export class Sound {
  44595. /**
  44596. * The name of the sound in the scene.
  44597. */
  44598. name: string;
  44599. /**
  44600. * Does the sound autoplay once loaded.
  44601. */
  44602. autoplay: boolean;
  44603. /**
  44604. * Does the sound loop after it finishes playing once.
  44605. */
  44606. loop: boolean;
  44607. /**
  44608. * Does the sound use a custom attenuation curve to simulate the falloff
  44609. * happening when the source gets further away from the camera.
  44610. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44611. */
  44612. useCustomAttenuation: boolean;
  44613. /**
  44614. * The sound track id this sound belongs to.
  44615. */
  44616. soundTrackId: number;
  44617. /**
  44618. * Is this sound currently played.
  44619. */
  44620. isPlaying: boolean;
  44621. /**
  44622. * Is this sound currently paused.
  44623. */
  44624. isPaused: boolean;
  44625. /**
  44626. * Does this sound enables spatial sound.
  44627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44628. */
  44629. spatialSound: boolean;
  44630. /**
  44631. * Define the reference distance the sound should be heard perfectly.
  44632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44633. */
  44634. refDistance: number;
  44635. /**
  44636. * Define the roll off factor of spatial sounds.
  44637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44638. */
  44639. rolloffFactor: number;
  44640. /**
  44641. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44642. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44643. */
  44644. maxDistance: number;
  44645. /**
  44646. * Define the distance attenuation model the sound will follow.
  44647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44648. */
  44649. distanceModel: string;
  44650. /**
  44651. * @hidden
  44652. * Back Compat
  44653. **/
  44654. onended: () => any;
  44655. /**
  44656. * Gets or sets an object used to store user defined information for the sound.
  44657. */
  44658. metadata: any;
  44659. /**
  44660. * Observable event when the current playing sound finishes.
  44661. */
  44662. onEndedObservable: Observable<Sound>;
  44663. private _panningModel;
  44664. private _playbackRate;
  44665. private _streaming;
  44666. private _startTime;
  44667. private _startOffset;
  44668. private _position;
  44669. /** @hidden */
  44670. _positionInEmitterSpace: boolean;
  44671. private _localDirection;
  44672. private _volume;
  44673. private _isReadyToPlay;
  44674. private _isDirectional;
  44675. private _readyToPlayCallback;
  44676. private _audioBuffer;
  44677. private _soundSource;
  44678. private _streamingSource;
  44679. private _soundPanner;
  44680. private _soundGain;
  44681. private _inputAudioNode;
  44682. private _outputAudioNode;
  44683. private _coneInnerAngle;
  44684. private _coneOuterAngle;
  44685. private _coneOuterGain;
  44686. private _scene;
  44687. private _connectedTransformNode;
  44688. private _customAttenuationFunction;
  44689. private _registerFunc;
  44690. private _isOutputConnected;
  44691. private _htmlAudioElement;
  44692. private _urlType;
  44693. private _length?;
  44694. private _offset?;
  44695. /** @hidden */
  44696. static _SceneComponentInitialization: (scene: Scene) => void;
  44697. /**
  44698. * Create a sound and attach it to a scene
  44699. * @param name Name of your sound
  44700. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44701. * @param scene defines the scene the sound belongs to
  44702. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44703. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44704. */
  44705. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44706. /**
  44707. * Release the sound and its associated resources
  44708. */
  44709. dispose(): void;
  44710. /**
  44711. * Gets if the sounds is ready to be played or not.
  44712. * @returns true if ready, otherwise false
  44713. */
  44714. isReady(): boolean;
  44715. private _soundLoaded;
  44716. /**
  44717. * Sets the data of the sound from an audiobuffer
  44718. * @param audioBuffer The audioBuffer containing the data
  44719. */
  44720. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44721. /**
  44722. * Updates the current sounds options such as maxdistance, loop...
  44723. * @param options A JSON object containing values named as the object properties
  44724. */
  44725. updateOptions(options: ISoundOptions): void;
  44726. private _createSpatialParameters;
  44727. private _updateSpatialParameters;
  44728. /**
  44729. * Switch the panning model to HRTF:
  44730. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44731. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44732. */
  44733. switchPanningModelToHRTF(): void;
  44734. /**
  44735. * Switch the panning model to Equal Power:
  44736. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44737. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44738. */
  44739. switchPanningModelToEqualPower(): void;
  44740. private _switchPanningModel;
  44741. /**
  44742. * Connect this sound to a sound track audio node like gain...
  44743. * @param soundTrackAudioNode the sound track audio node to connect to
  44744. */
  44745. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44746. /**
  44747. * Transform this sound into a directional source
  44748. * @param coneInnerAngle Size of the inner cone in degree
  44749. * @param coneOuterAngle Size of the outer cone in degree
  44750. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44751. */
  44752. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44753. /**
  44754. * Gets or sets the inner angle for the directional cone.
  44755. */
  44756. get directionalConeInnerAngle(): number;
  44757. /**
  44758. * Gets or sets the inner angle for the directional cone.
  44759. */
  44760. set directionalConeInnerAngle(value: number);
  44761. /**
  44762. * Gets or sets the outer angle for the directional cone.
  44763. */
  44764. get directionalConeOuterAngle(): number;
  44765. /**
  44766. * Gets or sets the outer angle for the directional cone.
  44767. */
  44768. set directionalConeOuterAngle(value: number);
  44769. /**
  44770. * Sets the position of the emitter if spatial sound is enabled
  44771. * @param newPosition Defines the new posisiton
  44772. */
  44773. setPosition(newPosition: Vector3): void;
  44774. /**
  44775. * Sets the local direction of the emitter if spatial sound is enabled
  44776. * @param newLocalDirection Defines the new local direction
  44777. */
  44778. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44779. private _updateDirection;
  44780. /** @hidden */
  44781. updateDistanceFromListener(): void;
  44782. /**
  44783. * Sets a new custom attenuation function for the sound.
  44784. * @param callback Defines the function used for the attenuation
  44785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44786. */
  44787. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44788. /**
  44789. * Play the sound
  44790. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44791. * @param offset (optional) Start the sound at a specific time in seconds
  44792. * @param length (optional) Sound duration (in seconds)
  44793. */
  44794. play(time?: number, offset?: number, length?: number): void;
  44795. private _onended;
  44796. /**
  44797. * Stop the sound
  44798. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44799. */
  44800. stop(time?: number): void;
  44801. /**
  44802. * Put the sound in pause
  44803. */
  44804. pause(): void;
  44805. /**
  44806. * Sets a dedicated volume for this sounds
  44807. * @param newVolume Define the new volume of the sound
  44808. * @param time Define time for gradual change to new volume
  44809. */
  44810. setVolume(newVolume: number, time?: number): void;
  44811. /**
  44812. * Set the sound play back rate
  44813. * @param newPlaybackRate Define the playback rate the sound should be played at
  44814. */
  44815. setPlaybackRate(newPlaybackRate: number): void;
  44816. /**
  44817. * Gets the volume of the sound.
  44818. * @returns the volume of the sound
  44819. */
  44820. getVolume(): number;
  44821. /**
  44822. * Attach the sound to a dedicated mesh
  44823. * @param transformNode The transform node to connect the sound with
  44824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44825. */
  44826. attachToMesh(transformNode: TransformNode): void;
  44827. /**
  44828. * Detach the sound from the previously attached mesh
  44829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44830. */
  44831. detachFromMesh(): void;
  44832. private _onRegisterAfterWorldMatrixUpdate;
  44833. /**
  44834. * Clone the current sound in the scene.
  44835. * @returns the new sound clone
  44836. */
  44837. clone(): Nullable<Sound>;
  44838. /**
  44839. * Gets the current underlying audio buffer containing the data
  44840. * @returns the audio buffer
  44841. */
  44842. getAudioBuffer(): Nullable<AudioBuffer>;
  44843. /**
  44844. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44845. * @returns the source node
  44846. */
  44847. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44848. /**
  44849. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44850. * @returns the gain node
  44851. */
  44852. getSoundGain(): Nullable<GainNode>;
  44853. /**
  44854. * Serializes the Sound in a JSON representation
  44855. * @returns the JSON representation of the sound
  44856. */
  44857. serialize(): any;
  44858. /**
  44859. * Parse a JSON representation of a sound to innstantiate in a given scene
  44860. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44861. * @param scene Define the scene the new parsed sound should be created in
  44862. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44863. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44864. * @returns the newly parsed sound
  44865. */
  44866. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44867. }
  44868. }
  44869. declare module BABYLON {
  44870. /**
  44871. * This defines an action helpful to play a defined sound on a triggered action.
  44872. */
  44873. export class PlaySoundAction extends Action {
  44874. private _sound;
  44875. /**
  44876. * Instantiate the action
  44877. * @param triggerOptions defines the trigger options
  44878. * @param sound defines the sound to play
  44879. * @param condition defines the trigger related conditions
  44880. */
  44881. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44882. /** @hidden */
  44883. _prepare(): void;
  44884. /**
  44885. * Execute the action and play the sound.
  44886. */
  44887. execute(): void;
  44888. /**
  44889. * Serializes the actions and its related information.
  44890. * @param parent defines the object to serialize in
  44891. * @returns the serialized object
  44892. */
  44893. serialize(parent: any): any;
  44894. }
  44895. /**
  44896. * This defines an action helpful to stop a defined sound on a triggered action.
  44897. */
  44898. export class StopSoundAction extends Action {
  44899. private _sound;
  44900. /**
  44901. * Instantiate the action
  44902. * @param triggerOptions defines the trigger options
  44903. * @param sound defines the sound to stop
  44904. * @param condition defines the trigger related conditions
  44905. */
  44906. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44907. /** @hidden */
  44908. _prepare(): void;
  44909. /**
  44910. * Execute the action and stop the sound.
  44911. */
  44912. execute(): void;
  44913. /**
  44914. * Serializes the actions and its related information.
  44915. * @param parent defines the object to serialize in
  44916. * @returns the serialized object
  44917. */
  44918. serialize(parent: any): any;
  44919. }
  44920. }
  44921. declare module BABYLON {
  44922. /**
  44923. * This defines an action responsible to change the value of a property
  44924. * by interpolating between its current value and the newly set one once triggered.
  44925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44926. */
  44927. export class InterpolateValueAction extends Action {
  44928. /**
  44929. * Defines the path of the property where the value should be interpolated
  44930. */
  44931. propertyPath: string;
  44932. /**
  44933. * Defines the target value at the end of the interpolation.
  44934. */
  44935. value: any;
  44936. /**
  44937. * Defines the time it will take for the property to interpolate to the value.
  44938. */
  44939. duration: number;
  44940. /**
  44941. * Defines if the other scene animations should be stopped when the action has been triggered
  44942. */
  44943. stopOtherAnimations?: boolean;
  44944. /**
  44945. * Defines a callback raised once the interpolation animation has been done.
  44946. */
  44947. onInterpolationDone?: () => void;
  44948. /**
  44949. * Observable triggered once the interpolation animation has been done.
  44950. */
  44951. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44952. private _target;
  44953. private _effectiveTarget;
  44954. private _property;
  44955. /**
  44956. * Instantiate the action
  44957. * @param triggerOptions defines the trigger options
  44958. * @param target defines the object containing the value to interpolate
  44959. * @param propertyPath defines the path to the property in the target object
  44960. * @param value defines the target value at the end of the interpolation
  44961. * @param duration deines the time it will take for the property to interpolate to the value.
  44962. * @param condition defines the trigger related conditions
  44963. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44964. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44965. */
  44966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44967. /** @hidden */
  44968. _prepare(): void;
  44969. /**
  44970. * Execute the action starts the value interpolation.
  44971. */
  44972. execute(): void;
  44973. /**
  44974. * Serializes the actions and its related information.
  44975. * @param parent defines the object to serialize in
  44976. * @returns the serialized object
  44977. */
  44978. serialize(parent: any): any;
  44979. }
  44980. }
  44981. declare module BABYLON {
  44982. /**
  44983. * Options allowed during the creation of a sound track.
  44984. */
  44985. export interface ISoundTrackOptions {
  44986. /**
  44987. * The volume the sound track should take during creation
  44988. */
  44989. volume?: number;
  44990. /**
  44991. * Define if the sound track is the main sound track of the scene
  44992. */
  44993. mainTrack?: boolean;
  44994. }
  44995. /**
  44996. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44997. * It will be also used in a future release to apply effects on a specific track.
  44998. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44999. */
  45000. export class SoundTrack {
  45001. /**
  45002. * The unique identifier of the sound track in the scene.
  45003. */
  45004. id: number;
  45005. /**
  45006. * The list of sounds included in the sound track.
  45007. */
  45008. soundCollection: Array<Sound>;
  45009. private _outputAudioNode;
  45010. private _scene;
  45011. private _connectedAnalyser;
  45012. private _options;
  45013. private _isInitialized;
  45014. /**
  45015. * Creates a new sound track.
  45016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45017. * @param scene Define the scene the sound track belongs to
  45018. * @param options
  45019. */
  45020. constructor(scene: Scene, options?: ISoundTrackOptions);
  45021. private _initializeSoundTrackAudioGraph;
  45022. /**
  45023. * Release the sound track and its associated resources
  45024. */
  45025. dispose(): void;
  45026. /**
  45027. * Adds a sound to this sound track
  45028. * @param sound define the cound to add
  45029. * @ignoreNaming
  45030. */
  45031. AddSound(sound: Sound): void;
  45032. /**
  45033. * Removes a sound to this sound track
  45034. * @param sound define the cound to remove
  45035. * @ignoreNaming
  45036. */
  45037. RemoveSound(sound: Sound): void;
  45038. /**
  45039. * Set a global volume for the full sound track.
  45040. * @param newVolume Define the new volume of the sound track
  45041. */
  45042. setVolume(newVolume: number): void;
  45043. /**
  45044. * Switch the panning model to HRTF:
  45045. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45047. */
  45048. switchPanningModelToHRTF(): void;
  45049. /**
  45050. * Switch the panning model to Equal Power:
  45051. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45052. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45053. */
  45054. switchPanningModelToEqualPower(): void;
  45055. /**
  45056. * Connect the sound track to an audio analyser allowing some amazing
  45057. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45059. * @param analyser The analyser to connect to the engine
  45060. */
  45061. connectToAnalyser(analyser: Analyser): void;
  45062. }
  45063. }
  45064. declare module BABYLON {
  45065. interface AbstractScene {
  45066. /**
  45067. * The list of sounds used in the scene.
  45068. */
  45069. sounds: Nullable<Array<Sound>>;
  45070. }
  45071. interface Scene {
  45072. /**
  45073. * @hidden
  45074. * Backing field
  45075. */
  45076. _mainSoundTrack: SoundTrack;
  45077. /**
  45078. * The main sound track played by the scene.
  45079. * It cotains your primary collection of sounds.
  45080. */
  45081. mainSoundTrack: SoundTrack;
  45082. /**
  45083. * The list of sound tracks added to the scene
  45084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45085. */
  45086. soundTracks: Nullable<Array<SoundTrack>>;
  45087. /**
  45088. * Gets a sound using a given name
  45089. * @param name defines the name to search for
  45090. * @return the found sound or null if not found at all.
  45091. */
  45092. getSoundByName(name: string): Nullable<Sound>;
  45093. /**
  45094. * Gets or sets if audio support is enabled
  45095. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45096. */
  45097. audioEnabled: boolean;
  45098. /**
  45099. * Gets or sets if audio will be output to headphones
  45100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45101. */
  45102. headphone: boolean;
  45103. /**
  45104. * Gets or sets custom audio listener position provider
  45105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45106. */
  45107. audioListenerPositionProvider: Nullable<() => Vector3>;
  45108. /**
  45109. * Gets or sets a refresh rate when using 3D audio positioning
  45110. */
  45111. audioPositioningRefreshRate: number;
  45112. }
  45113. /**
  45114. * Defines the sound scene component responsible to manage any sounds
  45115. * in a given scene.
  45116. */
  45117. export class AudioSceneComponent implements ISceneSerializableComponent {
  45118. private static _CameraDirectionLH;
  45119. private static _CameraDirectionRH;
  45120. /**
  45121. * The component name helpfull to identify the component in the list of scene components.
  45122. */
  45123. readonly name: string;
  45124. /**
  45125. * The scene the component belongs to.
  45126. */
  45127. scene: Scene;
  45128. private _audioEnabled;
  45129. /**
  45130. * Gets whether audio is enabled or not.
  45131. * Please use related enable/disable method to switch state.
  45132. */
  45133. get audioEnabled(): boolean;
  45134. private _headphone;
  45135. /**
  45136. * Gets whether audio is outputing to headphone or not.
  45137. * Please use the according Switch methods to change output.
  45138. */
  45139. get headphone(): boolean;
  45140. /**
  45141. * Gets or sets a refresh rate when using 3D audio positioning
  45142. */
  45143. audioPositioningRefreshRate: number;
  45144. private _audioListenerPositionProvider;
  45145. /**
  45146. * Gets the current audio listener position provider
  45147. */
  45148. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45149. /**
  45150. * Sets a custom listener position for all sounds in the scene
  45151. * By default, this is the position of the first active camera
  45152. */
  45153. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45154. /**
  45155. * Creates a new instance of the component for the given scene
  45156. * @param scene Defines the scene to register the component in
  45157. */
  45158. constructor(scene: Scene);
  45159. /**
  45160. * Registers the component in a given scene
  45161. */
  45162. register(): void;
  45163. /**
  45164. * Rebuilds the elements related to this component in case of
  45165. * context lost for instance.
  45166. */
  45167. rebuild(): void;
  45168. /**
  45169. * Serializes the component data to the specified json object
  45170. * @param serializationObject The object to serialize to
  45171. */
  45172. serialize(serializationObject: any): void;
  45173. /**
  45174. * Adds all the elements from the container to the scene
  45175. * @param container the container holding the elements
  45176. */
  45177. addFromContainer(container: AbstractScene): void;
  45178. /**
  45179. * Removes all the elements in the container from the scene
  45180. * @param container contains the elements to remove
  45181. * @param dispose if the removed element should be disposed (default: false)
  45182. */
  45183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45184. /**
  45185. * Disposes the component and the associated ressources.
  45186. */
  45187. dispose(): void;
  45188. /**
  45189. * Disables audio in the associated scene.
  45190. */
  45191. disableAudio(): void;
  45192. /**
  45193. * Enables audio in the associated scene.
  45194. */
  45195. enableAudio(): void;
  45196. /**
  45197. * Switch audio to headphone output.
  45198. */
  45199. switchAudioModeForHeadphones(): void;
  45200. /**
  45201. * Switch audio to normal speakers.
  45202. */
  45203. switchAudioModeForNormalSpeakers(): void;
  45204. private _cachedCameraDirection;
  45205. private _cachedCameraPosition;
  45206. private _lastCheck;
  45207. private _afterRender;
  45208. }
  45209. }
  45210. declare module BABYLON {
  45211. /**
  45212. * Wraps one or more Sound objects and selects one with random weight for playback.
  45213. */
  45214. export class WeightedSound {
  45215. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45216. loop: boolean;
  45217. private _coneInnerAngle;
  45218. private _coneOuterAngle;
  45219. private _volume;
  45220. /** A Sound is currently playing. */
  45221. isPlaying: boolean;
  45222. /** A Sound is currently paused. */
  45223. isPaused: boolean;
  45224. private _sounds;
  45225. private _weights;
  45226. private _currentIndex?;
  45227. /**
  45228. * Creates a new WeightedSound from the list of sounds given.
  45229. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45230. * @param sounds Array of Sounds that will be selected from.
  45231. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45232. */
  45233. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45234. /**
  45235. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45236. */
  45237. get directionalConeInnerAngle(): number;
  45238. /**
  45239. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45240. */
  45241. set directionalConeInnerAngle(value: number);
  45242. /**
  45243. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45244. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45245. */
  45246. get directionalConeOuterAngle(): number;
  45247. /**
  45248. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45249. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45250. */
  45251. set directionalConeOuterAngle(value: number);
  45252. /**
  45253. * Playback volume.
  45254. */
  45255. get volume(): number;
  45256. /**
  45257. * Playback volume.
  45258. */
  45259. set volume(value: number);
  45260. private _onended;
  45261. /**
  45262. * Suspend playback
  45263. */
  45264. pause(): void;
  45265. /**
  45266. * Stop playback
  45267. */
  45268. stop(): void;
  45269. /**
  45270. * Start playback.
  45271. * @param startOffset Position the clip head at a specific time in seconds.
  45272. */
  45273. play(startOffset?: number): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45279. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45280. */
  45281. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45282. /**
  45283. * Gets the name of the behavior.
  45284. */
  45285. get name(): string;
  45286. /**
  45287. * The easing function used by animations
  45288. */
  45289. static EasingFunction: BackEase;
  45290. /**
  45291. * The easing mode used by animations
  45292. */
  45293. static EasingMode: number;
  45294. /**
  45295. * The duration of the animation, in milliseconds
  45296. */
  45297. transitionDuration: number;
  45298. /**
  45299. * Length of the distance animated by the transition when lower radius is reached
  45300. */
  45301. lowerRadiusTransitionRange: number;
  45302. /**
  45303. * Length of the distance animated by the transition when upper radius is reached
  45304. */
  45305. upperRadiusTransitionRange: number;
  45306. private _autoTransitionRange;
  45307. /**
  45308. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45309. */
  45310. get autoTransitionRange(): boolean;
  45311. /**
  45312. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45313. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45314. */
  45315. set autoTransitionRange(value: boolean);
  45316. private _attachedCamera;
  45317. private _onAfterCheckInputsObserver;
  45318. private _onMeshTargetChangedObserver;
  45319. /**
  45320. * Initializes the behavior.
  45321. */
  45322. init(): void;
  45323. /**
  45324. * Attaches the behavior to its arc rotate camera.
  45325. * @param camera Defines the camera to attach the behavior to
  45326. */
  45327. attach(camera: ArcRotateCamera): void;
  45328. /**
  45329. * Detaches the behavior from its current arc rotate camera.
  45330. */
  45331. detach(): void;
  45332. private _radiusIsAnimating;
  45333. private _radiusBounceTransition;
  45334. private _animatables;
  45335. private _cachedWheelPrecision;
  45336. /**
  45337. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45338. * @param radiusLimit The limit to check against.
  45339. * @return Bool to indicate if at limit.
  45340. */
  45341. private _isRadiusAtLimit;
  45342. /**
  45343. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45344. * @param radiusDelta The delta by which to animate to. Can be negative.
  45345. */
  45346. private _applyBoundRadiusAnimation;
  45347. /**
  45348. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45349. */
  45350. protected _clearAnimationLocks(): void;
  45351. /**
  45352. * Stops and removes all animations that have been applied to the camera
  45353. */
  45354. stopAllAnimations(): void;
  45355. }
  45356. }
  45357. declare module BABYLON {
  45358. /**
  45359. * 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.
  45360. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45361. */
  45362. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45363. /**
  45364. * Gets the name of the behavior.
  45365. */
  45366. get name(): string;
  45367. private _mode;
  45368. private _radiusScale;
  45369. private _positionScale;
  45370. private _defaultElevation;
  45371. private _elevationReturnTime;
  45372. private _elevationReturnWaitTime;
  45373. private _zoomStopsAnimation;
  45374. private _framingTime;
  45375. /**
  45376. * The easing function used by animations
  45377. */
  45378. static EasingFunction: ExponentialEase;
  45379. /**
  45380. * The easing mode used by animations
  45381. */
  45382. static EasingMode: number;
  45383. /**
  45384. * Sets the current mode used by the behavior
  45385. */
  45386. set mode(mode: number);
  45387. /**
  45388. * Gets current mode used by the behavior.
  45389. */
  45390. get mode(): number;
  45391. /**
  45392. * Sets the scale applied to the radius (1 by default)
  45393. */
  45394. set radiusScale(radius: number);
  45395. /**
  45396. * Gets the scale applied to the radius
  45397. */
  45398. get radiusScale(): number;
  45399. /**
  45400. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45401. */
  45402. set positionScale(scale: number);
  45403. /**
  45404. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45405. */
  45406. get positionScale(): number;
  45407. /**
  45408. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45409. * behaviour is triggered, in radians.
  45410. */
  45411. set defaultElevation(elevation: number);
  45412. /**
  45413. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45414. * behaviour is triggered, in radians.
  45415. */
  45416. get defaultElevation(): number;
  45417. /**
  45418. * Sets the time (in milliseconds) taken to return to the default beta position.
  45419. * Negative value indicates camera should not return to default.
  45420. */
  45421. set elevationReturnTime(speed: number);
  45422. /**
  45423. * Gets the time (in milliseconds) taken to return to the default beta position.
  45424. * Negative value indicates camera should not return to default.
  45425. */
  45426. get elevationReturnTime(): number;
  45427. /**
  45428. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45429. */
  45430. set elevationReturnWaitTime(time: number);
  45431. /**
  45432. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45433. */
  45434. get elevationReturnWaitTime(): number;
  45435. /**
  45436. * Sets the flag that indicates if user zooming should stop animation.
  45437. */
  45438. set zoomStopsAnimation(flag: boolean);
  45439. /**
  45440. * Gets the flag that indicates if user zooming should stop animation.
  45441. */
  45442. get zoomStopsAnimation(): boolean;
  45443. /**
  45444. * Sets the transition time when framing the mesh, in milliseconds
  45445. */
  45446. set framingTime(time: number);
  45447. /**
  45448. * Gets the transition time when framing the mesh, in milliseconds
  45449. */
  45450. get framingTime(): number;
  45451. /**
  45452. * Define if the behavior should automatically change the configured
  45453. * camera limits and sensibilities.
  45454. */
  45455. autoCorrectCameraLimitsAndSensibility: boolean;
  45456. private _onPrePointerObservableObserver;
  45457. private _onAfterCheckInputsObserver;
  45458. private _onMeshTargetChangedObserver;
  45459. private _attachedCamera;
  45460. private _isPointerDown;
  45461. private _lastInteractionTime;
  45462. /**
  45463. * Initializes the behavior.
  45464. */
  45465. init(): void;
  45466. /**
  45467. * Attaches the behavior to its arc rotate camera.
  45468. * @param camera Defines the camera to attach the behavior to
  45469. */
  45470. attach(camera: ArcRotateCamera): void;
  45471. /**
  45472. * Detaches the behavior from its current arc rotate camera.
  45473. */
  45474. detach(): void;
  45475. private _animatables;
  45476. private _betaIsAnimating;
  45477. private _betaTransition;
  45478. private _radiusTransition;
  45479. private _vectorTransition;
  45480. /**
  45481. * Targets the given mesh and updates zoom level accordingly.
  45482. * @param mesh The mesh to target.
  45483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45485. */
  45486. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45487. /**
  45488. * Targets the given mesh with its children and updates zoom level accordingly.
  45489. * @param mesh The mesh to target.
  45490. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45491. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45492. */
  45493. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45494. /**
  45495. * Targets the given meshes with their children and updates zoom level accordingly.
  45496. * @param meshes The mesh to target.
  45497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45499. */
  45500. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45501. /**
  45502. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45503. * @param minimumWorld Determines the smaller position of the bounding box extend
  45504. * @param maximumWorld Determines the bigger position of the bounding box extend
  45505. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45506. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45507. */
  45508. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45509. /**
  45510. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45511. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45512. * frustum width.
  45513. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45514. * to fully enclose the mesh in the viewing frustum.
  45515. */
  45516. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45517. /**
  45518. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45519. * is automatically returned to its default position (expected to be above ground plane).
  45520. */
  45521. private _maintainCameraAboveGround;
  45522. /**
  45523. * Returns the frustum slope based on the canvas ratio and camera FOV
  45524. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45525. */
  45526. private _getFrustumSlope;
  45527. /**
  45528. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45529. */
  45530. private _clearAnimationLocks;
  45531. /**
  45532. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45533. */
  45534. private _applyUserInteraction;
  45535. /**
  45536. * Stops and removes all animations that have been applied to the camera
  45537. */
  45538. stopAllAnimations(): void;
  45539. /**
  45540. * Gets a value indicating if the user is moving the camera
  45541. */
  45542. get isUserIsMoving(): boolean;
  45543. /**
  45544. * The camera can move all the way towards the mesh.
  45545. */
  45546. static IgnoreBoundsSizeMode: number;
  45547. /**
  45548. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45549. */
  45550. static FitFrustumSidesMode: number;
  45551. }
  45552. }
  45553. declare module BABYLON {
  45554. /**
  45555. * Base class for Camera Pointer Inputs.
  45556. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45557. * for example usage.
  45558. */
  45559. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45560. /**
  45561. * Defines the camera the input is attached to.
  45562. */
  45563. abstract camera: Camera;
  45564. /**
  45565. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45566. */
  45567. protected _altKey: boolean;
  45568. protected _ctrlKey: boolean;
  45569. protected _metaKey: boolean;
  45570. protected _shiftKey: boolean;
  45571. /**
  45572. * Which mouse buttons were pressed at time of last mouse event.
  45573. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45574. */
  45575. protected _buttonsPressed: number;
  45576. /**
  45577. * Defines the buttons associated with the input to handle camera move.
  45578. */
  45579. buttons: number[];
  45580. /**
  45581. * Attach the input controls to a specific dom element to get the input from.
  45582. * @param element Defines the element the controls should be listened from
  45583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45584. */
  45585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45586. /**
  45587. * Detach the current controls from the specified dom element.
  45588. * @param element Defines the element to stop listening the inputs from
  45589. */
  45590. detachControl(element: Nullable<HTMLElement>): void;
  45591. /**
  45592. * Gets the class name of the current input.
  45593. * @returns the class name
  45594. */
  45595. getClassName(): string;
  45596. /**
  45597. * Get the friendly name associated with the input class.
  45598. * @returns the input friendly name
  45599. */
  45600. getSimpleName(): string;
  45601. /**
  45602. * Called on pointer POINTERDOUBLETAP event.
  45603. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45604. */
  45605. protected onDoubleTap(type: string): void;
  45606. /**
  45607. * Called on pointer POINTERMOVE event if only a single touch is active.
  45608. * Override this method to provide functionality.
  45609. */
  45610. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45611. /**
  45612. * Called on pointer POINTERMOVE event if multiple touches are active.
  45613. * Override this method to provide functionality.
  45614. */
  45615. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45616. /**
  45617. * Called on JS contextmenu event.
  45618. * Override this method to provide functionality.
  45619. */
  45620. protected onContextMenu(evt: PointerEvent): void;
  45621. /**
  45622. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45623. * press.
  45624. * Override this method to provide functionality.
  45625. */
  45626. protected onButtonDown(evt: PointerEvent): void;
  45627. /**
  45628. * Called each time a new POINTERUP event occurs. Ie, for each button
  45629. * release.
  45630. * Override this method to provide functionality.
  45631. */
  45632. protected onButtonUp(evt: PointerEvent): void;
  45633. /**
  45634. * Called when window becomes inactive.
  45635. * Override this method to provide functionality.
  45636. */
  45637. protected onLostFocus(): void;
  45638. private _pointerInput;
  45639. private _observer;
  45640. private _onLostFocus;
  45641. private pointA;
  45642. private pointB;
  45643. }
  45644. }
  45645. declare module BABYLON {
  45646. /**
  45647. * Manage the pointers inputs to control an arc rotate camera.
  45648. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45649. */
  45650. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45651. /**
  45652. * Defines the camera the input is attached to.
  45653. */
  45654. camera: ArcRotateCamera;
  45655. /**
  45656. * Gets the class name of the current input.
  45657. * @returns the class name
  45658. */
  45659. getClassName(): string;
  45660. /**
  45661. * Defines the buttons associated with the input to handle camera move.
  45662. */
  45663. buttons: number[];
  45664. /**
  45665. * Defines the pointer angular sensibility along the X axis or how fast is
  45666. * the camera rotating.
  45667. */
  45668. angularSensibilityX: number;
  45669. /**
  45670. * Defines the pointer angular sensibility along the Y axis or how fast is
  45671. * the camera rotating.
  45672. */
  45673. angularSensibilityY: number;
  45674. /**
  45675. * Defines the pointer pinch precision or how fast is the camera zooming.
  45676. */
  45677. pinchPrecision: number;
  45678. /**
  45679. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45680. * from 0.
  45681. * It defines the percentage of current camera.radius to use as delta when
  45682. * pinch zoom is used.
  45683. */
  45684. pinchDeltaPercentage: number;
  45685. /**
  45686. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45687. * that any object in the plane at the camera's target point will scale
  45688. * perfectly with finger motion.
  45689. * Overrides pinchDeltaPercentage and pinchPrecision.
  45690. */
  45691. useNaturalPinchZoom: boolean;
  45692. /**
  45693. * Defines the pointer panning sensibility or how fast is the camera moving.
  45694. */
  45695. panningSensibility: number;
  45696. /**
  45697. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45698. */
  45699. multiTouchPanning: boolean;
  45700. /**
  45701. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45702. * zoom (pinch) through multitouch.
  45703. */
  45704. multiTouchPanAndZoom: boolean;
  45705. /**
  45706. * Revers pinch action direction.
  45707. */
  45708. pinchInwards: boolean;
  45709. private _isPanClick;
  45710. private _twoFingerActivityCount;
  45711. private _isPinching;
  45712. /**
  45713. * Called on pointer POINTERMOVE event if only a single touch is active.
  45714. */
  45715. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45716. /**
  45717. * Called on pointer POINTERDOUBLETAP event.
  45718. */
  45719. protected onDoubleTap(type: string): void;
  45720. /**
  45721. * Called on pointer POINTERMOVE event if multiple touches are active.
  45722. */
  45723. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45724. /**
  45725. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45726. * press.
  45727. */
  45728. protected onButtonDown(evt: PointerEvent): void;
  45729. /**
  45730. * Called each time a new POINTERUP event occurs. Ie, for each button
  45731. * release.
  45732. */
  45733. protected onButtonUp(evt: PointerEvent): void;
  45734. /**
  45735. * Called when window becomes inactive.
  45736. */
  45737. protected onLostFocus(): void;
  45738. }
  45739. }
  45740. declare module BABYLON {
  45741. /**
  45742. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45743. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45744. */
  45745. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45746. /**
  45747. * Defines the camera the input is attached to.
  45748. */
  45749. camera: ArcRotateCamera;
  45750. /**
  45751. * Defines the list of key codes associated with the up action (increase alpha)
  45752. */
  45753. keysUp: number[];
  45754. /**
  45755. * Defines the list of key codes associated with the down action (decrease alpha)
  45756. */
  45757. keysDown: number[];
  45758. /**
  45759. * Defines the list of key codes associated with the left action (increase beta)
  45760. */
  45761. keysLeft: number[];
  45762. /**
  45763. * Defines the list of key codes associated with the right action (decrease beta)
  45764. */
  45765. keysRight: number[];
  45766. /**
  45767. * Defines the list of key codes associated with the reset action.
  45768. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45769. */
  45770. keysReset: number[];
  45771. /**
  45772. * Defines the panning sensibility of the inputs.
  45773. * (How fast is the camera panning)
  45774. */
  45775. panningSensibility: number;
  45776. /**
  45777. * Defines the zooming sensibility of the inputs.
  45778. * (How fast is the camera zooming)
  45779. */
  45780. zoomingSensibility: number;
  45781. /**
  45782. * Defines whether maintaining the alt key down switch the movement mode from
  45783. * orientation to zoom.
  45784. */
  45785. useAltToZoom: boolean;
  45786. /**
  45787. * Rotation speed of the camera
  45788. */
  45789. angularSpeed: number;
  45790. private _keys;
  45791. private _ctrlPressed;
  45792. private _altPressed;
  45793. private _onCanvasBlurObserver;
  45794. private _onKeyboardObserver;
  45795. private _engine;
  45796. private _scene;
  45797. /**
  45798. * Attach the input controls to a specific dom element to get the input from.
  45799. * @param element Defines the element the controls should be listened from
  45800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45801. */
  45802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45803. /**
  45804. * Detach the current controls from the specified dom element.
  45805. * @param element Defines the element to stop listening the inputs from
  45806. */
  45807. detachControl(element: Nullable<HTMLElement>): void;
  45808. /**
  45809. * Update the current camera state depending on the inputs that have been used this frame.
  45810. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45811. */
  45812. checkInputs(): void;
  45813. /**
  45814. * Gets the class name of the current intput.
  45815. * @returns the class name
  45816. */
  45817. getClassName(): string;
  45818. /**
  45819. * Get the friendly name associated with the input class.
  45820. * @returns the input friendly name
  45821. */
  45822. getSimpleName(): string;
  45823. }
  45824. }
  45825. declare module BABYLON {
  45826. /**
  45827. * Manage the mouse wheel inputs to control an arc rotate camera.
  45828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45829. */
  45830. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45831. /**
  45832. * Defines the camera the input is attached to.
  45833. */
  45834. camera: ArcRotateCamera;
  45835. /**
  45836. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45837. */
  45838. wheelPrecision: number;
  45839. /**
  45840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45842. */
  45843. wheelDeltaPercentage: number;
  45844. private _wheel;
  45845. private _observer;
  45846. private computeDeltaFromMouseWheelLegacyEvent;
  45847. /**
  45848. * Attach the input controls to a specific dom element to get the input from.
  45849. * @param element Defines the element the controls should be listened from
  45850. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45851. */
  45852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45853. /**
  45854. * Detach the current controls from the specified dom element.
  45855. * @param element Defines the element to stop listening the inputs from
  45856. */
  45857. detachControl(element: Nullable<HTMLElement>): void;
  45858. /**
  45859. * Gets the class name of the current intput.
  45860. * @returns the class name
  45861. */
  45862. getClassName(): string;
  45863. /**
  45864. * Get the friendly name associated with the input class.
  45865. * @returns the input friendly name
  45866. */
  45867. getSimpleName(): string;
  45868. }
  45869. }
  45870. declare module BABYLON {
  45871. /**
  45872. * Default Inputs manager for the ArcRotateCamera.
  45873. * It groups all the default supported inputs for ease of use.
  45874. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45875. */
  45876. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45877. /**
  45878. * Instantiates a new ArcRotateCameraInputsManager.
  45879. * @param camera Defines the camera the inputs belong to
  45880. */
  45881. constructor(camera: ArcRotateCamera);
  45882. /**
  45883. * Add mouse wheel input support to the input manager.
  45884. * @returns the current input manager
  45885. */
  45886. addMouseWheel(): ArcRotateCameraInputsManager;
  45887. /**
  45888. * Add pointers input support to the input manager.
  45889. * @returns the current input manager
  45890. */
  45891. addPointers(): ArcRotateCameraInputsManager;
  45892. /**
  45893. * Add keyboard input support to the input manager.
  45894. * @returns the current input manager
  45895. */
  45896. addKeyboard(): ArcRotateCameraInputsManager;
  45897. }
  45898. }
  45899. declare module BABYLON {
  45900. /**
  45901. * This represents an orbital type of camera.
  45902. *
  45903. * 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.
  45904. * 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.
  45905. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45906. */
  45907. export class ArcRotateCamera extends TargetCamera {
  45908. /**
  45909. * Defines the rotation angle of the camera along the longitudinal axis.
  45910. */
  45911. alpha: number;
  45912. /**
  45913. * Defines the rotation angle of the camera along the latitudinal axis.
  45914. */
  45915. beta: number;
  45916. /**
  45917. * Defines the radius of the camera from it s target point.
  45918. */
  45919. radius: number;
  45920. protected _target: Vector3;
  45921. protected _targetHost: Nullable<AbstractMesh>;
  45922. /**
  45923. * Defines the target point of the camera.
  45924. * The camera looks towards it form the radius distance.
  45925. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45926. */
  45927. get target(): Vector3;
  45928. set target(value: Vector3);
  45929. /**
  45930. * Define the current local position of the camera in the scene
  45931. */
  45932. get position(): Vector3;
  45933. set position(newPosition: Vector3);
  45934. protected _upToYMatrix: Matrix;
  45935. protected _YToUpMatrix: Matrix;
  45936. /**
  45937. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45938. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45939. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45940. */
  45941. set upVector(vec: Vector3);
  45942. get upVector(): Vector3;
  45943. /**
  45944. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45945. */
  45946. setMatUp(): void;
  45947. /**
  45948. * Current inertia value on the longitudinal axis.
  45949. * The bigger this number the longer it will take for the camera to stop.
  45950. */
  45951. inertialAlphaOffset: number;
  45952. /**
  45953. * Current inertia value on the latitudinal axis.
  45954. * The bigger this number the longer it will take for the camera to stop.
  45955. */
  45956. inertialBetaOffset: number;
  45957. /**
  45958. * Current inertia value on the radius axis.
  45959. * The bigger this number the longer it will take for the camera to stop.
  45960. */
  45961. inertialRadiusOffset: number;
  45962. /**
  45963. * Minimum allowed angle on the longitudinal axis.
  45964. * This can help limiting how the Camera is able to move in the scene.
  45965. */
  45966. lowerAlphaLimit: Nullable<number>;
  45967. /**
  45968. * Maximum allowed angle on the longitudinal axis.
  45969. * This can help limiting how the Camera is able to move in the scene.
  45970. */
  45971. upperAlphaLimit: Nullable<number>;
  45972. /**
  45973. * Minimum allowed angle on the latitudinal axis.
  45974. * This can help limiting how the Camera is able to move in the scene.
  45975. */
  45976. lowerBetaLimit: number;
  45977. /**
  45978. * Maximum allowed angle on the latitudinal axis.
  45979. * This can help limiting how the Camera is able to move in the scene.
  45980. */
  45981. upperBetaLimit: number;
  45982. /**
  45983. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45984. * This can help limiting how the Camera is able to move in the scene.
  45985. */
  45986. lowerRadiusLimit: Nullable<number>;
  45987. /**
  45988. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45989. * This can help limiting how the Camera is able to move in the scene.
  45990. */
  45991. upperRadiusLimit: Nullable<number>;
  45992. /**
  45993. * Defines the current inertia value used during panning of the camera along the X axis.
  45994. */
  45995. inertialPanningX: number;
  45996. /**
  45997. * Defines the current inertia value used during panning of the camera along the Y axis.
  45998. */
  45999. inertialPanningY: number;
  46000. /**
  46001. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46002. * Basically if your fingers moves away from more than this distance you will be considered
  46003. * in pinch mode.
  46004. */
  46005. pinchToPanMaxDistance: number;
  46006. /**
  46007. * Defines the maximum distance the camera can pan.
  46008. * This could help keeping the cammera always in your scene.
  46009. */
  46010. panningDistanceLimit: Nullable<number>;
  46011. /**
  46012. * Defines the target of the camera before paning.
  46013. */
  46014. panningOriginTarget: Vector3;
  46015. /**
  46016. * Defines the value of the inertia used during panning.
  46017. * 0 would mean stop inertia and one would mean no decelleration at all.
  46018. */
  46019. panningInertia: number;
  46020. /**
  46021. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46022. */
  46023. get angularSensibilityX(): number;
  46024. set angularSensibilityX(value: number);
  46025. /**
  46026. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46027. */
  46028. get angularSensibilityY(): number;
  46029. set angularSensibilityY(value: number);
  46030. /**
  46031. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46032. */
  46033. get pinchPrecision(): number;
  46034. set pinchPrecision(value: number);
  46035. /**
  46036. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46037. * It will be used instead of pinchDeltaPrecision if different from 0.
  46038. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46039. */
  46040. get pinchDeltaPercentage(): number;
  46041. set pinchDeltaPercentage(value: number);
  46042. /**
  46043. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46044. * and pinch delta percentage.
  46045. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46046. * that any object in the plane at the camera's target point will scale
  46047. * perfectly with finger motion.
  46048. */
  46049. get useNaturalPinchZoom(): boolean;
  46050. set useNaturalPinchZoom(value: boolean);
  46051. /**
  46052. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46053. */
  46054. get panningSensibility(): number;
  46055. set panningSensibility(value: number);
  46056. /**
  46057. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46058. */
  46059. get keysUp(): number[];
  46060. set keysUp(value: number[]);
  46061. /**
  46062. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46063. */
  46064. get keysDown(): number[];
  46065. set keysDown(value: number[]);
  46066. /**
  46067. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46068. */
  46069. get keysLeft(): number[];
  46070. set keysLeft(value: number[]);
  46071. /**
  46072. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46073. */
  46074. get keysRight(): number[];
  46075. set keysRight(value: number[]);
  46076. /**
  46077. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46078. */
  46079. get wheelPrecision(): number;
  46080. set wheelPrecision(value: number);
  46081. /**
  46082. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46083. * It will be used instead of pinchDeltaPrecision if different from 0.
  46084. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46085. */
  46086. get wheelDeltaPercentage(): number;
  46087. set wheelDeltaPercentage(value: number);
  46088. /**
  46089. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46090. */
  46091. zoomOnFactor: number;
  46092. /**
  46093. * Defines a screen offset for the camera position.
  46094. */
  46095. targetScreenOffset: Vector2;
  46096. /**
  46097. * Allows the camera to be completely reversed.
  46098. * If false the camera can not arrive upside down.
  46099. */
  46100. allowUpsideDown: boolean;
  46101. /**
  46102. * Define if double tap/click is used to restore the previously saved state of the camera.
  46103. */
  46104. useInputToRestoreState: boolean;
  46105. /** @hidden */
  46106. _viewMatrix: Matrix;
  46107. /** @hidden */
  46108. _useCtrlForPanning: boolean;
  46109. /** @hidden */
  46110. _panningMouseButton: number;
  46111. /**
  46112. * Defines the input associated to the camera.
  46113. */
  46114. inputs: ArcRotateCameraInputsManager;
  46115. /** @hidden */
  46116. _reset: () => void;
  46117. /**
  46118. * Defines the allowed panning axis.
  46119. */
  46120. panningAxis: Vector3;
  46121. protected _localDirection: Vector3;
  46122. protected _transformedDirection: Vector3;
  46123. private _bouncingBehavior;
  46124. /**
  46125. * Gets the bouncing behavior of the camera if it has been enabled.
  46126. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46127. */
  46128. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46129. /**
  46130. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46131. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46132. */
  46133. get useBouncingBehavior(): boolean;
  46134. set useBouncingBehavior(value: boolean);
  46135. private _framingBehavior;
  46136. /**
  46137. * Gets the framing behavior of the camera if it has been enabled.
  46138. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46139. */
  46140. get framingBehavior(): Nullable<FramingBehavior>;
  46141. /**
  46142. * Defines if the framing behavior of the camera is enabled on the camera.
  46143. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46144. */
  46145. get useFramingBehavior(): boolean;
  46146. set useFramingBehavior(value: boolean);
  46147. private _autoRotationBehavior;
  46148. /**
  46149. * Gets the auto rotation behavior of the camera if it has been enabled.
  46150. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46151. */
  46152. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46153. /**
  46154. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46155. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46156. */
  46157. get useAutoRotationBehavior(): boolean;
  46158. set useAutoRotationBehavior(value: boolean);
  46159. /**
  46160. * Observable triggered when the mesh target has been changed on the camera.
  46161. */
  46162. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46163. /**
  46164. * Event raised when the camera is colliding with a mesh.
  46165. */
  46166. onCollide: (collidedMesh: AbstractMesh) => void;
  46167. /**
  46168. * Defines whether the camera should check collision with the objects oh the scene.
  46169. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46170. */
  46171. checkCollisions: boolean;
  46172. /**
  46173. * Defines the collision radius of the camera.
  46174. * This simulates a sphere around the camera.
  46175. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46176. */
  46177. collisionRadius: Vector3;
  46178. protected _collider: Collider;
  46179. protected _previousPosition: Vector3;
  46180. protected _collisionVelocity: Vector3;
  46181. protected _newPosition: Vector3;
  46182. protected _previousAlpha: number;
  46183. protected _previousBeta: number;
  46184. protected _previousRadius: number;
  46185. protected _collisionTriggered: boolean;
  46186. protected _targetBoundingCenter: Nullable<Vector3>;
  46187. private _computationVector;
  46188. /**
  46189. * Instantiates a new ArcRotateCamera in a given scene
  46190. * @param name Defines the name of the camera
  46191. * @param alpha Defines the camera rotation along the logitudinal axis
  46192. * @param beta Defines the camera rotation along the latitudinal axis
  46193. * @param radius Defines the camera distance from its target
  46194. * @param target Defines the camera target
  46195. * @param scene Defines the scene the camera belongs to
  46196. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46197. */
  46198. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46199. /** @hidden */
  46200. _initCache(): void;
  46201. /** @hidden */
  46202. _updateCache(ignoreParentClass?: boolean): void;
  46203. protected _getTargetPosition(): Vector3;
  46204. private _storedAlpha;
  46205. private _storedBeta;
  46206. private _storedRadius;
  46207. private _storedTarget;
  46208. private _storedTargetScreenOffset;
  46209. /**
  46210. * Stores the current state of the camera (alpha, beta, radius and target)
  46211. * @returns the camera itself
  46212. */
  46213. storeState(): Camera;
  46214. /**
  46215. * @hidden
  46216. * Restored camera state. You must call storeState() first
  46217. */
  46218. _restoreStateValues(): boolean;
  46219. /** @hidden */
  46220. _isSynchronizedViewMatrix(): boolean;
  46221. /**
  46222. * Attached controls to the current camera.
  46223. * @param element Defines the element the controls should be listened from
  46224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46225. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46226. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46227. */
  46228. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46229. /**
  46230. * Detach the current controls from the camera.
  46231. * The camera will stop reacting to inputs.
  46232. * @param element Defines the element to stop listening the inputs from
  46233. */
  46234. detachControl(element: HTMLElement): void;
  46235. /** @hidden */
  46236. _checkInputs(): void;
  46237. protected _checkLimits(): void;
  46238. /**
  46239. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46240. */
  46241. rebuildAnglesAndRadius(): void;
  46242. /**
  46243. * Use a position to define the current camera related information like alpha, beta and radius
  46244. * @param position Defines the position to set the camera at
  46245. */
  46246. setPosition(position: Vector3): void;
  46247. /**
  46248. * Defines the target the camera should look at.
  46249. * This will automatically adapt alpha beta and radius to fit within the new target.
  46250. * @param target Defines the new target as a Vector or a mesh
  46251. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46252. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46253. */
  46254. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46255. /** @hidden */
  46256. _getViewMatrix(): Matrix;
  46257. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46258. /**
  46259. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46260. * @param meshes Defines the mesh to zoom on
  46261. * @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)
  46262. */
  46263. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46264. /**
  46265. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46266. * The target will be changed but the radius
  46267. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46268. * @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)
  46269. */
  46270. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46271. min: Vector3;
  46272. max: Vector3;
  46273. distance: number;
  46274. }, doNotUpdateMaxZ?: boolean): void;
  46275. /**
  46276. * @override
  46277. * Override Camera.createRigCamera
  46278. */
  46279. createRigCamera(name: string, cameraIndex: number): Camera;
  46280. /**
  46281. * @hidden
  46282. * @override
  46283. * Override Camera._updateRigCameras
  46284. */
  46285. _updateRigCameras(): void;
  46286. /**
  46287. * Destroy the camera and release the current resources hold by it.
  46288. */
  46289. dispose(): void;
  46290. /**
  46291. * Gets the current object class name.
  46292. * @return the class name
  46293. */
  46294. getClassName(): string;
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46300. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46301. */
  46302. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46303. /**
  46304. * Gets the name of the behavior.
  46305. */
  46306. get name(): string;
  46307. private _zoomStopsAnimation;
  46308. private _idleRotationSpeed;
  46309. private _idleRotationWaitTime;
  46310. private _idleRotationSpinupTime;
  46311. /**
  46312. * Sets the flag that indicates if user zooming should stop animation.
  46313. */
  46314. set zoomStopsAnimation(flag: boolean);
  46315. /**
  46316. * Gets the flag that indicates if user zooming should stop animation.
  46317. */
  46318. get zoomStopsAnimation(): boolean;
  46319. /**
  46320. * Sets the default speed at which the camera rotates around the model.
  46321. */
  46322. set idleRotationSpeed(speed: number);
  46323. /**
  46324. * Gets the default speed at which the camera rotates around the model.
  46325. */
  46326. get idleRotationSpeed(): number;
  46327. /**
  46328. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46329. */
  46330. set idleRotationWaitTime(time: number);
  46331. /**
  46332. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46333. */
  46334. get idleRotationWaitTime(): number;
  46335. /**
  46336. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46337. */
  46338. set idleRotationSpinupTime(time: number);
  46339. /**
  46340. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46341. */
  46342. get idleRotationSpinupTime(): number;
  46343. /**
  46344. * Gets a value indicating if the camera is currently rotating because of this behavior
  46345. */
  46346. get rotationInProgress(): boolean;
  46347. private _onPrePointerObservableObserver;
  46348. private _onAfterCheckInputsObserver;
  46349. private _attachedCamera;
  46350. private _isPointerDown;
  46351. private _lastFrameTime;
  46352. private _lastInteractionTime;
  46353. private _cameraRotationSpeed;
  46354. /**
  46355. * Initializes the behavior.
  46356. */
  46357. init(): void;
  46358. /**
  46359. * Attaches the behavior to its arc rotate camera.
  46360. * @param camera Defines the camera to attach the behavior to
  46361. */
  46362. attach(camera: ArcRotateCamera): void;
  46363. /**
  46364. * Detaches the behavior from its current arc rotate camera.
  46365. */
  46366. detach(): void;
  46367. /**
  46368. * Returns true if user is scrolling.
  46369. * @return true if user is scrolling.
  46370. */
  46371. private _userIsZooming;
  46372. private _lastFrameRadius;
  46373. private _shouldAnimationStopForInteraction;
  46374. /**
  46375. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46376. */
  46377. private _applyUserInteraction;
  46378. private _userIsMoving;
  46379. }
  46380. }
  46381. declare module BABYLON {
  46382. /**
  46383. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46384. */
  46385. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46386. private ui;
  46387. /**
  46388. * The name of the behavior
  46389. */
  46390. name: string;
  46391. /**
  46392. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46393. */
  46394. distanceAwayFromFace: number;
  46395. /**
  46396. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46397. */
  46398. distanceAwayFromBottomOfFace: number;
  46399. private _faceVectors;
  46400. private _target;
  46401. private _scene;
  46402. private _onRenderObserver;
  46403. private _tmpMatrix;
  46404. private _tmpVector;
  46405. /**
  46406. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46407. * @param ui The transform node that should be attched to the mesh
  46408. */
  46409. constructor(ui: TransformNode);
  46410. /**
  46411. * Initializes the behavior
  46412. */
  46413. init(): void;
  46414. private _closestFace;
  46415. private _zeroVector;
  46416. private _lookAtTmpMatrix;
  46417. private _lookAtToRef;
  46418. /**
  46419. * Attaches the AttachToBoxBehavior to the passed in mesh
  46420. * @param target The mesh that the specified node will be attached to
  46421. */
  46422. attach(target: Mesh): void;
  46423. /**
  46424. * Detaches the behavior from the mesh
  46425. */
  46426. detach(): void;
  46427. }
  46428. }
  46429. declare module BABYLON {
  46430. /**
  46431. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46432. */
  46433. export class FadeInOutBehavior implements Behavior<Mesh> {
  46434. /**
  46435. * Time in milliseconds to delay before fading in (Default: 0)
  46436. */
  46437. delay: number;
  46438. /**
  46439. * Time in milliseconds for the mesh to fade in (Default: 300)
  46440. */
  46441. fadeInTime: number;
  46442. private _millisecondsPerFrame;
  46443. private _hovered;
  46444. private _hoverValue;
  46445. private _ownerNode;
  46446. /**
  46447. * Instatiates the FadeInOutBehavior
  46448. */
  46449. constructor();
  46450. /**
  46451. * The name of the behavior
  46452. */
  46453. get name(): string;
  46454. /**
  46455. * Initializes the behavior
  46456. */
  46457. init(): void;
  46458. /**
  46459. * Attaches the fade behavior on the passed in mesh
  46460. * @param ownerNode The mesh that will be faded in/out once attached
  46461. */
  46462. attach(ownerNode: Mesh): void;
  46463. /**
  46464. * Detaches the behavior from the mesh
  46465. */
  46466. detach(): void;
  46467. /**
  46468. * Triggers the mesh to begin fading in or out
  46469. * @param value if the object should fade in or out (true to fade in)
  46470. */
  46471. fadeIn(value: boolean): void;
  46472. private _update;
  46473. private _setAllVisibility;
  46474. }
  46475. }
  46476. declare module BABYLON {
  46477. /**
  46478. * Class containing a set of static utilities functions for managing Pivots
  46479. * @hidden
  46480. */
  46481. export class PivotTools {
  46482. private static _PivotCached;
  46483. private static _OldPivotPoint;
  46484. private static _PivotTranslation;
  46485. private static _PivotTmpVector;
  46486. private static _PivotPostMultiplyPivotMatrix;
  46487. /** @hidden */
  46488. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46489. /** @hidden */
  46490. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46491. }
  46492. }
  46493. declare module BABYLON {
  46494. /**
  46495. * Class containing static functions to help procedurally build meshes
  46496. */
  46497. export class PlaneBuilder {
  46498. /**
  46499. * Creates a plane mesh
  46500. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46501. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46502. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46504. * * 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
  46505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46506. * @param name defines the name of the mesh
  46507. * @param options defines the options used to create the mesh
  46508. * @param scene defines the hosting scene
  46509. * @returns the plane mesh
  46510. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46511. */
  46512. static CreatePlane(name: string, options: {
  46513. size?: number;
  46514. width?: number;
  46515. height?: number;
  46516. sideOrientation?: number;
  46517. frontUVs?: Vector4;
  46518. backUVs?: Vector4;
  46519. updatable?: boolean;
  46520. sourcePlane?: Plane;
  46521. }, scene?: Nullable<Scene>): Mesh;
  46522. }
  46523. }
  46524. declare module BABYLON {
  46525. /**
  46526. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46527. */
  46528. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46529. private static _AnyMouseID;
  46530. /**
  46531. * Abstract mesh the behavior is set on
  46532. */
  46533. attachedNode: AbstractMesh;
  46534. private _dragPlane;
  46535. private _scene;
  46536. private _pointerObserver;
  46537. private _beforeRenderObserver;
  46538. private static _planeScene;
  46539. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46540. /**
  46541. * 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)
  46542. */
  46543. maxDragAngle: number;
  46544. /**
  46545. * @hidden
  46546. */
  46547. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46548. /**
  46549. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46550. */
  46551. currentDraggingPointerID: number;
  46552. /**
  46553. * The last position where the pointer hit the drag plane in world space
  46554. */
  46555. lastDragPosition: Vector3;
  46556. /**
  46557. * If the behavior is currently in a dragging state
  46558. */
  46559. dragging: boolean;
  46560. /**
  46561. * 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)
  46562. */
  46563. dragDeltaRatio: number;
  46564. /**
  46565. * If the drag plane orientation should be updated during the dragging (Default: true)
  46566. */
  46567. updateDragPlane: boolean;
  46568. private _debugMode;
  46569. private _moving;
  46570. /**
  46571. * Fires each time the attached mesh is dragged with the pointer
  46572. * * delta between last drag position and current drag position in world space
  46573. * * dragDistance along the drag axis
  46574. * * dragPlaneNormal normal of the current drag plane used during the drag
  46575. * * dragPlanePoint in world space where the drag intersects the drag plane
  46576. */
  46577. onDragObservable: Observable<{
  46578. delta: Vector3;
  46579. dragPlanePoint: Vector3;
  46580. dragPlaneNormal: Vector3;
  46581. dragDistance: number;
  46582. pointerId: number;
  46583. }>;
  46584. /**
  46585. * Fires each time a drag begins (eg. mouse down on mesh)
  46586. */
  46587. onDragStartObservable: Observable<{
  46588. dragPlanePoint: Vector3;
  46589. pointerId: number;
  46590. }>;
  46591. /**
  46592. * Fires each time a drag ends (eg. mouse release after drag)
  46593. */
  46594. onDragEndObservable: Observable<{
  46595. dragPlanePoint: Vector3;
  46596. pointerId: number;
  46597. }>;
  46598. /**
  46599. * If the attached mesh should be moved when dragged
  46600. */
  46601. moveAttached: boolean;
  46602. /**
  46603. * If the drag behavior will react to drag events (Default: true)
  46604. */
  46605. enabled: boolean;
  46606. /**
  46607. * If pointer events should start and release the drag (Default: true)
  46608. */
  46609. startAndReleaseDragOnPointerEvents: boolean;
  46610. /**
  46611. * If camera controls should be detached during the drag
  46612. */
  46613. detachCameraControls: boolean;
  46614. /**
  46615. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46616. */
  46617. useObjectOrientationForDragging: boolean;
  46618. private _options;
  46619. /**
  46620. * Gets the options used by the behavior
  46621. */
  46622. get options(): {
  46623. dragAxis?: Vector3;
  46624. dragPlaneNormal?: Vector3;
  46625. };
  46626. /**
  46627. * Sets the options used by the behavior
  46628. */
  46629. set options(options: {
  46630. dragAxis?: Vector3;
  46631. dragPlaneNormal?: Vector3;
  46632. });
  46633. /**
  46634. * Creates a pointer drag behavior that can be attached to a mesh
  46635. * @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)
  46636. */
  46637. constructor(options?: {
  46638. dragAxis?: Vector3;
  46639. dragPlaneNormal?: Vector3;
  46640. });
  46641. /**
  46642. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46643. */
  46644. validateDrag: (targetPosition: Vector3) => boolean;
  46645. /**
  46646. * The name of the behavior
  46647. */
  46648. get name(): string;
  46649. /**
  46650. * Initializes the behavior
  46651. */
  46652. init(): void;
  46653. private _tmpVector;
  46654. private _alternatePickedPoint;
  46655. private _worldDragAxis;
  46656. private _targetPosition;
  46657. private _attachedElement;
  46658. /**
  46659. * Attaches the drag behavior the passed in mesh
  46660. * @param ownerNode The mesh that will be dragged around once attached
  46661. * @param predicate Predicate to use for pick filtering
  46662. */
  46663. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46664. /**
  46665. * Force relase the drag action by code.
  46666. */
  46667. releaseDrag(): void;
  46668. private _startDragRay;
  46669. private _lastPointerRay;
  46670. /**
  46671. * Simulates the start of a pointer drag event on the behavior
  46672. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46673. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46674. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46675. */
  46676. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46677. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46678. private _dragDelta;
  46679. protected _moveDrag(ray: Ray): void;
  46680. private _pickWithRayOnDragPlane;
  46681. private _pointA;
  46682. private _pointC;
  46683. private _localAxis;
  46684. private _lookAt;
  46685. private _updateDragPlanePosition;
  46686. /**
  46687. * Detaches the behavior from the mesh
  46688. */
  46689. detach(): void;
  46690. }
  46691. }
  46692. declare module BABYLON {
  46693. /**
  46694. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46695. */
  46696. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46697. private _dragBehaviorA;
  46698. private _dragBehaviorB;
  46699. private _startDistance;
  46700. private _initialScale;
  46701. private _targetScale;
  46702. private _ownerNode;
  46703. private _sceneRenderObserver;
  46704. /**
  46705. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46706. */
  46707. constructor();
  46708. /**
  46709. * The name of the behavior
  46710. */
  46711. get name(): string;
  46712. /**
  46713. * Initializes the behavior
  46714. */
  46715. init(): void;
  46716. private _getCurrentDistance;
  46717. /**
  46718. * Attaches the scale behavior the passed in mesh
  46719. * @param ownerNode The mesh that will be scaled around once attached
  46720. */
  46721. attach(ownerNode: Mesh): void;
  46722. /**
  46723. * Detaches the behavior from the mesh
  46724. */
  46725. detach(): void;
  46726. }
  46727. }
  46728. declare module BABYLON {
  46729. /**
  46730. * 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
  46731. */
  46732. export class SixDofDragBehavior implements Behavior<Mesh> {
  46733. private static _virtualScene;
  46734. private _ownerNode;
  46735. private _sceneRenderObserver;
  46736. private _scene;
  46737. private _targetPosition;
  46738. private _virtualOriginMesh;
  46739. private _virtualDragMesh;
  46740. private _pointerObserver;
  46741. private _moving;
  46742. private _startingOrientation;
  46743. private _attachedElement;
  46744. /**
  46745. * 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)
  46746. */
  46747. private zDragFactor;
  46748. /**
  46749. * If the object should rotate to face the drag origin
  46750. */
  46751. rotateDraggedObject: boolean;
  46752. /**
  46753. * If the behavior is currently in a dragging state
  46754. */
  46755. dragging: boolean;
  46756. /**
  46757. * 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)
  46758. */
  46759. dragDeltaRatio: number;
  46760. /**
  46761. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46762. */
  46763. currentDraggingPointerID: number;
  46764. /**
  46765. * If camera controls should be detached during the drag
  46766. */
  46767. detachCameraControls: boolean;
  46768. /**
  46769. * Fires each time a drag starts
  46770. */
  46771. onDragStartObservable: Observable<{}>;
  46772. /**
  46773. * Fires each time a drag ends (eg. mouse release after drag)
  46774. */
  46775. onDragEndObservable: Observable<{}>;
  46776. /**
  46777. * 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
  46778. */
  46779. constructor();
  46780. /**
  46781. * The name of the behavior
  46782. */
  46783. get name(): string;
  46784. /**
  46785. * Initializes the behavior
  46786. */
  46787. init(): void;
  46788. /**
  46789. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46790. */
  46791. private get _pointerCamera();
  46792. /**
  46793. * Attaches the scale behavior the passed in mesh
  46794. * @param ownerNode The mesh that will be scaled around once attached
  46795. */
  46796. attach(ownerNode: Mesh): void;
  46797. /**
  46798. * Detaches the behavior from the mesh
  46799. */
  46800. detach(): void;
  46801. }
  46802. }
  46803. declare module BABYLON {
  46804. /**
  46805. * Class used to apply inverse kinematics to bones
  46806. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46807. */
  46808. export class BoneIKController {
  46809. private static _tmpVecs;
  46810. private static _tmpQuat;
  46811. private static _tmpMats;
  46812. /**
  46813. * Gets or sets the target mesh
  46814. */
  46815. targetMesh: AbstractMesh;
  46816. /** Gets or sets the mesh used as pole */
  46817. poleTargetMesh: AbstractMesh;
  46818. /**
  46819. * Gets or sets the bone used as pole
  46820. */
  46821. poleTargetBone: Nullable<Bone>;
  46822. /**
  46823. * Gets or sets the target position
  46824. */
  46825. targetPosition: Vector3;
  46826. /**
  46827. * Gets or sets the pole target position
  46828. */
  46829. poleTargetPosition: Vector3;
  46830. /**
  46831. * Gets or sets the pole target local offset
  46832. */
  46833. poleTargetLocalOffset: Vector3;
  46834. /**
  46835. * Gets or sets the pole angle
  46836. */
  46837. poleAngle: number;
  46838. /**
  46839. * Gets or sets the mesh associated with the controller
  46840. */
  46841. mesh: AbstractMesh;
  46842. /**
  46843. * 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)
  46844. */
  46845. slerpAmount: number;
  46846. private _bone1Quat;
  46847. private _bone1Mat;
  46848. private _bone2Ang;
  46849. private _bone1;
  46850. private _bone2;
  46851. private _bone1Length;
  46852. private _bone2Length;
  46853. private _maxAngle;
  46854. private _maxReach;
  46855. private _rightHandedSystem;
  46856. private _bendAxis;
  46857. private _slerping;
  46858. private _adjustRoll;
  46859. /**
  46860. * Gets or sets maximum allowed angle
  46861. */
  46862. get maxAngle(): number;
  46863. set maxAngle(value: number);
  46864. /**
  46865. * Creates a new BoneIKController
  46866. * @param mesh defines the mesh to control
  46867. * @param bone defines the bone to control
  46868. * @param options defines options to set up the controller
  46869. */
  46870. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46871. targetMesh?: AbstractMesh;
  46872. poleTargetMesh?: AbstractMesh;
  46873. poleTargetBone?: Bone;
  46874. poleTargetLocalOffset?: Vector3;
  46875. poleAngle?: number;
  46876. bendAxis?: Vector3;
  46877. maxAngle?: number;
  46878. slerpAmount?: number;
  46879. });
  46880. private _setMaxAngle;
  46881. /**
  46882. * Force the controller to update the bones
  46883. */
  46884. update(): void;
  46885. }
  46886. }
  46887. declare module BABYLON {
  46888. /**
  46889. * Class used to make a bone look toward a point in space
  46890. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46891. */
  46892. export class BoneLookController {
  46893. private static _tmpVecs;
  46894. private static _tmpQuat;
  46895. private static _tmpMats;
  46896. /**
  46897. * The target Vector3 that the bone will look at
  46898. */
  46899. target: Vector3;
  46900. /**
  46901. * The mesh that the bone is attached to
  46902. */
  46903. mesh: AbstractMesh;
  46904. /**
  46905. * The bone that will be looking to the target
  46906. */
  46907. bone: Bone;
  46908. /**
  46909. * The up axis of the coordinate system that is used when the bone is rotated
  46910. */
  46911. upAxis: Vector3;
  46912. /**
  46913. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46914. */
  46915. upAxisSpace: Space;
  46916. /**
  46917. * Used to make an adjustment to the yaw of the bone
  46918. */
  46919. adjustYaw: number;
  46920. /**
  46921. * Used to make an adjustment to the pitch of the bone
  46922. */
  46923. adjustPitch: number;
  46924. /**
  46925. * Used to make an adjustment to the roll of the bone
  46926. */
  46927. adjustRoll: number;
  46928. /**
  46929. * 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)
  46930. */
  46931. slerpAmount: number;
  46932. private _minYaw;
  46933. private _maxYaw;
  46934. private _minPitch;
  46935. private _maxPitch;
  46936. private _minYawSin;
  46937. private _minYawCos;
  46938. private _maxYawSin;
  46939. private _maxYawCos;
  46940. private _midYawConstraint;
  46941. private _minPitchTan;
  46942. private _maxPitchTan;
  46943. private _boneQuat;
  46944. private _slerping;
  46945. private _transformYawPitch;
  46946. private _transformYawPitchInv;
  46947. private _firstFrameSkipped;
  46948. private _yawRange;
  46949. private _fowardAxis;
  46950. /**
  46951. * Gets or sets the minimum yaw angle that the bone can look to
  46952. */
  46953. get minYaw(): number;
  46954. set minYaw(value: number);
  46955. /**
  46956. * Gets or sets the maximum yaw angle that the bone can look to
  46957. */
  46958. get maxYaw(): number;
  46959. set maxYaw(value: number);
  46960. /**
  46961. * Gets or sets the minimum pitch angle that the bone can look to
  46962. */
  46963. get minPitch(): number;
  46964. set minPitch(value: number);
  46965. /**
  46966. * Gets or sets the maximum pitch angle that the bone can look to
  46967. */
  46968. get maxPitch(): number;
  46969. set maxPitch(value: number);
  46970. /**
  46971. * Create a BoneLookController
  46972. * @param mesh the mesh that the bone belongs to
  46973. * @param bone the bone that will be looking to the target
  46974. * @param target the target Vector3 to look at
  46975. * @param options optional settings:
  46976. * * maxYaw: the maximum angle the bone will yaw to
  46977. * * minYaw: the minimum angle the bone will yaw to
  46978. * * maxPitch: the maximum angle the bone will pitch to
  46979. * * minPitch: the minimum angle the bone will yaw to
  46980. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46981. * * upAxis: the up axis of the coordinate system
  46982. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46983. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46984. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46985. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46986. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46987. * * adjustRoll: used to make an adjustment to the roll of the bone
  46988. **/
  46989. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46990. maxYaw?: number;
  46991. minYaw?: number;
  46992. maxPitch?: number;
  46993. minPitch?: number;
  46994. slerpAmount?: number;
  46995. upAxis?: Vector3;
  46996. upAxisSpace?: Space;
  46997. yawAxis?: Vector3;
  46998. pitchAxis?: Vector3;
  46999. adjustYaw?: number;
  47000. adjustPitch?: number;
  47001. adjustRoll?: number;
  47002. });
  47003. /**
  47004. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47005. */
  47006. update(): void;
  47007. private _getAngleDiff;
  47008. private _getAngleBetween;
  47009. private _isAngleBetween;
  47010. }
  47011. }
  47012. declare module BABYLON {
  47013. /**
  47014. * Manage the gamepad inputs to control an arc rotate camera.
  47015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47016. */
  47017. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47018. /**
  47019. * Defines the camera the input is attached to.
  47020. */
  47021. camera: ArcRotateCamera;
  47022. /**
  47023. * Defines the gamepad the input is gathering event from.
  47024. */
  47025. gamepad: Nullable<Gamepad>;
  47026. /**
  47027. * Defines the gamepad rotation sensiblity.
  47028. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47029. */
  47030. gamepadRotationSensibility: number;
  47031. /**
  47032. * Defines the gamepad move sensiblity.
  47033. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47034. */
  47035. gamepadMoveSensibility: number;
  47036. private _yAxisScale;
  47037. /**
  47038. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47039. */
  47040. get invertYAxis(): boolean;
  47041. set invertYAxis(value: boolean);
  47042. private _onGamepadConnectedObserver;
  47043. private _onGamepadDisconnectedObserver;
  47044. /**
  47045. * Attach the input controls to a specific dom element to get the input from.
  47046. * @param element Defines the element the controls should be listened from
  47047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47048. */
  47049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47050. /**
  47051. * Detach the current controls from the specified dom element.
  47052. * @param element Defines the element to stop listening the inputs from
  47053. */
  47054. detachControl(element: Nullable<HTMLElement>): void;
  47055. /**
  47056. * Update the current camera state depending on the inputs that have been used this frame.
  47057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47058. */
  47059. checkInputs(): void;
  47060. /**
  47061. * Gets the class name of the current intput.
  47062. * @returns the class name
  47063. */
  47064. getClassName(): string;
  47065. /**
  47066. * Get the friendly name associated with the input class.
  47067. * @returns the input friendly name
  47068. */
  47069. getSimpleName(): string;
  47070. }
  47071. }
  47072. declare module BABYLON {
  47073. interface ArcRotateCameraInputsManager {
  47074. /**
  47075. * Add orientation input support to the input manager.
  47076. * @returns the current input manager
  47077. */
  47078. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47079. }
  47080. /**
  47081. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47082. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47083. */
  47084. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47085. /**
  47086. * Defines the camera the input is attached to.
  47087. */
  47088. camera: ArcRotateCamera;
  47089. /**
  47090. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47091. */
  47092. alphaCorrection: number;
  47093. /**
  47094. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47095. */
  47096. gammaCorrection: number;
  47097. private _alpha;
  47098. private _gamma;
  47099. private _dirty;
  47100. private _deviceOrientationHandler;
  47101. /**
  47102. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47103. */
  47104. constructor();
  47105. /**
  47106. * Attach the input controls to a specific dom element to get the input from.
  47107. * @param element Defines the element the controls should be listened from
  47108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47109. */
  47110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47111. /** @hidden */
  47112. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47113. /**
  47114. * Update the current camera state depending on the inputs that have been used this frame.
  47115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47116. */
  47117. checkInputs(): void;
  47118. /**
  47119. * Detach the current controls from the specified dom element.
  47120. * @param element Defines the element to stop listening the inputs from
  47121. */
  47122. detachControl(element: Nullable<HTMLElement>): void;
  47123. /**
  47124. * Gets the class name of the current intput.
  47125. * @returns the class name
  47126. */
  47127. getClassName(): string;
  47128. /**
  47129. * Get the friendly name associated with the input class.
  47130. * @returns the input friendly name
  47131. */
  47132. getSimpleName(): string;
  47133. }
  47134. }
  47135. declare module BABYLON {
  47136. /**
  47137. * Listen to mouse events to control the camera.
  47138. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47139. */
  47140. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47141. /**
  47142. * Defines the camera the input is attached to.
  47143. */
  47144. camera: FlyCamera;
  47145. /**
  47146. * Defines if touch is enabled. (Default is true.)
  47147. */
  47148. touchEnabled: boolean;
  47149. /**
  47150. * Defines the buttons associated with the input to handle camera rotation.
  47151. */
  47152. buttons: number[];
  47153. /**
  47154. * Assign buttons for Yaw control.
  47155. */
  47156. buttonsYaw: number[];
  47157. /**
  47158. * Assign buttons for Pitch control.
  47159. */
  47160. buttonsPitch: number[];
  47161. /**
  47162. * Assign buttons for Roll control.
  47163. */
  47164. buttonsRoll: number[];
  47165. /**
  47166. * Detect if any button is being pressed while mouse is moved.
  47167. * -1 = Mouse locked.
  47168. * 0 = Left button.
  47169. * 1 = Middle Button.
  47170. * 2 = Right Button.
  47171. */
  47172. activeButton: number;
  47173. /**
  47174. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47175. * Higher values reduce its sensitivity.
  47176. */
  47177. angularSensibility: number;
  47178. private _observer;
  47179. private _rollObserver;
  47180. private previousPosition;
  47181. private noPreventDefault;
  47182. private element;
  47183. /**
  47184. * Listen to mouse events to control the camera.
  47185. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47186. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47187. */
  47188. constructor(touchEnabled?: boolean);
  47189. /**
  47190. * Attach the mouse control to the HTML DOM element.
  47191. * @param element Defines the element that listens to the input events.
  47192. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47193. */
  47194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47195. /**
  47196. * Detach the current controls from the specified dom element.
  47197. * @param element Defines the element to stop listening the inputs from
  47198. */
  47199. detachControl(element: Nullable<HTMLElement>): void;
  47200. /**
  47201. * Gets the class name of the current input.
  47202. * @returns the class name.
  47203. */
  47204. getClassName(): string;
  47205. /**
  47206. * Get the friendly name associated with the input class.
  47207. * @returns the input's friendly name.
  47208. */
  47209. getSimpleName(): string;
  47210. private _pointerInput;
  47211. private _onMouseMove;
  47212. /**
  47213. * Rotate camera by mouse offset.
  47214. */
  47215. private rotateCamera;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /**
  47220. * Default Inputs manager for the FlyCamera.
  47221. * It groups all the default supported inputs for ease of use.
  47222. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47223. */
  47224. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47225. /**
  47226. * Instantiates a new FlyCameraInputsManager.
  47227. * @param camera Defines the camera the inputs belong to.
  47228. */
  47229. constructor(camera: FlyCamera);
  47230. /**
  47231. * Add keyboard input support to the input manager.
  47232. * @returns the new FlyCameraKeyboardMoveInput().
  47233. */
  47234. addKeyboard(): FlyCameraInputsManager;
  47235. /**
  47236. * Add mouse input support to the input manager.
  47237. * @param touchEnabled Enable touch screen support.
  47238. * @returns the new FlyCameraMouseInput().
  47239. */
  47240. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47241. }
  47242. }
  47243. declare module BABYLON {
  47244. /**
  47245. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47246. * such as in a 3D Space Shooter or a Flight Simulator.
  47247. */
  47248. export class FlyCamera extends TargetCamera {
  47249. /**
  47250. * Define the collision ellipsoid of the camera.
  47251. * This is helpful for simulating a camera body, like a player's body.
  47252. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47253. */
  47254. ellipsoid: Vector3;
  47255. /**
  47256. * Define an offset for the position of the ellipsoid around the camera.
  47257. * This can be helpful if the camera is attached away from the player's body center,
  47258. * such as at its head.
  47259. */
  47260. ellipsoidOffset: Vector3;
  47261. /**
  47262. * Enable or disable collisions of the camera with the rest of the scene objects.
  47263. */
  47264. checkCollisions: boolean;
  47265. /**
  47266. * Enable or disable gravity on the camera.
  47267. */
  47268. applyGravity: boolean;
  47269. /**
  47270. * Define the current direction the camera is moving to.
  47271. */
  47272. cameraDirection: Vector3;
  47273. /**
  47274. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47275. * This overrides and empties cameraRotation.
  47276. */
  47277. rotationQuaternion: Quaternion;
  47278. /**
  47279. * Track Roll to maintain the wanted Rolling when looking around.
  47280. */
  47281. _trackRoll: number;
  47282. /**
  47283. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47284. */
  47285. rollCorrect: number;
  47286. /**
  47287. * Mimic a banked turn, Rolling the camera when Yawing.
  47288. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47289. */
  47290. bankedTurn: boolean;
  47291. /**
  47292. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47293. */
  47294. bankedTurnLimit: number;
  47295. /**
  47296. * Value of 0 disables the banked Roll.
  47297. * Value of 1 is equal to the Yaw angle in radians.
  47298. */
  47299. bankedTurnMultiplier: number;
  47300. /**
  47301. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47302. */
  47303. inputs: FlyCameraInputsManager;
  47304. /**
  47305. * Gets the input sensibility for mouse input.
  47306. * Higher values reduce sensitivity.
  47307. */
  47308. get angularSensibility(): number;
  47309. /**
  47310. * Sets the input sensibility for a mouse input.
  47311. * Higher values reduce sensitivity.
  47312. */
  47313. set angularSensibility(value: number);
  47314. /**
  47315. * Get the keys for camera movement forward.
  47316. */
  47317. get keysForward(): number[];
  47318. /**
  47319. * Set the keys for camera movement forward.
  47320. */
  47321. set keysForward(value: number[]);
  47322. /**
  47323. * Get the keys for camera movement backward.
  47324. */
  47325. get keysBackward(): number[];
  47326. set keysBackward(value: number[]);
  47327. /**
  47328. * Get the keys for camera movement up.
  47329. */
  47330. get keysUp(): number[];
  47331. /**
  47332. * Set the keys for camera movement up.
  47333. */
  47334. set keysUp(value: number[]);
  47335. /**
  47336. * Get the keys for camera movement down.
  47337. */
  47338. get keysDown(): number[];
  47339. /**
  47340. * Set the keys for camera movement down.
  47341. */
  47342. set keysDown(value: number[]);
  47343. /**
  47344. * Get the keys for camera movement left.
  47345. */
  47346. get keysLeft(): number[];
  47347. /**
  47348. * Set the keys for camera movement left.
  47349. */
  47350. set keysLeft(value: number[]);
  47351. /**
  47352. * Set the keys for camera movement right.
  47353. */
  47354. get keysRight(): number[];
  47355. /**
  47356. * Set the keys for camera movement right.
  47357. */
  47358. set keysRight(value: number[]);
  47359. /**
  47360. * Event raised when the camera collides with a mesh in the scene.
  47361. */
  47362. onCollide: (collidedMesh: AbstractMesh) => void;
  47363. private _collider;
  47364. private _needMoveForGravity;
  47365. private _oldPosition;
  47366. private _diffPosition;
  47367. private _newPosition;
  47368. /** @hidden */
  47369. _localDirection: Vector3;
  47370. /** @hidden */
  47371. _transformedDirection: Vector3;
  47372. /**
  47373. * Instantiates a FlyCamera.
  47374. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47375. * such as in a 3D Space Shooter or a Flight Simulator.
  47376. * @param name Define the name of the camera in the scene.
  47377. * @param position Define the starting position of the camera in the scene.
  47378. * @param scene Define the scene the camera belongs to.
  47379. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47380. */
  47381. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47382. /**
  47383. * Attach a control to the HTML DOM element.
  47384. * @param element Defines the element that listens to the input events.
  47385. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47386. */
  47387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47388. /**
  47389. * Detach a control from the HTML DOM element.
  47390. * The camera will stop reacting to that input.
  47391. * @param element Defines the element that listens to the input events.
  47392. */
  47393. detachControl(element: HTMLElement): void;
  47394. private _collisionMask;
  47395. /**
  47396. * Get the mask that the camera ignores in collision events.
  47397. */
  47398. get collisionMask(): number;
  47399. /**
  47400. * Set the mask that the camera ignores in collision events.
  47401. */
  47402. set collisionMask(mask: number);
  47403. /** @hidden */
  47404. _collideWithWorld(displacement: Vector3): void;
  47405. /** @hidden */
  47406. private _onCollisionPositionChange;
  47407. /** @hidden */
  47408. _checkInputs(): void;
  47409. /** @hidden */
  47410. _decideIfNeedsToMove(): boolean;
  47411. /** @hidden */
  47412. _updatePosition(): void;
  47413. /**
  47414. * Restore the Roll to its target value at the rate specified.
  47415. * @param rate - Higher means slower restoring.
  47416. * @hidden
  47417. */
  47418. restoreRoll(rate: number): void;
  47419. /**
  47420. * Destroy the camera and release the current resources held by it.
  47421. */
  47422. dispose(): void;
  47423. /**
  47424. * Get the current object class name.
  47425. * @returns the class name.
  47426. */
  47427. getClassName(): string;
  47428. }
  47429. }
  47430. declare module BABYLON {
  47431. /**
  47432. * Listen to keyboard events to control the camera.
  47433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47434. */
  47435. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47436. /**
  47437. * Defines the camera the input is attached to.
  47438. */
  47439. camera: FlyCamera;
  47440. /**
  47441. * The list of keyboard keys used to control the forward move of the camera.
  47442. */
  47443. keysForward: number[];
  47444. /**
  47445. * The list of keyboard keys used to control the backward move of the camera.
  47446. */
  47447. keysBackward: number[];
  47448. /**
  47449. * The list of keyboard keys used to control the forward move of the camera.
  47450. */
  47451. keysUp: number[];
  47452. /**
  47453. * The list of keyboard keys used to control the backward move of the camera.
  47454. */
  47455. keysDown: number[];
  47456. /**
  47457. * The list of keyboard keys used to control the right strafe move of the camera.
  47458. */
  47459. keysRight: number[];
  47460. /**
  47461. * The list of keyboard keys used to control the left strafe move of the camera.
  47462. */
  47463. keysLeft: number[];
  47464. private _keys;
  47465. private _onCanvasBlurObserver;
  47466. private _onKeyboardObserver;
  47467. private _engine;
  47468. private _scene;
  47469. /**
  47470. * Attach the input controls to a specific dom element to get the input from.
  47471. * @param element Defines the element the controls should be listened from
  47472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47473. */
  47474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47475. /**
  47476. * Detach the current controls from the specified dom element.
  47477. * @param element Defines the element to stop listening the inputs from
  47478. */
  47479. detachControl(element: Nullable<HTMLElement>): void;
  47480. /**
  47481. * Gets the class name of the current intput.
  47482. * @returns the class name
  47483. */
  47484. getClassName(): string;
  47485. /** @hidden */
  47486. _onLostFocus(e: FocusEvent): void;
  47487. /**
  47488. * Get the friendly name associated with the input class.
  47489. * @returns the input friendly name
  47490. */
  47491. getSimpleName(): string;
  47492. /**
  47493. * Update the current camera state depending on the inputs that have been used this frame.
  47494. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47495. */
  47496. checkInputs(): void;
  47497. }
  47498. }
  47499. declare module BABYLON {
  47500. /**
  47501. * Manage the mouse wheel inputs to control a follow camera.
  47502. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47503. */
  47504. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47505. /**
  47506. * Defines the camera the input is attached to.
  47507. */
  47508. camera: FollowCamera;
  47509. /**
  47510. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47511. */
  47512. axisControlRadius: boolean;
  47513. /**
  47514. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47515. */
  47516. axisControlHeight: boolean;
  47517. /**
  47518. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47519. */
  47520. axisControlRotation: boolean;
  47521. /**
  47522. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47523. * relation to mouseWheel events.
  47524. */
  47525. wheelPrecision: number;
  47526. /**
  47527. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47528. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47529. */
  47530. wheelDeltaPercentage: number;
  47531. private _wheel;
  47532. private _observer;
  47533. /**
  47534. * Attach the input controls to a specific dom element to get the input from.
  47535. * @param element Defines the element the controls should be listened from
  47536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47537. */
  47538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47539. /**
  47540. * Detach the current controls from the specified dom element.
  47541. * @param element Defines the element to stop listening the inputs from
  47542. */
  47543. detachControl(element: Nullable<HTMLElement>): void;
  47544. /**
  47545. * Gets the class name of the current intput.
  47546. * @returns the class name
  47547. */
  47548. getClassName(): string;
  47549. /**
  47550. * Get the friendly name associated with the input class.
  47551. * @returns the input friendly name
  47552. */
  47553. getSimpleName(): string;
  47554. }
  47555. }
  47556. declare module BABYLON {
  47557. /**
  47558. * Manage the pointers inputs to control an follow camera.
  47559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47560. */
  47561. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47562. /**
  47563. * Defines the camera the input is attached to.
  47564. */
  47565. camera: FollowCamera;
  47566. /**
  47567. * Gets the class name of the current input.
  47568. * @returns the class name
  47569. */
  47570. getClassName(): string;
  47571. /**
  47572. * Defines the pointer angular sensibility along the X axis or how fast is
  47573. * the camera rotating.
  47574. * A negative number will reverse the axis direction.
  47575. */
  47576. angularSensibilityX: number;
  47577. /**
  47578. * Defines the pointer angular sensibility along the Y axis or how fast is
  47579. * the camera rotating.
  47580. * A negative number will reverse the axis direction.
  47581. */
  47582. angularSensibilityY: number;
  47583. /**
  47584. * Defines the pointer pinch precision or how fast is the camera zooming.
  47585. * A negative number will reverse the axis direction.
  47586. */
  47587. pinchPrecision: number;
  47588. /**
  47589. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47590. * from 0.
  47591. * It defines the percentage of current camera.radius to use as delta when
  47592. * pinch zoom is used.
  47593. */
  47594. pinchDeltaPercentage: number;
  47595. /**
  47596. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47597. */
  47598. axisXControlRadius: boolean;
  47599. /**
  47600. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47601. */
  47602. axisXControlHeight: boolean;
  47603. /**
  47604. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47605. */
  47606. axisXControlRotation: boolean;
  47607. /**
  47608. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47609. */
  47610. axisYControlRadius: boolean;
  47611. /**
  47612. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47613. */
  47614. axisYControlHeight: boolean;
  47615. /**
  47616. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47617. */
  47618. axisYControlRotation: boolean;
  47619. /**
  47620. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47621. */
  47622. axisPinchControlRadius: boolean;
  47623. /**
  47624. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47625. */
  47626. axisPinchControlHeight: boolean;
  47627. /**
  47628. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47629. */
  47630. axisPinchControlRotation: boolean;
  47631. /**
  47632. * Log error messages if basic misconfiguration has occurred.
  47633. */
  47634. warningEnable: boolean;
  47635. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47636. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47637. private _warningCounter;
  47638. private _warning;
  47639. }
  47640. }
  47641. declare module BABYLON {
  47642. /**
  47643. * Default Inputs manager for the FollowCamera.
  47644. * It groups all the default supported inputs for ease of use.
  47645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47646. */
  47647. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47648. /**
  47649. * Instantiates a new FollowCameraInputsManager.
  47650. * @param camera Defines the camera the inputs belong to
  47651. */
  47652. constructor(camera: FollowCamera);
  47653. /**
  47654. * Add keyboard input support to the input manager.
  47655. * @returns the current input manager
  47656. */
  47657. addKeyboard(): FollowCameraInputsManager;
  47658. /**
  47659. * Add mouse wheel input support to the input manager.
  47660. * @returns the current input manager
  47661. */
  47662. addMouseWheel(): FollowCameraInputsManager;
  47663. /**
  47664. * Add pointers input support to the input manager.
  47665. * @returns the current input manager
  47666. */
  47667. addPointers(): FollowCameraInputsManager;
  47668. /**
  47669. * Add orientation input support to the input manager.
  47670. * @returns the current input manager
  47671. */
  47672. addVRDeviceOrientation(): FollowCameraInputsManager;
  47673. }
  47674. }
  47675. declare module BABYLON {
  47676. /**
  47677. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47678. * an arc rotate version arcFollowCamera are available.
  47679. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47680. */
  47681. export class FollowCamera extends TargetCamera {
  47682. /**
  47683. * Distance the follow camera should follow an object at
  47684. */
  47685. radius: number;
  47686. /**
  47687. * Minimum allowed distance of the camera to the axis of rotation
  47688. * (The camera can not get closer).
  47689. * This can help limiting how the Camera is able to move in the scene.
  47690. */
  47691. lowerRadiusLimit: Nullable<number>;
  47692. /**
  47693. * Maximum allowed distance of the camera to the axis of rotation
  47694. * (The camera can not get further).
  47695. * This can help limiting how the Camera is able to move in the scene.
  47696. */
  47697. upperRadiusLimit: Nullable<number>;
  47698. /**
  47699. * Define a rotation offset between the camera and the object it follows
  47700. */
  47701. rotationOffset: number;
  47702. /**
  47703. * Minimum allowed angle to camera position relative to target object.
  47704. * This can help limiting how the Camera is able to move in the scene.
  47705. */
  47706. lowerRotationOffsetLimit: Nullable<number>;
  47707. /**
  47708. * Maximum allowed angle to camera position relative to target object.
  47709. * This can help limiting how the Camera is able to move in the scene.
  47710. */
  47711. upperRotationOffsetLimit: Nullable<number>;
  47712. /**
  47713. * Define a height offset between the camera and the object it follows.
  47714. * It can help following an object from the top (like a car chaing a plane)
  47715. */
  47716. heightOffset: number;
  47717. /**
  47718. * Minimum allowed height of camera position relative to target object.
  47719. * This can help limiting how the Camera is able to move in the scene.
  47720. */
  47721. lowerHeightOffsetLimit: Nullable<number>;
  47722. /**
  47723. * Maximum allowed height of camera position relative to target object.
  47724. * This can help limiting how the Camera is able to move in the scene.
  47725. */
  47726. upperHeightOffsetLimit: Nullable<number>;
  47727. /**
  47728. * Define how fast the camera can accelerate to follow it s target.
  47729. */
  47730. cameraAcceleration: number;
  47731. /**
  47732. * Define the speed limit of the camera following an object.
  47733. */
  47734. maxCameraSpeed: number;
  47735. /**
  47736. * Define the target of the camera.
  47737. */
  47738. lockedTarget: Nullable<AbstractMesh>;
  47739. /**
  47740. * Defines the input associated with the camera.
  47741. */
  47742. inputs: FollowCameraInputsManager;
  47743. /**
  47744. * Instantiates the follow camera.
  47745. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47746. * @param name Define the name of the camera in the scene
  47747. * @param position Define the position of the camera
  47748. * @param scene Define the scene the camera belong to
  47749. * @param lockedTarget Define the target of the camera
  47750. */
  47751. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47752. private _follow;
  47753. /**
  47754. * Attached controls to the current camera.
  47755. * @param element Defines the element the controls should be listened from
  47756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47757. */
  47758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47759. /**
  47760. * Detach the current controls from the camera.
  47761. * The camera will stop reacting to inputs.
  47762. * @param element Defines the element to stop listening the inputs from
  47763. */
  47764. detachControl(element: HTMLElement): void;
  47765. /** @hidden */
  47766. _checkInputs(): void;
  47767. private _checkLimits;
  47768. /**
  47769. * Gets the camera class name.
  47770. * @returns the class name
  47771. */
  47772. getClassName(): string;
  47773. }
  47774. /**
  47775. * Arc Rotate version of the follow camera.
  47776. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47777. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47778. */
  47779. export class ArcFollowCamera extends TargetCamera {
  47780. /** The longitudinal angle of the camera */
  47781. alpha: number;
  47782. /** The latitudinal angle of the camera */
  47783. beta: number;
  47784. /** The radius of the camera from its target */
  47785. radius: number;
  47786. private _cartesianCoordinates;
  47787. /** Define the camera target (the mesh it should follow) */
  47788. private _meshTarget;
  47789. /**
  47790. * Instantiates a new ArcFollowCamera
  47791. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47792. * @param name Define the name of the camera
  47793. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47794. * @param beta Define the rotation angle of the camera around the elevation axis
  47795. * @param radius Define the radius of the camera from its target point
  47796. * @param target Define the target of the camera
  47797. * @param scene Define the scene the camera belongs to
  47798. */
  47799. constructor(name: string,
  47800. /** The longitudinal angle of the camera */
  47801. alpha: number,
  47802. /** The latitudinal angle of the camera */
  47803. beta: number,
  47804. /** The radius of the camera from its target */
  47805. radius: number,
  47806. /** Define the camera target (the mesh it should follow) */
  47807. target: Nullable<AbstractMesh>, scene: Scene);
  47808. private _follow;
  47809. /** @hidden */
  47810. _checkInputs(): void;
  47811. /**
  47812. * Returns the class name of the object.
  47813. * It is mostly used internally for serialization purposes.
  47814. */
  47815. getClassName(): string;
  47816. }
  47817. }
  47818. declare module BABYLON {
  47819. /**
  47820. * Manage the keyboard inputs to control the movement of a follow camera.
  47821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47822. */
  47823. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47824. /**
  47825. * Defines the camera the input is attached to.
  47826. */
  47827. camera: FollowCamera;
  47828. /**
  47829. * Defines the list of key codes associated with the up action (increase heightOffset)
  47830. */
  47831. keysHeightOffsetIncr: number[];
  47832. /**
  47833. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47834. */
  47835. keysHeightOffsetDecr: number[];
  47836. /**
  47837. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47838. */
  47839. keysHeightOffsetModifierAlt: boolean;
  47840. /**
  47841. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47842. */
  47843. keysHeightOffsetModifierCtrl: boolean;
  47844. /**
  47845. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47846. */
  47847. keysHeightOffsetModifierShift: boolean;
  47848. /**
  47849. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47850. */
  47851. keysRotationOffsetIncr: number[];
  47852. /**
  47853. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47854. */
  47855. keysRotationOffsetDecr: number[];
  47856. /**
  47857. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47858. */
  47859. keysRotationOffsetModifierAlt: boolean;
  47860. /**
  47861. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47862. */
  47863. keysRotationOffsetModifierCtrl: boolean;
  47864. /**
  47865. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47866. */
  47867. keysRotationOffsetModifierShift: boolean;
  47868. /**
  47869. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47870. */
  47871. keysRadiusIncr: number[];
  47872. /**
  47873. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47874. */
  47875. keysRadiusDecr: number[];
  47876. /**
  47877. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47878. */
  47879. keysRadiusModifierAlt: boolean;
  47880. /**
  47881. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47882. */
  47883. keysRadiusModifierCtrl: boolean;
  47884. /**
  47885. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47886. */
  47887. keysRadiusModifierShift: boolean;
  47888. /**
  47889. * Defines the rate of change of heightOffset.
  47890. */
  47891. heightSensibility: number;
  47892. /**
  47893. * Defines the rate of change of rotationOffset.
  47894. */
  47895. rotationSensibility: number;
  47896. /**
  47897. * Defines the rate of change of radius.
  47898. */
  47899. radiusSensibility: number;
  47900. private _keys;
  47901. private _ctrlPressed;
  47902. private _altPressed;
  47903. private _shiftPressed;
  47904. private _onCanvasBlurObserver;
  47905. private _onKeyboardObserver;
  47906. private _engine;
  47907. private _scene;
  47908. /**
  47909. * Attach the input controls to a specific dom element to get the input from.
  47910. * @param element Defines the element the controls should be listened from
  47911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47912. */
  47913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47914. /**
  47915. * Detach the current controls from the specified dom element.
  47916. * @param element Defines the element to stop listening the inputs from
  47917. */
  47918. detachControl(element: Nullable<HTMLElement>): void;
  47919. /**
  47920. * Update the current camera state depending on the inputs that have been used this frame.
  47921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47922. */
  47923. checkInputs(): void;
  47924. /**
  47925. * Gets the class name of the current input.
  47926. * @returns the class name
  47927. */
  47928. getClassName(): string;
  47929. /**
  47930. * Get the friendly name associated with the input class.
  47931. * @returns the input friendly name
  47932. */
  47933. getSimpleName(): string;
  47934. /**
  47935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47936. * allow modification of the heightOffset value.
  47937. */
  47938. private _modifierHeightOffset;
  47939. /**
  47940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47941. * allow modification of the rotationOffset value.
  47942. */
  47943. private _modifierRotationOffset;
  47944. /**
  47945. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47946. * allow modification of the radius value.
  47947. */
  47948. private _modifierRadius;
  47949. }
  47950. }
  47951. declare module BABYLON {
  47952. interface FreeCameraInputsManager {
  47953. /**
  47954. * @hidden
  47955. */
  47956. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47957. /**
  47958. * Add orientation input support to the input manager.
  47959. * @returns the current input manager
  47960. */
  47961. addDeviceOrientation(): FreeCameraInputsManager;
  47962. }
  47963. /**
  47964. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47965. * Screen rotation is taken into account.
  47966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47967. */
  47968. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47969. private _camera;
  47970. private _screenOrientationAngle;
  47971. private _constantTranform;
  47972. private _screenQuaternion;
  47973. private _alpha;
  47974. private _beta;
  47975. private _gamma;
  47976. /**
  47977. * Can be used to detect if a device orientation sensor is available on a device
  47978. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47979. * @returns a promise that will resolve on orientation change
  47980. */
  47981. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47982. /**
  47983. * @hidden
  47984. */
  47985. _onDeviceOrientationChangedObservable: Observable<void>;
  47986. /**
  47987. * Instantiates a new input
  47988. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47989. */
  47990. constructor();
  47991. /**
  47992. * Define the camera controlled by the input.
  47993. */
  47994. get camera(): FreeCamera;
  47995. set camera(camera: FreeCamera);
  47996. /**
  47997. * Attach the input controls to a specific dom element to get the input from.
  47998. * @param element Defines the element the controls should be listened from
  47999. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48000. */
  48001. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48002. private _orientationChanged;
  48003. private _deviceOrientation;
  48004. /**
  48005. * Detach the current controls from the specified dom element.
  48006. * @param element Defines the element to stop listening the inputs from
  48007. */
  48008. detachControl(element: Nullable<HTMLElement>): void;
  48009. /**
  48010. * Update the current camera state depending on the inputs that have been used this frame.
  48011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48012. */
  48013. checkInputs(): void;
  48014. /**
  48015. * Gets the class name of the current intput.
  48016. * @returns the class name
  48017. */
  48018. getClassName(): string;
  48019. /**
  48020. * Get the friendly name associated with the input class.
  48021. * @returns the input friendly name
  48022. */
  48023. getSimpleName(): string;
  48024. }
  48025. }
  48026. declare module BABYLON {
  48027. /**
  48028. * Manage the gamepad inputs to control a free camera.
  48029. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48030. */
  48031. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48032. /**
  48033. * Define the camera the input is attached to.
  48034. */
  48035. camera: FreeCamera;
  48036. /**
  48037. * Define the Gamepad controlling the input
  48038. */
  48039. gamepad: Nullable<Gamepad>;
  48040. /**
  48041. * Defines the gamepad rotation sensiblity.
  48042. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48043. */
  48044. gamepadAngularSensibility: number;
  48045. /**
  48046. * Defines the gamepad move sensiblity.
  48047. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48048. */
  48049. gamepadMoveSensibility: number;
  48050. private _yAxisScale;
  48051. /**
  48052. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48053. */
  48054. get invertYAxis(): boolean;
  48055. set invertYAxis(value: boolean);
  48056. private _onGamepadConnectedObserver;
  48057. private _onGamepadDisconnectedObserver;
  48058. private _cameraTransform;
  48059. private _deltaTransform;
  48060. private _vector3;
  48061. private _vector2;
  48062. /**
  48063. * Attach the input controls to a specific dom element to get the input from.
  48064. * @param element Defines the element the controls should be listened from
  48065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48066. */
  48067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48068. /**
  48069. * Detach the current controls from the specified dom element.
  48070. * @param element Defines the element to stop listening the inputs from
  48071. */
  48072. detachControl(element: Nullable<HTMLElement>): void;
  48073. /**
  48074. * Update the current camera state depending on the inputs that have been used this frame.
  48075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48076. */
  48077. checkInputs(): void;
  48078. /**
  48079. * Gets the class name of the current intput.
  48080. * @returns the class name
  48081. */
  48082. getClassName(): string;
  48083. /**
  48084. * Get the friendly name associated with the input class.
  48085. * @returns the input friendly name
  48086. */
  48087. getSimpleName(): string;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. /**
  48092. * Defines the potential axis of a Joystick
  48093. */
  48094. export enum JoystickAxis {
  48095. /** X axis */
  48096. X = 0,
  48097. /** Y axis */
  48098. Y = 1,
  48099. /** Z axis */
  48100. Z = 2
  48101. }
  48102. /**
  48103. * Represents the different customization options available
  48104. * for VirtualJoystick
  48105. */
  48106. interface VirtualJoystickCustomizations {
  48107. /**
  48108. * Size of the joystick's puck
  48109. */
  48110. puckSize: number;
  48111. /**
  48112. * Size of the joystick's container
  48113. */
  48114. containerSize: number;
  48115. /**
  48116. * Color of the joystick && puck
  48117. */
  48118. color: string;
  48119. /**
  48120. * Image URL for the joystick's puck
  48121. */
  48122. puckImage?: string;
  48123. /**
  48124. * Image URL for the joystick's container
  48125. */
  48126. containerImage?: string;
  48127. /**
  48128. * Defines the unmoving position of the joystick container
  48129. */
  48130. position?: {
  48131. x: number;
  48132. y: number;
  48133. };
  48134. /**
  48135. * Defines whether or not the joystick container is always visible
  48136. */
  48137. alwaysVisible: boolean;
  48138. /**
  48139. * Defines whether or not to limit the movement of the puck to the joystick's container
  48140. */
  48141. limitToContainer: boolean;
  48142. }
  48143. /**
  48144. * Class used to define virtual joystick (used in touch mode)
  48145. */
  48146. export class VirtualJoystick {
  48147. /**
  48148. * Gets or sets a boolean indicating that left and right values must be inverted
  48149. */
  48150. reverseLeftRight: boolean;
  48151. /**
  48152. * Gets or sets a boolean indicating that up and down values must be inverted
  48153. */
  48154. reverseUpDown: boolean;
  48155. /**
  48156. * Gets the offset value for the position (ie. the change of the position value)
  48157. */
  48158. deltaPosition: Vector3;
  48159. /**
  48160. * Gets a boolean indicating if the virtual joystick was pressed
  48161. */
  48162. pressed: boolean;
  48163. /**
  48164. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48165. */
  48166. static Canvas: Nullable<HTMLCanvasElement>;
  48167. /**
  48168. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48169. */
  48170. limitToContainer: boolean;
  48171. private static _globalJoystickIndex;
  48172. private static _alwaysVisibleSticks;
  48173. private static vjCanvasContext;
  48174. private static vjCanvasWidth;
  48175. private static vjCanvasHeight;
  48176. private static halfWidth;
  48177. private static _GetDefaultOptions;
  48178. private _action;
  48179. private _axisTargetedByLeftAndRight;
  48180. private _axisTargetedByUpAndDown;
  48181. private _joystickSensibility;
  48182. private _inversedSensibility;
  48183. private _joystickPointerID;
  48184. private _joystickColor;
  48185. private _joystickPointerPos;
  48186. private _joystickPreviousPointerPos;
  48187. private _joystickPointerStartPos;
  48188. private _deltaJoystickVector;
  48189. private _leftJoystick;
  48190. private _touches;
  48191. private _joystickPosition;
  48192. private _alwaysVisible;
  48193. private _puckImage;
  48194. private _containerImage;
  48195. private _joystickPuckSize;
  48196. private _joystickContainerSize;
  48197. private _clearPuckSize;
  48198. private _clearContainerSize;
  48199. private _clearPuckSizeOffset;
  48200. private _clearContainerSizeOffset;
  48201. private _onPointerDownHandlerRef;
  48202. private _onPointerMoveHandlerRef;
  48203. private _onPointerUpHandlerRef;
  48204. private _onResize;
  48205. /**
  48206. * Creates a new virtual joystick
  48207. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48208. * @param customizations Defines the options we want to customize the VirtualJoystick
  48209. */
  48210. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48211. /**
  48212. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48213. * @param newJoystickSensibility defines the new sensibility
  48214. */
  48215. setJoystickSensibility(newJoystickSensibility: number): void;
  48216. private _onPointerDown;
  48217. private _onPointerMove;
  48218. private _onPointerUp;
  48219. /**
  48220. * Change the color of the virtual joystick
  48221. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48222. */
  48223. setJoystickColor(newColor: string): void;
  48224. /**
  48225. * Size of the joystick's container
  48226. */
  48227. set containerSize(newSize: number);
  48228. get containerSize(): number;
  48229. /**
  48230. * Size of the joystick's puck
  48231. */
  48232. set puckSize(newSize: number);
  48233. get puckSize(): number;
  48234. /**
  48235. * Clears the set position of the joystick
  48236. */
  48237. clearPosition(): void;
  48238. /**
  48239. * Defines whether or not the joystick container is always visible
  48240. */
  48241. set alwaysVisible(value: boolean);
  48242. get alwaysVisible(): boolean;
  48243. /**
  48244. * Sets the constant position of the Joystick container
  48245. * @param x X axis coordinate
  48246. * @param y Y axis coordinate
  48247. */
  48248. setPosition(x: number, y: number): void;
  48249. /**
  48250. * Defines a callback to call when the joystick is touched
  48251. * @param action defines the callback
  48252. */
  48253. setActionOnTouch(action: () => any): void;
  48254. /**
  48255. * Defines which axis you'd like to control for left & right
  48256. * @param axis defines the axis to use
  48257. */
  48258. setAxisForLeftRight(axis: JoystickAxis): void;
  48259. /**
  48260. * Defines which axis you'd like to control for up & down
  48261. * @param axis defines the axis to use
  48262. */
  48263. setAxisForUpDown(axis: JoystickAxis): void;
  48264. /**
  48265. * Clears the canvas from the previous puck / container draw
  48266. */
  48267. private _clearPreviousDraw;
  48268. /**
  48269. * Loads `urlPath` to be used for the container's image
  48270. * @param urlPath defines the urlPath of an image to use
  48271. */
  48272. setContainerImage(urlPath: string): void;
  48273. /**
  48274. * Loads `urlPath` to be used for the puck's image
  48275. * @param urlPath defines the urlPath of an image to use
  48276. */
  48277. setPuckImage(urlPath: string): void;
  48278. /**
  48279. * Draws the Virtual Joystick's container
  48280. */
  48281. private _drawContainer;
  48282. /**
  48283. * Draws the Virtual Joystick's puck
  48284. */
  48285. private _drawPuck;
  48286. private _drawVirtualJoystick;
  48287. /**
  48288. * Release internal HTML canvas
  48289. */
  48290. releaseCanvas(): void;
  48291. }
  48292. }
  48293. declare module BABYLON {
  48294. interface FreeCameraInputsManager {
  48295. /**
  48296. * Add virtual joystick input support to the input manager.
  48297. * @returns the current input manager
  48298. */
  48299. addVirtualJoystick(): FreeCameraInputsManager;
  48300. }
  48301. /**
  48302. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48303. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48304. */
  48305. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48306. /**
  48307. * Defines the camera the input is attached to.
  48308. */
  48309. camera: FreeCamera;
  48310. private _leftjoystick;
  48311. private _rightjoystick;
  48312. /**
  48313. * Gets the left stick of the virtual joystick.
  48314. * @returns The virtual Joystick
  48315. */
  48316. getLeftJoystick(): VirtualJoystick;
  48317. /**
  48318. * Gets the right stick of the virtual joystick.
  48319. * @returns The virtual Joystick
  48320. */
  48321. getRightJoystick(): VirtualJoystick;
  48322. /**
  48323. * Update the current camera state depending on the inputs that have been used this frame.
  48324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48325. */
  48326. checkInputs(): void;
  48327. /**
  48328. * Attach the input controls to a specific dom element to get the input from.
  48329. * @param element Defines the element the controls should be listened from
  48330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48331. */
  48332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48333. /**
  48334. * Detach the current controls from the specified dom element.
  48335. * @param element Defines the element to stop listening the inputs from
  48336. */
  48337. detachControl(element: Nullable<HTMLElement>): void;
  48338. /**
  48339. * Gets the class name of the current intput.
  48340. * @returns the class name
  48341. */
  48342. getClassName(): string;
  48343. /**
  48344. * Get the friendly name associated with the input class.
  48345. * @returns the input friendly name
  48346. */
  48347. getSimpleName(): string;
  48348. }
  48349. }
  48350. declare module BABYLON {
  48351. /**
  48352. * This represents a FPS type of camera controlled by touch.
  48353. * This is like a universal camera minus the Gamepad controls.
  48354. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48355. */
  48356. export class TouchCamera extends FreeCamera {
  48357. /**
  48358. * Defines the touch sensibility for rotation.
  48359. * The higher the faster.
  48360. */
  48361. get touchAngularSensibility(): number;
  48362. set touchAngularSensibility(value: number);
  48363. /**
  48364. * Defines the touch sensibility for move.
  48365. * The higher the faster.
  48366. */
  48367. get touchMoveSensibility(): number;
  48368. set touchMoveSensibility(value: number);
  48369. /**
  48370. * Instantiates a new touch camera.
  48371. * This represents a FPS type of camera controlled by touch.
  48372. * This is like a universal camera minus the Gamepad controls.
  48373. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48374. * @param name Define the name of the camera in the scene
  48375. * @param position Define the start position of the camera in the scene
  48376. * @param scene Define the scene the camera belongs to
  48377. */
  48378. constructor(name: string, position: Vector3, scene: Scene);
  48379. /**
  48380. * Gets the current object class name.
  48381. * @return the class name
  48382. */
  48383. getClassName(): string;
  48384. /** @hidden */
  48385. _setupInputs(): void;
  48386. }
  48387. }
  48388. declare module BABYLON {
  48389. /**
  48390. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48391. * being tilted forward or back and left or right.
  48392. */
  48393. export class DeviceOrientationCamera extends FreeCamera {
  48394. private _initialQuaternion;
  48395. private _quaternionCache;
  48396. private _tmpDragQuaternion;
  48397. private _disablePointerInputWhenUsingDeviceOrientation;
  48398. /**
  48399. * Creates a new device orientation camera
  48400. * @param name The name of the camera
  48401. * @param position The start position camera
  48402. * @param scene The scene the camera belongs to
  48403. */
  48404. constructor(name: string, position: Vector3, scene: Scene);
  48405. /**
  48406. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48407. */
  48408. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48409. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48410. private _dragFactor;
  48411. /**
  48412. * Enabled turning on the y axis when the orientation sensor is active
  48413. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48414. */
  48415. enableHorizontalDragging(dragFactor?: number): void;
  48416. /**
  48417. * Gets the current instance class name ("DeviceOrientationCamera").
  48418. * This helps avoiding instanceof at run time.
  48419. * @returns the class name
  48420. */
  48421. getClassName(): string;
  48422. /**
  48423. * @hidden
  48424. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48425. */
  48426. _checkInputs(): void;
  48427. /**
  48428. * Reset the camera to its default orientation on the specified axis only.
  48429. * @param axis The axis to reset
  48430. */
  48431. resetToCurrentRotation(axis?: Axis): void;
  48432. }
  48433. }
  48434. declare module BABYLON {
  48435. /**
  48436. * Defines supported buttons for XBox360 compatible gamepads
  48437. */
  48438. export enum Xbox360Button {
  48439. /** A */
  48440. A = 0,
  48441. /** B */
  48442. B = 1,
  48443. /** X */
  48444. X = 2,
  48445. /** Y */
  48446. Y = 3,
  48447. /** Left button */
  48448. LB = 4,
  48449. /** Right button */
  48450. RB = 5,
  48451. /** Back */
  48452. Back = 8,
  48453. /** Start */
  48454. Start = 9,
  48455. /** Left stick */
  48456. LeftStick = 10,
  48457. /** Right stick */
  48458. RightStick = 11
  48459. }
  48460. /** Defines values for XBox360 DPad */
  48461. export enum Xbox360Dpad {
  48462. /** Up */
  48463. Up = 12,
  48464. /** Down */
  48465. Down = 13,
  48466. /** Left */
  48467. Left = 14,
  48468. /** Right */
  48469. Right = 15
  48470. }
  48471. /**
  48472. * Defines a XBox360 gamepad
  48473. */
  48474. export class Xbox360Pad extends Gamepad {
  48475. private _leftTrigger;
  48476. private _rightTrigger;
  48477. private _onlefttriggerchanged;
  48478. private _onrighttriggerchanged;
  48479. private _onbuttondown;
  48480. private _onbuttonup;
  48481. private _ondpaddown;
  48482. private _ondpadup;
  48483. /** Observable raised when a button is pressed */
  48484. onButtonDownObservable: Observable<Xbox360Button>;
  48485. /** Observable raised when a button is released */
  48486. onButtonUpObservable: Observable<Xbox360Button>;
  48487. /** Observable raised when a pad is pressed */
  48488. onPadDownObservable: Observable<Xbox360Dpad>;
  48489. /** Observable raised when a pad is released */
  48490. onPadUpObservable: Observable<Xbox360Dpad>;
  48491. private _buttonA;
  48492. private _buttonB;
  48493. private _buttonX;
  48494. private _buttonY;
  48495. private _buttonBack;
  48496. private _buttonStart;
  48497. private _buttonLB;
  48498. private _buttonRB;
  48499. private _buttonLeftStick;
  48500. private _buttonRightStick;
  48501. private _dPadUp;
  48502. private _dPadDown;
  48503. private _dPadLeft;
  48504. private _dPadRight;
  48505. private _isXboxOnePad;
  48506. /**
  48507. * Creates a new XBox360 gamepad object
  48508. * @param id defines the id of this gamepad
  48509. * @param index defines its index
  48510. * @param gamepad defines the internal HTML gamepad object
  48511. * @param xboxOne defines if it is a XBox One gamepad
  48512. */
  48513. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48514. /**
  48515. * Defines the callback to call when left trigger is pressed
  48516. * @param callback defines the callback to use
  48517. */
  48518. onlefttriggerchanged(callback: (value: number) => void): void;
  48519. /**
  48520. * Defines the callback to call when right trigger is pressed
  48521. * @param callback defines the callback to use
  48522. */
  48523. onrighttriggerchanged(callback: (value: number) => void): void;
  48524. /**
  48525. * Gets the left trigger value
  48526. */
  48527. get leftTrigger(): number;
  48528. /**
  48529. * Sets the left trigger value
  48530. */
  48531. set leftTrigger(newValue: number);
  48532. /**
  48533. * Gets the right trigger value
  48534. */
  48535. get rightTrigger(): number;
  48536. /**
  48537. * Sets the right trigger value
  48538. */
  48539. set rightTrigger(newValue: number);
  48540. /**
  48541. * Defines the callback to call when a button is pressed
  48542. * @param callback defines the callback to use
  48543. */
  48544. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48545. /**
  48546. * Defines the callback to call when a button is released
  48547. * @param callback defines the callback to use
  48548. */
  48549. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48550. /**
  48551. * Defines the callback to call when a pad is pressed
  48552. * @param callback defines the callback to use
  48553. */
  48554. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48555. /**
  48556. * Defines the callback to call when a pad is released
  48557. * @param callback defines the callback to use
  48558. */
  48559. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48560. private _setButtonValue;
  48561. private _setDPadValue;
  48562. /**
  48563. * Gets the value of the `A` button
  48564. */
  48565. get buttonA(): number;
  48566. /**
  48567. * Sets the value of the `A` button
  48568. */
  48569. set buttonA(value: number);
  48570. /**
  48571. * Gets the value of the `B` button
  48572. */
  48573. get buttonB(): number;
  48574. /**
  48575. * Sets the value of the `B` button
  48576. */
  48577. set buttonB(value: number);
  48578. /**
  48579. * Gets the value of the `X` button
  48580. */
  48581. get buttonX(): number;
  48582. /**
  48583. * Sets the value of the `X` button
  48584. */
  48585. set buttonX(value: number);
  48586. /**
  48587. * Gets the value of the `Y` button
  48588. */
  48589. get buttonY(): number;
  48590. /**
  48591. * Sets the value of the `Y` button
  48592. */
  48593. set buttonY(value: number);
  48594. /**
  48595. * Gets the value of the `Start` button
  48596. */
  48597. get buttonStart(): number;
  48598. /**
  48599. * Sets the value of the `Start` button
  48600. */
  48601. set buttonStart(value: number);
  48602. /**
  48603. * Gets the value of the `Back` button
  48604. */
  48605. get buttonBack(): number;
  48606. /**
  48607. * Sets the value of the `Back` button
  48608. */
  48609. set buttonBack(value: number);
  48610. /**
  48611. * Gets the value of the `Left` button
  48612. */
  48613. get buttonLB(): number;
  48614. /**
  48615. * Sets the value of the `Left` button
  48616. */
  48617. set buttonLB(value: number);
  48618. /**
  48619. * Gets the value of the `Right` button
  48620. */
  48621. get buttonRB(): number;
  48622. /**
  48623. * Sets the value of the `Right` button
  48624. */
  48625. set buttonRB(value: number);
  48626. /**
  48627. * Gets the value of the Left joystick
  48628. */
  48629. get buttonLeftStick(): number;
  48630. /**
  48631. * Sets the value of the Left joystick
  48632. */
  48633. set buttonLeftStick(value: number);
  48634. /**
  48635. * Gets the value of the Right joystick
  48636. */
  48637. get buttonRightStick(): number;
  48638. /**
  48639. * Sets the value of the Right joystick
  48640. */
  48641. set buttonRightStick(value: number);
  48642. /**
  48643. * Gets the value of D-pad up
  48644. */
  48645. get dPadUp(): number;
  48646. /**
  48647. * Sets the value of D-pad up
  48648. */
  48649. set dPadUp(value: number);
  48650. /**
  48651. * Gets the value of D-pad down
  48652. */
  48653. get dPadDown(): number;
  48654. /**
  48655. * Sets the value of D-pad down
  48656. */
  48657. set dPadDown(value: number);
  48658. /**
  48659. * Gets the value of D-pad left
  48660. */
  48661. get dPadLeft(): number;
  48662. /**
  48663. * Sets the value of D-pad left
  48664. */
  48665. set dPadLeft(value: number);
  48666. /**
  48667. * Gets the value of D-pad right
  48668. */
  48669. get dPadRight(): number;
  48670. /**
  48671. * Sets the value of D-pad right
  48672. */
  48673. set dPadRight(value: number);
  48674. /**
  48675. * Force the gamepad to synchronize with device values
  48676. */
  48677. update(): void;
  48678. /**
  48679. * Disposes the gamepad
  48680. */
  48681. dispose(): void;
  48682. }
  48683. }
  48684. declare module BABYLON {
  48685. /**
  48686. * Defines supported buttons for DualShock compatible gamepads
  48687. */
  48688. export enum DualShockButton {
  48689. /** Cross */
  48690. Cross = 0,
  48691. /** Circle */
  48692. Circle = 1,
  48693. /** Square */
  48694. Square = 2,
  48695. /** Triangle */
  48696. Triangle = 3,
  48697. /** L1 */
  48698. L1 = 4,
  48699. /** R1 */
  48700. R1 = 5,
  48701. /** Share */
  48702. Share = 8,
  48703. /** Options */
  48704. Options = 9,
  48705. /** Left stick */
  48706. LeftStick = 10,
  48707. /** Right stick */
  48708. RightStick = 11
  48709. }
  48710. /** Defines values for DualShock DPad */
  48711. export enum DualShockDpad {
  48712. /** Up */
  48713. Up = 12,
  48714. /** Down */
  48715. Down = 13,
  48716. /** Left */
  48717. Left = 14,
  48718. /** Right */
  48719. Right = 15
  48720. }
  48721. /**
  48722. * Defines a DualShock gamepad
  48723. */
  48724. export class DualShockPad extends Gamepad {
  48725. private _leftTrigger;
  48726. private _rightTrigger;
  48727. private _onlefttriggerchanged;
  48728. private _onrighttriggerchanged;
  48729. private _onbuttondown;
  48730. private _onbuttonup;
  48731. private _ondpaddown;
  48732. private _ondpadup;
  48733. /** Observable raised when a button is pressed */
  48734. onButtonDownObservable: Observable<DualShockButton>;
  48735. /** Observable raised when a button is released */
  48736. onButtonUpObservable: Observable<DualShockButton>;
  48737. /** Observable raised when a pad is pressed */
  48738. onPadDownObservable: Observable<DualShockDpad>;
  48739. /** Observable raised when a pad is released */
  48740. onPadUpObservable: Observable<DualShockDpad>;
  48741. private _buttonCross;
  48742. private _buttonCircle;
  48743. private _buttonSquare;
  48744. private _buttonTriangle;
  48745. private _buttonShare;
  48746. private _buttonOptions;
  48747. private _buttonL1;
  48748. private _buttonR1;
  48749. private _buttonLeftStick;
  48750. private _buttonRightStick;
  48751. private _dPadUp;
  48752. private _dPadDown;
  48753. private _dPadLeft;
  48754. private _dPadRight;
  48755. /**
  48756. * Creates a new DualShock gamepad object
  48757. * @param id defines the id of this gamepad
  48758. * @param index defines its index
  48759. * @param gamepad defines the internal HTML gamepad object
  48760. */
  48761. constructor(id: string, index: number, gamepad: any);
  48762. /**
  48763. * Defines the callback to call when left trigger is pressed
  48764. * @param callback defines the callback to use
  48765. */
  48766. onlefttriggerchanged(callback: (value: number) => void): void;
  48767. /**
  48768. * Defines the callback to call when right trigger is pressed
  48769. * @param callback defines the callback to use
  48770. */
  48771. onrighttriggerchanged(callback: (value: number) => void): void;
  48772. /**
  48773. * Gets the left trigger value
  48774. */
  48775. get leftTrigger(): number;
  48776. /**
  48777. * Sets the left trigger value
  48778. */
  48779. set leftTrigger(newValue: number);
  48780. /**
  48781. * Gets the right trigger value
  48782. */
  48783. get rightTrigger(): number;
  48784. /**
  48785. * Sets the right trigger value
  48786. */
  48787. set rightTrigger(newValue: number);
  48788. /**
  48789. * Defines the callback to call when a button is pressed
  48790. * @param callback defines the callback to use
  48791. */
  48792. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48793. /**
  48794. * Defines the callback to call when a button is released
  48795. * @param callback defines the callback to use
  48796. */
  48797. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48798. /**
  48799. * Defines the callback to call when a pad is pressed
  48800. * @param callback defines the callback to use
  48801. */
  48802. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48803. /**
  48804. * Defines the callback to call when a pad is released
  48805. * @param callback defines the callback to use
  48806. */
  48807. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48808. private _setButtonValue;
  48809. private _setDPadValue;
  48810. /**
  48811. * Gets the value of the `Cross` button
  48812. */
  48813. get buttonCross(): number;
  48814. /**
  48815. * Sets the value of the `Cross` button
  48816. */
  48817. set buttonCross(value: number);
  48818. /**
  48819. * Gets the value of the `Circle` button
  48820. */
  48821. get buttonCircle(): number;
  48822. /**
  48823. * Sets the value of the `Circle` button
  48824. */
  48825. set buttonCircle(value: number);
  48826. /**
  48827. * Gets the value of the `Square` button
  48828. */
  48829. get buttonSquare(): number;
  48830. /**
  48831. * Sets the value of the `Square` button
  48832. */
  48833. set buttonSquare(value: number);
  48834. /**
  48835. * Gets the value of the `Triangle` button
  48836. */
  48837. get buttonTriangle(): number;
  48838. /**
  48839. * Sets the value of the `Triangle` button
  48840. */
  48841. set buttonTriangle(value: number);
  48842. /**
  48843. * Gets the value of the `Options` button
  48844. */
  48845. get buttonOptions(): number;
  48846. /**
  48847. * Sets the value of the `Options` button
  48848. */
  48849. set buttonOptions(value: number);
  48850. /**
  48851. * Gets the value of the `Share` button
  48852. */
  48853. get buttonShare(): number;
  48854. /**
  48855. * Sets the value of the `Share` button
  48856. */
  48857. set buttonShare(value: number);
  48858. /**
  48859. * Gets the value of the `L1` button
  48860. */
  48861. get buttonL1(): number;
  48862. /**
  48863. * Sets the value of the `L1` button
  48864. */
  48865. set buttonL1(value: number);
  48866. /**
  48867. * Gets the value of the `R1` button
  48868. */
  48869. get buttonR1(): number;
  48870. /**
  48871. * Sets the value of the `R1` button
  48872. */
  48873. set buttonR1(value: number);
  48874. /**
  48875. * Gets the value of the Left joystick
  48876. */
  48877. get buttonLeftStick(): number;
  48878. /**
  48879. * Sets the value of the Left joystick
  48880. */
  48881. set buttonLeftStick(value: number);
  48882. /**
  48883. * Gets the value of the Right joystick
  48884. */
  48885. get buttonRightStick(): number;
  48886. /**
  48887. * Sets the value of the Right joystick
  48888. */
  48889. set buttonRightStick(value: number);
  48890. /**
  48891. * Gets the value of D-pad up
  48892. */
  48893. get dPadUp(): number;
  48894. /**
  48895. * Sets the value of D-pad up
  48896. */
  48897. set dPadUp(value: number);
  48898. /**
  48899. * Gets the value of D-pad down
  48900. */
  48901. get dPadDown(): number;
  48902. /**
  48903. * Sets the value of D-pad down
  48904. */
  48905. set dPadDown(value: number);
  48906. /**
  48907. * Gets the value of D-pad left
  48908. */
  48909. get dPadLeft(): number;
  48910. /**
  48911. * Sets the value of D-pad left
  48912. */
  48913. set dPadLeft(value: number);
  48914. /**
  48915. * Gets the value of D-pad right
  48916. */
  48917. get dPadRight(): number;
  48918. /**
  48919. * Sets the value of D-pad right
  48920. */
  48921. set dPadRight(value: number);
  48922. /**
  48923. * Force the gamepad to synchronize with device values
  48924. */
  48925. update(): void;
  48926. /**
  48927. * Disposes the gamepad
  48928. */
  48929. dispose(): void;
  48930. }
  48931. }
  48932. declare module BABYLON {
  48933. /**
  48934. * Manager for handling gamepads
  48935. */
  48936. export class GamepadManager {
  48937. private _scene?;
  48938. private _babylonGamepads;
  48939. private _oneGamepadConnected;
  48940. /** @hidden */
  48941. _isMonitoring: boolean;
  48942. private _gamepadEventSupported;
  48943. private _gamepadSupport?;
  48944. /**
  48945. * observable to be triggered when the gamepad controller has been connected
  48946. */
  48947. onGamepadConnectedObservable: Observable<Gamepad>;
  48948. /**
  48949. * observable to be triggered when the gamepad controller has been disconnected
  48950. */
  48951. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48952. private _onGamepadConnectedEvent;
  48953. private _onGamepadDisconnectedEvent;
  48954. /**
  48955. * Initializes the gamepad manager
  48956. * @param _scene BabylonJS scene
  48957. */
  48958. constructor(_scene?: Scene | undefined);
  48959. /**
  48960. * The gamepads in the game pad manager
  48961. */
  48962. get gamepads(): Gamepad[];
  48963. /**
  48964. * Get the gamepad controllers based on type
  48965. * @param type The type of gamepad controller
  48966. * @returns Nullable gamepad
  48967. */
  48968. getGamepadByType(type?: number): Nullable<Gamepad>;
  48969. /**
  48970. * Disposes the gamepad manager
  48971. */
  48972. dispose(): void;
  48973. private _addNewGamepad;
  48974. private _startMonitoringGamepads;
  48975. private _stopMonitoringGamepads;
  48976. /** @hidden */
  48977. _checkGamepadsStatus(): void;
  48978. private _updateGamepadObjects;
  48979. }
  48980. }
  48981. declare module BABYLON {
  48982. interface Scene {
  48983. /** @hidden */
  48984. _gamepadManager: Nullable<GamepadManager>;
  48985. /**
  48986. * Gets the gamepad manager associated with the scene
  48987. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48988. */
  48989. gamepadManager: GamepadManager;
  48990. }
  48991. /**
  48992. * Interface representing a free camera inputs manager
  48993. */
  48994. interface FreeCameraInputsManager {
  48995. /**
  48996. * Adds gamepad input support to the FreeCameraInputsManager.
  48997. * @returns the FreeCameraInputsManager
  48998. */
  48999. addGamepad(): FreeCameraInputsManager;
  49000. }
  49001. /**
  49002. * Interface representing an arc rotate camera inputs manager
  49003. */
  49004. interface ArcRotateCameraInputsManager {
  49005. /**
  49006. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49007. * @returns the camera inputs manager
  49008. */
  49009. addGamepad(): ArcRotateCameraInputsManager;
  49010. }
  49011. /**
  49012. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49013. */
  49014. export class GamepadSystemSceneComponent implements ISceneComponent {
  49015. /**
  49016. * The component name helpfull to identify the component in the list of scene components.
  49017. */
  49018. readonly name: string;
  49019. /**
  49020. * The scene the component belongs to.
  49021. */
  49022. scene: Scene;
  49023. /**
  49024. * Creates a new instance of the component for the given scene
  49025. * @param scene Defines the scene to register the component in
  49026. */
  49027. constructor(scene: Scene);
  49028. /**
  49029. * Registers the component in a given scene
  49030. */
  49031. register(): void;
  49032. /**
  49033. * Rebuilds the elements related to this component in case of
  49034. * context lost for instance.
  49035. */
  49036. rebuild(): void;
  49037. /**
  49038. * Disposes the component and the associated ressources
  49039. */
  49040. dispose(): void;
  49041. private _beforeCameraUpdate;
  49042. }
  49043. }
  49044. declare module BABYLON {
  49045. /**
  49046. * 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,
  49047. * which still works and will still be found in many Playgrounds.
  49048. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49049. */
  49050. export class UniversalCamera extends TouchCamera {
  49051. /**
  49052. * Defines the gamepad rotation sensiblity.
  49053. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49054. */
  49055. get gamepadAngularSensibility(): number;
  49056. set gamepadAngularSensibility(value: number);
  49057. /**
  49058. * Defines the gamepad move sensiblity.
  49059. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49060. */
  49061. get gamepadMoveSensibility(): number;
  49062. set gamepadMoveSensibility(value: number);
  49063. /**
  49064. * 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,
  49065. * which still works and will still be found in many Playgrounds.
  49066. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49067. * @param name Define the name of the camera in the scene
  49068. * @param position Define the start position of the camera in the scene
  49069. * @param scene Define the scene the camera belongs to
  49070. */
  49071. constructor(name: string, position: Vector3, scene: Scene);
  49072. /**
  49073. * Gets the current object class name.
  49074. * @return the class name
  49075. */
  49076. getClassName(): string;
  49077. }
  49078. }
  49079. declare module BABYLON {
  49080. /**
  49081. * This represents a FPS type of camera. This is only here for back compat purpose.
  49082. * Please use the UniversalCamera instead as both are identical.
  49083. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49084. */
  49085. export class GamepadCamera extends UniversalCamera {
  49086. /**
  49087. * Instantiates a new Gamepad Camera
  49088. * This represents a FPS type of camera. This is only here for back compat purpose.
  49089. * Please use the UniversalCamera instead as both are identical.
  49090. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49091. * @param name Define the name of the camera in the scene
  49092. * @param position Define the start position of the camera in the scene
  49093. * @param scene Define the scene the camera belongs to
  49094. */
  49095. constructor(name: string, position: Vector3, scene: Scene);
  49096. /**
  49097. * Gets the current object class name.
  49098. * @return the class name
  49099. */
  49100. getClassName(): string;
  49101. }
  49102. }
  49103. declare module BABYLON {
  49104. /** @hidden */
  49105. export var passPixelShader: {
  49106. name: string;
  49107. shader: string;
  49108. };
  49109. }
  49110. declare module BABYLON {
  49111. /** @hidden */
  49112. export var passCubePixelShader: {
  49113. name: string;
  49114. shader: string;
  49115. };
  49116. }
  49117. declare module BABYLON {
  49118. /**
  49119. * PassPostProcess which produces an output the same as it's input
  49120. */
  49121. export class PassPostProcess extends PostProcess {
  49122. /**
  49123. * Gets a string identifying the name of the class
  49124. * @returns "PassPostProcess" string
  49125. */
  49126. getClassName(): string;
  49127. /**
  49128. * Creates the PassPostProcess
  49129. * @param name The name of the effect.
  49130. * @param options The required width/height ratio to downsize to before computing the render pass.
  49131. * @param camera The camera to apply the render pass to.
  49132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49133. * @param engine The engine which the post process will be applied. (default: current engine)
  49134. * @param reusable If the post process can be reused on the same frame. (default: false)
  49135. * @param textureType The type of texture to be used when performing the post processing.
  49136. * @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)
  49137. */
  49138. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49139. /** @hidden */
  49140. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49141. }
  49142. /**
  49143. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49144. */
  49145. export class PassCubePostProcess extends PostProcess {
  49146. private _face;
  49147. /**
  49148. * Gets or sets the cube face to display.
  49149. * * 0 is +X
  49150. * * 1 is -X
  49151. * * 2 is +Y
  49152. * * 3 is -Y
  49153. * * 4 is +Z
  49154. * * 5 is -Z
  49155. */
  49156. get face(): number;
  49157. set face(value: number);
  49158. /**
  49159. * Gets a string identifying the name of the class
  49160. * @returns "PassCubePostProcess" string
  49161. */
  49162. getClassName(): string;
  49163. /**
  49164. * Creates the PassCubePostProcess
  49165. * @param name The name of the effect.
  49166. * @param options The required width/height ratio to downsize to before computing the render pass.
  49167. * @param camera The camera to apply the render pass to.
  49168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49169. * @param engine The engine which the post process will be applied. (default: current engine)
  49170. * @param reusable If the post process can be reused on the same frame. (default: false)
  49171. * @param textureType The type of texture to be used when performing the post processing.
  49172. * @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)
  49173. */
  49174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49175. /** @hidden */
  49176. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49177. }
  49178. }
  49179. declare module BABYLON {
  49180. /** @hidden */
  49181. export var anaglyphPixelShader: {
  49182. name: string;
  49183. shader: string;
  49184. };
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Postprocess used to generate anaglyphic rendering
  49189. */
  49190. export class AnaglyphPostProcess extends PostProcess {
  49191. private _passedProcess;
  49192. /**
  49193. * Gets a string identifying the name of the class
  49194. * @returns "AnaglyphPostProcess" string
  49195. */
  49196. getClassName(): string;
  49197. /**
  49198. * Creates a new AnaglyphPostProcess
  49199. * @param name defines postprocess name
  49200. * @param options defines creation options or target ratio scale
  49201. * @param rigCameras defines cameras using this postprocess
  49202. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49203. * @param engine defines hosting engine
  49204. * @param reusable defines if the postprocess will be reused multiple times per frame
  49205. */
  49206. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49212. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49213. */
  49214. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49215. /**
  49216. * Creates a new AnaglyphArcRotateCamera
  49217. * @param name defines camera name
  49218. * @param alpha defines alpha angle (in radians)
  49219. * @param beta defines beta angle (in radians)
  49220. * @param radius defines radius
  49221. * @param target defines camera target
  49222. * @param interaxialDistance defines distance between each color axis
  49223. * @param scene defines the hosting scene
  49224. */
  49225. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49226. /**
  49227. * Gets camera class name
  49228. * @returns AnaglyphArcRotateCamera
  49229. */
  49230. getClassName(): string;
  49231. }
  49232. }
  49233. declare module BABYLON {
  49234. /**
  49235. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49236. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49237. */
  49238. export class AnaglyphFreeCamera extends FreeCamera {
  49239. /**
  49240. * Creates a new AnaglyphFreeCamera
  49241. * @param name defines camera name
  49242. * @param position defines initial position
  49243. * @param interaxialDistance defines distance between each color axis
  49244. * @param scene defines the hosting scene
  49245. */
  49246. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49247. /**
  49248. * Gets camera class name
  49249. * @returns AnaglyphFreeCamera
  49250. */
  49251. getClassName(): string;
  49252. }
  49253. }
  49254. declare module BABYLON {
  49255. /**
  49256. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49257. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49258. */
  49259. export class AnaglyphGamepadCamera extends GamepadCamera {
  49260. /**
  49261. * Creates a new AnaglyphGamepadCamera
  49262. * @param name defines camera name
  49263. * @param position defines initial position
  49264. * @param interaxialDistance defines distance between each color axis
  49265. * @param scene defines the hosting scene
  49266. */
  49267. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49268. /**
  49269. * Gets camera class name
  49270. * @returns AnaglyphGamepadCamera
  49271. */
  49272. getClassName(): string;
  49273. }
  49274. }
  49275. declare module BABYLON {
  49276. /**
  49277. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49278. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49279. */
  49280. export class AnaglyphUniversalCamera extends UniversalCamera {
  49281. /**
  49282. * Creates a new AnaglyphUniversalCamera
  49283. * @param name defines camera name
  49284. * @param position defines initial position
  49285. * @param interaxialDistance defines distance between each color axis
  49286. * @param scene defines the hosting scene
  49287. */
  49288. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49289. /**
  49290. * Gets camera class name
  49291. * @returns AnaglyphUniversalCamera
  49292. */
  49293. getClassName(): string;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49299. * @see https://doc.babylonjs.com/features/cameras
  49300. */
  49301. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49302. /**
  49303. * Creates a new StereoscopicArcRotateCamera
  49304. * @param name defines camera name
  49305. * @param alpha defines alpha angle (in radians)
  49306. * @param beta defines beta angle (in radians)
  49307. * @param radius defines radius
  49308. * @param target defines camera target
  49309. * @param interaxialDistance defines distance between each color axis
  49310. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49311. * @param scene defines the hosting scene
  49312. */
  49313. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49314. /**
  49315. * Gets camera class name
  49316. * @returns StereoscopicArcRotateCamera
  49317. */
  49318. getClassName(): string;
  49319. }
  49320. }
  49321. declare module BABYLON {
  49322. /**
  49323. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49324. * @see https://doc.babylonjs.com/features/cameras
  49325. */
  49326. export class StereoscopicFreeCamera extends FreeCamera {
  49327. /**
  49328. * Creates a new StereoscopicFreeCamera
  49329. * @param name defines camera name
  49330. * @param position defines initial position
  49331. * @param interaxialDistance defines distance between each color axis
  49332. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49333. * @param scene defines the hosting scene
  49334. */
  49335. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49336. /**
  49337. * Gets camera class name
  49338. * @returns StereoscopicFreeCamera
  49339. */
  49340. getClassName(): string;
  49341. }
  49342. }
  49343. declare module BABYLON {
  49344. /**
  49345. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49346. * @see https://doc.babylonjs.com/features/cameras
  49347. */
  49348. export class StereoscopicGamepadCamera extends GamepadCamera {
  49349. /**
  49350. * Creates a new StereoscopicGamepadCamera
  49351. * @param name defines camera name
  49352. * @param position defines initial position
  49353. * @param interaxialDistance defines distance between each color axis
  49354. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49355. * @param scene defines the hosting scene
  49356. */
  49357. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49358. /**
  49359. * Gets camera class name
  49360. * @returns StereoscopicGamepadCamera
  49361. */
  49362. getClassName(): string;
  49363. }
  49364. }
  49365. declare module BABYLON {
  49366. /**
  49367. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49368. * @see https://doc.babylonjs.com/features/cameras
  49369. */
  49370. export class StereoscopicUniversalCamera extends UniversalCamera {
  49371. /**
  49372. * Creates a new StereoscopicUniversalCamera
  49373. * @param name defines camera name
  49374. * @param position defines initial position
  49375. * @param interaxialDistance defines distance between each color axis
  49376. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49377. * @param scene defines the hosting scene
  49378. */
  49379. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49380. /**
  49381. * Gets camera class name
  49382. * @returns StereoscopicUniversalCamera
  49383. */
  49384. getClassName(): string;
  49385. }
  49386. }
  49387. declare module BABYLON {
  49388. /**
  49389. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49390. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49391. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49392. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49393. */
  49394. export class VirtualJoysticksCamera extends FreeCamera {
  49395. /**
  49396. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49397. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49398. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49399. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49400. * @param name Define the name of the camera in the scene
  49401. * @param position Define the start position of the camera in the scene
  49402. * @param scene Define the scene the camera belongs to
  49403. */
  49404. constructor(name: string, position: Vector3, scene: Scene);
  49405. /**
  49406. * Gets the current object class name.
  49407. * @return the class name
  49408. */
  49409. getClassName(): string;
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * This represents all the required metrics to create a VR camera.
  49415. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49416. */
  49417. export class VRCameraMetrics {
  49418. /**
  49419. * Define the horizontal resolution off the screen.
  49420. */
  49421. hResolution: number;
  49422. /**
  49423. * Define the vertical resolution off the screen.
  49424. */
  49425. vResolution: number;
  49426. /**
  49427. * Define the horizontal screen size.
  49428. */
  49429. hScreenSize: number;
  49430. /**
  49431. * Define the vertical screen size.
  49432. */
  49433. vScreenSize: number;
  49434. /**
  49435. * Define the vertical screen center position.
  49436. */
  49437. vScreenCenter: number;
  49438. /**
  49439. * Define the distance of the eyes to the screen.
  49440. */
  49441. eyeToScreenDistance: number;
  49442. /**
  49443. * Define the distance between both lenses
  49444. */
  49445. lensSeparationDistance: number;
  49446. /**
  49447. * Define the distance between both viewer's eyes.
  49448. */
  49449. interpupillaryDistance: number;
  49450. /**
  49451. * Define the distortion factor of the VR postprocess.
  49452. * Please, touch with care.
  49453. */
  49454. distortionK: number[];
  49455. /**
  49456. * Define the chromatic aberration correction factors for the VR post process.
  49457. */
  49458. chromaAbCorrection: number[];
  49459. /**
  49460. * Define the scale factor of the post process.
  49461. * The smaller the better but the slower.
  49462. */
  49463. postProcessScaleFactor: number;
  49464. /**
  49465. * Define an offset for the lens center.
  49466. */
  49467. lensCenterOffset: number;
  49468. /**
  49469. * Define if the current vr camera should compensate the distortion of the lense or not.
  49470. */
  49471. compensateDistortion: boolean;
  49472. /**
  49473. * Defines if multiview should be enabled when rendering (Default: false)
  49474. */
  49475. multiviewEnabled: boolean;
  49476. /**
  49477. * Gets the rendering aspect ratio based on the provided resolutions.
  49478. */
  49479. get aspectRatio(): number;
  49480. /**
  49481. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49482. */
  49483. get aspectRatioFov(): number;
  49484. /**
  49485. * @hidden
  49486. */
  49487. get leftHMatrix(): Matrix;
  49488. /**
  49489. * @hidden
  49490. */
  49491. get rightHMatrix(): Matrix;
  49492. /**
  49493. * @hidden
  49494. */
  49495. get leftPreViewMatrix(): Matrix;
  49496. /**
  49497. * @hidden
  49498. */
  49499. get rightPreViewMatrix(): Matrix;
  49500. /**
  49501. * Get the default VRMetrics based on the most generic setup.
  49502. * @returns the default vr metrics
  49503. */
  49504. static GetDefault(): VRCameraMetrics;
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /** @hidden */
  49509. export var vrDistortionCorrectionPixelShader: {
  49510. name: string;
  49511. shader: string;
  49512. };
  49513. }
  49514. declare module BABYLON {
  49515. /**
  49516. * VRDistortionCorrectionPostProcess used for mobile VR
  49517. */
  49518. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49519. private _isRightEye;
  49520. private _distortionFactors;
  49521. private _postProcessScaleFactor;
  49522. private _lensCenterOffset;
  49523. private _scaleIn;
  49524. private _scaleFactor;
  49525. private _lensCenter;
  49526. /**
  49527. * Gets a string identifying the name of the class
  49528. * @returns "VRDistortionCorrectionPostProcess" string
  49529. */
  49530. getClassName(): string;
  49531. /**
  49532. * Initializes the VRDistortionCorrectionPostProcess
  49533. * @param name The name of the effect.
  49534. * @param camera The camera to apply the render pass to.
  49535. * @param isRightEye If this is for the right eye distortion
  49536. * @param vrMetrics All the required metrics for the VR camera
  49537. */
  49538. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49539. }
  49540. }
  49541. declare module BABYLON {
  49542. /**
  49543. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49544. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49545. */
  49546. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49547. /**
  49548. * Creates a new VRDeviceOrientationArcRotateCamera
  49549. * @param name defines camera name
  49550. * @param alpha defines the camera rotation along the logitudinal axis
  49551. * @param beta defines the camera rotation along the latitudinal axis
  49552. * @param radius defines the camera distance from its target
  49553. * @param target defines the camera target
  49554. * @param scene defines the scene the camera belongs to
  49555. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49556. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49557. */
  49558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49559. /**
  49560. * Gets camera class name
  49561. * @returns VRDeviceOrientationArcRotateCamera
  49562. */
  49563. getClassName(): string;
  49564. }
  49565. }
  49566. declare module BABYLON {
  49567. /**
  49568. * Camera used to simulate VR rendering (based on FreeCamera)
  49569. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49570. */
  49571. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49572. /**
  49573. * Creates a new VRDeviceOrientationFreeCamera
  49574. * @param name defines camera name
  49575. * @param position defines the start position of the camera
  49576. * @param scene defines the scene the camera belongs to
  49577. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49578. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49579. */
  49580. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49581. /**
  49582. * Gets camera class name
  49583. * @returns VRDeviceOrientationFreeCamera
  49584. */
  49585. getClassName(): string;
  49586. }
  49587. }
  49588. declare module BABYLON {
  49589. /**
  49590. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49591. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49592. */
  49593. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49594. /**
  49595. * Creates a new VRDeviceOrientationGamepadCamera
  49596. * @param name defines camera name
  49597. * @param position defines the start position of the camera
  49598. * @param scene defines the scene the camera belongs to
  49599. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49600. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49601. */
  49602. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49603. /**
  49604. * Gets camera class name
  49605. * @returns VRDeviceOrientationGamepadCamera
  49606. */
  49607. getClassName(): string;
  49608. }
  49609. }
  49610. declare module BABYLON {
  49611. /**
  49612. * A class extending Texture allowing drawing on a texture
  49613. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49614. */
  49615. export class DynamicTexture extends Texture {
  49616. private _generateMipMaps;
  49617. private _canvas;
  49618. private _context;
  49619. /**
  49620. * Creates a DynamicTexture
  49621. * @param name defines the name of the texture
  49622. * @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
  49623. * @param scene defines the scene where you want the texture
  49624. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49625. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49626. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49627. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49628. */
  49629. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49630. /**
  49631. * Get the current class name of the texture useful for serialization or dynamic coding.
  49632. * @returns "DynamicTexture"
  49633. */
  49634. getClassName(): string;
  49635. /**
  49636. * Gets the current state of canRescale
  49637. */
  49638. get canRescale(): boolean;
  49639. private _recreate;
  49640. /**
  49641. * Scales the texture
  49642. * @param ratio the scale factor to apply to both width and height
  49643. */
  49644. scale(ratio: number): void;
  49645. /**
  49646. * Resizes the texture
  49647. * @param width the new width
  49648. * @param height the new height
  49649. */
  49650. scaleTo(width: number, height: number): void;
  49651. /**
  49652. * Gets the context of the canvas used by the texture
  49653. * @returns the canvas context of the dynamic texture
  49654. */
  49655. getContext(): CanvasRenderingContext2D;
  49656. /**
  49657. * Clears the texture
  49658. */
  49659. clear(): void;
  49660. /**
  49661. * Updates the texture
  49662. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49663. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49664. */
  49665. update(invertY?: boolean, premulAlpha?: boolean): void;
  49666. /**
  49667. * Draws text onto the texture
  49668. * @param text defines the text to be drawn
  49669. * @param x defines the placement of the text from the left
  49670. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49671. * @param font defines the font to be used with font-style, font-size, font-name
  49672. * @param color defines the color used for the text
  49673. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49674. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49675. * @param update defines whether texture is immediately update (default is true)
  49676. */
  49677. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49678. /**
  49679. * Clones the texture
  49680. * @returns the clone of the texture.
  49681. */
  49682. clone(): DynamicTexture;
  49683. /**
  49684. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49685. * @returns a serialized dynamic texture object
  49686. */
  49687. serialize(): any;
  49688. private _IsCanvasElement;
  49689. /** @hidden */
  49690. _rebuild(): void;
  49691. }
  49692. }
  49693. declare module BABYLON {
  49694. /**
  49695. * Class containing static functions to help procedurally build meshes
  49696. */
  49697. export class GroundBuilder {
  49698. /**
  49699. * Creates a ground mesh
  49700. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49701. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49703. * @param name defines the name of the mesh
  49704. * @param options defines the options used to create the mesh
  49705. * @param scene defines the hosting scene
  49706. * @returns the ground mesh
  49707. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49708. */
  49709. static CreateGround(name: string, options: {
  49710. width?: number;
  49711. height?: number;
  49712. subdivisions?: number;
  49713. subdivisionsX?: number;
  49714. subdivisionsY?: number;
  49715. updatable?: boolean;
  49716. }, scene: any): Mesh;
  49717. /**
  49718. * Creates a tiled ground mesh
  49719. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49720. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49721. * * 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
  49722. * * 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
  49723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49724. * @param name defines the name of the mesh
  49725. * @param options defines the options used to create the mesh
  49726. * @param scene defines the hosting scene
  49727. * @returns the tiled ground mesh
  49728. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49729. */
  49730. static CreateTiledGround(name: string, options: {
  49731. xmin: number;
  49732. zmin: number;
  49733. xmax: number;
  49734. zmax: number;
  49735. subdivisions?: {
  49736. w: number;
  49737. h: number;
  49738. };
  49739. precision?: {
  49740. w: number;
  49741. h: number;
  49742. };
  49743. updatable?: boolean;
  49744. }, scene?: Nullable<Scene>): Mesh;
  49745. /**
  49746. * Creates a ground mesh from a height map
  49747. * * The parameter `url` sets the URL of the height map image resource.
  49748. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49749. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49750. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49751. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49752. * * 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.
  49753. * * 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).
  49754. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49756. * @param name defines the name of the mesh
  49757. * @param url defines the url to the height map
  49758. * @param options defines the options used to create the mesh
  49759. * @param scene defines the hosting scene
  49760. * @returns the ground mesh
  49761. * @see https://doc.babylonjs.com/babylon101/height_map
  49762. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49763. */
  49764. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49765. width?: number;
  49766. height?: number;
  49767. subdivisions?: number;
  49768. minHeight?: number;
  49769. maxHeight?: number;
  49770. colorFilter?: Color3;
  49771. alphaFilter?: number;
  49772. updatable?: boolean;
  49773. onReady?: (mesh: GroundMesh) => void;
  49774. }, scene?: Nullable<Scene>): GroundMesh;
  49775. }
  49776. }
  49777. declare module BABYLON {
  49778. /**
  49779. * Class containing static functions to help procedurally build meshes
  49780. */
  49781. export class TorusBuilder {
  49782. /**
  49783. * Creates a torus mesh
  49784. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49785. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49786. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49788. * * 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
  49789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49790. * @param name defines the name of the mesh
  49791. * @param options defines the options used to create the mesh
  49792. * @param scene defines the hosting scene
  49793. * @returns the torus mesh
  49794. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49795. */
  49796. static CreateTorus(name: string, options: {
  49797. diameter?: number;
  49798. thickness?: number;
  49799. tessellation?: number;
  49800. updatable?: boolean;
  49801. sideOrientation?: number;
  49802. frontUVs?: Vector4;
  49803. backUVs?: Vector4;
  49804. }, scene: any): Mesh;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * Class containing static functions to help procedurally build meshes
  49810. */
  49811. export class CylinderBuilder {
  49812. /**
  49813. * Creates a cylinder or a cone mesh
  49814. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49815. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49816. * * 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.
  49817. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49818. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49819. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49820. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49821. * * 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).
  49822. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49823. * * 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).
  49824. * * 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
  49825. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49826. * * 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
  49827. * * 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.
  49828. * * If `enclose` is false, a ring surface is one element.
  49829. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49830. * * 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
  49831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49832. * * 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
  49833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49834. * @param name defines the name of the mesh
  49835. * @param options defines the options used to create the mesh
  49836. * @param scene defines the hosting scene
  49837. * @returns the cylinder mesh
  49838. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49839. */
  49840. static CreateCylinder(name: string, options: {
  49841. height?: number;
  49842. diameterTop?: number;
  49843. diameterBottom?: number;
  49844. diameter?: number;
  49845. tessellation?: number;
  49846. subdivisions?: number;
  49847. arc?: number;
  49848. faceColors?: Color4[];
  49849. faceUV?: Vector4[];
  49850. updatable?: boolean;
  49851. hasRings?: boolean;
  49852. enclose?: boolean;
  49853. cap?: number;
  49854. sideOrientation?: number;
  49855. frontUVs?: Vector4;
  49856. backUVs?: Vector4;
  49857. }, scene: any): Mesh;
  49858. }
  49859. }
  49860. declare module BABYLON {
  49861. /**
  49862. * States of the webXR experience
  49863. */
  49864. export enum WebXRState {
  49865. /**
  49866. * Transitioning to being in XR mode
  49867. */
  49868. ENTERING_XR = 0,
  49869. /**
  49870. * Transitioning to non XR mode
  49871. */
  49872. EXITING_XR = 1,
  49873. /**
  49874. * In XR mode and presenting
  49875. */
  49876. IN_XR = 2,
  49877. /**
  49878. * Not entered XR mode
  49879. */
  49880. NOT_IN_XR = 3
  49881. }
  49882. /**
  49883. * The state of the XR camera's tracking
  49884. */
  49885. export enum WebXRTrackingState {
  49886. /**
  49887. * No transformation received, device is not being tracked
  49888. */
  49889. NOT_TRACKING = 0,
  49890. /**
  49891. * Tracking lost - using emulated position
  49892. */
  49893. TRACKING_LOST = 1,
  49894. /**
  49895. * Transformation tracking works normally
  49896. */
  49897. TRACKING = 2
  49898. }
  49899. /**
  49900. * Abstraction of the XR render target
  49901. */
  49902. export interface WebXRRenderTarget extends IDisposable {
  49903. /**
  49904. * xrpresent context of the canvas which can be used to display/mirror xr content
  49905. */
  49906. canvasContext: WebGLRenderingContext;
  49907. /**
  49908. * xr layer for the canvas
  49909. */
  49910. xrLayer: Nullable<XRWebGLLayer>;
  49911. /**
  49912. * Initializes the xr layer for the session
  49913. * @param xrSession xr session
  49914. * @returns a promise that will resolve once the XR Layer has been created
  49915. */
  49916. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /**
  49921. * COnfiguration object for WebXR output canvas
  49922. */
  49923. export class WebXRManagedOutputCanvasOptions {
  49924. /**
  49925. * An optional canvas in case you wish to create it yourself and provide it here.
  49926. * If not provided, a new canvas will be created
  49927. */
  49928. canvasElement?: HTMLCanvasElement;
  49929. /**
  49930. * Options for this XR Layer output
  49931. */
  49932. canvasOptions?: XRWebGLLayerOptions;
  49933. /**
  49934. * CSS styling for a newly created canvas (if not provided)
  49935. */
  49936. newCanvasCssStyle?: string;
  49937. /**
  49938. * Get the default values of the configuration object
  49939. * @param engine defines the engine to use (can be null)
  49940. * @returns default values of this configuration object
  49941. */
  49942. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49943. }
  49944. /**
  49945. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49946. */
  49947. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49948. private _options;
  49949. private _canvas;
  49950. private _engine;
  49951. private _originalCanvasSize;
  49952. /**
  49953. * Rendering context of the canvas which can be used to display/mirror xr content
  49954. */
  49955. canvasContext: WebGLRenderingContext;
  49956. /**
  49957. * xr layer for the canvas
  49958. */
  49959. xrLayer: Nullable<XRWebGLLayer>;
  49960. /**
  49961. * Obseervers registered here will be triggered when the xr layer was initialized
  49962. */
  49963. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49964. /**
  49965. * Initializes the canvas to be added/removed upon entering/exiting xr
  49966. * @param _xrSessionManager The XR Session manager
  49967. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49968. */
  49969. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49970. /**
  49971. * Disposes of the object
  49972. */
  49973. dispose(): void;
  49974. /**
  49975. * Initializes the xr layer for the session
  49976. * @param xrSession xr session
  49977. * @returns a promise that will resolve once the XR Layer has been created
  49978. */
  49979. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49980. private _addCanvas;
  49981. private _removeCanvas;
  49982. private _setCanvasSize;
  49983. private _setManagedOutputCanvas;
  49984. }
  49985. }
  49986. declare module BABYLON {
  49987. /**
  49988. * Manages an XRSession to work with Babylon's engine
  49989. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49990. */
  49991. export class WebXRSessionManager implements IDisposable {
  49992. /** The scene which the session should be created for */
  49993. scene: Scene;
  49994. private _referenceSpace;
  49995. private _rttProvider;
  49996. private _sessionEnded;
  49997. private _xrNavigator;
  49998. private baseLayer;
  49999. /**
  50000. * The base reference space from which the session started. good if you want to reset your
  50001. * reference space
  50002. */
  50003. baseReferenceSpace: XRReferenceSpace;
  50004. /**
  50005. * Current XR frame
  50006. */
  50007. currentFrame: Nullable<XRFrame>;
  50008. /** WebXR timestamp updated every frame */
  50009. currentTimestamp: number;
  50010. /**
  50011. * Used just in case of a failure to initialize an immersive session.
  50012. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50013. */
  50014. defaultHeightCompensation: number;
  50015. /**
  50016. * Fires every time a new xrFrame arrives which can be used to update the camera
  50017. */
  50018. onXRFrameObservable: Observable<XRFrame>;
  50019. /**
  50020. * Fires when the reference space changed
  50021. */
  50022. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50023. /**
  50024. * Fires when the xr session is ended either by the device or manually done
  50025. */
  50026. onXRSessionEnded: Observable<any>;
  50027. /**
  50028. * Fires when the xr session is ended either by the device or manually done
  50029. */
  50030. onXRSessionInit: Observable<XRSession>;
  50031. /**
  50032. * Underlying xr session
  50033. */
  50034. session: XRSession;
  50035. /**
  50036. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50037. * or get the offset the player is currently at.
  50038. */
  50039. viewerReferenceSpace: XRReferenceSpace;
  50040. /**
  50041. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50042. * @param scene The scene which the session should be created for
  50043. */
  50044. constructor(
  50045. /** The scene which the session should be created for */
  50046. scene: Scene);
  50047. /**
  50048. * The current reference space used in this session. This reference space can constantly change!
  50049. * It is mainly used to offset the camera's position.
  50050. */
  50051. get referenceSpace(): XRReferenceSpace;
  50052. /**
  50053. * Set a new reference space and triggers the observable
  50054. */
  50055. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50056. /**
  50057. * Disposes of the session manager
  50058. */
  50059. dispose(): void;
  50060. /**
  50061. * Stops the xrSession and restores the render loop
  50062. * @returns Promise which resolves after it exits XR
  50063. */
  50064. exitXRAsync(): Promise<void>;
  50065. /**
  50066. * Gets the correct render target texture to be rendered this frame for this eye
  50067. * @param eye the eye for which to get the render target
  50068. * @returns the render target for the specified eye
  50069. */
  50070. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50071. /**
  50072. * Creates a WebXRRenderTarget object for the XR session
  50073. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50074. * @param options optional options to provide when creating a new render target
  50075. * @returns a WebXR render target to which the session can render
  50076. */
  50077. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50078. /**
  50079. * Initializes the manager
  50080. * After initialization enterXR can be called to start an XR session
  50081. * @returns Promise which resolves after it is initialized
  50082. */
  50083. initializeAsync(): Promise<void>;
  50084. /**
  50085. * Initializes an xr session
  50086. * @param xrSessionMode mode to initialize
  50087. * @param xrSessionInit defines optional and required values to pass to the session builder
  50088. * @returns a promise which will resolve once the session has been initialized
  50089. */
  50090. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50091. /**
  50092. * Checks if a session would be supported for the creation options specified
  50093. * @param sessionMode session mode to check if supported eg. immersive-vr
  50094. * @returns A Promise that resolves to true if supported and false if not
  50095. */
  50096. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50097. /**
  50098. * Resets the reference space to the one started the session
  50099. */
  50100. resetReferenceSpace(): void;
  50101. /**
  50102. * Starts rendering to the xr layer
  50103. */
  50104. runXRRenderLoop(): void;
  50105. /**
  50106. * Sets the reference space on the xr session
  50107. * @param referenceSpaceType space to set
  50108. * @returns a promise that will resolve once the reference space has been set
  50109. */
  50110. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50111. /**
  50112. * Updates the render state of the session
  50113. * @param state state to set
  50114. * @returns a promise that resolves once the render state has been updated
  50115. */
  50116. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50117. /**
  50118. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50119. * @param sessionMode defines the session to test
  50120. * @returns a promise with boolean as final value
  50121. */
  50122. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50123. private _createRenderTargetTexture;
  50124. }
  50125. }
  50126. declare module BABYLON {
  50127. /**
  50128. * WebXR Camera which holds the views for the xrSession
  50129. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50130. */
  50131. export class WebXRCamera extends FreeCamera {
  50132. private _xrSessionManager;
  50133. private _firstFrame;
  50134. private _referenceQuaternion;
  50135. private _referencedPosition;
  50136. private _xrInvPositionCache;
  50137. private _xrInvQuaternionCache;
  50138. private _trackingState;
  50139. /**
  50140. * Observable raised before camera teleportation
  50141. */
  50142. onBeforeCameraTeleport: Observable<Vector3>;
  50143. /**
  50144. * Observable raised after camera teleportation
  50145. */
  50146. onAfterCameraTeleport: Observable<Vector3>;
  50147. /**
  50148. * Notifies when the camera's tracking state has changed.
  50149. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50150. */
  50151. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50152. /**
  50153. * Should position compensation execute on first frame.
  50154. * This is used when copying the position from a native (non XR) camera
  50155. */
  50156. compensateOnFirstFrame: boolean;
  50157. /**
  50158. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50159. * @param name the name of the camera
  50160. * @param scene the scene to add the camera to
  50161. * @param _xrSessionManager a constructed xr session manager
  50162. */
  50163. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50164. /**
  50165. * Get the current XR tracking state of the camera
  50166. */
  50167. get trackingState(): WebXRTrackingState;
  50168. private _setTrackingState;
  50169. /**
  50170. * Return the user's height, unrelated to the current ground.
  50171. * This will be the y position of this camera, when ground level is 0.
  50172. */
  50173. get realWorldHeight(): number;
  50174. /** @hidden */
  50175. _updateForDualEyeDebugging(): void;
  50176. /**
  50177. * Sets this camera's transformation based on a non-vr camera
  50178. * @param otherCamera the non-vr camera to copy the transformation from
  50179. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50180. */
  50181. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50182. /**
  50183. * Gets the current instance class name ("WebXRCamera").
  50184. * @returns the class name
  50185. */
  50186. getClassName(): string;
  50187. private _rotate180;
  50188. private _updateFromXRSession;
  50189. private _updateNumberOfRigCameras;
  50190. private _updateReferenceSpace;
  50191. private _updateReferenceSpaceOffset;
  50192. }
  50193. }
  50194. declare module BABYLON {
  50195. /**
  50196. * Defining the interface required for a (webxr) feature
  50197. */
  50198. export interface IWebXRFeature extends IDisposable {
  50199. /**
  50200. * Is this feature attached
  50201. */
  50202. attached: boolean;
  50203. /**
  50204. * Should auto-attach be disabled?
  50205. */
  50206. disableAutoAttach: boolean;
  50207. /**
  50208. * Attach the feature to the session
  50209. * Will usually be called by the features manager
  50210. *
  50211. * @param force should attachment be forced (even when already attached)
  50212. * @returns true if successful.
  50213. */
  50214. attach(force?: boolean): boolean;
  50215. /**
  50216. * Detach the feature from the session
  50217. * Will usually be called by the features manager
  50218. *
  50219. * @returns true if successful.
  50220. */
  50221. detach(): boolean;
  50222. /**
  50223. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50224. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50225. *
  50226. * @returns whether or not the feature is compatible in this environment
  50227. */
  50228. isCompatible(): boolean;
  50229. /**
  50230. * Was this feature disposed;
  50231. */
  50232. isDisposed: boolean;
  50233. /**
  50234. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50235. */
  50236. xrNativeFeatureName?: string;
  50237. /**
  50238. * A list of (Babylon WebXR) features this feature depends on
  50239. */
  50240. dependsOn?: string[];
  50241. }
  50242. /**
  50243. * A list of the currently available features without referencing them
  50244. */
  50245. export class WebXRFeatureName {
  50246. /**
  50247. * The name of the anchor system feature
  50248. */
  50249. static readonly ANCHOR_SYSTEM: string;
  50250. /**
  50251. * The name of the background remover feature
  50252. */
  50253. static readonly BACKGROUND_REMOVER: string;
  50254. /**
  50255. * The name of the hit test feature
  50256. */
  50257. static readonly HIT_TEST: string;
  50258. /**
  50259. * physics impostors for xr controllers feature
  50260. */
  50261. static readonly PHYSICS_CONTROLLERS: string;
  50262. /**
  50263. * The name of the plane detection feature
  50264. */
  50265. static readonly PLANE_DETECTION: string;
  50266. /**
  50267. * The name of the pointer selection feature
  50268. */
  50269. static readonly POINTER_SELECTION: string;
  50270. /**
  50271. * The name of the teleportation feature
  50272. */
  50273. static readonly TELEPORTATION: string;
  50274. /**
  50275. * The name of the feature points feature.
  50276. */
  50277. static readonly FEATURE_POINTS: string;
  50278. /**
  50279. * The name of the hand tracking feature.
  50280. */
  50281. static readonly HAND_TRACKING: string;
  50282. }
  50283. /**
  50284. * Defining the constructor of a feature. Used to register the modules.
  50285. */
  50286. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50287. /**
  50288. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50289. * It is mainly used in AR sessions.
  50290. *
  50291. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50292. */
  50293. export class WebXRFeaturesManager implements IDisposable {
  50294. private _xrSessionManager;
  50295. private static readonly _AvailableFeatures;
  50296. private _features;
  50297. /**
  50298. * constructs a new features manages.
  50299. *
  50300. * @param _xrSessionManager an instance of WebXRSessionManager
  50301. */
  50302. constructor(_xrSessionManager: WebXRSessionManager);
  50303. /**
  50304. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50305. * Mainly used internally.
  50306. *
  50307. * @param featureName the name of the feature to register
  50308. * @param constructorFunction the function used to construct the module
  50309. * @param version the (babylon) version of the module
  50310. * @param stable is that a stable version of this module
  50311. */
  50312. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50313. /**
  50314. * Returns a constructor of a specific feature.
  50315. *
  50316. * @param featureName the name of the feature to construct
  50317. * @param version the version of the feature to load
  50318. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50319. * @param options optional options provided to the module.
  50320. * @returns a function that, when called, will return a new instance of this feature
  50321. */
  50322. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50323. /**
  50324. * Can be used to return the list of features currently registered
  50325. *
  50326. * @returns an Array of available features
  50327. */
  50328. static GetAvailableFeatures(): string[];
  50329. /**
  50330. * Gets the versions available for a specific feature
  50331. * @param featureName the name of the feature
  50332. * @returns an array with the available versions
  50333. */
  50334. static GetAvailableVersions(featureName: string): string[];
  50335. /**
  50336. * Return the latest unstable version of this feature
  50337. * @param featureName the name of the feature to search
  50338. * @returns the version number. if not found will return -1
  50339. */
  50340. static GetLatestVersionOfFeature(featureName: string): number;
  50341. /**
  50342. * Return the latest stable version of this feature
  50343. * @param featureName the name of the feature to search
  50344. * @returns the version number. if not found will return -1
  50345. */
  50346. static GetStableVersionOfFeature(featureName: string): number;
  50347. /**
  50348. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50349. * Can be used during a session to start a feature
  50350. * @param featureName the name of feature to attach
  50351. */
  50352. attachFeature(featureName: string): void;
  50353. /**
  50354. * Can be used inside a session or when the session ends to detach a specific feature
  50355. * @param featureName the name of the feature to detach
  50356. */
  50357. detachFeature(featureName: string): void;
  50358. /**
  50359. * Used to disable an already-enabled feature
  50360. * The feature will be disposed and will be recreated once enabled.
  50361. * @param featureName the feature to disable
  50362. * @returns true if disable was successful
  50363. */
  50364. disableFeature(featureName: string | {
  50365. Name: string;
  50366. }): boolean;
  50367. /**
  50368. * dispose this features manager
  50369. */
  50370. dispose(): void;
  50371. /**
  50372. * 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.
  50373. * 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.
  50374. *
  50375. * @param featureName the name of the feature to load or the class of the feature
  50376. * @param version optional version to load. if not provided the latest version will be enabled
  50377. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50378. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50379. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50380. * @returns a new constructed feature or throws an error if feature not found.
  50381. */
  50382. enableFeature(featureName: string | {
  50383. Name: string;
  50384. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50385. /**
  50386. * get the implementation of an enabled feature.
  50387. * @param featureName the name of the feature to load
  50388. * @returns the feature class, if found
  50389. */
  50390. getEnabledFeature(featureName: string): IWebXRFeature;
  50391. /**
  50392. * Get the list of enabled features
  50393. * @returns an array of enabled features
  50394. */
  50395. getEnabledFeatures(): string[];
  50396. /**
  50397. * This function will exten the session creation configuration object with enabled features.
  50398. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50399. * according to the defined "required" variable, provided during enableFeature call
  50400. * @param xrSessionInit the xr Session init object to extend
  50401. *
  50402. * @returns an extended XRSessionInit object
  50403. */
  50404. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50405. }
  50406. }
  50407. declare module BABYLON {
  50408. /**
  50409. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50410. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50411. */
  50412. export class WebXRExperienceHelper implements IDisposable {
  50413. private scene;
  50414. private _nonVRCamera;
  50415. private _originalSceneAutoClear;
  50416. private _supported;
  50417. /**
  50418. * Camera used to render xr content
  50419. */
  50420. camera: WebXRCamera;
  50421. /** A features manager for this xr session */
  50422. featuresManager: WebXRFeaturesManager;
  50423. /**
  50424. * Observers registered here will be triggered after the camera's initial transformation is set
  50425. * This can be used to set a different ground level or an extra rotation.
  50426. *
  50427. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50428. * to the position set after this observable is done executing.
  50429. */
  50430. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50431. /**
  50432. * Fires when the state of the experience helper has changed
  50433. */
  50434. onStateChangedObservable: Observable<WebXRState>;
  50435. /** Session manager used to keep track of xr session */
  50436. sessionManager: WebXRSessionManager;
  50437. /**
  50438. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50439. */
  50440. state: WebXRState;
  50441. /**
  50442. * Creates a WebXRExperienceHelper
  50443. * @param scene The scene the helper should be created in
  50444. */
  50445. private constructor();
  50446. /**
  50447. * Creates the experience helper
  50448. * @param scene the scene to attach the experience helper to
  50449. * @returns a promise for the experience helper
  50450. */
  50451. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50452. /**
  50453. * Disposes of the experience helper
  50454. */
  50455. dispose(): void;
  50456. /**
  50457. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50458. * @param sessionMode options for the XR session
  50459. * @param referenceSpaceType frame of reference of the XR session
  50460. * @param renderTarget the output canvas that will be used to enter XR mode
  50461. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50462. * @returns promise that resolves after xr mode has entered
  50463. */
  50464. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50465. /**
  50466. * Exits XR mode and returns the scene to its original state
  50467. * @returns promise that resolves after xr mode has exited
  50468. */
  50469. exitXRAsync(): Promise<void>;
  50470. private _nonXRToXRCamera;
  50471. private _setState;
  50472. }
  50473. }
  50474. declare module BABYLON {
  50475. /**
  50476. * X-Y values for axes in WebXR
  50477. */
  50478. export interface IWebXRMotionControllerAxesValue {
  50479. /**
  50480. * The value of the x axis
  50481. */
  50482. x: number;
  50483. /**
  50484. * The value of the y-axis
  50485. */
  50486. y: number;
  50487. }
  50488. /**
  50489. * changed / previous values for the values of this component
  50490. */
  50491. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50492. /**
  50493. * current (this frame) value
  50494. */
  50495. current: T;
  50496. /**
  50497. * previous (last change) value
  50498. */
  50499. previous: T;
  50500. }
  50501. /**
  50502. * Represents changes in the component between current frame and last values recorded
  50503. */
  50504. export interface IWebXRMotionControllerComponentChanges {
  50505. /**
  50506. * will be populated with previous and current values if axes changed
  50507. */
  50508. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50509. /**
  50510. * will be populated with previous and current values if pressed changed
  50511. */
  50512. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50513. /**
  50514. * will be populated with previous and current values if touched changed
  50515. */
  50516. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50517. /**
  50518. * will be populated with previous and current values if value changed
  50519. */
  50520. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50521. }
  50522. /**
  50523. * This class represents a single component (for example button or thumbstick) of a motion controller
  50524. */
  50525. export class WebXRControllerComponent implements IDisposable {
  50526. /**
  50527. * the id of this component
  50528. */
  50529. id: string;
  50530. /**
  50531. * the type of the component
  50532. */
  50533. type: MotionControllerComponentType;
  50534. private _buttonIndex;
  50535. private _axesIndices;
  50536. private _axes;
  50537. private _changes;
  50538. private _currentValue;
  50539. private _hasChanges;
  50540. private _pressed;
  50541. private _touched;
  50542. /**
  50543. * button component type
  50544. */
  50545. static BUTTON_TYPE: MotionControllerComponentType;
  50546. /**
  50547. * squeeze component type
  50548. */
  50549. static SQUEEZE_TYPE: MotionControllerComponentType;
  50550. /**
  50551. * Thumbstick component type
  50552. */
  50553. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50554. /**
  50555. * Touchpad component type
  50556. */
  50557. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50558. /**
  50559. * trigger component type
  50560. */
  50561. static TRIGGER_TYPE: MotionControllerComponentType;
  50562. /**
  50563. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50564. * the axes data changes
  50565. */
  50566. onAxisValueChangedObservable: Observable<{
  50567. x: number;
  50568. y: number;
  50569. }>;
  50570. /**
  50571. * Observers registered here will be triggered when the state of a button changes
  50572. * State change is either pressed / touched / value
  50573. */
  50574. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50575. /**
  50576. * Creates a new component for a motion controller.
  50577. * It is created by the motion controller itself
  50578. *
  50579. * @param id the id of this component
  50580. * @param type the type of the component
  50581. * @param _buttonIndex index in the buttons array of the gamepad
  50582. * @param _axesIndices indices of the values in the axes array of the gamepad
  50583. */
  50584. constructor(
  50585. /**
  50586. * the id of this component
  50587. */
  50588. id: string,
  50589. /**
  50590. * the type of the component
  50591. */
  50592. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50593. /**
  50594. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50595. */
  50596. get axes(): IWebXRMotionControllerAxesValue;
  50597. /**
  50598. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50599. */
  50600. get changes(): IWebXRMotionControllerComponentChanges;
  50601. /**
  50602. * Return whether or not the component changed the last frame
  50603. */
  50604. get hasChanges(): boolean;
  50605. /**
  50606. * is the button currently pressed
  50607. */
  50608. get pressed(): boolean;
  50609. /**
  50610. * is the button currently touched
  50611. */
  50612. get touched(): boolean;
  50613. /**
  50614. * Get the current value of this component
  50615. */
  50616. get value(): number;
  50617. /**
  50618. * Dispose this component
  50619. */
  50620. dispose(): void;
  50621. /**
  50622. * Are there axes correlating to this component
  50623. * @return true is axes data is available
  50624. */
  50625. isAxes(): boolean;
  50626. /**
  50627. * Is this component a button (hence - pressable)
  50628. * @returns true if can be pressed
  50629. */
  50630. isButton(): boolean;
  50631. /**
  50632. * update this component using the gamepad object it is in. Called on every frame
  50633. * @param nativeController the native gamepad controller object
  50634. */
  50635. update(nativeController: IMinimalMotionControllerObject): void;
  50636. }
  50637. }
  50638. declare module BABYLON {
  50639. /**
  50640. * Interface used to represent data loading progression
  50641. */
  50642. export interface ISceneLoaderProgressEvent {
  50643. /**
  50644. * Defines if data length to load can be evaluated
  50645. */
  50646. readonly lengthComputable: boolean;
  50647. /**
  50648. * Defines the loaded data length
  50649. */
  50650. readonly loaded: number;
  50651. /**
  50652. * Defines the data length to load
  50653. */
  50654. readonly total: number;
  50655. }
  50656. /**
  50657. * Interface used by SceneLoader plugins to define supported file extensions
  50658. */
  50659. export interface ISceneLoaderPluginExtensions {
  50660. /**
  50661. * Defines the list of supported extensions
  50662. */
  50663. [extension: string]: {
  50664. isBinary: boolean;
  50665. };
  50666. }
  50667. /**
  50668. * Interface used by SceneLoader plugin factory
  50669. */
  50670. export interface ISceneLoaderPluginFactory {
  50671. /**
  50672. * Defines the name of the factory
  50673. */
  50674. name: string;
  50675. /**
  50676. * Function called to create a new plugin
  50677. * @return the new plugin
  50678. */
  50679. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50680. /**
  50681. * The callback that returns true if the data can be directly loaded.
  50682. * @param data string containing the file data
  50683. * @returns if the data can be loaded directly
  50684. */
  50685. canDirectLoad?(data: string): boolean;
  50686. }
  50687. /**
  50688. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50689. */
  50690. export interface ISceneLoaderPluginBase {
  50691. /**
  50692. * The friendly name of this plugin.
  50693. */
  50694. name: string;
  50695. /**
  50696. * The file extensions supported by this plugin.
  50697. */
  50698. extensions: string | ISceneLoaderPluginExtensions;
  50699. /**
  50700. * The callback called when loading from a url.
  50701. * @param scene scene loading this url
  50702. * @param url url to load
  50703. * @param onSuccess callback called when the file successfully loads
  50704. * @param onProgress callback called while file is loading (if the server supports this mode)
  50705. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50706. * @param onError callback called when the file fails to load
  50707. * @returns a file request object
  50708. */
  50709. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50710. /**
  50711. * The callback called when loading from a file object.
  50712. * @param scene scene loading this file
  50713. * @param file defines the file to load
  50714. * @param onSuccess defines the callback to call when data is loaded
  50715. * @param onProgress defines the callback to call during loading process
  50716. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50717. * @param onError defines the callback to call when an error occurs
  50718. * @returns a file request object
  50719. */
  50720. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50721. /**
  50722. * The callback that returns true if the data can be directly loaded.
  50723. * @param data string containing the file data
  50724. * @returns if the data can be loaded directly
  50725. */
  50726. canDirectLoad?(data: string): boolean;
  50727. /**
  50728. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50729. * @param scene scene loading this data
  50730. * @param data string containing the data
  50731. * @returns data to pass to the plugin
  50732. */
  50733. directLoad?(scene: Scene, data: string): any;
  50734. /**
  50735. * The callback that allows custom handling of the root url based on the response url.
  50736. * @param rootUrl the original root url
  50737. * @param responseURL the response url if available
  50738. * @returns the new root url
  50739. */
  50740. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50741. }
  50742. /**
  50743. * Interface used to define a SceneLoader plugin
  50744. */
  50745. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50746. /**
  50747. * Import meshes into a scene.
  50748. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50749. * @param scene The scene to import into
  50750. * @param data The data to import
  50751. * @param rootUrl The root url for scene and resources
  50752. * @param meshes The meshes array to import into
  50753. * @param particleSystems The particle systems array to import into
  50754. * @param skeletons The skeletons array to import into
  50755. * @param onError The callback when import fails
  50756. * @returns True if successful or false otherwise
  50757. */
  50758. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50759. /**
  50760. * Load into a scene.
  50761. * @param scene The scene to load into
  50762. * @param data The data to import
  50763. * @param rootUrl The root url for scene and resources
  50764. * @param onError The callback when import fails
  50765. * @returns True if successful or false otherwise
  50766. */
  50767. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50768. /**
  50769. * Load into an asset container.
  50770. * @param scene The scene to load into
  50771. * @param data The data to import
  50772. * @param rootUrl The root url for scene and resources
  50773. * @param onError The callback when import fails
  50774. * @returns The loaded asset container
  50775. */
  50776. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50777. }
  50778. /**
  50779. * Interface used to define an async SceneLoader plugin
  50780. */
  50781. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50782. /**
  50783. * Import meshes into a scene.
  50784. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50785. * @param scene The scene to import into
  50786. * @param data The data to import
  50787. * @param rootUrl The root url for scene and resources
  50788. * @param onProgress The callback when the load progresses
  50789. * @param fileName Defines the name of the file to load
  50790. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50791. */
  50792. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50793. meshes: AbstractMesh[];
  50794. particleSystems: IParticleSystem[];
  50795. skeletons: Skeleton[];
  50796. animationGroups: AnimationGroup[];
  50797. }>;
  50798. /**
  50799. * Load into a scene.
  50800. * @param scene The scene to load into
  50801. * @param data The data to import
  50802. * @param rootUrl The root url for scene and resources
  50803. * @param onProgress The callback when the load progresses
  50804. * @param fileName Defines the name of the file to load
  50805. * @returns Nothing
  50806. */
  50807. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50808. /**
  50809. * Load into an asset container.
  50810. * @param scene The scene to load into
  50811. * @param data The data to import
  50812. * @param rootUrl The root url for scene and resources
  50813. * @param onProgress The callback when the load progresses
  50814. * @param fileName Defines the name of the file to load
  50815. * @returns The loaded asset container
  50816. */
  50817. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50818. }
  50819. /**
  50820. * Mode that determines how to handle old animation groups before loading new ones.
  50821. */
  50822. export enum SceneLoaderAnimationGroupLoadingMode {
  50823. /**
  50824. * Reset all old animations to initial state then dispose them.
  50825. */
  50826. Clean = 0,
  50827. /**
  50828. * Stop all old animations.
  50829. */
  50830. Stop = 1,
  50831. /**
  50832. * Restart old animations from first frame.
  50833. */
  50834. Sync = 2,
  50835. /**
  50836. * Old animations remains untouched.
  50837. */
  50838. NoSync = 3
  50839. }
  50840. /**
  50841. * Defines a plugin registered by the SceneLoader
  50842. */
  50843. interface IRegisteredPlugin {
  50844. /**
  50845. * Defines the plugin to use
  50846. */
  50847. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50848. /**
  50849. * Defines if the plugin supports binary data
  50850. */
  50851. isBinary: boolean;
  50852. }
  50853. /**
  50854. * Class used to load scene from various file formats using registered plugins
  50855. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50856. */
  50857. export class SceneLoader {
  50858. /**
  50859. * No logging while loading
  50860. */
  50861. static readonly NO_LOGGING: number;
  50862. /**
  50863. * Minimal logging while loading
  50864. */
  50865. static readonly MINIMAL_LOGGING: number;
  50866. /**
  50867. * Summary logging while loading
  50868. */
  50869. static readonly SUMMARY_LOGGING: number;
  50870. /**
  50871. * Detailled logging while loading
  50872. */
  50873. static readonly DETAILED_LOGGING: number;
  50874. /**
  50875. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50876. */
  50877. static get ForceFullSceneLoadingForIncremental(): boolean;
  50878. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50879. /**
  50880. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50881. */
  50882. static get ShowLoadingScreen(): boolean;
  50883. static set ShowLoadingScreen(value: boolean);
  50884. /**
  50885. * Defines the current logging level (while loading the scene)
  50886. * @ignorenaming
  50887. */
  50888. static get loggingLevel(): number;
  50889. static set loggingLevel(value: number);
  50890. /**
  50891. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50892. */
  50893. static get CleanBoneMatrixWeights(): boolean;
  50894. static set CleanBoneMatrixWeights(value: boolean);
  50895. /**
  50896. * Event raised when a plugin is used to load a scene
  50897. */
  50898. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50899. private static _registeredPlugins;
  50900. private static _showingLoadingScreen;
  50901. /**
  50902. * Gets the default plugin (used to load Babylon files)
  50903. * @returns the .babylon plugin
  50904. */
  50905. static GetDefaultPlugin(): IRegisteredPlugin;
  50906. private static _GetPluginForExtension;
  50907. private static _GetPluginForDirectLoad;
  50908. private static _GetPluginForFilename;
  50909. private static _GetDirectLoad;
  50910. private static _LoadData;
  50911. private static _GetFileInfo;
  50912. /**
  50913. * Gets a plugin that can load the given extension
  50914. * @param extension defines the extension to load
  50915. * @returns a plugin or null if none works
  50916. */
  50917. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50918. /**
  50919. * Gets a boolean indicating that the given extension can be loaded
  50920. * @param extension defines the extension to load
  50921. * @returns true if the extension is supported
  50922. */
  50923. static IsPluginForExtensionAvailable(extension: string): boolean;
  50924. /**
  50925. * Adds a new plugin to the list of registered plugins
  50926. * @param plugin defines the plugin to add
  50927. */
  50928. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50929. /**
  50930. * Import meshes into a scene
  50931. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50932. * @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)
  50933. * @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)
  50934. * @param scene the instance of BABYLON.Scene to append to
  50935. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50936. * @param onProgress a callback with a progress event for each file being loaded
  50937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50938. * @param pluginExtension the extension used to determine the plugin
  50939. * @returns The loaded plugin
  50940. */
  50941. 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>;
  50942. /**
  50943. * Import meshes into a scene
  50944. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50945. * @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)
  50946. * @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)
  50947. * @param scene the instance of BABYLON.Scene to append to
  50948. * @param onProgress a callback with a progress event for each file being loaded
  50949. * @param pluginExtension the extension used to determine the plugin
  50950. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50951. */
  50952. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50953. meshes: AbstractMesh[];
  50954. particleSystems: IParticleSystem[];
  50955. skeletons: Skeleton[];
  50956. animationGroups: AnimationGroup[];
  50957. }>;
  50958. /**
  50959. * Load a scene
  50960. * @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)
  50961. * @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)
  50962. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50963. * @param onSuccess a callback with the scene when import succeeds
  50964. * @param onProgress a callback with a progress event for each file being loaded
  50965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50966. * @param pluginExtension the extension used to determine the plugin
  50967. * @returns The loaded plugin
  50968. */
  50969. 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>;
  50970. /**
  50971. * Load a scene
  50972. * @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)
  50973. * @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)
  50974. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50975. * @param onProgress a callback with a progress event for each file being loaded
  50976. * @param pluginExtension the extension used to determine the plugin
  50977. * @returns The loaded scene
  50978. */
  50979. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50980. /**
  50981. * Append a scene
  50982. * @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)
  50983. * @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)
  50984. * @param scene is the instance of BABYLON.Scene to append to
  50985. * @param onSuccess a callback with the scene when import succeeds
  50986. * @param onProgress a callback with a progress event for each file being loaded
  50987. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50988. * @param pluginExtension the extension used to determine the plugin
  50989. * @returns The loaded plugin
  50990. */
  50991. 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>;
  50992. /**
  50993. * Append a scene
  50994. * @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)
  50995. * @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)
  50996. * @param scene is the instance of BABYLON.Scene to append to
  50997. * @param onProgress a callback with a progress event for each file being loaded
  50998. * @param pluginExtension the extension used to determine the plugin
  50999. * @returns The given scene
  51000. */
  51001. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51002. /**
  51003. * Load a scene into an asset container
  51004. * @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)
  51005. * @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)
  51006. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51007. * @param onSuccess a callback with the scene when import succeeds
  51008. * @param onProgress a callback with a progress event for each file being loaded
  51009. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51010. * @param pluginExtension the extension used to determine the plugin
  51011. * @returns The loaded plugin
  51012. */
  51013. 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>;
  51014. /**
  51015. * Load a scene into an asset container
  51016. * @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)
  51017. * @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)
  51018. * @param scene is the instance of Scene to append to
  51019. * @param onProgress a callback with a progress event for each file being loaded
  51020. * @param pluginExtension the extension used to determine the plugin
  51021. * @returns The loaded asset container
  51022. */
  51023. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51024. /**
  51025. * Import animations from a file into a scene
  51026. * @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)
  51027. * @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)
  51028. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51029. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51030. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51031. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51032. * @param onSuccess a callback with the scene when import succeeds
  51033. * @param onProgress a callback with a progress event for each file being loaded
  51034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51035. * @param pluginExtension the extension used to determine the plugin
  51036. */
  51037. 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;
  51038. /**
  51039. * Import animations from a file into a scene
  51040. * @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)
  51041. * @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)
  51042. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51043. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51044. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51045. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51046. * @param onSuccess a callback with the scene when import succeeds
  51047. * @param onProgress a callback with a progress event for each file being loaded
  51048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51049. * @param pluginExtension the extension used to determine the plugin
  51050. * @returns the updated scene with imported animations
  51051. */
  51052. 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>;
  51053. }
  51054. }
  51055. declare module BABYLON {
  51056. /**
  51057. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51058. */
  51059. export type MotionControllerHandedness = "none" | "left" | "right";
  51060. /**
  51061. * The type of components available in motion controllers.
  51062. * This is not the name of the component.
  51063. */
  51064. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51065. /**
  51066. * The state of a controller component
  51067. */
  51068. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51069. /**
  51070. * The schema of motion controller layout.
  51071. * No object will be initialized using this interface
  51072. * This is used just to define the profile.
  51073. */
  51074. export interface IMotionControllerLayout {
  51075. /**
  51076. * Path to load the assets. Usually relative to the base path
  51077. */
  51078. assetPath: string;
  51079. /**
  51080. * Available components (unsorted)
  51081. */
  51082. components: {
  51083. /**
  51084. * A map of component Ids
  51085. */
  51086. [componentId: string]: {
  51087. /**
  51088. * The type of input the component outputs
  51089. */
  51090. type: MotionControllerComponentType;
  51091. /**
  51092. * The indices of this component in the gamepad object
  51093. */
  51094. gamepadIndices: {
  51095. /**
  51096. * Index of button
  51097. */
  51098. button?: number;
  51099. /**
  51100. * If available, index of x-axis
  51101. */
  51102. xAxis?: number;
  51103. /**
  51104. * If available, index of y-axis
  51105. */
  51106. yAxis?: number;
  51107. };
  51108. /**
  51109. * The mesh's root node name
  51110. */
  51111. rootNodeName: string;
  51112. /**
  51113. * Animation definitions for this model
  51114. */
  51115. visualResponses: {
  51116. [stateKey: string]: {
  51117. /**
  51118. * What property will be animated
  51119. */
  51120. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51121. /**
  51122. * What states influence this visual response
  51123. */
  51124. states: MotionControllerComponentStateType[];
  51125. /**
  51126. * Type of animation - movement or visibility
  51127. */
  51128. valueNodeProperty: "transform" | "visibility";
  51129. /**
  51130. * Base node name to move. Its position will be calculated according to the min and max nodes
  51131. */
  51132. valueNodeName?: string;
  51133. /**
  51134. * Minimum movement node
  51135. */
  51136. minNodeName?: string;
  51137. /**
  51138. * Max movement node
  51139. */
  51140. maxNodeName?: string;
  51141. };
  51142. };
  51143. /**
  51144. * If touch enabled, what is the name of node to display user feedback
  51145. */
  51146. touchPointNodeName?: string;
  51147. };
  51148. };
  51149. /**
  51150. * Is it xr standard mapping or not
  51151. */
  51152. gamepadMapping: "" | "xr-standard";
  51153. /**
  51154. * Base root node of this entire model
  51155. */
  51156. rootNodeName: string;
  51157. /**
  51158. * Defines the main button component id
  51159. */
  51160. selectComponentId: string;
  51161. }
  51162. /**
  51163. * A definition for the layout map in the input profile
  51164. */
  51165. export interface IMotionControllerLayoutMap {
  51166. /**
  51167. * Layouts with handedness type as a key
  51168. */
  51169. [handedness: string]: IMotionControllerLayout;
  51170. }
  51171. /**
  51172. * The XR Input profile schema
  51173. * Profiles can be found here:
  51174. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51175. */
  51176. export interface IMotionControllerProfile {
  51177. /**
  51178. * fallback profiles for this profileId
  51179. */
  51180. fallbackProfileIds: string[];
  51181. /**
  51182. * The layout map, with handedness as key
  51183. */
  51184. layouts: IMotionControllerLayoutMap;
  51185. /**
  51186. * The id of this profile
  51187. * correlates to the profile(s) in the xrInput.profiles array
  51188. */
  51189. profileId: string;
  51190. }
  51191. /**
  51192. * A helper-interface for the 3 meshes needed for controller button animation
  51193. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51194. */
  51195. export interface IMotionControllerButtonMeshMap {
  51196. /**
  51197. * the mesh that defines the pressed value mesh position.
  51198. * This is used to find the max-position of this button
  51199. */
  51200. pressedMesh: AbstractMesh;
  51201. /**
  51202. * the mesh that defines the unpressed value mesh position.
  51203. * This is used to find the min (or initial) position of this button
  51204. */
  51205. unpressedMesh: AbstractMesh;
  51206. /**
  51207. * The mesh that will be changed when value changes
  51208. */
  51209. valueMesh: AbstractMesh;
  51210. }
  51211. /**
  51212. * A helper-interface for the 3 meshes needed for controller axis animation.
  51213. * This will be expanded when touchpad animations are fully supported
  51214. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51215. */
  51216. export interface IMotionControllerMeshMap {
  51217. /**
  51218. * the mesh that defines the maximum value mesh position.
  51219. */
  51220. maxMesh?: AbstractMesh;
  51221. /**
  51222. * the mesh that defines the minimum value mesh position.
  51223. */
  51224. minMesh?: AbstractMesh;
  51225. /**
  51226. * The mesh that will be changed when axis value changes
  51227. */
  51228. valueMesh?: AbstractMesh;
  51229. }
  51230. /**
  51231. * The elements needed for change-detection of the gamepad objects in motion controllers
  51232. */
  51233. export interface IMinimalMotionControllerObject {
  51234. /**
  51235. * Available axes of this controller
  51236. */
  51237. axes: number[];
  51238. /**
  51239. * An array of available buttons
  51240. */
  51241. buttons: Array<{
  51242. /**
  51243. * Value of the button/trigger
  51244. */
  51245. value: number;
  51246. /**
  51247. * If the button/trigger is currently touched
  51248. */
  51249. touched: boolean;
  51250. /**
  51251. * If the button/trigger is currently pressed
  51252. */
  51253. pressed: boolean;
  51254. }>;
  51255. /**
  51256. * EXPERIMENTAL haptic support.
  51257. */
  51258. hapticActuators?: Array<{
  51259. pulse: (value: number, duration: number) => Promise<boolean>;
  51260. }>;
  51261. }
  51262. /**
  51263. * An Abstract Motion controller
  51264. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51265. * Each component has an observable to check for changes in value and state
  51266. */
  51267. export abstract class WebXRAbstractMotionController implements IDisposable {
  51268. protected scene: Scene;
  51269. protected layout: IMotionControllerLayout;
  51270. /**
  51271. * The gamepad object correlating to this controller
  51272. */
  51273. gamepadObject: IMinimalMotionControllerObject;
  51274. /**
  51275. * handedness (left/right/none) of this controller
  51276. */
  51277. handedness: MotionControllerHandedness;
  51278. private _initComponent;
  51279. private _modelReady;
  51280. /**
  51281. * A map of components (WebXRControllerComponent) in this motion controller
  51282. * Components have a ComponentType and can also have both button and axis definitions
  51283. */
  51284. readonly components: {
  51285. [id: string]: WebXRControllerComponent;
  51286. };
  51287. /**
  51288. * Disable the model's animation. Can be set at any time.
  51289. */
  51290. disableAnimation: boolean;
  51291. /**
  51292. * Observers registered here will be triggered when the model of this controller is done loading
  51293. */
  51294. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51295. /**
  51296. * The profile id of this motion controller
  51297. */
  51298. abstract profileId: string;
  51299. /**
  51300. * The root mesh of the model. It is null if the model was not yet initialized
  51301. */
  51302. rootMesh: Nullable<AbstractMesh>;
  51303. /**
  51304. * constructs a new abstract motion controller
  51305. * @param scene the scene to which the model of the controller will be added
  51306. * @param layout The profile layout to load
  51307. * @param gamepadObject The gamepad object correlating to this controller
  51308. * @param handedness handedness (left/right/none) of this controller
  51309. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51310. */
  51311. constructor(scene: Scene, layout: IMotionControllerLayout,
  51312. /**
  51313. * The gamepad object correlating to this controller
  51314. */
  51315. gamepadObject: IMinimalMotionControllerObject,
  51316. /**
  51317. * handedness (left/right/none) of this controller
  51318. */
  51319. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51320. /**
  51321. * Dispose this controller, the model mesh and all its components
  51322. */
  51323. dispose(): void;
  51324. /**
  51325. * Returns all components of specific type
  51326. * @param type the type to search for
  51327. * @return an array of components with this type
  51328. */
  51329. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51330. /**
  51331. * get a component based an its component id as defined in layout.components
  51332. * @param id the id of the component
  51333. * @returns the component correlates to the id or undefined if not found
  51334. */
  51335. getComponent(id: string): WebXRControllerComponent;
  51336. /**
  51337. * Get the list of components available in this motion controller
  51338. * @returns an array of strings correlating to available components
  51339. */
  51340. getComponentIds(): string[];
  51341. /**
  51342. * Get the first component of specific type
  51343. * @param type type of component to find
  51344. * @return a controller component or null if not found
  51345. */
  51346. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51347. /**
  51348. * Get the main (Select) component of this controller as defined in the layout
  51349. * @returns the main component of this controller
  51350. */
  51351. getMainComponent(): WebXRControllerComponent;
  51352. /**
  51353. * Loads the model correlating to this controller
  51354. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51355. * @returns A promise fulfilled with the result of the model loading
  51356. */
  51357. loadModel(): Promise<boolean>;
  51358. /**
  51359. * Update this model using the current XRFrame
  51360. * @param xrFrame the current xr frame to use and update the model
  51361. */
  51362. updateFromXRFrame(xrFrame: XRFrame): void;
  51363. /**
  51364. * Backwards compatibility due to a deeply-integrated typo
  51365. */
  51366. get handness(): XREye;
  51367. /**
  51368. * Pulse (vibrate) this controller
  51369. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51370. * Consecutive calls to this function will cancel the last pulse call
  51371. *
  51372. * @param value the strength of the pulse in 0.0...1.0 range
  51373. * @param duration Duration of the pulse in milliseconds
  51374. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51375. * @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
  51376. */
  51377. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51378. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51379. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51380. /**
  51381. * Moves the axis on the controller mesh based on its current state
  51382. * @param axis the index of the axis
  51383. * @param axisValue the value of the axis which determines the meshes new position
  51384. * @hidden
  51385. */
  51386. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51387. /**
  51388. * Update the model itself with the current frame data
  51389. * @param xrFrame the frame to use for updating the model mesh
  51390. */
  51391. protected updateModel(xrFrame: XRFrame): void;
  51392. /**
  51393. * Get the filename and path for this controller's model
  51394. * @returns a map of filename and path
  51395. */
  51396. protected abstract _getFilenameAndPath(): {
  51397. filename: string;
  51398. path: string;
  51399. };
  51400. /**
  51401. * This function is called before the mesh is loaded. It checks for loading constraints.
  51402. * For example, this function can check if the GLB loader is available
  51403. * If this function returns false, the generic controller will be loaded instead
  51404. * @returns Is the client ready to load the mesh
  51405. */
  51406. protected abstract _getModelLoadingConstraints(): boolean;
  51407. /**
  51408. * This function will be called after the model was successfully loaded and can be used
  51409. * for mesh transformations before it is available for the user
  51410. * @param meshes the loaded meshes
  51411. */
  51412. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51413. /**
  51414. * Set the root mesh for this controller. Important for the WebXR controller class
  51415. * @param meshes the loaded meshes
  51416. */
  51417. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51418. /**
  51419. * A function executed each frame that updates the mesh (if needed)
  51420. * @param xrFrame the current xrFrame
  51421. */
  51422. protected abstract _updateModel(xrFrame: XRFrame): void;
  51423. private _getGenericFilenameAndPath;
  51424. private _getGenericParentMesh;
  51425. }
  51426. }
  51427. declare module BABYLON {
  51428. /**
  51429. * A generic trigger-only motion controller for WebXR
  51430. */
  51431. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51432. /**
  51433. * Static version of the profile id of this controller
  51434. */
  51435. static ProfileId: string;
  51436. profileId: string;
  51437. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51438. protected _getFilenameAndPath(): {
  51439. filename: string;
  51440. path: string;
  51441. };
  51442. protected _getModelLoadingConstraints(): boolean;
  51443. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51444. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51445. protected _updateModel(): void;
  51446. }
  51447. }
  51448. declare module BABYLON {
  51449. /**
  51450. * Class containing static functions to help procedurally build meshes
  51451. */
  51452. export class SphereBuilder {
  51453. /**
  51454. * Creates a sphere mesh
  51455. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51456. * * 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`)
  51457. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51458. * * 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
  51459. * * 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)
  51460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51461. * * 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
  51462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51463. * @param name defines the name of the mesh
  51464. * @param options defines the options used to create the mesh
  51465. * @param scene defines the hosting scene
  51466. * @returns the sphere mesh
  51467. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51468. */
  51469. static CreateSphere(name: string, options: {
  51470. segments?: number;
  51471. diameter?: number;
  51472. diameterX?: number;
  51473. diameterY?: number;
  51474. diameterZ?: number;
  51475. arc?: number;
  51476. slice?: number;
  51477. sideOrientation?: number;
  51478. frontUVs?: Vector4;
  51479. backUVs?: Vector4;
  51480. updatable?: boolean;
  51481. }, scene?: Nullable<Scene>): Mesh;
  51482. }
  51483. }
  51484. declare module BABYLON {
  51485. /**
  51486. * A profiled motion controller has its profile loaded from an online repository.
  51487. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51488. */
  51489. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51490. private _repositoryUrl;
  51491. private _buttonMeshMapping;
  51492. private _touchDots;
  51493. /**
  51494. * The profile ID of this controller. Will be populated when the controller initializes.
  51495. */
  51496. profileId: string;
  51497. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51498. dispose(): void;
  51499. protected _getFilenameAndPath(): {
  51500. filename: string;
  51501. path: string;
  51502. };
  51503. protected _getModelLoadingConstraints(): boolean;
  51504. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51505. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51506. protected _updateModel(_xrFrame: XRFrame): void;
  51507. }
  51508. }
  51509. declare module BABYLON {
  51510. /**
  51511. * A construction function type to create a new controller based on an xrInput object
  51512. */
  51513. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51514. /**
  51515. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51516. *
  51517. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51518. * it should be replaced with auto-loaded controllers.
  51519. *
  51520. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51521. */
  51522. export class WebXRMotionControllerManager {
  51523. private static _AvailableControllers;
  51524. private static _Fallbacks;
  51525. private static _ProfileLoadingPromises;
  51526. private static _ProfilesList;
  51527. /**
  51528. * The base URL of the online controller repository. Can be changed at any time.
  51529. */
  51530. static BaseRepositoryUrl: string;
  51531. /**
  51532. * Which repository gets priority - local or online
  51533. */
  51534. static PrioritizeOnlineRepository: boolean;
  51535. /**
  51536. * Use the online repository, or use only locally-defined controllers
  51537. */
  51538. static UseOnlineRepository: boolean;
  51539. /**
  51540. * Clear the cache used for profile loading and reload when requested again
  51541. */
  51542. static ClearProfilesCache(): void;
  51543. /**
  51544. * Register the default fallbacks.
  51545. * This function is called automatically when this file is imported.
  51546. */
  51547. static DefaultFallbacks(): void;
  51548. /**
  51549. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51550. * @param profileId the profile to which a fallback needs to be found
  51551. * @return an array with corresponding fallback profiles
  51552. */
  51553. static FindFallbackWithProfileId(profileId: string): string[];
  51554. /**
  51555. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51556. * The order of search:
  51557. *
  51558. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51559. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51560. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51561. * 4) return the generic trigger controller if none were found
  51562. *
  51563. * @param xrInput the xrInput to which a new controller is initialized
  51564. * @param scene the scene to which the model will be added
  51565. * @param forceProfile force a certain profile for this controller
  51566. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51567. */
  51568. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51569. /**
  51570. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51571. *
  51572. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51573. *
  51574. * @param type the profile type to register
  51575. * @param constructFunction the function to be called when loading this profile
  51576. */
  51577. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51578. /**
  51579. * Register a fallback to a specific profile.
  51580. * @param profileId the profileId that will receive the fallbacks
  51581. * @param fallbacks A list of fallback profiles
  51582. */
  51583. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51584. /**
  51585. * Will update the list of profiles available in the repository
  51586. * @return a promise that resolves to a map of profiles available online
  51587. */
  51588. static UpdateProfilesList(): Promise<{
  51589. [profile: string]: string;
  51590. }>;
  51591. private static _LoadProfileFromRepository;
  51592. private static _LoadProfilesFromAvailableControllers;
  51593. }
  51594. }
  51595. declare module BABYLON {
  51596. /**
  51597. * Configuration options for the WebXR controller creation
  51598. */
  51599. export interface IWebXRControllerOptions {
  51600. /**
  51601. * Should the controller mesh be animated when a user interacts with it
  51602. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51603. */
  51604. disableMotionControllerAnimation?: boolean;
  51605. /**
  51606. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51607. */
  51608. doNotLoadControllerMesh?: boolean;
  51609. /**
  51610. * Force a specific controller type for this controller.
  51611. * This can be used when creating your own profile or when testing different controllers
  51612. */
  51613. forceControllerProfile?: string;
  51614. /**
  51615. * Defines a rendering group ID for meshes that will be loaded.
  51616. * This is for the default controllers only.
  51617. */
  51618. renderingGroupId?: number;
  51619. }
  51620. /**
  51621. * Represents an XR controller
  51622. */
  51623. export class WebXRInputSource {
  51624. private _scene;
  51625. /** The underlying input source for the controller */
  51626. inputSource: XRInputSource;
  51627. private _options;
  51628. private _tmpVector;
  51629. private _uniqueId;
  51630. private _disposed;
  51631. /**
  51632. * 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
  51633. */
  51634. grip?: AbstractMesh;
  51635. /**
  51636. * If available, this is the gamepad object related to this controller.
  51637. * Using this object it is possible to get click events and trackpad changes of the
  51638. * webxr controller that is currently being used.
  51639. */
  51640. motionController?: WebXRAbstractMotionController;
  51641. /**
  51642. * Event that fires when the controller is removed/disposed.
  51643. * The object provided as event data is this controller, after associated assets were disposed.
  51644. * uniqueId is still available.
  51645. */
  51646. onDisposeObservable: Observable<WebXRInputSource>;
  51647. /**
  51648. * Will be triggered when the mesh associated with the motion controller is done loading.
  51649. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51650. * A shortened version of controller -> motion controller -> on mesh loaded.
  51651. */
  51652. onMeshLoadedObservable: Observable<AbstractMesh>;
  51653. /**
  51654. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51655. */
  51656. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51657. /**
  51658. * Pointer which can be used to select objects or attach a visible laser to
  51659. */
  51660. pointer: AbstractMesh;
  51661. /**
  51662. * Creates the input source object
  51663. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51664. * @param _scene the scene which the controller should be associated to
  51665. * @param inputSource the underlying input source for the controller
  51666. * @param _options options for this controller creation
  51667. */
  51668. constructor(_scene: Scene,
  51669. /** The underlying input source for the controller */
  51670. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51671. /**
  51672. * Get this controllers unique id
  51673. */
  51674. get uniqueId(): string;
  51675. /**
  51676. * Disposes of the object
  51677. */
  51678. dispose(): void;
  51679. /**
  51680. * Gets a world space ray coming from the pointer or grip
  51681. * @param result the resulting ray
  51682. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51683. */
  51684. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51685. /**
  51686. * Updates the controller pose based on the given XRFrame
  51687. * @param xrFrame xr frame to update the pose with
  51688. * @param referenceSpace reference space to use
  51689. */
  51690. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51691. }
  51692. }
  51693. declare module BABYLON {
  51694. /**
  51695. * The schema for initialization options of the XR Input class
  51696. */
  51697. export interface IWebXRInputOptions {
  51698. /**
  51699. * If set to true no model will be automatically loaded
  51700. */
  51701. doNotLoadControllerMeshes?: boolean;
  51702. /**
  51703. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51704. * If not found, the xr input profile data will be used.
  51705. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51706. */
  51707. forceInputProfile?: string;
  51708. /**
  51709. * Do not send a request to the controller repository to load the profile.
  51710. *
  51711. * Instead, use the controllers available in babylon itself.
  51712. */
  51713. disableOnlineControllerRepository?: boolean;
  51714. /**
  51715. * A custom URL for the controllers repository
  51716. */
  51717. customControllersRepositoryURL?: string;
  51718. /**
  51719. * Should the controller model's components not move according to the user input
  51720. */
  51721. disableControllerAnimation?: boolean;
  51722. /**
  51723. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51724. */
  51725. controllerOptions?: IWebXRControllerOptions;
  51726. }
  51727. /**
  51728. * XR input used to track XR inputs such as controllers/rays
  51729. */
  51730. export class WebXRInput implements IDisposable {
  51731. /**
  51732. * the xr session manager for this session
  51733. */
  51734. xrSessionManager: WebXRSessionManager;
  51735. /**
  51736. * the WebXR camera for this session. Mainly used for teleportation
  51737. */
  51738. xrCamera: WebXRCamera;
  51739. private readonly options;
  51740. /**
  51741. * XR controllers being tracked
  51742. */
  51743. controllers: Array<WebXRInputSource>;
  51744. private _frameObserver;
  51745. private _sessionEndedObserver;
  51746. private _sessionInitObserver;
  51747. /**
  51748. * Event when a controller has been connected/added
  51749. */
  51750. onControllerAddedObservable: Observable<WebXRInputSource>;
  51751. /**
  51752. * Event when a controller has been removed/disconnected
  51753. */
  51754. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51755. /**
  51756. * Initializes the WebXRInput
  51757. * @param xrSessionManager the xr session manager for this session
  51758. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51759. * @param options = initialization options for this xr input
  51760. */
  51761. constructor(
  51762. /**
  51763. * the xr session manager for this session
  51764. */
  51765. xrSessionManager: WebXRSessionManager,
  51766. /**
  51767. * the WebXR camera for this session. Mainly used for teleportation
  51768. */
  51769. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51770. private _onInputSourcesChange;
  51771. private _addAndRemoveControllers;
  51772. /**
  51773. * Disposes of the object
  51774. */
  51775. dispose(): void;
  51776. }
  51777. }
  51778. declare module BABYLON {
  51779. /**
  51780. * This is the base class for all WebXR features.
  51781. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51782. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51783. */
  51784. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51785. protected _xrSessionManager: WebXRSessionManager;
  51786. private _attached;
  51787. private _removeOnDetach;
  51788. /**
  51789. * Is this feature disposed?
  51790. */
  51791. isDisposed: boolean;
  51792. /**
  51793. * Should auto-attach be disabled?
  51794. */
  51795. disableAutoAttach: boolean;
  51796. /**
  51797. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51798. */
  51799. xrNativeFeatureName: string;
  51800. /**
  51801. * Construct a new (abstract) WebXR feature
  51802. * @param _xrSessionManager the xr session manager for this feature
  51803. */
  51804. constructor(_xrSessionManager: WebXRSessionManager);
  51805. /**
  51806. * Is this feature attached
  51807. */
  51808. get attached(): boolean;
  51809. /**
  51810. * attach this feature
  51811. *
  51812. * @param force should attachment be forced (even when already attached)
  51813. * @returns true if successful, false is failed or already attached
  51814. */
  51815. attach(force?: boolean): boolean;
  51816. /**
  51817. * detach this feature.
  51818. *
  51819. * @returns true if successful, false if failed or already detached
  51820. */
  51821. detach(): boolean;
  51822. /**
  51823. * Dispose this feature and all of the resources attached
  51824. */
  51825. dispose(): void;
  51826. /**
  51827. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51828. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51829. *
  51830. * @returns whether or not the feature is compatible in this environment
  51831. */
  51832. isCompatible(): boolean;
  51833. /**
  51834. * This is used to register callbacks that will automatically be removed when detach is called.
  51835. * @param observable the observable to which the observer will be attached
  51836. * @param callback the callback to register
  51837. */
  51838. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51839. /**
  51840. * Code in this function will be executed on each xrFrame received from the browser.
  51841. * This function will not execute after the feature is detached.
  51842. * @param _xrFrame the current frame
  51843. */
  51844. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51845. }
  51846. }
  51847. declare module BABYLON {
  51848. /**
  51849. * Renders a layer on top of an existing scene
  51850. */
  51851. export class UtilityLayerRenderer implements IDisposable {
  51852. /** the original scene that will be rendered on top of */
  51853. originalScene: Scene;
  51854. private _pointerCaptures;
  51855. private _lastPointerEvents;
  51856. private static _DefaultUtilityLayer;
  51857. private static _DefaultKeepDepthUtilityLayer;
  51858. private _sharedGizmoLight;
  51859. private _renderCamera;
  51860. /**
  51861. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51862. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51863. * @returns the camera that is used when rendering the utility layer
  51864. */
  51865. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51866. /**
  51867. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51868. * @param cam the camera that should be used when rendering the utility layer
  51869. */
  51870. setRenderCamera(cam: Nullable<Camera>): void;
  51871. /**
  51872. * @hidden
  51873. * Light which used by gizmos to get light shading
  51874. */
  51875. _getSharedGizmoLight(): HemisphericLight;
  51876. /**
  51877. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51878. */
  51879. pickUtilitySceneFirst: boolean;
  51880. /**
  51881. * 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)
  51882. */
  51883. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51884. /**
  51885. * 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)
  51886. */
  51887. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51888. /**
  51889. * The scene that is rendered on top of the original scene
  51890. */
  51891. utilityLayerScene: Scene;
  51892. /**
  51893. * If the utility layer should automatically be rendered on top of existing scene
  51894. */
  51895. shouldRender: boolean;
  51896. /**
  51897. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51898. */
  51899. onlyCheckPointerDownEvents: boolean;
  51900. /**
  51901. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51902. */
  51903. processAllEvents: boolean;
  51904. /**
  51905. * Observable raised when the pointer move from the utility layer scene to the main scene
  51906. */
  51907. onPointerOutObservable: Observable<number>;
  51908. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51909. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51910. private _afterRenderObserver;
  51911. private _sceneDisposeObserver;
  51912. private _originalPointerObserver;
  51913. /**
  51914. * Instantiates a UtilityLayerRenderer
  51915. * @param originalScene the original scene that will be rendered on top of
  51916. * @param handleEvents boolean indicating if the utility layer should handle events
  51917. */
  51918. constructor(
  51919. /** the original scene that will be rendered on top of */
  51920. originalScene: Scene, handleEvents?: boolean);
  51921. private _notifyObservers;
  51922. /**
  51923. * Renders the utility layers scene on top of the original scene
  51924. */
  51925. render(): void;
  51926. /**
  51927. * Disposes of the renderer
  51928. */
  51929. dispose(): void;
  51930. private _updateCamera;
  51931. }
  51932. }
  51933. declare module BABYLON {
  51934. /**
  51935. * Options interface for the pointer selection module
  51936. */
  51937. export interface IWebXRControllerPointerSelectionOptions {
  51938. /**
  51939. * if provided, this scene will be used to render meshes.
  51940. */
  51941. customUtilityLayerScene?: Scene;
  51942. /**
  51943. * 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)
  51944. * If not disabled, the last picked point will be used to execute a pointer up event
  51945. * If disabled, pointer up event will be triggered right after the pointer down event.
  51946. * Used in screen and gaze target ray mode only
  51947. */
  51948. disablePointerUpOnTouchOut: boolean;
  51949. /**
  51950. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51951. */
  51952. forceGazeMode: boolean;
  51953. /**
  51954. * 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
  51955. * to start a new countdown to the pointer down event.
  51956. * Defaults to 1.
  51957. */
  51958. gazeModePointerMovedFactor?: number;
  51959. /**
  51960. * Different button type to use instead of the main component
  51961. */
  51962. overrideButtonId?: string;
  51963. /**
  51964. * use this rendering group id for the meshes (optional)
  51965. */
  51966. renderingGroupId?: number;
  51967. /**
  51968. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51969. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51970. * 3000 means 3 seconds between pointing at something and selecting it
  51971. */
  51972. timeToSelect?: number;
  51973. /**
  51974. * Should meshes created here be added to a utility layer or the main scene
  51975. */
  51976. useUtilityLayer?: boolean;
  51977. /**
  51978. * Optional WebXR camera to be used for gaze selection
  51979. */
  51980. gazeCamera?: WebXRCamera;
  51981. /**
  51982. * the xr input to use with this pointer selection
  51983. */
  51984. xrInput: WebXRInput;
  51985. /**
  51986. * Should the scene pointerX and pointerY update be disabled
  51987. * This is required for fullscreen AR GUI, but might slow down other experiences.
  51988. * Disable in VR, if not needed.
  51989. * The first rig camera (left eye) will be used to calculate the projection
  51990. */
  51991. disableScenePointerVectorUpdate: boolean;
  51992. /**
  51993. * Enable pointer selection on all controllers instead of switching between them
  51994. */
  51995. enablePointerSelectionOnAllControllers?: boolean;
  51996. /**
  51997. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  51998. * If switch is enabled, it will still allow the user to switch between the different controllers
  51999. */
  52000. preferredHandedness?: XRHandedness;
  52001. /**
  52002. * Disable switching the pointer selection from one controller to the other.
  52003. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52004. */
  52005. disableSwitchOnClick?: boolean;
  52006. /**
  52007. * The maximum distance of the pointer selection feature. Defaults to 100.
  52008. */
  52009. maxPointerDistance?: number;
  52010. }
  52011. /**
  52012. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52013. */
  52014. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52015. private readonly _options;
  52016. private static _idCounter;
  52017. private _attachController;
  52018. private _controllers;
  52019. private _scene;
  52020. private _tmpVectorForPickCompare;
  52021. private _attachedController;
  52022. /**
  52023. * The module's name
  52024. */
  52025. static readonly Name: string;
  52026. /**
  52027. * The (Babylon) version of this module.
  52028. * This is an integer representing the implementation version.
  52029. * This number does not correspond to the WebXR specs version
  52030. */
  52031. static readonly Version: number;
  52032. /**
  52033. * Disable lighting on the laser pointer (so it will always be visible)
  52034. */
  52035. disablePointerLighting: boolean;
  52036. /**
  52037. * Disable lighting on the selection mesh (so it will always be visible)
  52038. */
  52039. disableSelectionMeshLighting: boolean;
  52040. /**
  52041. * Should the laser pointer be displayed
  52042. */
  52043. displayLaserPointer: boolean;
  52044. /**
  52045. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52046. */
  52047. displaySelectionMesh: boolean;
  52048. /**
  52049. * This color will be set to the laser pointer when selection is triggered
  52050. */
  52051. laserPointerPickedColor: Color3;
  52052. /**
  52053. * Default color of the laser pointer
  52054. */
  52055. laserPointerDefaultColor: Color3;
  52056. /**
  52057. * default color of the selection ring
  52058. */
  52059. selectionMeshDefaultColor: Color3;
  52060. /**
  52061. * This color will be applied to the selection ring when selection is triggered
  52062. */
  52063. selectionMeshPickedColor: Color3;
  52064. /**
  52065. * Optional filter to be used for ray selection. This predicate shares behavior with
  52066. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52067. */
  52068. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52069. /**
  52070. * constructs a new background remover module
  52071. * @param _xrSessionManager the session manager for this module
  52072. * @param _options read-only options to be used in this module
  52073. */
  52074. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52075. /**
  52076. * attach this feature
  52077. * Will usually be called by the features manager
  52078. *
  52079. * @returns true if successful.
  52080. */
  52081. attach(): boolean;
  52082. /**
  52083. * detach this feature.
  52084. * Will usually be called by the features manager
  52085. *
  52086. * @returns true if successful.
  52087. */
  52088. detach(): boolean;
  52089. /**
  52090. * Will get the mesh under a specific pointer.
  52091. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52092. * @param controllerId the controllerId to check
  52093. * @returns The mesh under pointer or null if no mesh is under the pointer
  52094. */
  52095. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52096. /**
  52097. * Get the xr controller that correlates to the pointer id in the pointer event
  52098. *
  52099. * @param id the pointer id to search for
  52100. * @returns the controller that correlates to this id or null if not found
  52101. */
  52102. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52103. private _identityMatrix;
  52104. private _screenCoordinatesRef;
  52105. private _viewportRef;
  52106. protected _onXRFrame(_xrFrame: XRFrame): void;
  52107. private _attachGazeMode;
  52108. private _attachScreenRayMode;
  52109. private _attachTrackedPointerRayMode;
  52110. private _convertNormalToDirectionOfRay;
  52111. private _detachController;
  52112. private _generateNewMeshPair;
  52113. private _pickingMoved;
  52114. private _updatePointerDistance;
  52115. /** @hidden */
  52116. get lasterPointerDefaultColor(): Color3;
  52117. }
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * Button which can be used to enter a different mode of XR
  52122. */
  52123. export class WebXREnterExitUIButton {
  52124. /** button element */
  52125. element: HTMLElement;
  52126. /** XR initialization options for the button */
  52127. sessionMode: XRSessionMode;
  52128. /** Reference space type */
  52129. referenceSpaceType: XRReferenceSpaceType;
  52130. /**
  52131. * Creates a WebXREnterExitUIButton
  52132. * @param element button element
  52133. * @param sessionMode XR initialization session mode
  52134. * @param referenceSpaceType the type of reference space to be used
  52135. */
  52136. constructor(
  52137. /** button element */
  52138. element: HTMLElement,
  52139. /** XR initialization options for the button */
  52140. sessionMode: XRSessionMode,
  52141. /** Reference space type */
  52142. referenceSpaceType: XRReferenceSpaceType);
  52143. /**
  52144. * Extendable function which can be used to update the button's visuals when the state changes
  52145. * @param activeButton the current active button in the UI
  52146. */
  52147. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52148. }
  52149. /**
  52150. * Options to create the webXR UI
  52151. */
  52152. export class WebXREnterExitUIOptions {
  52153. /**
  52154. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52155. */
  52156. customButtons?: Array<WebXREnterExitUIButton>;
  52157. /**
  52158. * A reference space type to use when creating the default button.
  52159. * Default is local-floor
  52160. */
  52161. referenceSpaceType?: XRReferenceSpaceType;
  52162. /**
  52163. * Context to enter xr with
  52164. */
  52165. renderTarget?: Nullable<WebXRRenderTarget>;
  52166. /**
  52167. * A session mode to use when creating the default button.
  52168. * Default is immersive-vr
  52169. */
  52170. sessionMode?: XRSessionMode;
  52171. /**
  52172. * A list of optional features to init the session with
  52173. */
  52174. optionalFeatures?: string[];
  52175. /**
  52176. * A list of optional features to init the session with
  52177. */
  52178. requiredFeatures?: string[];
  52179. }
  52180. /**
  52181. * UI to allow the user to enter/exit XR mode
  52182. */
  52183. export class WebXREnterExitUI implements IDisposable {
  52184. private scene;
  52185. /** version of the options passed to this UI */
  52186. options: WebXREnterExitUIOptions;
  52187. private _activeButton;
  52188. private _buttons;
  52189. /**
  52190. * The HTML Div Element to which buttons are added.
  52191. */
  52192. readonly overlay: HTMLDivElement;
  52193. /**
  52194. * Fired every time the active button is changed.
  52195. *
  52196. * When xr is entered via a button that launches xr that button will be the callback parameter
  52197. *
  52198. * When exiting xr the callback parameter will be null)
  52199. */
  52200. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52201. /**
  52202. *
  52203. * @param scene babylon scene object to use
  52204. * @param options (read-only) version of the options passed to this UI
  52205. */
  52206. private constructor();
  52207. /**
  52208. * Creates UI to allow the user to enter/exit XR mode
  52209. * @param scene the scene to add the ui to
  52210. * @param helper the xr experience helper to enter/exit xr with
  52211. * @param options options to configure the UI
  52212. * @returns the created ui
  52213. */
  52214. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52215. /**
  52216. * Disposes of the XR UI component
  52217. */
  52218. dispose(): void;
  52219. private _updateButtons;
  52220. }
  52221. }
  52222. declare module BABYLON {
  52223. /**
  52224. * Class containing static functions to help procedurally build meshes
  52225. */
  52226. export class LinesBuilder {
  52227. /**
  52228. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52229. * * 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
  52230. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52231. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52232. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52233. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52234. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52235. * * 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
  52236. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52239. * @param name defines the name of the new line system
  52240. * @param options defines the options used to create the line system
  52241. * @param scene defines the hosting scene
  52242. * @returns a new line system mesh
  52243. */
  52244. static CreateLineSystem(name: string, options: {
  52245. lines: Vector3[][];
  52246. updatable?: boolean;
  52247. instance?: Nullable<LinesMesh>;
  52248. colors?: Nullable<Color4[][]>;
  52249. useVertexAlpha?: boolean;
  52250. }, scene: Nullable<Scene>): LinesMesh;
  52251. /**
  52252. * Creates a line mesh
  52253. * 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
  52254. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52255. * * The parameter `points` is an array successive Vector3
  52256. * * 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
  52257. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52258. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52259. * * When updating an instance, remember that only point positions can change, not the number of points
  52260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52262. * @param name defines the name of the new line system
  52263. * @param options defines the options used to create the line system
  52264. * @param scene defines the hosting scene
  52265. * @returns a new line mesh
  52266. */
  52267. static CreateLines(name: string, options: {
  52268. points: Vector3[];
  52269. updatable?: boolean;
  52270. instance?: Nullable<LinesMesh>;
  52271. colors?: Color4[];
  52272. useVertexAlpha?: boolean;
  52273. }, scene?: Nullable<Scene>): LinesMesh;
  52274. /**
  52275. * Creates a dashed line mesh
  52276. * * 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
  52277. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52278. * * The parameter `points` is an array successive Vector3
  52279. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52280. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52281. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52282. * * 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
  52283. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52284. * * When updating an instance, remember that only point positions can change, not the number of points
  52285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52286. * @param name defines the name of the mesh
  52287. * @param options defines the options used to create the mesh
  52288. * @param scene defines the hosting scene
  52289. * @returns the dashed line mesh
  52290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52291. */
  52292. static CreateDashedLines(name: string, options: {
  52293. points: Vector3[];
  52294. dashSize?: number;
  52295. gapSize?: number;
  52296. dashNb?: number;
  52297. updatable?: boolean;
  52298. instance?: LinesMesh;
  52299. useVertexAlpha?: boolean;
  52300. }, scene?: Nullable<Scene>): LinesMesh;
  52301. }
  52302. }
  52303. declare module BABYLON {
  52304. /**
  52305. * Construction options for a timer
  52306. */
  52307. export interface ITimerOptions<T> {
  52308. /**
  52309. * Time-to-end
  52310. */
  52311. timeout: number;
  52312. /**
  52313. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52314. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52315. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52316. */
  52317. contextObservable: Observable<T>;
  52318. /**
  52319. * Optional parameters when adding an observer to the observable
  52320. */
  52321. observableParameters?: {
  52322. mask?: number;
  52323. insertFirst?: boolean;
  52324. scope?: any;
  52325. };
  52326. /**
  52327. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52328. */
  52329. breakCondition?: (data?: ITimerData<T>) => boolean;
  52330. /**
  52331. * Will be triggered when the time condition has met
  52332. */
  52333. onEnded?: (data: ITimerData<any>) => void;
  52334. /**
  52335. * Will be triggered when the break condition has met (prematurely ended)
  52336. */
  52337. onAborted?: (data: ITimerData<any>) => void;
  52338. /**
  52339. * Optional function to execute on each tick (or count)
  52340. */
  52341. onTick?: (data: ITimerData<any>) => void;
  52342. }
  52343. /**
  52344. * An interface defining the data sent by the timer
  52345. */
  52346. export interface ITimerData<T> {
  52347. /**
  52348. * When did it start
  52349. */
  52350. startTime: number;
  52351. /**
  52352. * Time now
  52353. */
  52354. currentTime: number;
  52355. /**
  52356. * Time passed since started
  52357. */
  52358. deltaTime: number;
  52359. /**
  52360. * How much is completed, in [0.0...1.0].
  52361. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52362. */
  52363. completeRate: number;
  52364. /**
  52365. * What the registered observable sent in the last count
  52366. */
  52367. payload: T;
  52368. }
  52369. /**
  52370. * The current state of the timer
  52371. */
  52372. export enum TimerState {
  52373. /**
  52374. * Timer initialized, not yet started
  52375. */
  52376. INIT = 0,
  52377. /**
  52378. * Timer started and counting
  52379. */
  52380. STARTED = 1,
  52381. /**
  52382. * Timer ended (whether aborted or time reached)
  52383. */
  52384. ENDED = 2
  52385. }
  52386. /**
  52387. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52388. *
  52389. * @param options options with which to initialize this timer
  52390. */
  52391. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52392. /**
  52393. * An advanced implementation of a timer class
  52394. */
  52395. export class AdvancedTimer<T = any> implements IDisposable {
  52396. /**
  52397. * Will notify each time the timer calculates the remaining time
  52398. */
  52399. onEachCountObservable: Observable<ITimerData<T>>;
  52400. /**
  52401. * Will trigger when the timer was aborted due to the break condition
  52402. */
  52403. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52404. /**
  52405. * Will trigger when the timer ended successfully
  52406. */
  52407. onTimerEndedObservable: Observable<ITimerData<T>>;
  52408. /**
  52409. * Will trigger when the timer state has changed
  52410. */
  52411. onStateChangedObservable: Observable<TimerState>;
  52412. private _observer;
  52413. private _contextObservable;
  52414. private _observableParameters;
  52415. private _startTime;
  52416. private _timer;
  52417. private _state;
  52418. private _breakCondition;
  52419. private _timeToEnd;
  52420. private _breakOnNextTick;
  52421. /**
  52422. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52423. * @param options construction options for this advanced timer
  52424. */
  52425. constructor(options: ITimerOptions<T>);
  52426. /**
  52427. * set a breaking condition for this timer. Default is to never break during count
  52428. * @param predicate the new break condition. Returns true to break, false otherwise
  52429. */
  52430. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52431. /**
  52432. * Reset ALL associated observables in this advanced timer
  52433. */
  52434. clearObservables(): void;
  52435. /**
  52436. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52437. *
  52438. * @param timeToEnd how much time to measure until timer ended
  52439. */
  52440. start(timeToEnd?: number): void;
  52441. /**
  52442. * Will force a stop on the next tick.
  52443. */
  52444. stop(): void;
  52445. /**
  52446. * Dispose this timer, clearing all resources
  52447. */
  52448. dispose(): void;
  52449. private _setState;
  52450. private _tick;
  52451. private _stop;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /**
  52456. * The options container for the teleportation module
  52457. */
  52458. export interface IWebXRTeleportationOptions {
  52459. /**
  52460. * if provided, this scene will be used to render meshes.
  52461. */
  52462. customUtilityLayerScene?: Scene;
  52463. /**
  52464. * Values to configure the default target mesh
  52465. */
  52466. defaultTargetMeshOptions?: {
  52467. /**
  52468. * Fill color of the teleportation area
  52469. */
  52470. teleportationFillColor?: string;
  52471. /**
  52472. * Border color for the teleportation area
  52473. */
  52474. teleportationBorderColor?: string;
  52475. /**
  52476. * Disable the mesh's animation sequence
  52477. */
  52478. disableAnimation?: boolean;
  52479. /**
  52480. * Disable lighting on the material or the ring and arrow
  52481. */
  52482. disableLighting?: boolean;
  52483. /**
  52484. * Override the default material of the torus and arrow
  52485. */
  52486. torusArrowMaterial?: Material;
  52487. };
  52488. /**
  52489. * A list of meshes to use as floor meshes.
  52490. * Meshes can be added and removed after initializing the feature using the
  52491. * addFloorMesh and removeFloorMesh functions
  52492. * If empty, rotation will still work
  52493. */
  52494. floorMeshes?: AbstractMesh[];
  52495. /**
  52496. * use this rendering group id for the meshes (optional)
  52497. */
  52498. renderingGroupId?: number;
  52499. /**
  52500. * Should teleportation move only to snap points
  52501. */
  52502. snapPointsOnly?: boolean;
  52503. /**
  52504. * An array of points to which the teleportation will snap to.
  52505. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52506. */
  52507. snapPositions?: Vector3[];
  52508. /**
  52509. * How close should the teleportation ray be in order to snap to position.
  52510. * Default to 0.8 units (meters)
  52511. */
  52512. snapToPositionRadius?: number;
  52513. /**
  52514. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52515. * If you want to support rotation, make sure your mesh has a direction indicator.
  52516. *
  52517. * When left untouched, the default mesh will be initialized.
  52518. */
  52519. teleportationTargetMesh?: AbstractMesh;
  52520. /**
  52521. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52522. */
  52523. timeToTeleport?: number;
  52524. /**
  52525. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52526. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52527. */
  52528. useMainComponentOnly?: boolean;
  52529. /**
  52530. * Should meshes created here be added to a utility layer or the main scene
  52531. */
  52532. useUtilityLayer?: boolean;
  52533. /**
  52534. * Babylon XR Input class for controller
  52535. */
  52536. xrInput: WebXRInput;
  52537. /**
  52538. * Meshes that the teleportation ray cannot go through
  52539. */
  52540. pickBlockerMeshes?: AbstractMesh[];
  52541. }
  52542. /**
  52543. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52544. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52545. * the input of the attached controllers.
  52546. */
  52547. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52548. private _options;
  52549. private _controllers;
  52550. private _currentTeleportationControllerId;
  52551. private _floorMeshes;
  52552. private _quadraticBezierCurve;
  52553. private _selectionFeature;
  52554. private _snapToPositions;
  52555. private _snappedToPoint;
  52556. private _teleportationRingMaterial?;
  52557. private _tmpRay;
  52558. private _tmpVector;
  52559. private _tmpQuaternion;
  52560. /**
  52561. * The module's name
  52562. */
  52563. static readonly Name: string;
  52564. /**
  52565. * The (Babylon) version of this module.
  52566. * This is an integer representing the implementation version.
  52567. * This number does not correspond to the webxr specs version
  52568. */
  52569. static readonly Version: number;
  52570. /**
  52571. * Is movement backwards enabled
  52572. */
  52573. backwardsMovementEnabled: boolean;
  52574. /**
  52575. * Distance to travel when moving backwards
  52576. */
  52577. backwardsTeleportationDistance: number;
  52578. /**
  52579. * The distance from the user to the inspection point in the direction of the controller
  52580. * A higher number will allow the user to move further
  52581. * defaults to 5 (meters, in xr units)
  52582. */
  52583. parabolicCheckRadius: number;
  52584. /**
  52585. * Should the module support parabolic ray on top of direct ray
  52586. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52587. * Very helpful when moving between floors / different heights
  52588. */
  52589. parabolicRayEnabled: boolean;
  52590. /**
  52591. * How much rotation should be applied when rotating right and left
  52592. */
  52593. rotationAngle: number;
  52594. /**
  52595. * Is rotation enabled when moving forward?
  52596. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52597. */
  52598. rotationEnabled: boolean;
  52599. /**
  52600. * constructs a new anchor system
  52601. * @param _xrSessionManager an instance of WebXRSessionManager
  52602. * @param _options configuration object for this feature
  52603. */
  52604. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52605. /**
  52606. * Get the snapPointsOnly flag
  52607. */
  52608. get snapPointsOnly(): boolean;
  52609. /**
  52610. * Sets the snapPointsOnly flag
  52611. * @param snapToPoints should teleportation be exclusively to snap points
  52612. */
  52613. set snapPointsOnly(snapToPoints: boolean);
  52614. /**
  52615. * Add a new mesh to the floor meshes array
  52616. * @param mesh the mesh to use as floor mesh
  52617. */
  52618. addFloorMesh(mesh: AbstractMesh): void;
  52619. /**
  52620. * Add a new snap-to point to fix teleportation to this position
  52621. * @param newSnapPoint The new Snap-To point
  52622. */
  52623. addSnapPoint(newSnapPoint: Vector3): void;
  52624. attach(): boolean;
  52625. detach(): boolean;
  52626. dispose(): void;
  52627. /**
  52628. * Remove a mesh from the floor meshes array
  52629. * @param mesh the mesh to remove
  52630. */
  52631. removeFloorMesh(mesh: AbstractMesh): void;
  52632. /**
  52633. * Remove a mesh from the floor meshes array using its name
  52634. * @param name the mesh name to remove
  52635. */
  52636. removeFloorMeshByName(name: string): void;
  52637. /**
  52638. * 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
  52639. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52640. * @returns was the point found and removed or not
  52641. */
  52642. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52643. /**
  52644. * This function sets a selection feature that will be disabled when
  52645. * the forward ray is shown and will be reattached when hidden.
  52646. * This is used to remove the selection rays when moving.
  52647. * @param selectionFeature the feature to disable when forward movement is enabled
  52648. */
  52649. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52650. protected _onXRFrame(_xrFrame: XRFrame): void;
  52651. private _attachController;
  52652. private _createDefaultTargetMesh;
  52653. private _detachController;
  52654. private _findClosestSnapPointWithRadius;
  52655. private _setTargetMeshPosition;
  52656. private _setTargetMeshVisibility;
  52657. private _showParabolicPath;
  52658. private _teleportForward;
  52659. }
  52660. }
  52661. declare module BABYLON {
  52662. /**
  52663. * Options for the default xr helper
  52664. */
  52665. export class WebXRDefaultExperienceOptions {
  52666. /**
  52667. * Enable or disable default UI to enter XR
  52668. */
  52669. disableDefaultUI?: boolean;
  52670. /**
  52671. * Should teleportation not initialize. defaults to false.
  52672. */
  52673. disableTeleportation?: boolean;
  52674. /**
  52675. * Floor meshes that will be used for teleport
  52676. */
  52677. floorMeshes?: Array<AbstractMesh>;
  52678. /**
  52679. * If set to true, the first frame will not be used to reset position
  52680. * The first frame is mainly used when copying transformation from the old camera
  52681. * Mainly used in AR
  52682. */
  52683. ignoreNativeCameraTransformation?: boolean;
  52684. /**
  52685. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52686. */
  52687. inputOptions?: IWebXRInputOptions;
  52688. /**
  52689. * optional configuration for the output canvas
  52690. */
  52691. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52692. /**
  52693. * optional UI options. This can be used among other to change session mode and reference space type
  52694. */
  52695. uiOptions?: WebXREnterExitUIOptions;
  52696. /**
  52697. * When loading teleportation and pointer select, use stable versions instead of latest.
  52698. */
  52699. useStablePlugins?: boolean;
  52700. /**
  52701. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52702. */
  52703. renderingGroupId?: number;
  52704. /**
  52705. * A list of optional features to init the session with
  52706. * If set to true, all features we support will be added
  52707. */
  52708. optionalFeatures?: boolean | string[];
  52709. }
  52710. /**
  52711. * Default experience which provides a similar setup to the previous webVRExperience
  52712. */
  52713. export class WebXRDefaultExperience {
  52714. /**
  52715. * Base experience
  52716. */
  52717. baseExperience: WebXRExperienceHelper;
  52718. /**
  52719. * Enables ui for entering/exiting xr
  52720. */
  52721. enterExitUI: WebXREnterExitUI;
  52722. /**
  52723. * Input experience extension
  52724. */
  52725. input: WebXRInput;
  52726. /**
  52727. * Enables laser pointer and selection
  52728. */
  52729. pointerSelection: WebXRControllerPointerSelection;
  52730. /**
  52731. * Default target xr should render to
  52732. */
  52733. renderTarget: WebXRRenderTarget;
  52734. /**
  52735. * Enables teleportation
  52736. */
  52737. teleportation: WebXRMotionControllerTeleportation;
  52738. private constructor();
  52739. /**
  52740. * Creates the default xr experience
  52741. * @param scene scene
  52742. * @param options options for basic configuration
  52743. * @returns resulting WebXRDefaultExperience
  52744. */
  52745. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52746. /**
  52747. * DIsposes of the experience helper
  52748. */
  52749. dispose(): void;
  52750. }
  52751. }
  52752. declare module BABYLON {
  52753. /**
  52754. * Options to modify the vr teleportation behavior.
  52755. */
  52756. export interface VRTeleportationOptions {
  52757. /**
  52758. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52759. */
  52760. floorMeshName?: string;
  52761. /**
  52762. * A list of meshes to be used as the teleportation floor. (default: empty)
  52763. */
  52764. floorMeshes?: Mesh[];
  52765. /**
  52766. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52767. */
  52768. teleportationMode?: number;
  52769. /**
  52770. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52771. */
  52772. teleportationTime?: number;
  52773. /**
  52774. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52775. */
  52776. teleportationSpeed?: number;
  52777. /**
  52778. * The easing function used in the animation or null for Linear. (default CircleEase)
  52779. */
  52780. easingFunction?: EasingFunction;
  52781. }
  52782. /**
  52783. * Options to modify the vr experience helper's behavior.
  52784. */
  52785. export interface VRExperienceHelperOptions extends WebVROptions {
  52786. /**
  52787. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52788. */
  52789. createDeviceOrientationCamera?: boolean;
  52790. /**
  52791. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52792. */
  52793. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52794. /**
  52795. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52796. */
  52797. laserToggle?: boolean;
  52798. /**
  52799. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52800. */
  52801. floorMeshes?: Mesh[];
  52802. /**
  52803. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52804. */
  52805. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52806. /**
  52807. * Defines if WebXR should be used instead of WebVR (if available)
  52808. */
  52809. useXR?: boolean;
  52810. }
  52811. /**
  52812. * Event containing information after VR has been entered
  52813. */
  52814. export class OnAfterEnteringVRObservableEvent {
  52815. /**
  52816. * If entering vr was successful
  52817. */
  52818. success: boolean;
  52819. }
  52820. /**
  52821. * Helps to quickly add VR support to an existing scene.
  52822. * See https://doc.babylonjs.com/how_to/webvr_helper
  52823. */
  52824. export class VRExperienceHelper {
  52825. /** Options to modify the vr experience helper's behavior. */
  52826. webVROptions: VRExperienceHelperOptions;
  52827. private _scene;
  52828. private _position;
  52829. private _btnVR;
  52830. private _btnVRDisplayed;
  52831. private _webVRsupported;
  52832. private _webVRready;
  52833. private _webVRrequesting;
  52834. private _webVRpresenting;
  52835. private _hasEnteredVR;
  52836. private _fullscreenVRpresenting;
  52837. private _inputElement;
  52838. private _webVRCamera;
  52839. private _vrDeviceOrientationCamera;
  52840. private _deviceOrientationCamera;
  52841. private _existingCamera;
  52842. private _onKeyDown;
  52843. private _onVrDisplayPresentChange;
  52844. private _onVRDisplayChanged;
  52845. private _onVRRequestPresentStart;
  52846. private _onVRRequestPresentComplete;
  52847. /**
  52848. * 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)
  52849. */
  52850. enableGazeEvenWhenNoPointerLock: boolean;
  52851. /**
  52852. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52853. */
  52854. exitVROnDoubleTap: boolean;
  52855. /**
  52856. * Observable raised right before entering VR.
  52857. */
  52858. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52859. /**
  52860. * Observable raised when entering VR has completed.
  52861. */
  52862. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52863. /**
  52864. * Observable raised when exiting VR.
  52865. */
  52866. onExitingVRObservable: Observable<VRExperienceHelper>;
  52867. /**
  52868. * Observable raised when controller mesh is loaded.
  52869. */
  52870. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52871. /** Return this.onEnteringVRObservable
  52872. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52873. */
  52874. get onEnteringVR(): Observable<VRExperienceHelper>;
  52875. /** Return this.onExitingVRObservable
  52876. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52877. */
  52878. get onExitingVR(): Observable<VRExperienceHelper>;
  52879. /** Return this.onControllerMeshLoadedObservable
  52880. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52881. */
  52882. get onControllerMeshLoaded(): Observable<WebVRController>;
  52883. private _rayLength;
  52884. private _useCustomVRButton;
  52885. private _teleportationRequested;
  52886. private _teleportActive;
  52887. private _floorMeshName;
  52888. private _floorMeshesCollection;
  52889. private _teleportationMode;
  52890. private _teleportationTime;
  52891. private _teleportationSpeed;
  52892. private _teleportationEasing;
  52893. private _rotationAllowed;
  52894. private _teleportBackwardsVector;
  52895. private _teleportationTarget;
  52896. private _isDefaultTeleportationTarget;
  52897. private _postProcessMove;
  52898. private _teleportationFillColor;
  52899. private _teleportationBorderColor;
  52900. private _rotationAngle;
  52901. private _haloCenter;
  52902. private _cameraGazer;
  52903. private _padSensibilityUp;
  52904. private _padSensibilityDown;
  52905. private _leftController;
  52906. private _rightController;
  52907. private _gazeColor;
  52908. private _laserColor;
  52909. private _pickedLaserColor;
  52910. private _pickedGazeColor;
  52911. /**
  52912. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52913. */
  52914. onNewMeshSelected: Observable<AbstractMesh>;
  52915. /**
  52916. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52917. * This observable will provide the mesh and the controller used to select the mesh
  52918. */
  52919. onMeshSelectedWithController: Observable<{
  52920. mesh: AbstractMesh;
  52921. controller: WebVRController;
  52922. }>;
  52923. /**
  52924. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52925. */
  52926. onNewMeshPicked: Observable<PickingInfo>;
  52927. private _circleEase;
  52928. /**
  52929. * Observable raised before camera teleportation
  52930. */
  52931. onBeforeCameraTeleport: Observable<Vector3>;
  52932. /**
  52933. * Observable raised after camera teleportation
  52934. */
  52935. onAfterCameraTeleport: Observable<Vector3>;
  52936. /**
  52937. * Observable raised when current selected mesh gets unselected
  52938. */
  52939. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52940. private _raySelectionPredicate;
  52941. /**
  52942. * To be optionaly changed by user to define custom ray selection
  52943. */
  52944. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52945. /**
  52946. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52947. */
  52948. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52949. /**
  52950. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52951. */
  52952. teleportationEnabled: boolean;
  52953. private _defaultHeight;
  52954. private _teleportationInitialized;
  52955. private _interactionsEnabled;
  52956. private _interactionsRequested;
  52957. private _displayGaze;
  52958. private _displayLaserPointer;
  52959. /**
  52960. * The mesh used to display where the user is going to teleport.
  52961. */
  52962. get teleportationTarget(): Mesh;
  52963. /**
  52964. * Sets the mesh to be used to display where the user is going to teleport.
  52965. */
  52966. set teleportationTarget(value: Mesh);
  52967. /**
  52968. * 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
  52969. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52970. * See https://doc.babylonjs.com/resources/baking_transformations
  52971. */
  52972. get gazeTrackerMesh(): Mesh;
  52973. set gazeTrackerMesh(value: Mesh);
  52974. /**
  52975. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52976. */
  52977. updateGazeTrackerScale: boolean;
  52978. /**
  52979. * If the gaze trackers color should be updated when selecting meshes
  52980. */
  52981. updateGazeTrackerColor: boolean;
  52982. /**
  52983. * If the controller laser color should be updated when selecting meshes
  52984. */
  52985. updateControllerLaserColor: boolean;
  52986. /**
  52987. * The gaze tracking mesh corresponding to the left controller
  52988. */
  52989. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52990. /**
  52991. * The gaze tracking mesh corresponding to the right controller
  52992. */
  52993. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52994. /**
  52995. * If the ray of the gaze should be displayed.
  52996. */
  52997. get displayGaze(): boolean;
  52998. /**
  52999. * Sets if the ray of the gaze should be displayed.
  53000. */
  53001. set displayGaze(value: boolean);
  53002. /**
  53003. * If the ray of the LaserPointer should be displayed.
  53004. */
  53005. get displayLaserPointer(): boolean;
  53006. /**
  53007. * Sets if the ray of the LaserPointer should be displayed.
  53008. */
  53009. set displayLaserPointer(value: boolean);
  53010. /**
  53011. * The deviceOrientationCamera used as the camera when not in VR.
  53012. */
  53013. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53014. /**
  53015. * Based on the current WebVR support, returns the current VR camera used.
  53016. */
  53017. get currentVRCamera(): Nullable<Camera>;
  53018. /**
  53019. * The webVRCamera which is used when in VR.
  53020. */
  53021. get webVRCamera(): WebVRFreeCamera;
  53022. /**
  53023. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53024. */
  53025. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53026. /**
  53027. * The html button that is used to trigger entering into VR.
  53028. */
  53029. get vrButton(): Nullable<HTMLButtonElement>;
  53030. private get _teleportationRequestInitiated();
  53031. /**
  53032. * Defines whether or not Pointer lock should be requested when switching to
  53033. * full screen.
  53034. */
  53035. requestPointerLockOnFullScreen: boolean;
  53036. /**
  53037. * If asking to force XR, this will be populated with the default xr experience
  53038. */
  53039. xr: WebXRDefaultExperience;
  53040. /**
  53041. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53042. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53043. */
  53044. xrTestDone: boolean;
  53045. /**
  53046. * Instantiates a VRExperienceHelper.
  53047. * Helps to quickly add VR support to an existing scene.
  53048. * @param scene The scene the VRExperienceHelper belongs to.
  53049. * @param webVROptions Options to modify the vr experience helper's behavior.
  53050. */
  53051. constructor(scene: Scene,
  53052. /** Options to modify the vr experience helper's behavior. */
  53053. webVROptions?: VRExperienceHelperOptions);
  53054. private completeVRInit;
  53055. private _onDefaultMeshLoaded;
  53056. private _onResize;
  53057. private _onFullscreenChange;
  53058. /**
  53059. * Gets a value indicating if we are currently in VR mode.
  53060. */
  53061. get isInVRMode(): boolean;
  53062. private onVrDisplayPresentChange;
  53063. private onVRDisplayChanged;
  53064. private moveButtonToBottomRight;
  53065. private displayVRButton;
  53066. private updateButtonVisibility;
  53067. private _cachedAngularSensibility;
  53068. /**
  53069. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53070. * Otherwise, will use the fullscreen API.
  53071. */
  53072. enterVR(): void;
  53073. /**
  53074. * Attempt to exit VR, or fullscreen.
  53075. */
  53076. exitVR(): void;
  53077. /**
  53078. * The position of the vr experience helper.
  53079. */
  53080. get position(): Vector3;
  53081. /**
  53082. * Sets the position of the vr experience helper.
  53083. */
  53084. set position(value: Vector3);
  53085. /**
  53086. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53087. */
  53088. enableInteractions(): void;
  53089. private get _noControllerIsActive();
  53090. private beforeRender;
  53091. private _isTeleportationFloor;
  53092. /**
  53093. * Adds a floor mesh to be used for teleportation.
  53094. * @param floorMesh the mesh to be used for teleportation.
  53095. */
  53096. addFloorMesh(floorMesh: Mesh): void;
  53097. /**
  53098. * Removes a floor mesh from being used for teleportation.
  53099. * @param floorMesh the mesh to be removed.
  53100. */
  53101. removeFloorMesh(floorMesh: Mesh): void;
  53102. /**
  53103. * Enables interactions and teleportation using the VR controllers and gaze.
  53104. * @param vrTeleportationOptions options to modify teleportation behavior.
  53105. */
  53106. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53107. private _onNewGamepadConnected;
  53108. private _tryEnableInteractionOnController;
  53109. private _onNewGamepadDisconnected;
  53110. private _enableInteractionOnController;
  53111. private _checkTeleportWithRay;
  53112. private _checkRotate;
  53113. private _checkTeleportBackwards;
  53114. private _enableTeleportationOnController;
  53115. private _createTeleportationCircles;
  53116. private _displayTeleportationTarget;
  53117. private _hideTeleportationTarget;
  53118. private _rotateCamera;
  53119. private _moveTeleportationSelectorTo;
  53120. private _workingVector;
  53121. private _workingQuaternion;
  53122. private _workingMatrix;
  53123. /**
  53124. * Time Constant Teleportation Mode
  53125. */
  53126. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53127. /**
  53128. * Speed Constant Teleportation Mode
  53129. */
  53130. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53131. /**
  53132. * Teleports the users feet to the desired location
  53133. * @param location The location where the user's feet should be placed
  53134. */
  53135. teleportCamera(location: Vector3): void;
  53136. private _convertNormalToDirectionOfRay;
  53137. private _castRayAndSelectObject;
  53138. private _notifySelectedMeshUnselected;
  53139. /**
  53140. * Permanently set new colors for the laser pointer
  53141. * @param color the new laser color
  53142. * @param pickedColor the new laser color when picked mesh detected
  53143. */
  53144. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53145. /**
  53146. * Set lighting enabled / disabled on the laser pointer of both controllers
  53147. * @param enabled should the lighting be enabled on the laser pointer
  53148. */
  53149. setLaserLightingState(enabled?: boolean): void;
  53150. /**
  53151. * Permanently set new colors for the gaze pointer
  53152. * @param color the new gaze color
  53153. * @param pickedColor the new gaze color when picked mesh detected
  53154. */
  53155. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53156. /**
  53157. * Sets the color of the laser ray from the vr controllers.
  53158. * @param color new color for the ray.
  53159. */
  53160. changeLaserColor(color: Color3): void;
  53161. /**
  53162. * Sets the color of the ray from the vr headsets gaze.
  53163. * @param color new color for the ray.
  53164. */
  53165. changeGazeColor(color: Color3): void;
  53166. /**
  53167. * Exits VR and disposes of the vr experience helper
  53168. */
  53169. dispose(): void;
  53170. /**
  53171. * Gets the name of the VRExperienceHelper class
  53172. * @returns "VRExperienceHelper"
  53173. */
  53174. getClassName(): string;
  53175. }
  53176. }
  53177. declare module BABYLON {
  53178. /**
  53179. * Contains an array of blocks representing the octree
  53180. */
  53181. export interface IOctreeContainer<T> {
  53182. /**
  53183. * Blocks within the octree
  53184. */
  53185. blocks: Array<OctreeBlock<T>>;
  53186. }
  53187. /**
  53188. * Class used to store a cell in an octree
  53189. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53190. */
  53191. export class OctreeBlock<T> {
  53192. /**
  53193. * Gets the content of the current block
  53194. */
  53195. entries: T[];
  53196. /**
  53197. * Gets the list of block children
  53198. */
  53199. blocks: Array<OctreeBlock<T>>;
  53200. private _depth;
  53201. private _maxDepth;
  53202. private _capacity;
  53203. private _minPoint;
  53204. private _maxPoint;
  53205. private _boundingVectors;
  53206. private _creationFunc;
  53207. /**
  53208. * Creates a new block
  53209. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53210. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53211. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53212. * @param depth defines the current depth of this block in the octree
  53213. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53214. * @param creationFunc defines a callback to call when an element is added to the block
  53215. */
  53216. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53217. /**
  53218. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53219. */
  53220. get capacity(): number;
  53221. /**
  53222. * Gets the minimum vector (in world space) of the block's bounding box
  53223. */
  53224. get minPoint(): Vector3;
  53225. /**
  53226. * Gets the maximum vector (in world space) of the block's bounding box
  53227. */
  53228. get maxPoint(): Vector3;
  53229. /**
  53230. * Add a new element to this block
  53231. * @param entry defines the element to add
  53232. */
  53233. addEntry(entry: T): void;
  53234. /**
  53235. * Remove an element from this block
  53236. * @param entry defines the element to remove
  53237. */
  53238. removeEntry(entry: T): void;
  53239. /**
  53240. * Add an array of elements to this block
  53241. * @param entries defines the array of elements to add
  53242. */
  53243. addEntries(entries: T[]): void;
  53244. /**
  53245. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53246. * @param frustumPlanes defines the frustum planes to test
  53247. * @param selection defines the array to store current content if selection is positive
  53248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53249. */
  53250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53251. /**
  53252. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53253. * @param sphereCenter defines the bounding sphere center
  53254. * @param sphereRadius defines the bounding sphere radius
  53255. * @param selection defines the array to store current content if selection is positive
  53256. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53257. */
  53258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53259. /**
  53260. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53261. * @param ray defines the ray to test with
  53262. * @param selection defines the array to store current content if selection is positive
  53263. */
  53264. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53265. /**
  53266. * Subdivide the content into child blocks (this block will then be empty)
  53267. */
  53268. createInnerBlocks(): void;
  53269. /**
  53270. * @hidden
  53271. */
  53272. 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;
  53273. }
  53274. }
  53275. declare module BABYLON {
  53276. /**
  53277. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53279. */
  53280. export class Octree<T> {
  53281. /** 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.) */
  53282. maxDepth: number;
  53283. /**
  53284. * Blocks within the octree containing objects
  53285. */
  53286. blocks: Array<OctreeBlock<T>>;
  53287. /**
  53288. * Content stored in the octree
  53289. */
  53290. dynamicContent: T[];
  53291. private _maxBlockCapacity;
  53292. private _selectionContent;
  53293. private _creationFunc;
  53294. /**
  53295. * Creates a octree
  53296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53297. * @param creationFunc function to be used to instatiate the octree
  53298. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53299. * @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.)
  53300. */
  53301. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53302. /** 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.) */
  53303. maxDepth?: number);
  53304. /**
  53305. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53306. * @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);
  53307. * @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);
  53308. * @param entries meshes to be added to the octree blocks
  53309. */
  53310. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53311. /**
  53312. * Adds a mesh to the octree
  53313. * @param entry Mesh to add to the octree
  53314. */
  53315. addMesh(entry: T): void;
  53316. /**
  53317. * Remove an element from the octree
  53318. * @param entry defines the element to remove
  53319. */
  53320. removeMesh(entry: T): void;
  53321. /**
  53322. * Selects an array of meshes within the frustum
  53323. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53324. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53325. * @returns array of meshes within the frustum
  53326. */
  53327. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53328. /**
  53329. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53330. * @param sphereCenter defines the bounding sphere center
  53331. * @param sphereRadius defines the bounding sphere radius
  53332. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53333. * @returns an array of objects that intersect the sphere
  53334. */
  53335. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53336. /**
  53337. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53338. * @param ray defines the ray to test with
  53339. * @returns array of intersected objects
  53340. */
  53341. intersectsRay(ray: Ray): SmartArray<T>;
  53342. /**
  53343. * Adds a mesh into the octree block if it intersects the block
  53344. */
  53345. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53346. /**
  53347. * Adds a submesh into the octree block if it intersects the block
  53348. */
  53349. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53350. }
  53351. }
  53352. declare module BABYLON {
  53353. interface Scene {
  53354. /**
  53355. * @hidden
  53356. * Backing Filed
  53357. */
  53358. _selectionOctree: Octree<AbstractMesh>;
  53359. /**
  53360. * Gets the octree used to boost mesh selection (picking)
  53361. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53362. */
  53363. selectionOctree: Octree<AbstractMesh>;
  53364. /**
  53365. * Creates or updates the octree used to boost selection (picking)
  53366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53367. * @param maxCapacity defines the maximum capacity per leaf
  53368. * @param maxDepth defines the maximum depth of the octree
  53369. * @returns an octree of AbstractMesh
  53370. */
  53371. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53372. }
  53373. interface AbstractMesh {
  53374. /**
  53375. * @hidden
  53376. * Backing Field
  53377. */
  53378. _submeshesOctree: Octree<SubMesh>;
  53379. /**
  53380. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53381. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53382. * @param maxCapacity defines the maximum size of each block (64 by default)
  53383. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53384. * @returns the new octree
  53385. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53386. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53387. */
  53388. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53389. }
  53390. /**
  53391. * Defines the octree scene component responsible to manage any octrees
  53392. * in a given scene.
  53393. */
  53394. export class OctreeSceneComponent {
  53395. /**
  53396. * The component name help to identify the component in the list of scene components.
  53397. */
  53398. readonly name: string;
  53399. /**
  53400. * The scene the component belongs to.
  53401. */
  53402. scene: Scene;
  53403. /**
  53404. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53405. */
  53406. readonly checksIsEnabled: boolean;
  53407. /**
  53408. * Creates a new instance of the component for the given scene
  53409. * @param scene Defines the scene to register the component in
  53410. */
  53411. constructor(scene: Scene);
  53412. /**
  53413. * Registers the component in a given scene
  53414. */
  53415. register(): void;
  53416. /**
  53417. * Return the list of active meshes
  53418. * @returns the list of active meshes
  53419. */
  53420. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53421. /**
  53422. * Return the list of active sub meshes
  53423. * @param mesh The mesh to get the candidates sub meshes from
  53424. * @returns the list of active sub meshes
  53425. */
  53426. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53427. private _tempRay;
  53428. /**
  53429. * Return the list of sub meshes intersecting with a given local ray
  53430. * @param mesh defines the mesh to find the submesh for
  53431. * @param localRay defines the ray in local space
  53432. * @returns the list of intersecting sub meshes
  53433. */
  53434. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53435. /**
  53436. * Return the list of sub meshes colliding with a collider
  53437. * @param mesh defines the mesh to find the submesh for
  53438. * @param collider defines the collider to evaluate the collision against
  53439. * @returns the list of colliding sub meshes
  53440. */
  53441. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53442. /**
  53443. * Rebuilds the elements related to this component in case of
  53444. * context lost for instance.
  53445. */
  53446. rebuild(): void;
  53447. /**
  53448. * Disposes the component and the associated ressources.
  53449. */
  53450. dispose(): void;
  53451. }
  53452. }
  53453. declare module BABYLON {
  53454. /**
  53455. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53456. */
  53457. export class Gizmo implements IDisposable {
  53458. /** The utility layer the gizmo will be added to */
  53459. gizmoLayer: UtilityLayerRenderer;
  53460. /**
  53461. * The root mesh of the gizmo
  53462. */
  53463. _rootMesh: Mesh;
  53464. private _attachedMesh;
  53465. private _attachedNode;
  53466. /**
  53467. * Ratio for the scale of the gizmo (Default: 1)
  53468. */
  53469. protected _scaleRatio: number;
  53470. /**
  53471. * boolean updated by pointermove when a gizmo mesh is hovered
  53472. */
  53473. protected _isHovered: boolean;
  53474. /**
  53475. * Ratio for the scale of the gizmo (Default: 1)
  53476. */
  53477. set scaleRatio(value: number);
  53478. get scaleRatio(): number;
  53479. /**
  53480. * True when the mouse pointer is hovered a gizmo mesh
  53481. */
  53482. get isHovered(): boolean;
  53483. /**
  53484. * If a custom mesh has been set (Default: false)
  53485. */
  53486. protected _customMeshSet: boolean;
  53487. /**
  53488. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53489. * * When set, interactions will be enabled
  53490. */
  53491. get attachedMesh(): Nullable<AbstractMesh>;
  53492. set attachedMesh(value: Nullable<AbstractMesh>);
  53493. /**
  53494. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53495. * * When set, interactions will be enabled
  53496. */
  53497. get attachedNode(): Nullable<Node>;
  53498. set attachedNode(value: Nullable<Node>);
  53499. /**
  53500. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53501. * @param mesh The mesh to replace the default mesh of the gizmo
  53502. */
  53503. setCustomMesh(mesh: Mesh): void;
  53504. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53505. /**
  53506. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53507. */
  53508. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53509. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53510. /**
  53511. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53512. */
  53513. updateGizmoPositionToMatchAttachedMesh: boolean;
  53514. /**
  53515. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53516. */
  53517. updateScale: boolean;
  53518. protected _interactionsEnabled: boolean;
  53519. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53520. private _beforeRenderObserver;
  53521. private _tempQuaternion;
  53522. private _tempVector;
  53523. private _tempVector2;
  53524. private _tempMatrix1;
  53525. private _tempMatrix2;
  53526. private _rightHandtoLeftHandMatrix;
  53527. /**
  53528. * Creates a gizmo
  53529. * @param gizmoLayer The utility layer the gizmo will be added to
  53530. */
  53531. constructor(
  53532. /** The utility layer the gizmo will be added to */
  53533. gizmoLayer?: UtilityLayerRenderer);
  53534. /**
  53535. * Updates the gizmo to match the attached mesh's position/rotation
  53536. */
  53537. protected _update(): void;
  53538. /**
  53539. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53540. * @param value Node, TransformNode or mesh
  53541. */
  53542. protected _matrixChanged(): void;
  53543. /**
  53544. * Disposes of the gizmo
  53545. */
  53546. dispose(): void;
  53547. }
  53548. }
  53549. declare module BABYLON {
  53550. /**
  53551. * Single plane drag gizmo
  53552. */
  53553. export class PlaneDragGizmo extends Gizmo {
  53554. /**
  53555. * Drag behavior responsible for the gizmos dragging interactions
  53556. */
  53557. dragBehavior: PointerDragBehavior;
  53558. private _pointerObserver;
  53559. /**
  53560. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53561. */
  53562. snapDistance: number;
  53563. /**
  53564. * Event that fires each time the gizmo snaps to a new location.
  53565. * * snapDistance is the the change in distance
  53566. */
  53567. onSnapObservable: Observable<{
  53568. snapDistance: number;
  53569. }>;
  53570. private _plane;
  53571. private _coloredMaterial;
  53572. private _hoverMaterial;
  53573. private _isEnabled;
  53574. private _parent;
  53575. /** @hidden */
  53576. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53577. /** @hidden */
  53578. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53579. /**
  53580. * Creates a PlaneDragGizmo
  53581. * @param gizmoLayer The utility layer the gizmo will be added to
  53582. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53583. * @param color The color of the gizmo
  53584. */
  53585. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53586. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53587. /**
  53588. * If the gizmo is enabled
  53589. */
  53590. set isEnabled(value: boolean);
  53591. get isEnabled(): boolean;
  53592. /**
  53593. * Disposes of the gizmo
  53594. */
  53595. dispose(): void;
  53596. }
  53597. }
  53598. declare module BABYLON {
  53599. /**
  53600. * Gizmo that enables dragging a mesh along 3 axis
  53601. */
  53602. export class PositionGizmo extends Gizmo {
  53603. /**
  53604. * Internal gizmo used for interactions on the x axis
  53605. */
  53606. xGizmo: AxisDragGizmo;
  53607. /**
  53608. * Internal gizmo used for interactions on the y axis
  53609. */
  53610. yGizmo: AxisDragGizmo;
  53611. /**
  53612. * Internal gizmo used for interactions on the z axis
  53613. */
  53614. zGizmo: AxisDragGizmo;
  53615. /**
  53616. * Internal gizmo used for interactions on the yz plane
  53617. */
  53618. xPlaneGizmo: PlaneDragGizmo;
  53619. /**
  53620. * Internal gizmo used for interactions on the xz plane
  53621. */
  53622. yPlaneGizmo: PlaneDragGizmo;
  53623. /**
  53624. * Internal gizmo used for interactions on the xy plane
  53625. */
  53626. zPlaneGizmo: PlaneDragGizmo;
  53627. /**
  53628. * private variables
  53629. */
  53630. private _meshAttached;
  53631. private _nodeAttached;
  53632. private _snapDistance;
  53633. /** Fires an event when any of it's sub gizmos are dragged */
  53634. onDragStartObservable: Observable<unknown>;
  53635. /** Fires an event when any of it's sub gizmos are released from dragging */
  53636. onDragEndObservable: Observable<unknown>;
  53637. /**
  53638. * If set to true, planar drag is enabled
  53639. */
  53640. private _planarGizmoEnabled;
  53641. get attachedMesh(): Nullable<AbstractMesh>;
  53642. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53643. get attachedNode(): Nullable<Node>;
  53644. set attachedNode(node: Nullable<Node>);
  53645. /**
  53646. * True when the mouse pointer is hovering a gizmo mesh
  53647. */
  53648. get isHovered(): boolean;
  53649. /**
  53650. * Creates a PositionGizmo
  53651. * @param gizmoLayer The utility layer the gizmo will be added to
  53652. @param thickness display gizmo axis thickness
  53653. */
  53654. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53655. /**
  53656. * If the planar drag gizmo is enabled
  53657. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53658. */
  53659. set planarGizmoEnabled(value: boolean);
  53660. get planarGizmoEnabled(): boolean;
  53661. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53662. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53663. /**
  53664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53665. */
  53666. set snapDistance(value: number);
  53667. get snapDistance(): number;
  53668. /**
  53669. * Ratio for the scale of the gizmo (Default: 1)
  53670. */
  53671. set scaleRatio(value: number);
  53672. get scaleRatio(): number;
  53673. /**
  53674. * Disposes of the gizmo
  53675. */
  53676. dispose(): void;
  53677. /**
  53678. * CustomMeshes are not supported by this gizmo
  53679. * @param mesh The mesh to replace the default mesh of the gizmo
  53680. */
  53681. setCustomMesh(mesh: Mesh): void;
  53682. }
  53683. }
  53684. declare module BABYLON {
  53685. /**
  53686. * Single axis drag gizmo
  53687. */
  53688. export class AxisDragGizmo extends Gizmo {
  53689. /**
  53690. * Drag behavior responsible for the gizmos dragging interactions
  53691. */
  53692. dragBehavior: PointerDragBehavior;
  53693. private _pointerObserver;
  53694. /**
  53695. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53696. */
  53697. snapDistance: number;
  53698. /**
  53699. * Event that fires each time the gizmo snaps to a new location.
  53700. * * snapDistance is the the change in distance
  53701. */
  53702. onSnapObservable: Observable<{
  53703. snapDistance: number;
  53704. }>;
  53705. private _isEnabled;
  53706. private _parent;
  53707. private _arrow;
  53708. private _coloredMaterial;
  53709. private _hoverMaterial;
  53710. /** @hidden */
  53711. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53712. /** @hidden */
  53713. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53714. /**
  53715. * Creates an AxisDragGizmo
  53716. * @param gizmoLayer The utility layer the gizmo will be added to
  53717. * @param dragAxis The axis which the gizmo will be able to drag on
  53718. * @param color The color of the gizmo
  53719. * @param thickness display gizmo axis thickness
  53720. */
  53721. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53722. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53723. /**
  53724. * If the gizmo is enabled
  53725. */
  53726. set isEnabled(value: boolean);
  53727. get isEnabled(): boolean;
  53728. /**
  53729. * Disposes of the gizmo
  53730. */
  53731. dispose(): void;
  53732. }
  53733. }
  53734. declare module BABYLON.Debug {
  53735. /**
  53736. * The Axes viewer will show 3 axes in a specific point in space
  53737. */
  53738. export class AxesViewer {
  53739. private _xAxis;
  53740. private _yAxis;
  53741. private _zAxis;
  53742. private _scaleLinesFactor;
  53743. private _instanced;
  53744. /**
  53745. * Gets the hosting scene
  53746. */
  53747. scene: Nullable<Scene>;
  53748. /**
  53749. * Gets or sets a number used to scale line length
  53750. */
  53751. scaleLines: number;
  53752. /** Gets the node hierarchy used to render x-axis */
  53753. get xAxis(): TransformNode;
  53754. /** Gets the node hierarchy used to render y-axis */
  53755. get yAxis(): TransformNode;
  53756. /** Gets the node hierarchy used to render z-axis */
  53757. get zAxis(): TransformNode;
  53758. /**
  53759. * Creates a new AxesViewer
  53760. * @param scene defines the hosting scene
  53761. * @param scaleLines defines a number used to scale line length (1 by default)
  53762. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53763. * @param xAxis defines the node hierarchy used to render the x-axis
  53764. * @param yAxis defines the node hierarchy used to render the y-axis
  53765. * @param zAxis defines the node hierarchy used to render the z-axis
  53766. */
  53767. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53768. /**
  53769. * Force the viewer to update
  53770. * @param position defines the position of the viewer
  53771. * @param xaxis defines the x axis of the viewer
  53772. * @param yaxis defines the y axis of the viewer
  53773. * @param zaxis defines the z axis of the viewer
  53774. */
  53775. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53776. /**
  53777. * Creates an instance of this axes viewer.
  53778. * @returns a new axes viewer with instanced meshes
  53779. */
  53780. createInstance(): AxesViewer;
  53781. /** Releases resources */
  53782. dispose(): void;
  53783. private static _SetRenderingGroupId;
  53784. }
  53785. }
  53786. declare module BABYLON.Debug {
  53787. /**
  53788. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53789. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53790. */
  53791. export class BoneAxesViewer extends AxesViewer {
  53792. /**
  53793. * Gets or sets the target mesh where to display the axes viewer
  53794. */
  53795. mesh: Nullable<Mesh>;
  53796. /**
  53797. * Gets or sets the target bone where to display the axes viewer
  53798. */
  53799. bone: Nullable<Bone>;
  53800. /** Gets current position */
  53801. pos: Vector3;
  53802. /** Gets direction of X axis */
  53803. xaxis: Vector3;
  53804. /** Gets direction of Y axis */
  53805. yaxis: Vector3;
  53806. /** Gets direction of Z axis */
  53807. zaxis: Vector3;
  53808. /**
  53809. * Creates a new BoneAxesViewer
  53810. * @param scene defines the hosting scene
  53811. * @param bone defines the target bone
  53812. * @param mesh defines the target mesh
  53813. * @param scaleLines defines a scaling factor for line length (1 by default)
  53814. */
  53815. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53816. /**
  53817. * Force the viewer to update
  53818. */
  53819. update(): void;
  53820. /** Releases resources */
  53821. dispose(): void;
  53822. }
  53823. }
  53824. declare module BABYLON {
  53825. /**
  53826. * Interface used to define scene explorer extensibility option
  53827. */
  53828. export interface IExplorerExtensibilityOption {
  53829. /**
  53830. * Define the option label
  53831. */
  53832. label: string;
  53833. /**
  53834. * Defines the action to execute on click
  53835. */
  53836. action: (entity: any) => void;
  53837. }
  53838. /**
  53839. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53840. */
  53841. export interface IExplorerExtensibilityGroup {
  53842. /**
  53843. * Defines a predicate to test if a given type mut be extended
  53844. */
  53845. predicate: (entity: any) => boolean;
  53846. /**
  53847. * Gets the list of options added to a type
  53848. */
  53849. entries: IExplorerExtensibilityOption[];
  53850. }
  53851. /**
  53852. * Interface used to define the options to use to create the Inspector
  53853. */
  53854. export interface IInspectorOptions {
  53855. /**
  53856. * Display in overlay mode (default: false)
  53857. */
  53858. overlay?: boolean;
  53859. /**
  53860. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53861. */
  53862. globalRoot?: HTMLElement;
  53863. /**
  53864. * Display the Scene explorer
  53865. */
  53866. showExplorer?: boolean;
  53867. /**
  53868. * Display the property inspector
  53869. */
  53870. showInspector?: boolean;
  53871. /**
  53872. * Display in embed mode (both panes on the right)
  53873. */
  53874. embedMode?: boolean;
  53875. /**
  53876. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53877. */
  53878. handleResize?: boolean;
  53879. /**
  53880. * Allow the panes to popup (default: true)
  53881. */
  53882. enablePopup?: boolean;
  53883. /**
  53884. * Allow the panes to be closed by users (default: true)
  53885. */
  53886. enableClose?: boolean;
  53887. /**
  53888. * Optional list of extensibility entries
  53889. */
  53890. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53891. /**
  53892. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53893. */
  53894. inspectorURL?: string;
  53895. /**
  53896. * Optional initial tab (default to DebugLayerTab.Properties)
  53897. */
  53898. initialTab?: DebugLayerTab;
  53899. }
  53900. interface Scene {
  53901. /**
  53902. * @hidden
  53903. * Backing field
  53904. */
  53905. _debugLayer: DebugLayer;
  53906. /**
  53907. * Gets the debug layer (aka Inspector) associated with the scene
  53908. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53909. */
  53910. debugLayer: DebugLayer;
  53911. }
  53912. /**
  53913. * Enum of inspector action tab
  53914. */
  53915. export enum DebugLayerTab {
  53916. /**
  53917. * Properties tag (default)
  53918. */
  53919. Properties = 0,
  53920. /**
  53921. * Debug tab
  53922. */
  53923. Debug = 1,
  53924. /**
  53925. * Statistics tab
  53926. */
  53927. Statistics = 2,
  53928. /**
  53929. * Tools tab
  53930. */
  53931. Tools = 3,
  53932. /**
  53933. * Settings tab
  53934. */
  53935. Settings = 4
  53936. }
  53937. /**
  53938. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53939. * what is happening in your scene
  53940. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53941. */
  53942. export class DebugLayer {
  53943. /**
  53944. * Define the url to get the inspector script from.
  53945. * By default it uses the babylonjs CDN.
  53946. * @ignoreNaming
  53947. */
  53948. static InspectorURL: string;
  53949. private _scene;
  53950. private BJSINSPECTOR;
  53951. private _onPropertyChangedObservable?;
  53952. /**
  53953. * Observable triggered when a property is changed through the inspector.
  53954. */
  53955. get onPropertyChangedObservable(): any;
  53956. /**
  53957. * Instantiates a new debug layer.
  53958. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53959. * what is happening in your scene
  53960. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53961. * @param scene Defines the scene to inspect
  53962. */
  53963. constructor(scene: Scene);
  53964. /** Creates the inspector window. */
  53965. private _createInspector;
  53966. /**
  53967. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53968. * @param entity defines the entity to select
  53969. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53970. */
  53971. select(entity: any, lineContainerTitles?: string | string[]): void;
  53972. /** Get the inspector from bundle or global */
  53973. private _getGlobalInspector;
  53974. /**
  53975. * Get if the inspector is visible or not.
  53976. * @returns true if visible otherwise, false
  53977. */
  53978. isVisible(): boolean;
  53979. /**
  53980. * Hide the inspector and close its window.
  53981. */
  53982. hide(): void;
  53983. /**
  53984. * Update the scene in the inspector
  53985. */
  53986. setAsActiveScene(): void;
  53987. /**
  53988. * Launch the debugLayer.
  53989. * @param config Define the configuration of the inspector
  53990. * @return a promise fulfilled when the debug layer is visible
  53991. */
  53992. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53993. }
  53994. }
  53995. declare module BABYLON {
  53996. /**
  53997. * Class containing static functions to help procedurally build meshes
  53998. */
  53999. export class BoxBuilder {
  54000. /**
  54001. * Creates a box mesh
  54002. * * The parameter `size` sets the size (float) of each box side (default 1)
  54003. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54004. * * 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)
  54005. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54007. * * 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
  54008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54009. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54010. * @param name defines the name of the mesh
  54011. * @param options defines the options used to create the mesh
  54012. * @param scene defines the hosting scene
  54013. * @returns the box mesh
  54014. */
  54015. static CreateBox(name: string, options: {
  54016. size?: number;
  54017. width?: number;
  54018. height?: number;
  54019. depth?: number;
  54020. faceUV?: Vector4[];
  54021. faceColors?: Color4[];
  54022. sideOrientation?: number;
  54023. frontUVs?: Vector4;
  54024. backUVs?: Vector4;
  54025. wrap?: boolean;
  54026. topBaseAt?: number;
  54027. bottomBaseAt?: number;
  54028. updatable?: boolean;
  54029. }, scene?: Nullable<Scene>): Mesh;
  54030. }
  54031. }
  54032. declare module BABYLON.Debug {
  54033. /**
  54034. * Used to show the physics impostor around the specific mesh
  54035. */
  54036. export class PhysicsViewer {
  54037. /** @hidden */
  54038. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54039. /** @hidden */
  54040. protected _meshes: Array<Nullable<AbstractMesh>>;
  54041. /** @hidden */
  54042. protected _scene: Nullable<Scene>;
  54043. /** @hidden */
  54044. protected _numMeshes: number;
  54045. /** @hidden */
  54046. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54047. private _renderFunction;
  54048. private _utilityLayer;
  54049. private _debugBoxMesh;
  54050. private _debugSphereMesh;
  54051. private _debugCylinderMesh;
  54052. private _debugMaterial;
  54053. private _debugMeshMeshes;
  54054. /**
  54055. * Creates a new PhysicsViewer
  54056. * @param scene defines the hosting scene
  54057. */
  54058. constructor(scene: Scene);
  54059. /** @hidden */
  54060. protected _updateDebugMeshes(): void;
  54061. /**
  54062. * Renders a specified physic impostor
  54063. * @param impostor defines the impostor to render
  54064. * @param targetMesh defines the mesh represented by the impostor
  54065. * @returns the new debug mesh used to render the impostor
  54066. */
  54067. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54068. /**
  54069. * Hides a specified physic impostor
  54070. * @param impostor defines the impostor to hide
  54071. */
  54072. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54073. private _getDebugMaterial;
  54074. private _getDebugBoxMesh;
  54075. private _getDebugSphereMesh;
  54076. private _getDebugCylinderMesh;
  54077. private _getDebugMeshMesh;
  54078. private _getDebugMesh;
  54079. /** Releases all resources */
  54080. dispose(): void;
  54081. }
  54082. }
  54083. declare module BABYLON {
  54084. /**
  54085. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54086. * in order to better appreciate the issue one might have.
  54087. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54088. */
  54089. export class RayHelper {
  54090. /**
  54091. * Defines the ray we are currently tryin to visualize.
  54092. */
  54093. ray: Nullable<Ray>;
  54094. private _renderPoints;
  54095. private _renderLine;
  54096. private _renderFunction;
  54097. private _scene;
  54098. private _onAfterRenderObserver;
  54099. private _onAfterStepObserver;
  54100. private _attachedToMesh;
  54101. private _meshSpaceDirection;
  54102. private _meshSpaceOrigin;
  54103. /**
  54104. * Helper function to create a colored helper in a scene in one line.
  54105. * @param ray Defines the ray we are currently tryin to visualize
  54106. * @param scene Defines the scene the ray is used in
  54107. * @param color Defines the color we want to see the ray in
  54108. * @returns The newly created ray helper.
  54109. */
  54110. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54111. /**
  54112. * Instantiate a new ray helper.
  54113. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54114. * in order to better appreciate the issue one might have.
  54115. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54116. * @param ray Defines the ray we are currently tryin to visualize
  54117. */
  54118. constructor(ray: Ray);
  54119. /**
  54120. * Shows the ray we are willing to debug.
  54121. * @param scene Defines the scene the ray needs to be rendered in
  54122. * @param color Defines the color the ray needs to be rendered in
  54123. */
  54124. show(scene: Scene, color?: Color3): void;
  54125. /**
  54126. * Hides the ray we are debugging.
  54127. */
  54128. hide(): void;
  54129. private _render;
  54130. /**
  54131. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54132. * @param mesh Defines the mesh we want the helper attached to
  54133. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54134. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54135. * @param length Defines the length of the ray
  54136. */
  54137. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54138. /**
  54139. * Detach the ray helper from the mesh it has previously been attached to.
  54140. */
  54141. detachFromMesh(): void;
  54142. private _updateToMesh;
  54143. /**
  54144. * Dispose the helper and release its associated resources.
  54145. */
  54146. dispose(): void;
  54147. }
  54148. }
  54149. declare module BABYLON {
  54150. /**
  54151. * Defines the options associated with the creation of a SkeletonViewer.
  54152. */
  54153. export interface ISkeletonViewerOptions {
  54154. /** Should the system pause animations before building the Viewer? */
  54155. pauseAnimations: boolean;
  54156. /** Should the system return the skeleton to rest before building? */
  54157. returnToRest: boolean;
  54158. /** public Display Mode of the Viewer */
  54159. displayMode: number;
  54160. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54161. displayOptions: ISkeletonViewerDisplayOptions;
  54162. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54163. computeBonesUsingShaders: boolean;
  54164. /** Flag ignore non weighted bones */
  54165. useAllBones: boolean;
  54166. }
  54167. /**
  54168. * Defines how to display the various bone meshes for the viewer.
  54169. */
  54170. export interface ISkeletonViewerDisplayOptions {
  54171. /** How far down to start tapering the bone spurs */
  54172. midStep?: number;
  54173. /** How big is the midStep? */
  54174. midStepFactor?: number;
  54175. /** Base for the Sphere Size */
  54176. sphereBaseSize?: number;
  54177. /** The ratio of the sphere to the longest bone in units */
  54178. sphereScaleUnit?: number;
  54179. /** Ratio for the Sphere Size */
  54180. sphereFactor?: number;
  54181. /** Whether a spur should attach its far end to the child bone position */
  54182. spurFollowsChild?: boolean;
  54183. /** Whether to show local axes or not */
  54184. showLocalAxes?: boolean;
  54185. /** Length of each local axis */
  54186. localAxesSize?: number;
  54187. }
  54188. /**
  54189. * Defines the constructor options for the BoneWeight Shader.
  54190. */
  54191. export interface IBoneWeightShaderOptions {
  54192. /** Skeleton to Map */
  54193. skeleton: Skeleton;
  54194. /** Colors for Uninfluenced bones */
  54195. colorBase?: Color3;
  54196. /** Colors for 0.0-0.25 Weight bones */
  54197. colorZero?: Color3;
  54198. /** Color for 0.25-0.5 Weight Influence */
  54199. colorQuarter?: Color3;
  54200. /** Color for 0.5-0.75 Weight Influence */
  54201. colorHalf?: Color3;
  54202. /** Color for 0.75-1 Weight Influence */
  54203. colorFull?: Color3;
  54204. /** Color for Zero Weight Influence */
  54205. targetBoneIndex?: number;
  54206. }
  54207. /**
  54208. * Simple structure of the gradient steps for the Color Map.
  54209. */
  54210. export interface ISkeletonMapShaderColorMapKnot {
  54211. /** Color of the Knot */
  54212. color: Color3;
  54213. /** Location of the Knot */
  54214. location: number;
  54215. }
  54216. /**
  54217. * Defines the constructor options for the SkeletonMap Shader.
  54218. */
  54219. export interface ISkeletonMapShaderOptions {
  54220. /** Skeleton to Map */
  54221. skeleton: Skeleton;
  54222. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54223. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54224. }
  54225. }
  54226. declare module BABYLON {
  54227. /**
  54228. * Class containing static functions to help procedurally build meshes
  54229. */
  54230. export class RibbonBuilder {
  54231. /**
  54232. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54233. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54234. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54235. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54236. * * 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
  54237. * * 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
  54238. * * 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
  54239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54240. * * 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
  54241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54242. * * 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
  54243. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54244. * * 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
  54245. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54247. * @param name defines the name of the mesh
  54248. * @param options defines the options used to create the mesh
  54249. * @param scene defines the hosting scene
  54250. * @returns the ribbon mesh
  54251. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54253. */
  54254. static CreateRibbon(name: string, options: {
  54255. pathArray: Vector3[][];
  54256. closeArray?: boolean;
  54257. closePath?: boolean;
  54258. offset?: number;
  54259. updatable?: boolean;
  54260. sideOrientation?: number;
  54261. frontUVs?: Vector4;
  54262. backUVs?: Vector4;
  54263. instance?: Mesh;
  54264. invertUV?: boolean;
  54265. uvs?: Vector2[];
  54266. colors?: Color4[];
  54267. }, scene?: Nullable<Scene>): Mesh;
  54268. }
  54269. }
  54270. declare module BABYLON {
  54271. /**
  54272. * Class containing static functions to help procedurally build meshes
  54273. */
  54274. export class ShapeBuilder {
  54275. /**
  54276. * 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.
  54277. * * 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.
  54278. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54279. * * 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.
  54280. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54281. * * 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
  54282. * * 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
  54283. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54285. * * 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
  54286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54288. * @param name defines the name of the mesh
  54289. * @param options defines the options used to create the mesh
  54290. * @param scene defines the hosting scene
  54291. * @returns the extruded shape mesh
  54292. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54294. */
  54295. static ExtrudeShape(name: string, options: {
  54296. shape: Vector3[];
  54297. path: Vector3[];
  54298. scale?: number;
  54299. rotation?: number;
  54300. cap?: number;
  54301. updatable?: boolean;
  54302. sideOrientation?: number;
  54303. frontUVs?: Vector4;
  54304. backUVs?: Vector4;
  54305. instance?: Mesh;
  54306. invertUV?: boolean;
  54307. }, scene?: Nullable<Scene>): Mesh;
  54308. /**
  54309. * Creates an custom extruded shape mesh.
  54310. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54311. * * 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.
  54312. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54313. * * 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
  54314. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54315. * * 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
  54316. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54317. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54318. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54319. * * 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
  54320. * * 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
  54321. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54323. * * 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
  54324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54326. * @param name defines the name of the mesh
  54327. * @param options defines the options used to create the mesh
  54328. * @param scene defines the hosting scene
  54329. * @returns the custom extruded shape mesh
  54330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54331. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54333. */
  54334. static ExtrudeShapeCustom(name: string, options: {
  54335. shape: Vector3[];
  54336. path: Vector3[];
  54337. scaleFunction?: any;
  54338. rotationFunction?: any;
  54339. ribbonCloseArray?: boolean;
  54340. ribbonClosePath?: boolean;
  54341. cap?: number;
  54342. updatable?: boolean;
  54343. sideOrientation?: number;
  54344. frontUVs?: Vector4;
  54345. backUVs?: Vector4;
  54346. instance?: Mesh;
  54347. invertUV?: boolean;
  54348. }, scene?: Nullable<Scene>): Mesh;
  54349. private static _ExtrudeShapeGeneric;
  54350. }
  54351. }
  54352. declare module BABYLON.Debug {
  54353. /**
  54354. * Class used to render a debug view of a given skeleton
  54355. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54356. */
  54357. export class SkeletonViewer {
  54358. /** defines the skeleton to render */
  54359. skeleton: Skeleton;
  54360. /** defines the mesh attached to the skeleton */
  54361. mesh: AbstractMesh;
  54362. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54363. autoUpdateBonesMatrices: boolean;
  54364. /** defines the rendering group id to use with the viewer */
  54365. renderingGroupId: number;
  54366. /** is the options for the viewer */
  54367. options: Partial<ISkeletonViewerOptions>;
  54368. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54369. static readonly DISPLAY_LINES: number;
  54370. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54371. static readonly DISPLAY_SPHERES: number;
  54372. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54373. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54374. /** public static method to create a BoneWeight Shader
  54375. * @param options The constructor options
  54376. * @param scene The scene that the shader is scoped to
  54377. * @returns The created ShaderMaterial
  54378. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54379. */
  54380. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54381. /** public static method to create a BoneWeight Shader
  54382. * @param options The constructor options
  54383. * @param scene The scene that the shader is scoped to
  54384. * @returns The created ShaderMaterial
  54385. */
  54386. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54387. /** private static method to create a BoneWeight Shader
  54388. * @param size The size of the buffer to create (usually the bone count)
  54389. * @param colorMap The gradient data to generate
  54390. * @param scene The scene that the shader is scoped to
  54391. * @returns an Array of floats from the color gradient values
  54392. */
  54393. private static _CreateBoneMapColorBuffer;
  54394. /** If SkeletonViewer scene scope. */
  54395. private _scene;
  54396. /** Gets or sets the color used to render the skeleton */
  54397. color: Color3;
  54398. /** Array of the points of the skeleton fo the line view. */
  54399. private _debugLines;
  54400. /** The SkeletonViewers Mesh. */
  54401. private _debugMesh;
  54402. /** The local axes Meshes. */
  54403. private _localAxes;
  54404. /** If SkeletonViewer is enabled. */
  54405. private _isEnabled;
  54406. /** If SkeletonViewer is ready. */
  54407. private _ready;
  54408. /** SkeletonViewer render observable. */
  54409. private _obs;
  54410. /** The Utility Layer to render the gizmos in. */
  54411. private _utilityLayer;
  54412. private _boneIndices;
  54413. /** Gets the Scene. */
  54414. get scene(): Scene;
  54415. /** Gets the utilityLayer. */
  54416. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54417. /** Checks Ready Status. */
  54418. get isReady(): Boolean;
  54419. /** Sets Ready Status. */
  54420. set ready(value: boolean);
  54421. /** Gets the debugMesh */
  54422. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54423. /** Sets the debugMesh */
  54424. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54425. /** Gets the displayMode */
  54426. get displayMode(): number;
  54427. /** Sets the displayMode */
  54428. set displayMode(value: number);
  54429. /**
  54430. * Creates a new SkeletonViewer
  54431. * @param skeleton defines the skeleton to render
  54432. * @param mesh defines the mesh attached to the skeleton
  54433. * @param scene defines the hosting scene
  54434. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54435. * @param renderingGroupId defines the rendering group id to use with the viewer
  54436. * @param options All of the extra constructor options for the SkeletonViewer
  54437. */
  54438. constructor(
  54439. /** defines the skeleton to render */
  54440. skeleton: Skeleton,
  54441. /** defines the mesh attached to the skeleton */
  54442. mesh: AbstractMesh,
  54443. /** The Scene scope*/
  54444. scene: Scene,
  54445. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54446. autoUpdateBonesMatrices?: boolean,
  54447. /** defines the rendering group id to use with the viewer */
  54448. renderingGroupId?: number,
  54449. /** is the options for the viewer */
  54450. options?: Partial<ISkeletonViewerOptions>);
  54451. /** The Dynamic bindings for the update functions */
  54452. private _bindObs;
  54453. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54454. update(): void;
  54455. /** Gets or sets a boolean indicating if the viewer is enabled */
  54456. set isEnabled(value: boolean);
  54457. get isEnabled(): boolean;
  54458. private _getBonePosition;
  54459. private _getLinesForBonesWithLength;
  54460. private _getLinesForBonesNoLength;
  54461. /** function to revert the mesh and scene back to the initial state. */
  54462. private _revert;
  54463. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54464. private _getAbsoluteBindPoseToRef;
  54465. /** function to build and bind sphere joint points and spur bone representations. */
  54466. private _buildSpheresAndSpurs;
  54467. private _buildLocalAxes;
  54468. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54469. private _displayLinesUpdate;
  54470. /** Changes the displayMode of the skeleton viewer
  54471. * @param mode The displayMode numerical value
  54472. */
  54473. changeDisplayMode(mode: number): void;
  54474. /** Sets a display option of the skeleton viewer
  54475. *
  54476. * | Option | Type | Default | Description |
  54477. * | ---------------- | ------- | ------- | ----------- |
  54478. * | 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`. |
  54479. * | 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`. |
  54480. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54481. * | 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`. |
  54482. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54483. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54484. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54485. *
  54486. * @param option String of the option name
  54487. * @param value The numerical option value
  54488. */
  54489. changeDisplayOptions(option: string, value: number): void;
  54490. /** Release associated resources */
  54491. dispose(): void;
  54492. }
  54493. }
  54494. declare module BABYLON {
  54495. /**
  54496. * Enum for Device Types
  54497. */
  54498. export enum DeviceType {
  54499. /** Generic */
  54500. Generic = 0,
  54501. /** Keyboard */
  54502. Keyboard = 1,
  54503. /** Mouse */
  54504. Mouse = 2,
  54505. /** Touch Pointers */
  54506. Touch = 3,
  54507. /** PS4 Dual Shock */
  54508. DualShock = 4,
  54509. /** Xbox */
  54510. Xbox = 5,
  54511. /** Switch Controller */
  54512. Switch = 6
  54513. }
  54514. /**
  54515. * Enum for All Pointers (Touch/Mouse)
  54516. */
  54517. export enum PointerInput {
  54518. /** Horizontal Axis */
  54519. Horizontal = 0,
  54520. /** Vertical Axis */
  54521. Vertical = 1,
  54522. /** Left Click or Touch */
  54523. LeftClick = 2,
  54524. /** Middle Click */
  54525. MiddleClick = 3,
  54526. /** Right Click */
  54527. RightClick = 4,
  54528. /** Browser Back */
  54529. BrowserBack = 5,
  54530. /** Browser Forward */
  54531. BrowserForward = 6
  54532. }
  54533. /**
  54534. * Enum for Dual Shock Gamepad
  54535. */
  54536. export enum DualShockInput {
  54537. /** Cross */
  54538. Cross = 0,
  54539. /** Circle */
  54540. Circle = 1,
  54541. /** Square */
  54542. Square = 2,
  54543. /** Triangle */
  54544. Triangle = 3,
  54545. /** L1 */
  54546. L1 = 4,
  54547. /** R1 */
  54548. R1 = 5,
  54549. /** L2 */
  54550. L2 = 6,
  54551. /** R2 */
  54552. R2 = 7,
  54553. /** Share */
  54554. Share = 8,
  54555. /** Options */
  54556. Options = 9,
  54557. /** L3 */
  54558. L3 = 10,
  54559. /** R3 */
  54560. R3 = 11,
  54561. /** DPadUp */
  54562. DPadUp = 12,
  54563. /** DPadDown */
  54564. DPadDown = 13,
  54565. /** DPadLeft */
  54566. DPadLeft = 14,
  54567. /** DRight */
  54568. DPadRight = 15,
  54569. /** Home */
  54570. Home = 16,
  54571. /** TouchPad */
  54572. TouchPad = 17,
  54573. /** LStickXAxis */
  54574. LStickXAxis = 18,
  54575. /** LStickYAxis */
  54576. LStickYAxis = 19,
  54577. /** RStickXAxis */
  54578. RStickXAxis = 20,
  54579. /** RStickYAxis */
  54580. RStickYAxis = 21
  54581. }
  54582. /**
  54583. * Enum for Xbox Gamepad
  54584. */
  54585. export enum XboxInput {
  54586. /** A */
  54587. A = 0,
  54588. /** B */
  54589. B = 1,
  54590. /** X */
  54591. X = 2,
  54592. /** Y */
  54593. Y = 3,
  54594. /** LB */
  54595. LB = 4,
  54596. /** RB */
  54597. RB = 5,
  54598. /** LT */
  54599. LT = 6,
  54600. /** RT */
  54601. RT = 7,
  54602. /** Back */
  54603. Back = 8,
  54604. /** Start */
  54605. Start = 9,
  54606. /** LS */
  54607. LS = 10,
  54608. /** RS */
  54609. RS = 11,
  54610. /** DPadUp */
  54611. DPadUp = 12,
  54612. /** DPadDown */
  54613. DPadDown = 13,
  54614. /** DPadLeft */
  54615. DPadLeft = 14,
  54616. /** DRight */
  54617. DPadRight = 15,
  54618. /** Home */
  54619. Home = 16,
  54620. /** LStickXAxis */
  54621. LStickXAxis = 17,
  54622. /** LStickYAxis */
  54623. LStickYAxis = 18,
  54624. /** RStickXAxis */
  54625. RStickXAxis = 19,
  54626. /** RStickYAxis */
  54627. RStickYAxis = 20
  54628. }
  54629. /**
  54630. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54631. */
  54632. export enum SwitchInput {
  54633. /** B */
  54634. B = 0,
  54635. /** A */
  54636. A = 1,
  54637. /** Y */
  54638. Y = 2,
  54639. /** X */
  54640. X = 3,
  54641. /** L */
  54642. L = 4,
  54643. /** R */
  54644. R = 5,
  54645. /** ZL */
  54646. ZL = 6,
  54647. /** ZR */
  54648. ZR = 7,
  54649. /** Minus */
  54650. Minus = 8,
  54651. /** Plus */
  54652. Plus = 9,
  54653. /** LS */
  54654. LS = 10,
  54655. /** RS */
  54656. RS = 11,
  54657. /** DPadUp */
  54658. DPadUp = 12,
  54659. /** DPadDown */
  54660. DPadDown = 13,
  54661. /** DPadLeft */
  54662. DPadLeft = 14,
  54663. /** DRight */
  54664. DPadRight = 15,
  54665. /** Home */
  54666. Home = 16,
  54667. /** Capture */
  54668. Capture = 17,
  54669. /** LStickXAxis */
  54670. LStickXAxis = 18,
  54671. /** LStickYAxis */
  54672. LStickYAxis = 19,
  54673. /** RStickXAxis */
  54674. RStickXAxis = 20,
  54675. /** RStickYAxis */
  54676. RStickYAxis = 21
  54677. }
  54678. }
  54679. declare module BABYLON {
  54680. /**
  54681. * This class will take all inputs from Keyboard, Pointer, and
  54682. * any Gamepads and provide a polling system that all devices
  54683. * will use. This class assumes that there will only be one
  54684. * pointer device and one keyboard.
  54685. */
  54686. export class DeviceInputSystem implements IDisposable {
  54687. /**
  54688. * Callback to be triggered when a device is connected
  54689. */
  54690. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54691. /**
  54692. * Callback to be triggered when a device is disconnected
  54693. */
  54694. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54695. /**
  54696. * Callback to be triggered when event driven input is updated
  54697. */
  54698. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54699. private _inputs;
  54700. private _gamepads;
  54701. private _keyboardActive;
  54702. private _pointerActive;
  54703. private _elementToAttachTo;
  54704. private _keyboardDownEvent;
  54705. private _keyboardUpEvent;
  54706. private _pointerMoveEvent;
  54707. private _pointerDownEvent;
  54708. private _pointerUpEvent;
  54709. private _gamepadConnectedEvent;
  54710. private _gamepadDisconnectedEvent;
  54711. private static _MAX_KEYCODES;
  54712. private static _MAX_POINTER_INPUTS;
  54713. private constructor();
  54714. /**
  54715. * Creates a new DeviceInputSystem instance
  54716. * @param engine Engine to pull input element from
  54717. * @returns The new instance
  54718. */
  54719. static Create(engine: Engine): DeviceInputSystem;
  54720. /**
  54721. * Checks for current device input value, given an id and input index
  54722. * @param deviceName Id of connected device
  54723. * @param inputIndex Index of device input
  54724. * @returns Current value of input
  54725. */
  54726. /**
  54727. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54728. * @param deviceType Enum specifiying device type
  54729. * @param deviceSlot "Slot" or index that device is referenced in
  54730. * @param inputIndex Id of input to be checked
  54731. * @returns Current value of input
  54732. */
  54733. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54734. /**
  54735. * Dispose of all the eventlisteners
  54736. */
  54737. dispose(): void;
  54738. /**
  54739. * Add device and inputs to device array
  54740. * @param deviceType Enum specifiying device type
  54741. * @param deviceSlot "Slot" or index that device is referenced in
  54742. * @param numberOfInputs Number of input entries to create for given device
  54743. */
  54744. private _registerDevice;
  54745. /**
  54746. * Given a specific device name, remove that device from the device map
  54747. * @param deviceType Enum specifiying device type
  54748. * @param deviceSlot "Slot" or index that device is referenced in
  54749. */
  54750. private _unregisterDevice;
  54751. /**
  54752. * Handle all actions that come from keyboard interaction
  54753. */
  54754. private _handleKeyActions;
  54755. /**
  54756. * Handle all actions that come from pointer interaction
  54757. */
  54758. private _handlePointerActions;
  54759. /**
  54760. * Handle all actions that come from gamepad interaction
  54761. */
  54762. private _handleGamepadActions;
  54763. /**
  54764. * Update all non-event based devices with each frame
  54765. * @param deviceType Enum specifiying device type
  54766. * @param deviceSlot "Slot" or index that device is referenced in
  54767. * @param inputIndex Id of input to be checked
  54768. */
  54769. private _updateDevice;
  54770. /**
  54771. * Gets DeviceType from the device name
  54772. * @param deviceName Name of Device from DeviceInputSystem
  54773. * @returns DeviceType enum value
  54774. */
  54775. private _getGamepadDeviceType;
  54776. }
  54777. }
  54778. declare module BABYLON {
  54779. /**
  54780. * Type to handle enforcement of inputs
  54781. */
  54782. 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;
  54783. }
  54784. declare module BABYLON {
  54785. /**
  54786. * Class that handles all input for a specific device
  54787. */
  54788. export class DeviceSource<T extends DeviceType> {
  54789. /** Type of device */
  54790. readonly deviceType: DeviceType;
  54791. /** "Slot" or index that device is referenced in */
  54792. readonly deviceSlot: number;
  54793. /**
  54794. * Observable to handle device input changes per device
  54795. */
  54796. readonly onInputChangedObservable: Observable<{
  54797. inputIndex: DeviceInput<T>;
  54798. previousState: Nullable<number>;
  54799. currentState: Nullable<number>;
  54800. }>;
  54801. private readonly _deviceInputSystem;
  54802. /**
  54803. * Default Constructor
  54804. * @param deviceInputSystem Reference to DeviceInputSystem
  54805. * @param deviceType Type of device
  54806. * @param deviceSlot "Slot" or index that device is referenced in
  54807. */
  54808. constructor(deviceInputSystem: DeviceInputSystem,
  54809. /** Type of device */
  54810. deviceType: DeviceType,
  54811. /** "Slot" or index that device is referenced in */
  54812. deviceSlot?: number);
  54813. /**
  54814. * Get input for specific input
  54815. * @param inputIndex index of specific input on device
  54816. * @returns Input value from DeviceInputSystem
  54817. */
  54818. getInput(inputIndex: DeviceInput<T>): number;
  54819. }
  54820. /**
  54821. * Class to keep track of devices
  54822. */
  54823. export class DeviceSourceManager implements IDisposable {
  54824. /**
  54825. * Observable to be triggered when before a device is connected
  54826. */
  54827. readonly onBeforeDeviceConnectedObservable: Observable<{
  54828. deviceType: DeviceType;
  54829. deviceSlot: number;
  54830. }>;
  54831. /**
  54832. * Observable to be triggered when before a device is disconnected
  54833. */
  54834. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54835. deviceType: DeviceType;
  54836. deviceSlot: number;
  54837. }>;
  54838. /**
  54839. * Observable to be triggered when after a device is connected
  54840. */
  54841. readonly onAfterDeviceConnectedObservable: Observable<{
  54842. deviceType: DeviceType;
  54843. deviceSlot: number;
  54844. }>;
  54845. /**
  54846. * Observable to be triggered when after a device is disconnected
  54847. */
  54848. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54849. deviceType: DeviceType;
  54850. deviceSlot: number;
  54851. }>;
  54852. private readonly _devices;
  54853. private readonly _firstDevice;
  54854. private readonly _deviceInputSystem;
  54855. /**
  54856. * Default Constructor
  54857. * @param engine engine to pull input element from
  54858. */
  54859. constructor(engine: Engine);
  54860. /**
  54861. * Gets a DeviceSource, given a type and slot
  54862. * @param deviceType Enum specifying device type
  54863. * @param deviceSlot "Slot" or index that device is referenced in
  54864. * @returns DeviceSource object
  54865. */
  54866. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54867. /**
  54868. * Gets an array of DeviceSource objects for a given device type
  54869. * @param deviceType Enum specifying device type
  54870. * @returns Array of DeviceSource objects
  54871. */
  54872. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54873. /**
  54874. * Dispose of DeviceInputSystem and other parts
  54875. */
  54876. dispose(): void;
  54877. /**
  54878. * Function to add device name to device list
  54879. * @param deviceType Enum specifying device type
  54880. * @param deviceSlot "Slot" or index that device is referenced in
  54881. */
  54882. private _addDevice;
  54883. /**
  54884. * Function to remove device name to device list
  54885. * @param deviceType Enum specifying device type
  54886. * @param deviceSlot "Slot" or index that device is referenced in
  54887. */
  54888. private _removeDevice;
  54889. /**
  54890. * Updates array storing first connected device of each type
  54891. * @param type Type of Device
  54892. */
  54893. private _updateFirstDevices;
  54894. }
  54895. }
  54896. declare module BABYLON {
  54897. /**
  54898. * Options to create the null engine
  54899. */
  54900. export class NullEngineOptions {
  54901. /**
  54902. * Render width (Default: 512)
  54903. */
  54904. renderWidth: number;
  54905. /**
  54906. * Render height (Default: 256)
  54907. */
  54908. renderHeight: number;
  54909. /**
  54910. * Texture size (Default: 512)
  54911. */
  54912. textureSize: number;
  54913. /**
  54914. * If delta time between frames should be constant
  54915. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54916. */
  54917. deterministicLockstep: boolean;
  54918. /**
  54919. * Maximum about of steps between frames (Default: 4)
  54920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54921. */
  54922. lockstepMaxSteps: number;
  54923. /**
  54924. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54925. */
  54926. useHighPrecisionMatrix?: boolean;
  54927. }
  54928. /**
  54929. * The null engine class provides support for headless version of babylon.js.
  54930. * This can be used in server side scenario or for testing purposes
  54931. */
  54932. export class NullEngine extends Engine {
  54933. private _options;
  54934. /**
  54935. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54937. * @returns true if engine is in deterministic lock step mode
  54938. */
  54939. isDeterministicLockStep(): boolean;
  54940. /**
  54941. * Gets the max steps when engine is running in deterministic lock step
  54942. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54943. * @returns the max steps
  54944. */
  54945. getLockstepMaxSteps(): number;
  54946. /**
  54947. * Gets the current hardware scaling level.
  54948. * By default the hardware scaling level is computed from the window device ratio.
  54949. * 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.
  54950. * @returns a number indicating the current hardware scaling level
  54951. */
  54952. getHardwareScalingLevel(): number;
  54953. constructor(options?: NullEngineOptions);
  54954. /**
  54955. * Creates a vertex buffer
  54956. * @param vertices the data for the vertex buffer
  54957. * @returns the new WebGL static buffer
  54958. */
  54959. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54960. /**
  54961. * Creates a new index buffer
  54962. * @param indices defines the content of the index buffer
  54963. * @param updatable defines if the index buffer must be updatable
  54964. * @returns a new webGL buffer
  54965. */
  54966. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54967. /**
  54968. * Clear the current render buffer or the current render target (if any is set up)
  54969. * @param color defines the color to use
  54970. * @param backBuffer defines if the back buffer must be cleared
  54971. * @param depth defines if the depth buffer must be cleared
  54972. * @param stencil defines if the stencil buffer must be cleared
  54973. */
  54974. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54975. /**
  54976. * Gets the current render width
  54977. * @param useScreen defines if screen size must be used (or the current render target if any)
  54978. * @returns a number defining the current render width
  54979. */
  54980. getRenderWidth(useScreen?: boolean): number;
  54981. /**
  54982. * Gets the current render height
  54983. * @param useScreen defines if screen size must be used (or the current render target if any)
  54984. * @returns a number defining the current render height
  54985. */
  54986. getRenderHeight(useScreen?: boolean): number;
  54987. /**
  54988. * Set the WebGL's viewport
  54989. * @param viewport defines the viewport element to be used
  54990. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54991. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54992. */
  54993. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54994. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54995. /**
  54996. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54997. * @param pipelineContext defines the pipeline context to use
  54998. * @param uniformsNames defines the list of uniform names
  54999. * @returns an array of webGL uniform locations
  55000. */
  55001. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55002. /**
  55003. * Gets the lsit of active attributes for a given webGL program
  55004. * @param pipelineContext defines the pipeline context to use
  55005. * @param attributesNames defines the list of attribute names to get
  55006. * @returns an array of indices indicating the offset of each attribute
  55007. */
  55008. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55009. /**
  55010. * Binds an effect to the webGL context
  55011. * @param effect defines the effect to bind
  55012. */
  55013. bindSamplers(effect: Effect): void;
  55014. /**
  55015. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55016. * @param effect defines the effect to activate
  55017. */
  55018. enableEffect(effect: Effect): void;
  55019. /**
  55020. * Set various states to the webGL context
  55021. * @param culling defines backface culling state
  55022. * @param zOffset defines the value to apply to zOffset (0 by default)
  55023. * @param force defines if states must be applied even if cache is up to date
  55024. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55025. */
  55026. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55027. /**
  55028. * Set the value of an uniform to an array of int32
  55029. * @param uniform defines the webGL uniform location where to store the value
  55030. * @param array defines the array of int32 to store
  55031. * @returns true if value was set
  55032. */
  55033. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55034. /**
  55035. * Set the value of an uniform to an array of int32 (stored as vec2)
  55036. * @param uniform defines the webGL uniform location where to store the value
  55037. * @param array defines the array of int32 to store
  55038. * @returns true if value was set
  55039. */
  55040. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55041. /**
  55042. * Set the value of an uniform to an array of int32 (stored as vec3)
  55043. * @param uniform defines the webGL uniform location where to store the value
  55044. * @param array defines the array of int32 to store
  55045. * @returns true if value was set
  55046. */
  55047. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55048. /**
  55049. * Set the value of an uniform to an array of int32 (stored as vec4)
  55050. * @param uniform defines the webGL uniform location where to store the value
  55051. * @param array defines the array of int32 to store
  55052. * @returns true if value was set
  55053. */
  55054. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55055. /**
  55056. * Set the value of an uniform to an array of float32
  55057. * @param uniform defines the webGL uniform location where to store the value
  55058. * @param array defines the array of float32 to store
  55059. * @returns true if value was set
  55060. */
  55061. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55062. /**
  55063. * Set the value of an uniform to an array of float32 (stored as vec2)
  55064. * @param uniform defines the webGL uniform location where to store the value
  55065. * @param array defines the array of float32 to store
  55066. * @returns true if value was set
  55067. */
  55068. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55069. /**
  55070. * Set the value of an uniform to an array of float32 (stored as vec3)
  55071. * @param uniform defines the webGL uniform location where to store the value
  55072. * @param array defines the array of float32 to store
  55073. * @returns true if value was set
  55074. */
  55075. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55076. /**
  55077. * Set the value of an uniform to an array of float32 (stored as vec4)
  55078. * @param uniform defines the webGL uniform location where to store the value
  55079. * @param array defines the array of float32 to store
  55080. * @returns true if value was set
  55081. */
  55082. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55083. /**
  55084. * Set the value of an uniform to an array of number
  55085. * @param uniform defines the webGL uniform location where to store the value
  55086. * @param array defines the array of number to store
  55087. * @returns true if value was set
  55088. */
  55089. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55090. /**
  55091. * Set the value of an uniform to an array of number (stored as vec2)
  55092. * @param uniform defines the webGL uniform location where to store the value
  55093. * @param array defines the array of number to store
  55094. * @returns true if value was set
  55095. */
  55096. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55097. /**
  55098. * Set the value of an uniform to an array of number (stored as vec3)
  55099. * @param uniform defines the webGL uniform location where to store the value
  55100. * @param array defines the array of number to store
  55101. * @returns true if value was set
  55102. */
  55103. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55104. /**
  55105. * Set the value of an uniform to an array of number (stored as vec4)
  55106. * @param uniform defines the webGL uniform location where to store the value
  55107. * @param array defines the array of number to store
  55108. * @returns true if value was set
  55109. */
  55110. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55111. /**
  55112. * Set the value of an uniform to an array of float32 (stored as matrices)
  55113. * @param uniform defines the webGL uniform location where to store the value
  55114. * @param matrices defines the array of float32 to store
  55115. * @returns true if value was set
  55116. */
  55117. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55118. /**
  55119. * Set the value of an uniform to a matrix (3x3)
  55120. * @param uniform defines the webGL uniform location where to store the value
  55121. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55122. * @returns true if value was set
  55123. */
  55124. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55125. /**
  55126. * Set the value of an uniform to a matrix (2x2)
  55127. * @param uniform defines the webGL uniform location where to store the value
  55128. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55129. * @returns true if value was set
  55130. */
  55131. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55132. /**
  55133. * Set the value of an uniform to a number (float)
  55134. * @param uniform defines the webGL uniform location where to store the value
  55135. * @param value defines the float number to store
  55136. * @returns true if value was set
  55137. */
  55138. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55139. /**
  55140. * Set the value of an uniform to a vec2
  55141. * @param uniform defines the webGL uniform location where to store the value
  55142. * @param x defines the 1st component of the value
  55143. * @param y defines the 2nd component of the value
  55144. * @returns true if value was set
  55145. */
  55146. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55147. /**
  55148. * Set the value of an uniform to a vec3
  55149. * @param uniform defines the webGL uniform location where to store the value
  55150. * @param x defines the 1st component of the value
  55151. * @param y defines the 2nd component of the value
  55152. * @param z defines the 3rd component of the value
  55153. * @returns true if value was set
  55154. */
  55155. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55156. /**
  55157. * Set the value of an uniform to a boolean
  55158. * @param uniform defines the webGL uniform location where to store the value
  55159. * @param bool defines the boolean to store
  55160. * @returns true if value was set
  55161. */
  55162. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55163. /**
  55164. * Set the value of an uniform to a vec4
  55165. * @param uniform defines the webGL uniform location where to store the value
  55166. * @param x defines the 1st component of the value
  55167. * @param y defines the 2nd component of the value
  55168. * @param z defines the 3rd component of the value
  55169. * @param w defines the 4th component of the value
  55170. * @returns true if value was set
  55171. */
  55172. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55173. /**
  55174. * Sets the current alpha mode
  55175. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55176. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55177. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55178. */
  55179. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55180. /**
  55181. * Bind webGl buffers directly to the webGL context
  55182. * @param vertexBuffers defines the vertex buffer to bind
  55183. * @param indexBuffer defines the index buffer to bind
  55184. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55185. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55186. * @param effect defines the effect associated with the vertex buffer
  55187. */
  55188. bindBuffers(vertexBuffers: {
  55189. [key: string]: VertexBuffer;
  55190. }, indexBuffer: DataBuffer, effect: Effect): void;
  55191. /**
  55192. * Force the entire cache to be cleared
  55193. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55194. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55195. */
  55196. wipeCaches(bruteForce?: boolean): void;
  55197. /**
  55198. * Send a draw order
  55199. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55200. * @param indexStart defines the starting index
  55201. * @param indexCount defines the number of index to draw
  55202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55203. */
  55204. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55205. /**
  55206. * Draw a list of indexed primitives
  55207. * @param fillMode defines the primitive to use
  55208. * @param indexStart defines the starting index
  55209. * @param indexCount defines the number of index to draw
  55210. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55211. */
  55212. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55213. /**
  55214. * Draw a list of unindexed primitives
  55215. * @param fillMode defines the primitive to use
  55216. * @param verticesStart defines the index of first vertex to draw
  55217. * @param verticesCount defines the count of vertices to draw
  55218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55219. */
  55220. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55221. /** @hidden */
  55222. _createTexture(): WebGLTexture;
  55223. /** @hidden */
  55224. _releaseTexture(texture: InternalTexture): void;
  55225. /**
  55226. * Usually called from Texture.ts.
  55227. * Passed information to create a WebGLTexture
  55228. * @param urlArg defines a value which contains one of the following:
  55229. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55230. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55231. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55233. * @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)
  55234. * @param scene needed for loading to the correct scene
  55235. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55236. * @param onLoad optional callback to be called upon successful completion
  55237. * @param onError optional callback to be called upon failure
  55238. * @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
  55239. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55240. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55241. * @param forcedExtension defines the extension to use to pick the right loader
  55242. * @param mimeType defines an optional mime type
  55243. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55244. */
  55245. 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;
  55246. /**
  55247. * Creates a new render target texture
  55248. * @param size defines the size of the texture
  55249. * @param options defines the options used to create the texture
  55250. * @returns a new render target texture stored in an InternalTexture
  55251. */
  55252. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55253. /**
  55254. * Update the sampling mode of a given texture
  55255. * @param samplingMode defines the required sampling mode
  55256. * @param texture defines the texture to update
  55257. */
  55258. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55259. /**
  55260. * Binds the frame buffer to the specified texture.
  55261. * @param texture The texture to render to or null for the default canvas
  55262. * @param faceIndex The face of the texture to render to in case of cube texture
  55263. * @param requiredWidth The width of the target to render to
  55264. * @param requiredHeight The height of the target to render to
  55265. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55266. * @param lodLevel defines le lod level to bind to the frame buffer
  55267. */
  55268. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55269. /**
  55270. * Unbind the current render target texture from the webGL context
  55271. * @param texture defines the render target texture to unbind
  55272. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55273. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55274. */
  55275. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55276. /**
  55277. * Creates a dynamic vertex buffer
  55278. * @param vertices the data for the dynamic vertex buffer
  55279. * @returns the new WebGL dynamic buffer
  55280. */
  55281. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55282. /**
  55283. * Update the content of a dynamic texture
  55284. * @param texture defines the texture to update
  55285. * @param canvas defines the canvas containing the source
  55286. * @param invertY defines if data must be stored with Y axis inverted
  55287. * @param premulAlpha defines if alpha is stored as premultiplied
  55288. * @param format defines the format of the data
  55289. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55290. */
  55291. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55292. /**
  55293. * Gets a boolean indicating if all created effects are ready
  55294. * @returns true if all effects are ready
  55295. */
  55296. areAllEffectsReady(): boolean;
  55297. /**
  55298. * @hidden
  55299. * Get the current error code of the webGL context
  55300. * @returns the error code
  55301. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55302. */
  55303. getError(): number;
  55304. /** @hidden */
  55305. _getUnpackAlignement(): number;
  55306. /** @hidden */
  55307. _unpackFlipY(value: boolean): void;
  55308. /**
  55309. * Update a dynamic index buffer
  55310. * @param indexBuffer defines the target index buffer
  55311. * @param indices defines the data to update
  55312. * @param offset defines the offset in the target index buffer where update should start
  55313. */
  55314. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55315. /**
  55316. * Updates a dynamic vertex buffer.
  55317. * @param vertexBuffer the vertex buffer to update
  55318. * @param vertices the data used to update the vertex buffer
  55319. * @param byteOffset the byte offset of the data (optional)
  55320. * @param byteLength the byte length of the data (optional)
  55321. */
  55322. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55323. /** @hidden */
  55324. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55325. /** @hidden */
  55326. _bindTexture(channel: number, texture: InternalTexture): void;
  55327. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55328. /**
  55329. * 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
  55330. */
  55331. releaseEffects(): void;
  55332. displayLoadingUI(): void;
  55333. hideLoadingUI(): void;
  55334. /** @hidden */
  55335. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55336. /** @hidden */
  55337. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55338. /** @hidden */
  55339. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55340. /** @hidden */
  55341. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55342. }
  55343. }
  55344. declare module BABYLON {
  55345. /**
  55346. * @hidden
  55347. **/
  55348. export class _TimeToken {
  55349. _startTimeQuery: Nullable<WebGLQuery>;
  55350. _endTimeQuery: Nullable<WebGLQuery>;
  55351. _timeElapsedQuery: Nullable<WebGLQuery>;
  55352. _timeElapsedQueryEnded: boolean;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /** @hidden */
  55357. export class _OcclusionDataStorage {
  55358. /** @hidden */
  55359. occlusionInternalRetryCounter: number;
  55360. /** @hidden */
  55361. isOcclusionQueryInProgress: boolean;
  55362. /** @hidden */
  55363. isOccluded: boolean;
  55364. /** @hidden */
  55365. occlusionRetryCount: number;
  55366. /** @hidden */
  55367. occlusionType: number;
  55368. /** @hidden */
  55369. occlusionQueryAlgorithmType: number;
  55370. }
  55371. interface Engine {
  55372. /**
  55373. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55374. * @return the new query
  55375. */
  55376. createQuery(): WebGLQuery;
  55377. /**
  55378. * Delete and release a webGL query
  55379. * @param query defines the query to delete
  55380. * @return the current engine
  55381. */
  55382. deleteQuery(query: WebGLQuery): Engine;
  55383. /**
  55384. * Check if a given query has resolved and got its value
  55385. * @param query defines the query to check
  55386. * @returns true if the query got its value
  55387. */
  55388. isQueryResultAvailable(query: WebGLQuery): boolean;
  55389. /**
  55390. * Gets the value of a given query
  55391. * @param query defines the query to check
  55392. * @returns the value of the query
  55393. */
  55394. getQueryResult(query: WebGLQuery): number;
  55395. /**
  55396. * Initiates an occlusion query
  55397. * @param algorithmType defines the algorithm to use
  55398. * @param query defines the query to use
  55399. * @returns the current engine
  55400. * @see https://doc.babylonjs.com/features/occlusionquery
  55401. */
  55402. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55403. /**
  55404. * Ends an occlusion query
  55405. * @see https://doc.babylonjs.com/features/occlusionquery
  55406. * @param algorithmType defines the algorithm to use
  55407. * @returns the current engine
  55408. */
  55409. endOcclusionQuery(algorithmType: number): Engine;
  55410. /**
  55411. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55412. * Please note that only one query can be issued at a time
  55413. * @returns a time token used to track the time span
  55414. */
  55415. startTimeQuery(): Nullable<_TimeToken>;
  55416. /**
  55417. * Ends a time query
  55418. * @param token defines the token used to measure the time span
  55419. * @returns the time spent (in ns)
  55420. */
  55421. endTimeQuery(token: _TimeToken): int;
  55422. /** @hidden */
  55423. _currentNonTimestampToken: Nullable<_TimeToken>;
  55424. /** @hidden */
  55425. _createTimeQuery(): WebGLQuery;
  55426. /** @hidden */
  55427. _deleteTimeQuery(query: WebGLQuery): void;
  55428. /** @hidden */
  55429. _getGlAlgorithmType(algorithmType: number): number;
  55430. /** @hidden */
  55431. _getTimeQueryResult(query: WebGLQuery): any;
  55432. /** @hidden */
  55433. _getTimeQueryAvailability(query: WebGLQuery): any;
  55434. }
  55435. interface AbstractMesh {
  55436. /**
  55437. * Backing filed
  55438. * @hidden
  55439. */
  55440. __occlusionDataStorage: _OcclusionDataStorage;
  55441. /**
  55442. * Access property
  55443. * @hidden
  55444. */
  55445. _occlusionDataStorage: _OcclusionDataStorage;
  55446. /**
  55447. * 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.
  55448. * The default value is -1 which means don't break the query and wait till the result
  55449. * @see https://doc.babylonjs.com/features/occlusionquery
  55450. */
  55451. occlusionRetryCount: number;
  55452. /**
  55453. * 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:
  55454. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55455. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55456. * * 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.
  55457. * @see https://doc.babylonjs.com/features/occlusionquery
  55458. */
  55459. occlusionType: number;
  55460. /**
  55461. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55462. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55463. * * 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.
  55464. * @see https://doc.babylonjs.com/features/occlusionquery
  55465. */
  55466. occlusionQueryAlgorithmType: number;
  55467. /**
  55468. * 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
  55469. * @see https://doc.babylonjs.com/features/occlusionquery
  55470. */
  55471. isOccluded: boolean;
  55472. /**
  55473. * Flag to check the progress status of the query
  55474. * @see https://doc.babylonjs.com/features/occlusionquery
  55475. */
  55476. isOcclusionQueryInProgress: boolean;
  55477. }
  55478. }
  55479. declare module BABYLON {
  55480. /** @hidden */
  55481. export var _forceTransformFeedbackToBundle: boolean;
  55482. interface Engine {
  55483. /**
  55484. * Creates a webGL transform feedback object
  55485. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55486. * @returns the webGL transform feedback object
  55487. */
  55488. createTransformFeedback(): WebGLTransformFeedback;
  55489. /**
  55490. * Delete a webGL transform feedback object
  55491. * @param value defines the webGL transform feedback object to delete
  55492. */
  55493. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55494. /**
  55495. * Bind a webGL transform feedback object to the webgl context
  55496. * @param value defines the webGL transform feedback object to bind
  55497. */
  55498. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55499. /**
  55500. * Begins a transform feedback operation
  55501. * @param usePoints defines if points or triangles must be used
  55502. */
  55503. beginTransformFeedback(usePoints: boolean): void;
  55504. /**
  55505. * Ends a transform feedback operation
  55506. */
  55507. endTransformFeedback(): void;
  55508. /**
  55509. * Specify the varyings to use with transform feedback
  55510. * @param program defines the associated webGL program
  55511. * @param value defines the list of strings representing the varying names
  55512. */
  55513. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55514. /**
  55515. * Bind a webGL buffer for a transform feedback operation
  55516. * @param value defines the webGL buffer to bind
  55517. */
  55518. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55519. }
  55520. }
  55521. declare module BABYLON {
  55522. /**
  55523. * Class used to define an additional view for the engine
  55524. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55525. */
  55526. export class EngineView {
  55527. /** Defines the canvas where to render the view */
  55528. target: HTMLCanvasElement;
  55529. /** Defines an optional camera used to render the view (will use active camera else) */
  55530. camera?: Camera;
  55531. }
  55532. interface Engine {
  55533. /**
  55534. * Gets or sets the HTML element to use for attaching events
  55535. */
  55536. inputElement: Nullable<HTMLElement>;
  55537. /**
  55538. * Gets the current engine view
  55539. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55540. */
  55541. activeView: Nullable<EngineView>;
  55542. /** Gets or sets the list of views */
  55543. views: EngineView[];
  55544. /**
  55545. * Register a new child canvas
  55546. * @param canvas defines the canvas to register
  55547. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55548. * @returns the associated view
  55549. */
  55550. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55551. /**
  55552. * Remove a registered child canvas
  55553. * @param canvas defines the canvas to remove
  55554. * @returns the current engine
  55555. */
  55556. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55557. }
  55558. }
  55559. declare module BABYLON {
  55560. interface Engine {
  55561. /** @hidden */
  55562. _excludedCompressedTextures: string[];
  55563. /** @hidden */
  55564. _textureFormatInUse: string;
  55565. /**
  55566. * Gets the list of texture formats supported
  55567. */
  55568. readonly texturesSupported: Array<string>;
  55569. /**
  55570. * Gets the texture format in use
  55571. */
  55572. readonly textureFormatInUse: Nullable<string>;
  55573. /**
  55574. * Set the compressed texture extensions or file names to skip.
  55575. *
  55576. * @param skippedFiles defines the list of those texture files you want to skip
  55577. * Example: [".dds", ".env", "myfile.png"]
  55578. */
  55579. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55580. /**
  55581. * Set the compressed texture format to use, based on the formats you have, and the formats
  55582. * supported by the hardware / browser.
  55583. *
  55584. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55585. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55586. * to API arguments needed to compressed textures. This puts the burden on the container
  55587. * generator to house the arcane code for determining these for current & future formats.
  55588. *
  55589. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55590. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55591. *
  55592. * Note: The result of this call is not taken into account when a texture is base64.
  55593. *
  55594. * @param formatsAvailable defines the list of those format families you have created
  55595. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55596. *
  55597. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55598. * @returns The extension selected.
  55599. */
  55600. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55601. }
  55602. }
  55603. declare module BABYLON {
  55604. /** @hidden */
  55605. export var rgbdEncodePixelShader: {
  55606. name: string;
  55607. shader: string;
  55608. };
  55609. }
  55610. declare module BABYLON {
  55611. /**
  55612. * Raw texture data and descriptor sufficient for WebGL texture upload
  55613. */
  55614. export interface EnvironmentTextureInfo {
  55615. /**
  55616. * Version of the environment map
  55617. */
  55618. version: number;
  55619. /**
  55620. * Width of image
  55621. */
  55622. width: number;
  55623. /**
  55624. * Irradiance information stored in the file.
  55625. */
  55626. irradiance: any;
  55627. /**
  55628. * Specular information stored in the file.
  55629. */
  55630. specular: any;
  55631. }
  55632. /**
  55633. * Defines One Image in the file. It requires only the position in the file
  55634. * as well as the length.
  55635. */
  55636. interface BufferImageData {
  55637. /**
  55638. * Length of the image data.
  55639. */
  55640. length: number;
  55641. /**
  55642. * Position of the data from the null terminator delimiting the end of the JSON.
  55643. */
  55644. position: number;
  55645. }
  55646. /**
  55647. * Defines the specular data enclosed in the file.
  55648. * This corresponds to the version 1 of the data.
  55649. */
  55650. export interface EnvironmentTextureSpecularInfoV1 {
  55651. /**
  55652. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55653. */
  55654. specularDataPosition?: number;
  55655. /**
  55656. * This contains all the images data needed to reconstruct the cubemap.
  55657. */
  55658. mipmaps: Array<BufferImageData>;
  55659. /**
  55660. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55661. */
  55662. lodGenerationScale: number;
  55663. }
  55664. /**
  55665. * Sets of helpers addressing the serialization and deserialization of environment texture
  55666. * stored in a BabylonJS env file.
  55667. * Those files are usually stored as .env files.
  55668. */
  55669. export class EnvironmentTextureTools {
  55670. /**
  55671. * Magic number identifying the env file.
  55672. */
  55673. private static _MagicBytes;
  55674. /**
  55675. * Gets the environment info from an env file.
  55676. * @param data The array buffer containing the .env bytes.
  55677. * @returns the environment file info (the json header) if successfully parsed.
  55678. */
  55679. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55680. /**
  55681. * Creates an environment texture from a loaded cube texture.
  55682. * @param texture defines the cube texture to convert in env file
  55683. * @return a promise containing the environment data if succesfull.
  55684. */
  55685. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55686. /**
  55687. * Creates a JSON representation of the spherical data.
  55688. * @param texture defines the texture containing the polynomials
  55689. * @return the JSON representation of the spherical info
  55690. */
  55691. private static _CreateEnvTextureIrradiance;
  55692. /**
  55693. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55694. * @param data the image data
  55695. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55696. * @return the views described by info providing access to the underlying buffer
  55697. */
  55698. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55699. /**
  55700. * Uploads the texture info contained in the env file to the GPU.
  55701. * @param texture defines the internal texture to upload to
  55702. * @param data defines the data to load
  55703. * @param info defines the texture info retrieved through the GetEnvInfo method
  55704. * @returns a promise
  55705. */
  55706. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55707. private static _OnImageReadyAsync;
  55708. /**
  55709. * Uploads the levels of image data to the GPU.
  55710. * @param texture defines the internal texture to upload to
  55711. * @param imageData defines the array buffer views of image data [mipmap][face]
  55712. * @returns a promise
  55713. */
  55714. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55715. /**
  55716. * Uploads spherical polynomials information to the texture.
  55717. * @param texture defines the texture we are trying to upload the information to
  55718. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55719. */
  55720. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55721. /** @hidden */
  55722. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55723. }
  55724. }
  55725. declare module BABYLON {
  55726. /**
  55727. * Class used to inline functions in shader code
  55728. */
  55729. export class ShaderCodeInliner {
  55730. private static readonly _RegexpFindFunctionNameAndType;
  55731. private _sourceCode;
  55732. private _functionDescr;
  55733. private _numMaxIterations;
  55734. /** Gets or sets the token used to mark the functions to inline */
  55735. inlineToken: string;
  55736. /** Gets or sets the debug mode */
  55737. debug: boolean;
  55738. /** Gets the code after the inlining process */
  55739. get code(): string;
  55740. /**
  55741. * Initializes the inliner
  55742. * @param sourceCode shader code source to inline
  55743. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55744. */
  55745. constructor(sourceCode: string, numMaxIterations?: number);
  55746. /**
  55747. * Start the processing of the shader code
  55748. */
  55749. processCode(): void;
  55750. private _collectFunctions;
  55751. private _processInlining;
  55752. private _extractBetweenMarkers;
  55753. private _skipWhitespaces;
  55754. private _removeComments;
  55755. private _replaceFunctionCallsByCode;
  55756. private _findBackward;
  55757. private _escapeRegExp;
  55758. private _replaceNames;
  55759. }
  55760. }
  55761. declare module BABYLON {
  55762. /**
  55763. * Container for accessors for natively-stored mesh data buffers.
  55764. */
  55765. class NativeDataBuffer extends DataBuffer {
  55766. /**
  55767. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55768. */
  55769. nativeIndexBuffer?: any;
  55770. /**
  55771. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55772. */
  55773. nativeVertexBuffer?: any;
  55774. }
  55775. /** @hidden */
  55776. class NativeTexture extends InternalTexture {
  55777. getInternalTexture(): InternalTexture;
  55778. getViewCount(): number;
  55779. }
  55780. /** @hidden */
  55781. export class NativeEngine extends Engine {
  55782. private readonly _native;
  55783. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55784. private readonly INVALID_HANDLE;
  55785. private _boundBuffersVertexArray;
  55786. private _currentDepthTest;
  55787. getHardwareScalingLevel(): number;
  55788. constructor();
  55789. dispose(): void;
  55790. /**
  55791. * Can be used to override the current requestAnimationFrame requester.
  55792. * @hidden
  55793. */
  55794. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55795. /**
  55796. * Override default engine behavior.
  55797. * @param color
  55798. * @param backBuffer
  55799. * @param depth
  55800. * @param stencil
  55801. */
  55802. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55803. /**
  55804. * Gets host document
  55805. * @returns the host document object
  55806. */
  55807. getHostDocument(): Nullable<Document>;
  55808. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55809. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55810. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55811. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55812. [key: string]: VertexBuffer;
  55813. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55814. bindBuffers(vertexBuffers: {
  55815. [key: string]: VertexBuffer;
  55816. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55817. recordVertexArrayObject(vertexBuffers: {
  55818. [key: string]: VertexBuffer;
  55819. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55820. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55821. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55822. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55823. /**
  55824. * Draw a list of indexed primitives
  55825. * @param fillMode defines the primitive to use
  55826. * @param indexStart defines the starting index
  55827. * @param indexCount defines the number of index to draw
  55828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55829. */
  55830. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55831. /**
  55832. * Draw a list of unindexed primitives
  55833. * @param fillMode defines the primitive to use
  55834. * @param verticesStart defines the index of first vertex to draw
  55835. * @param verticesCount defines the count of vertices to draw
  55836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55837. */
  55838. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55839. createPipelineContext(): IPipelineContext;
  55840. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55841. /** @hidden */
  55842. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55843. /** @hidden */
  55844. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55845. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55846. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55847. protected _setProgram(program: WebGLProgram): void;
  55848. _releaseEffect(effect: Effect): void;
  55849. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55850. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55851. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55852. bindSamplers(effect: Effect): void;
  55853. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55854. getRenderWidth(useScreen?: boolean): number;
  55855. getRenderHeight(useScreen?: boolean): number;
  55856. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55857. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55858. /**
  55859. * Set the z offset to apply to current rendering
  55860. * @param value defines the offset to apply
  55861. */
  55862. setZOffset(value: number): void;
  55863. /**
  55864. * Gets the current value of the zOffset
  55865. * @returns the current zOffset state
  55866. */
  55867. getZOffset(): number;
  55868. /**
  55869. * Enable or disable depth buffering
  55870. * @param enable defines the state to set
  55871. */
  55872. setDepthBuffer(enable: boolean): void;
  55873. /**
  55874. * Gets a boolean indicating if depth writing is enabled
  55875. * @returns the current depth writing state
  55876. */
  55877. getDepthWrite(): boolean;
  55878. setDepthFunctionToGreater(): void;
  55879. setDepthFunctionToGreaterOrEqual(): void;
  55880. setDepthFunctionToLess(): void;
  55881. setDepthFunctionToLessOrEqual(): void;
  55882. /**
  55883. * Enable or disable depth writing
  55884. * @param enable defines the state to set
  55885. */
  55886. setDepthWrite(enable: boolean): void;
  55887. /**
  55888. * Enable or disable color writing
  55889. * @param enable defines the state to set
  55890. */
  55891. setColorWrite(enable: boolean): void;
  55892. /**
  55893. * Gets a boolean indicating if color writing is enabled
  55894. * @returns the current color writing state
  55895. */
  55896. getColorWrite(): boolean;
  55897. /**
  55898. * Sets alpha constants used by some alpha blending modes
  55899. * @param r defines the red component
  55900. * @param g defines the green component
  55901. * @param b defines the blue component
  55902. * @param a defines the alpha component
  55903. */
  55904. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55905. /**
  55906. * Sets the current alpha mode
  55907. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55908. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55910. */
  55911. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55912. /**
  55913. * Gets the current alpha mode
  55914. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55915. * @returns the current alpha mode
  55916. */
  55917. getAlphaMode(): number;
  55918. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55927. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55928. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55929. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55930. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55934. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55937. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55938. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55939. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55940. wipeCaches(bruteForce?: boolean): void;
  55941. _createTexture(): WebGLTexture;
  55942. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55943. /**
  55944. * Update the content of a dynamic texture
  55945. * @param texture defines the texture to update
  55946. * @param canvas defines the canvas containing the source
  55947. * @param invertY defines if data must be stored with Y axis inverted
  55948. * @param premulAlpha defines if alpha is stored as premultiplied
  55949. * @param format defines the format of the data
  55950. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55951. */
  55952. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55953. /**
  55954. * Usually called from Texture.ts.
  55955. * Passed information to create a WebGLTexture
  55956. * @param url defines a value which contains one of the following:
  55957. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55958. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55959. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55960. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55961. * @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)
  55962. * @param scene needed for loading to the correct scene
  55963. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55964. * @param onLoad optional callback to be called upon successful completion
  55965. * @param onError optional callback to be called upon failure
  55966. * @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
  55967. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55968. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55969. * @param forcedExtension defines the extension to use to pick the right loader
  55970. * @param mimeType defines an optional mime type
  55971. * @param loaderOptions options to be passed to the loader
  55972. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55973. */
  55974. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  55975. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55976. _releaseFramebufferObjects(texture: InternalTexture): void;
  55977. /**
  55978. * Creates a cube texture
  55979. * @param rootUrl defines the url where the files to load is located
  55980. * @param scene defines the current scene
  55981. * @param files defines the list of files to load (1 per face)
  55982. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55983. * @param onLoad defines an optional callback raised when the texture is loaded
  55984. * @param onError defines an optional callback raised if there is an issue to load the texture
  55985. * @param format defines the format of the data
  55986. * @param forcedExtension defines the extension to use to pick the right loader
  55987. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55988. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55989. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55990. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55991. * @returns the cube texture as an InternalTexture
  55992. */
  55993. 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;
  55994. createRenderTargetTexture(size: number | {
  55995. width: number;
  55996. height: number;
  55997. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55998. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55999. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56000. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56001. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56002. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56003. /**
  56004. * Updates a dynamic vertex buffer.
  56005. * @param vertexBuffer the vertex buffer to update
  56006. * @param data the data used to update the vertex buffer
  56007. * @param byteOffset the byte offset of the data (optional)
  56008. * @param byteLength the byte length of the data (optional)
  56009. */
  56010. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56011. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56012. private _updateAnisotropicLevel;
  56013. private _getAddressMode;
  56014. /** @hidden */
  56015. _bindTexture(channel: number, texture: InternalTexture): void;
  56016. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56017. releaseEffects(): void;
  56018. /** @hidden */
  56019. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56020. /** @hidden */
  56021. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56022. /** @hidden */
  56023. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56024. /** @hidden */
  56025. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56026. private _getNativeSamplingMode;
  56027. private _getNativeTextureFormat;
  56028. private _getNativeAlphaMode;
  56029. private _getNativeAttribType;
  56030. }
  56031. }
  56032. declare module BABYLON {
  56033. /**
  56034. * Gather the list of clipboard event types as constants.
  56035. */
  56036. export class ClipboardEventTypes {
  56037. /**
  56038. * The clipboard event is fired when a copy command is active (pressed).
  56039. */
  56040. static readonly COPY: number;
  56041. /**
  56042. * The clipboard event is fired when a cut command is active (pressed).
  56043. */
  56044. static readonly CUT: number;
  56045. /**
  56046. * The clipboard event is fired when a paste command is active (pressed).
  56047. */
  56048. static readonly PASTE: number;
  56049. }
  56050. /**
  56051. * This class is used to store clipboard related info for the onClipboardObservable event.
  56052. */
  56053. export class ClipboardInfo {
  56054. /**
  56055. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56056. */
  56057. type: number;
  56058. /**
  56059. * Defines the related dom event
  56060. */
  56061. event: ClipboardEvent;
  56062. /**
  56063. *Creates an instance of ClipboardInfo.
  56064. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56065. * @param event Defines the related dom event
  56066. */
  56067. constructor(
  56068. /**
  56069. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56070. */
  56071. type: number,
  56072. /**
  56073. * Defines the related dom event
  56074. */
  56075. event: ClipboardEvent);
  56076. /**
  56077. * Get the clipboard event's type from the keycode.
  56078. * @param keyCode Defines the keyCode for the current keyboard event.
  56079. * @return {number}
  56080. */
  56081. static GetTypeFromCharacter(keyCode: number): number;
  56082. }
  56083. }
  56084. declare module BABYLON {
  56085. /**
  56086. * Google Daydream controller
  56087. */
  56088. export class DaydreamController extends WebVRController {
  56089. /**
  56090. * Base Url for the controller model.
  56091. */
  56092. static MODEL_BASE_URL: string;
  56093. /**
  56094. * File name for the controller model.
  56095. */
  56096. static MODEL_FILENAME: string;
  56097. /**
  56098. * Gamepad Id prefix used to identify Daydream Controller.
  56099. */
  56100. static readonly GAMEPAD_ID_PREFIX: string;
  56101. /**
  56102. * Creates a new DaydreamController from a gamepad
  56103. * @param vrGamepad the gamepad that the controller should be created from
  56104. */
  56105. constructor(vrGamepad: any);
  56106. /**
  56107. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56108. * @param scene scene in which to add meshes
  56109. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56110. */
  56111. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56112. /**
  56113. * Called once for each button that changed state since the last frame
  56114. * @param buttonIdx Which button index changed
  56115. * @param state New state of the button
  56116. * @param changes Which properties on the state changed since last frame
  56117. */
  56118. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56119. }
  56120. }
  56121. declare module BABYLON {
  56122. /**
  56123. * Gear VR Controller
  56124. */
  56125. export class GearVRController extends WebVRController {
  56126. /**
  56127. * Base Url for the controller model.
  56128. */
  56129. static MODEL_BASE_URL: string;
  56130. /**
  56131. * File name for the controller model.
  56132. */
  56133. static MODEL_FILENAME: string;
  56134. /**
  56135. * Gamepad Id prefix used to identify this controller.
  56136. */
  56137. static readonly GAMEPAD_ID_PREFIX: string;
  56138. private readonly _buttonIndexToObservableNameMap;
  56139. /**
  56140. * Creates a new GearVRController from a gamepad
  56141. * @param vrGamepad the gamepad that the controller should be created from
  56142. */
  56143. constructor(vrGamepad: any);
  56144. /**
  56145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56146. * @param scene scene in which to add meshes
  56147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56148. */
  56149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56150. /**
  56151. * Called once for each button that changed state since the last frame
  56152. * @param buttonIdx Which button index changed
  56153. * @param state New state of the button
  56154. * @param changes Which properties on the state changed since last frame
  56155. */
  56156. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56157. }
  56158. }
  56159. declare module BABYLON {
  56160. /**
  56161. * Generic Controller
  56162. */
  56163. export class GenericController extends WebVRController {
  56164. /**
  56165. * Base Url for the controller model.
  56166. */
  56167. static readonly MODEL_BASE_URL: string;
  56168. /**
  56169. * File name for the controller model.
  56170. */
  56171. static readonly MODEL_FILENAME: string;
  56172. /**
  56173. * Creates a new GenericController from a gamepad
  56174. * @param vrGamepad the gamepad that the controller should be created from
  56175. */
  56176. constructor(vrGamepad: any);
  56177. /**
  56178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56179. * @param scene scene in which to add meshes
  56180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56181. */
  56182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56183. /**
  56184. * Called once for each button that changed state since the last frame
  56185. * @param buttonIdx Which button index changed
  56186. * @param state New state of the button
  56187. * @param changes Which properties on the state changed since last frame
  56188. */
  56189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56190. }
  56191. }
  56192. declare module BABYLON {
  56193. /**
  56194. * Oculus Touch Controller
  56195. */
  56196. export class OculusTouchController extends WebVRController {
  56197. /**
  56198. * Base Url for the controller model.
  56199. */
  56200. static MODEL_BASE_URL: string;
  56201. /**
  56202. * File name for the left controller model.
  56203. */
  56204. static MODEL_LEFT_FILENAME: string;
  56205. /**
  56206. * File name for the right controller model.
  56207. */
  56208. static MODEL_RIGHT_FILENAME: string;
  56209. /**
  56210. * Base Url for the Quest controller model.
  56211. */
  56212. static QUEST_MODEL_BASE_URL: string;
  56213. /**
  56214. * @hidden
  56215. * If the controllers are running on a device that needs the updated Quest controller models
  56216. */
  56217. static _IsQuest: boolean;
  56218. /**
  56219. * Fired when the secondary trigger on this controller is modified
  56220. */
  56221. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56222. /**
  56223. * Fired when the thumb rest on this controller is modified
  56224. */
  56225. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56226. /**
  56227. * Creates a new OculusTouchController from a gamepad
  56228. * @param vrGamepad the gamepad that the controller should be created from
  56229. */
  56230. constructor(vrGamepad: any);
  56231. /**
  56232. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56233. * @param scene scene in which to add meshes
  56234. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56235. */
  56236. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56237. /**
  56238. * Fired when the A button on this controller is modified
  56239. */
  56240. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56241. /**
  56242. * Fired when the B button on this controller is modified
  56243. */
  56244. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56245. /**
  56246. * Fired when the X button on this controller is modified
  56247. */
  56248. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56249. /**
  56250. * Fired when the Y button on this controller is modified
  56251. */
  56252. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56253. /**
  56254. * Called once for each button that changed state since the last frame
  56255. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56256. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56257. * 2) secondary trigger (same)
  56258. * 3) A (right) X (left), touch, pressed = value
  56259. * 4) B / Y
  56260. * 5) thumb rest
  56261. * @param buttonIdx Which button index changed
  56262. * @param state New state of the button
  56263. * @param changes Which properties on the state changed since last frame
  56264. */
  56265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56266. }
  56267. }
  56268. declare module BABYLON {
  56269. /**
  56270. * Vive Controller
  56271. */
  56272. export class ViveController extends WebVRController {
  56273. /**
  56274. * Base Url for the controller model.
  56275. */
  56276. static MODEL_BASE_URL: string;
  56277. /**
  56278. * File name for the controller model.
  56279. */
  56280. static MODEL_FILENAME: string;
  56281. /**
  56282. * Creates a new ViveController from a gamepad
  56283. * @param vrGamepad the gamepad that the controller should be created from
  56284. */
  56285. constructor(vrGamepad: any);
  56286. /**
  56287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56288. * @param scene scene in which to add meshes
  56289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56290. */
  56291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56292. /**
  56293. * Fired when the left button on this controller is modified
  56294. */
  56295. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56296. /**
  56297. * Fired when the right button on this controller is modified
  56298. */
  56299. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56300. /**
  56301. * Fired when the menu button on this controller is modified
  56302. */
  56303. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56304. /**
  56305. * Called once for each button that changed state since the last frame
  56306. * Vive mapping:
  56307. * 0: touchpad
  56308. * 1: trigger
  56309. * 2: left AND right buttons
  56310. * 3: menu button
  56311. * @param buttonIdx Which button index changed
  56312. * @param state New state of the button
  56313. * @param changes Which properties on the state changed since last frame
  56314. */
  56315. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56316. }
  56317. }
  56318. declare module BABYLON {
  56319. /**
  56320. * Defines the WindowsMotionController object that the state of the windows motion controller
  56321. */
  56322. export class WindowsMotionController extends WebVRController {
  56323. /**
  56324. * The base url used to load the left and right controller models
  56325. */
  56326. static MODEL_BASE_URL: string;
  56327. /**
  56328. * The name of the left controller model file
  56329. */
  56330. static MODEL_LEFT_FILENAME: string;
  56331. /**
  56332. * The name of the right controller model file
  56333. */
  56334. static MODEL_RIGHT_FILENAME: string;
  56335. /**
  56336. * The controller name prefix for this controller type
  56337. */
  56338. static readonly GAMEPAD_ID_PREFIX: string;
  56339. /**
  56340. * The controller id pattern for this controller type
  56341. */
  56342. private static readonly GAMEPAD_ID_PATTERN;
  56343. private _loadedMeshInfo;
  56344. protected readonly _mapping: {
  56345. buttons: string[];
  56346. buttonMeshNames: {
  56347. trigger: string;
  56348. menu: string;
  56349. grip: string;
  56350. thumbstick: string;
  56351. trackpad: string;
  56352. };
  56353. buttonObservableNames: {
  56354. trigger: string;
  56355. menu: string;
  56356. grip: string;
  56357. thumbstick: string;
  56358. trackpad: string;
  56359. };
  56360. axisMeshNames: string[];
  56361. pointingPoseMeshName: string;
  56362. };
  56363. /**
  56364. * Fired when the trackpad on this controller is clicked
  56365. */
  56366. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56367. /**
  56368. * Fired when the trackpad on this controller is modified
  56369. */
  56370. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56371. /**
  56372. * The current x and y values of this controller's trackpad
  56373. */
  56374. trackpad: StickValues;
  56375. /**
  56376. * Creates a new WindowsMotionController from a gamepad
  56377. * @param vrGamepad the gamepad that the controller should be created from
  56378. */
  56379. constructor(vrGamepad: any);
  56380. /**
  56381. * Fired when the trigger on this controller is modified
  56382. */
  56383. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56384. /**
  56385. * Fired when the menu button on this controller is modified
  56386. */
  56387. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56388. /**
  56389. * Fired when the grip button on this controller is modified
  56390. */
  56391. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56392. /**
  56393. * Fired when the thumbstick button on this controller is modified
  56394. */
  56395. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56396. /**
  56397. * Fired when the touchpad button on this controller is modified
  56398. */
  56399. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56400. /**
  56401. * Fired when the touchpad values on this controller are modified
  56402. */
  56403. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56404. protected _updateTrackpad(): void;
  56405. /**
  56406. * Called once per frame by the engine.
  56407. */
  56408. update(): void;
  56409. /**
  56410. * Called once for each button that changed state since the last frame
  56411. * @param buttonIdx Which button index changed
  56412. * @param state New state of the button
  56413. * @param changes Which properties on the state changed since last frame
  56414. */
  56415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56416. /**
  56417. * Moves the buttons on the controller mesh based on their current state
  56418. * @param buttonName the name of the button to move
  56419. * @param buttonValue the value of the button which determines the buttons new position
  56420. */
  56421. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56422. /**
  56423. * Moves the axis on the controller mesh based on its current state
  56424. * @param axis the index of the axis
  56425. * @param axisValue the value of the axis which determines the meshes new position
  56426. * @hidden
  56427. */
  56428. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56429. /**
  56430. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56431. * @param scene scene in which to add meshes
  56432. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56433. */
  56434. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56435. /**
  56436. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56437. * can be transformed by button presses and axes values, based on this._mapping.
  56438. *
  56439. * @param scene scene in which the meshes exist
  56440. * @param meshes list of meshes that make up the controller model to process
  56441. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56442. */
  56443. private processModel;
  56444. private createMeshInfo;
  56445. /**
  56446. * Gets the ray of the controller in the direction the controller is pointing
  56447. * @param length the length the resulting ray should be
  56448. * @returns a ray in the direction the controller is pointing
  56449. */
  56450. getForwardRay(length?: number): Ray;
  56451. /**
  56452. * Disposes of the controller
  56453. */
  56454. dispose(): void;
  56455. }
  56456. /**
  56457. * This class represents a new windows motion controller in XR.
  56458. */
  56459. export class XRWindowsMotionController extends WindowsMotionController {
  56460. /**
  56461. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56462. */
  56463. protected readonly _mapping: {
  56464. buttons: string[];
  56465. buttonMeshNames: {
  56466. trigger: string;
  56467. menu: string;
  56468. grip: string;
  56469. thumbstick: string;
  56470. trackpad: string;
  56471. };
  56472. buttonObservableNames: {
  56473. trigger: string;
  56474. menu: string;
  56475. grip: string;
  56476. thumbstick: string;
  56477. trackpad: string;
  56478. };
  56479. axisMeshNames: string[];
  56480. pointingPoseMeshName: string;
  56481. };
  56482. /**
  56483. * Construct a new XR-Based windows motion controller
  56484. *
  56485. * @param gamepadInfo the gamepad object from the browser
  56486. */
  56487. constructor(gamepadInfo: any);
  56488. /**
  56489. * holds the thumbstick values (X,Y)
  56490. */
  56491. thumbstickValues: StickValues;
  56492. /**
  56493. * Fired when the thumbstick on this controller is clicked
  56494. */
  56495. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56496. /**
  56497. * Fired when the thumbstick on this controller is modified
  56498. */
  56499. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56500. /**
  56501. * Fired when the touchpad button on this controller is modified
  56502. */
  56503. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56504. /**
  56505. * Fired when the touchpad values on this controller are modified
  56506. */
  56507. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56508. /**
  56509. * Fired when the thumbstick button on this controller is modified
  56510. * here to prevent breaking changes
  56511. */
  56512. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56513. /**
  56514. * updating the thumbstick(!) and not the trackpad.
  56515. * This is named this way due to the difference between WebVR and XR and to avoid
  56516. * changing the parent class.
  56517. */
  56518. protected _updateTrackpad(): void;
  56519. /**
  56520. * Disposes the class with joy
  56521. */
  56522. dispose(): void;
  56523. }
  56524. }
  56525. declare module BABYLON {
  56526. /**
  56527. * Class containing static functions to help procedurally build meshes
  56528. */
  56529. export class PolyhedronBuilder {
  56530. /**
  56531. * Creates a polyhedron mesh
  56532. * * 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
  56533. * * The parameter `size` (positive float, default 1) sets the polygon size
  56534. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56535. * * 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`
  56536. * * 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
  56537. * * 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)`)
  56538. * * 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
  56539. * * 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
  56540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56541. * * 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
  56542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56543. * @param name defines the name of the mesh
  56544. * @param options defines the options used to create the mesh
  56545. * @param scene defines the hosting scene
  56546. * @returns the polyhedron mesh
  56547. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56548. */
  56549. static CreatePolyhedron(name: string, options: {
  56550. type?: number;
  56551. size?: number;
  56552. sizeX?: number;
  56553. sizeY?: number;
  56554. sizeZ?: number;
  56555. custom?: any;
  56556. faceUV?: Vector4[];
  56557. faceColors?: Color4[];
  56558. flat?: boolean;
  56559. updatable?: boolean;
  56560. sideOrientation?: number;
  56561. frontUVs?: Vector4;
  56562. backUVs?: Vector4;
  56563. }, scene?: Nullable<Scene>): Mesh;
  56564. }
  56565. }
  56566. declare module BABYLON {
  56567. /**
  56568. * Gizmo that enables scaling a mesh along 3 axis
  56569. */
  56570. export class ScaleGizmo extends Gizmo {
  56571. /**
  56572. * Internal gizmo used for interactions on the x axis
  56573. */
  56574. xGizmo: AxisScaleGizmo;
  56575. /**
  56576. * Internal gizmo used for interactions on the y axis
  56577. */
  56578. yGizmo: AxisScaleGizmo;
  56579. /**
  56580. * Internal gizmo used for interactions on the z axis
  56581. */
  56582. zGizmo: AxisScaleGizmo;
  56583. /**
  56584. * Internal gizmo used to scale all axis equally
  56585. */
  56586. uniformScaleGizmo: AxisScaleGizmo;
  56587. private _meshAttached;
  56588. private _nodeAttached;
  56589. private _snapDistance;
  56590. private _uniformScalingMesh;
  56591. private _octahedron;
  56592. private _sensitivity;
  56593. /** Fires an event when any of it's sub gizmos are dragged */
  56594. onDragStartObservable: Observable<unknown>;
  56595. /** Fires an event when any of it's sub gizmos are released from dragging */
  56596. onDragEndObservable: Observable<unknown>;
  56597. get attachedMesh(): Nullable<AbstractMesh>;
  56598. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56599. get attachedNode(): Nullable<Node>;
  56600. set attachedNode(node: Nullable<Node>);
  56601. /**
  56602. * True when the mouse pointer is hovering a gizmo mesh
  56603. */
  56604. get isHovered(): boolean;
  56605. /**
  56606. * Creates a ScaleGizmo
  56607. * @param gizmoLayer The utility layer the gizmo will be added to
  56608. * @param thickness display gizmo axis thickness
  56609. */
  56610. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56611. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56612. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56613. /**
  56614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56615. */
  56616. set snapDistance(value: number);
  56617. get snapDistance(): number;
  56618. /**
  56619. * Ratio for the scale of the gizmo (Default: 1)
  56620. */
  56621. set scaleRatio(value: number);
  56622. get scaleRatio(): number;
  56623. /**
  56624. * Sensitivity factor for dragging (Default: 1)
  56625. */
  56626. set sensitivity(value: number);
  56627. get sensitivity(): number;
  56628. /**
  56629. * Disposes of the gizmo
  56630. */
  56631. dispose(): void;
  56632. }
  56633. }
  56634. declare module BABYLON {
  56635. /**
  56636. * Single axis scale gizmo
  56637. */
  56638. export class AxisScaleGizmo extends Gizmo {
  56639. /**
  56640. * Drag behavior responsible for the gizmos dragging interactions
  56641. */
  56642. dragBehavior: PointerDragBehavior;
  56643. private _pointerObserver;
  56644. /**
  56645. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56646. */
  56647. snapDistance: number;
  56648. /**
  56649. * Event that fires each time the gizmo snaps to a new location.
  56650. * * snapDistance is the the change in distance
  56651. */
  56652. onSnapObservable: Observable<{
  56653. snapDistance: number;
  56654. }>;
  56655. /**
  56656. * If the scaling operation should be done on all axis (default: false)
  56657. */
  56658. uniformScaling: boolean;
  56659. /**
  56660. * Custom sensitivity value for the drag strength
  56661. */
  56662. sensitivity: number;
  56663. private _isEnabled;
  56664. private _parent;
  56665. private _arrow;
  56666. private _coloredMaterial;
  56667. private _hoverMaterial;
  56668. /**
  56669. * Creates an AxisScaleGizmo
  56670. * @param gizmoLayer The utility layer the gizmo will be added to
  56671. * @param dragAxis The axis which the gizmo will be able to scale on
  56672. * @param color The color of the gizmo
  56673. * @param thickness display gizmo axis thickness
  56674. */
  56675. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56676. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56677. /**
  56678. * If the gizmo is enabled
  56679. */
  56680. set isEnabled(value: boolean);
  56681. get isEnabled(): boolean;
  56682. /**
  56683. * Disposes of the gizmo
  56684. */
  56685. dispose(): void;
  56686. /**
  56687. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56688. * @param mesh The mesh to replace the default mesh of the gizmo
  56689. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56690. */
  56691. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56692. }
  56693. }
  56694. declare module BABYLON {
  56695. /**
  56696. * Bounding box gizmo
  56697. */
  56698. export class BoundingBoxGizmo extends Gizmo {
  56699. private _lineBoundingBox;
  56700. private _rotateSpheresParent;
  56701. private _scaleBoxesParent;
  56702. private _boundingDimensions;
  56703. private _renderObserver;
  56704. private _pointerObserver;
  56705. private _scaleDragSpeed;
  56706. private _tmpQuaternion;
  56707. private _tmpVector;
  56708. private _tmpRotationMatrix;
  56709. /**
  56710. * 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)
  56711. */
  56712. ignoreChildren: boolean;
  56713. /**
  56714. * 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)
  56715. */
  56716. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56717. /**
  56718. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56719. */
  56720. rotationSphereSize: number;
  56721. /**
  56722. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56723. */
  56724. scaleBoxSize: number;
  56725. /**
  56726. * 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)
  56727. */
  56728. fixedDragMeshScreenSize: boolean;
  56729. /**
  56730. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56731. */
  56732. fixedDragMeshScreenSizeDistanceFactor: number;
  56733. /**
  56734. * Fired when a rotation sphere or scale box is dragged
  56735. */
  56736. onDragStartObservable: Observable<{}>;
  56737. /**
  56738. * Fired when a scale box is dragged
  56739. */
  56740. onScaleBoxDragObservable: Observable<{}>;
  56741. /**
  56742. * Fired when a scale box drag is ended
  56743. */
  56744. onScaleBoxDragEndObservable: Observable<{}>;
  56745. /**
  56746. * Fired when a rotation sphere is dragged
  56747. */
  56748. onRotationSphereDragObservable: Observable<{}>;
  56749. /**
  56750. * Fired when a rotation sphere drag is ended
  56751. */
  56752. onRotationSphereDragEndObservable: Observable<{}>;
  56753. /**
  56754. * 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)
  56755. */
  56756. scalePivot: Nullable<Vector3>;
  56757. /**
  56758. * Mesh used as a pivot to rotate the attached node
  56759. */
  56760. private _anchorMesh;
  56761. private _existingMeshScale;
  56762. private _dragMesh;
  56763. private pointerDragBehavior;
  56764. private coloredMaterial;
  56765. private hoverColoredMaterial;
  56766. /**
  56767. * Sets the color of the bounding box gizmo
  56768. * @param color the color to set
  56769. */
  56770. setColor(color: Color3): void;
  56771. /**
  56772. * Creates an BoundingBoxGizmo
  56773. * @param gizmoLayer The utility layer the gizmo will be added to
  56774. * @param color The color of the gizmo
  56775. */
  56776. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56777. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56778. private _selectNode;
  56779. /**
  56780. * Updates the bounding box information for the Gizmo
  56781. */
  56782. updateBoundingBox(): void;
  56783. private _updateRotationSpheres;
  56784. private _updateScaleBoxes;
  56785. /**
  56786. * Enables rotation on the specified axis and disables rotation on the others
  56787. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56788. */
  56789. setEnabledRotationAxis(axis: string): void;
  56790. /**
  56791. * Enables/disables scaling
  56792. * @param enable if scaling should be enabled
  56793. * @param homogeneousScaling defines if scaling should only be homogeneous
  56794. */
  56795. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56796. private _updateDummy;
  56797. /**
  56798. * Enables a pointer drag behavior on the bounding box of the gizmo
  56799. */
  56800. enableDragBehavior(): void;
  56801. /**
  56802. * Disposes of the gizmo
  56803. */
  56804. dispose(): void;
  56805. /**
  56806. * 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)
  56807. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56808. * @returns the bounding box mesh with the passed in mesh as a child
  56809. */
  56810. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56811. /**
  56812. * CustomMeshes are not supported by this gizmo
  56813. * @param mesh The mesh to replace the default mesh of the gizmo
  56814. */
  56815. setCustomMesh(mesh: Mesh): void;
  56816. }
  56817. }
  56818. declare module BABYLON {
  56819. /**
  56820. * Single plane rotation gizmo
  56821. */
  56822. export class PlaneRotationGizmo extends Gizmo {
  56823. /**
  56824. * Drag behavior responsible for the gizmos dragging interactions
  56825. */
  56826. dragBehavior: PointerDragBehavior;
  56827. private _pointerObserver;
  56828. /**
  56829. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56830. */
  56831. snapDistance: number;
  56832. /**
  56833. * Event that fires each time the gizmo snaps to a new location.
  56834. * * snapDistance is the the change in distance
  56835. */
  56836. onSnapObservable: Observable<{
  56837. snapDistance: number;
  56838. }>;
  56839. private _isEnabled;
  56840. private _parent;
  56841. /**
  56842. * Creates a PlaneRotationGizmo
  56843. * @param gizmoLayer The utility layer the gizmo will be added to
  56844. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56845. * @param color The color of the gizmo
  56846. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56847. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56848. * @param thickness display gizmo axis thickness
  56849. */
  56850. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56851. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56852. /**
  56853. * If the gizmo is enabled
  56854. */
  56855. set isEnabled(value: boolean);
  56856. get isEnabled(): boolean;
  56857. /**
  56858. * Disposes of the gizmo
  56859. */
  56860. dispose(): void;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /**
  56865. * Gizmo that enables rotating a mesh along 3 axis
  56866. */
  56867. export class RotationGizmo extends Gizmo {
  56868. /**
  56869. * Internal gizmo used for interactions on the x axis
  56870. */
  56871. xGizmo: PlaneRotationGizmo;
  56872. /**
  56873. * Internal gizmo used for interactions on the y axis
  56874. */
  56875. yGizmo: PlaneRotationGizmo;
  56876. /**
  56877. * Internal gizmo used for interactions on the z axis
  56878. */
  56879. zGizmo: PlaneRotationGizmo;
  56880. /** Fires an event when any of it's sub gizmos are dragged */
  56881. onDragStartObservable: Observable<unknown>;
  56882. /** Fires an event when any of it's sub gizmos are released from dragging */
  56883. onDragEndObservable: Observable<unknown>;
  56884. private _meshAttached;
  56885. private _nodeAttached;
  56886. get attachedMesh(): Nullable<AbstractMesh>;
  56887. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56888. get attachedNode(): Nullable<Node>;
  56889. set attachedNode(node: Nullable<Node>);
  56890. protected _checkBillboardTransform(): void;
  56891. /**
  56892. * True when the mouse pointer is hovering a gizmo mesh
  56893. */
  56894. get isHovered(): boolean;
  56895. /**
  56896. * Creates a RotationGizmo
  56897. * @param gizmoLayer The utility layer the gizmo will be added to
  56898. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56899. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56900. * @param thickness display gizmo axis thickness
  56901. */
  56902. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56903. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56904. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56905. /**
  56906. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56907. */
  56908. set snapDistance(value: number);
  56909. get snapDistance(): number;
  56910. /**
  56911. * Ratio for the scale of the gizmo (Default: 1)
  56912. */
  56913. set scaleRatio(value: number);
  56914. get scaleRatio(): number;
  56915. /**
  56916. * Disposes of the gizmo
  56917. */
  56918. dispose(): void;
  56919. /**
  56920. * CustomMeshes are not supported by this gizmo
  56921. * @param mesh The mesh to replace the default mesh of the gizmo
  56922. */
  56923. setCustomMesh(mesh: Mesh): void;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56929. */
  56930. export class GizmoManager implements IDisposable {
  56931. private scene;
  56932. /**
  56933. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56934. */
  56935. gizmos: {
  56936. positionGizmo: Nullable<PositionGizmo>;
  56937. rotationGizmo: Nullable<RotationGizmo>;
  56938. scaleGizmo: Nullable<ScaleGizmo>;
  56939. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56940. };
  56941. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56942. clearGizmoOnEmptyPointerEvent: boolean;
  56943. /** Fires an event when the manager is attached to a mesh */
  56944. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56945. /** Fires an event when the manager is attached to a node */
  56946. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56947. private _gizmosEnabled;
  56948. private _pointerObserver;
  56949. private _attachedMesh;
  56950. private _attachedNode;
  56951. private _boundingBoxColor;
  56952. private _defaultUtilityLayer;
  56953. private _defaultKeepDepthUtilityLayer;
  56954. private _thickness;
  56955. /**
  56956. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56957. */
  56958. boundingBoxDragBehavior: SixDofDragBehavior;
  56959. /**
  56960. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56961. */
  56962. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56963. /**
  56964. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56965. */
  56966. attachableNodes: Nullable<Array<Node>>;
  56967. /**
  56968. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56969. */
  56970. usePointerToAttachGizmos: boolean;
  56971. /**
  56972. * Utility layer that the bounding box gizmo belongs to
  56973. */
  56974. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56975. /**
  56976. * Utility layer that all gizmos besides bounding box belong to
  56977. */
  56978. get utilityLayer(): UtilityLayerRenderer;
  56979. /**
  56980. * True when the mouse pointer is hovering a gizmo mesh
  56981. */
  56982. get isHovered(): boolean;
  56983. /**
  56984. * Instatiates a gizmo manager
  56985. * @param scene the scene to overlay the gizmos on top of
  56986. * @param thickness display gizmo axis thickness
  56987. */
  56988. constructor(scene: Scene, thickness?: number);
  56989. /**
  56990. * Attaches a set of gizmos to the specified mesh
  56991. * @param mesh The mesh the gizmo's should be attached to
  56992. */
  56993. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56994. /**
  56995. * Attaches a set of gizmos to the specified node
  56996. * @param node The node the gizmo's should be attached to
  56997. */
  56998. attachToNode(node: Nullable<Node>): void;
  56999. /**
  57000. * If the position gizmo is enabled
  57001. */
  57002. set positionGizmoEnabled(value: boolean);
  57003. get positionGizmoEnabled(): boolean;
  57004. /**
  57005. * If the rotation gizmo is enabled
  57006. */
  57007. set rotationGizmoEnabled(value: boolean);
  57008. get rotationGizmoEnabled(): boolean;
  57009. /**
  57010. * If the scale gizmo is enabled
  57011. */
  57012. set scaleGizmoEnabled(value: boolean);
  57013. get scaleGizmoEnabled(): boolean;
  57014. /**
  57015. * If the boundingBox gizmo is enabled
  57016. */
  57017. set boundingBoxGizmoEnabled(value: boolean);
  57018. get boundingBoxGizmoEnabled(): boolean;
  57019. /**
  57020. * Disposes of the gizmo manager
  57021. */
  57022. dispose(): void;
  57023. }
  57024. }
  57025. declare module BABYLON {
  57026. /**
  57027. * A directional light is defined by a direction (what a surprise!).
  57028. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57029. * 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.
  57030. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57031. */
  57032. export class DirectionalLight extends ShadowLight {
  57033. private _shadowFrustumSize;
  57034. /**
  57035. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57036. */
  57037. get shadowFrustumSize(): number;
  57038. /**
  57039. * Specifies a fix frustum size for the shadow generation.
  57040. */
  57041. set shadowFrustumSize(value: number);
  57042. private _shadowOrthoScale;
  57043. /**
  57044. * Gets the shadow projection scale against the optimal computed one.
  57045. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57046. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57047. */
  57048. get shadowOrthoScale(): number;
  57049. /**
  57050. * Sets the shadow projection scale against the optimal computed one.
  57051. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57052. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57053. */
  57054. set shadowOrthoScale(value: number);
  57055. /**
  57056. * Automatically compute the projection matrix to best fit (including all the casters)
  57057. * on each frame.
  57058. */
  57059. autoUpdateExtends: boolean;
  57060. /**
  57061. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57062. * on each frame. autoUpdateExtends must be set to true for this to work
  57063. */
  57064. autoCalcShadowZBounds: boolean;
  57065. private _orthoLeft;
  57066. private _orthoRight;
  57067. private _orthoTop;
  57068. private _orthoBottom;
  57069. /**
  57070. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57071. * The directional light is emitted from everywhere in the given direction.
  57072. * It can cast shadows.
  57073. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57074. * @param name The friendly name of the light
  57075. * @param direction The direction of the light
  57076. * @param scene The scene the light belongs to
  57077. */
  57078. constructor(name: string, direction: Vector3, scene: Scene);
  57079. /**
  57080. * Returns the string "DirectionalLight".
  57081. * @return The class name
  57082. */
  57083. getClassName(): string;
  57084. /**
  57085. * Returns the integer 1.
  57086. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57087. */
  57088. getTypeID(): number;
  57089. /**
  57090. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57091. * Returns the DirectionalLight Shadow projection matrix.
  57092. */
  57093. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57094. /**
  57095. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57096. * Returns the DirectionalLight Shadow projection matrix.
  57097. */
  57098. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57099. /**
  57100. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57101. * Returns the DirectionalLight Shadow projection matrix.
  57102. */
  57103. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57104. protected _buildUniformLayout(): void;
  57105. /**
  57106. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57107. * @param effect The effect to update
  57108. * @param lightIndex The index of the light in the effect to update
  57109. * @returns The directional light
  57110. */
  57111. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57112. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57113. /**
  57114. * Gets the minZ used for shadow according to both the scene and the light.
  57115. *
  57116. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57117. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57118. * @param activeCamera The camera we are returning the min for
  57119. * @returns the depth min z
  57120. */
  57121. getDepthMinZ(activeCamera: Camera): number;
  57122. /**
  57123. * Gets the maxZ used for shadow according to both the scene and the light.
  57124. *
  57125. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57126. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57127. * @param activeCamera The camera we are returning the max for
  57128. * @returns the depth max z
  57129. */
  57130. getDepthMaxZ(activeCamera: Camera): number;
  57131. /**
  57132. * Prepares the list of defines specific to the light type.
  57133. * @param defines the list of defines
  57134. * @param lightIndex defines the index of the light for the effect
  57135. */
  57136. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57137. }
  57138. }
  57139. declare module BABYLON {
  57140. /**
  57141. * Class containing static functions to help procedurally build meshes
  57142. */
  57143. export class HemisphereBuilder {
  57144. /**
  57145. * Creates a hemisphere mesh
  57146. * @param name defines the name of the mesh
  57147. * @param options defines the options used to create the mesh
  57148. * @param scene defines the hosting scene
  57149. * @returns the hemisphere mesh
  57150. */
  57151. static CreateHemisphere(name: string, options: {
  57152. segments?: number;
  57153. diameter?: number;
  57154. sideOrientation?: number;
  57155. }, scene: any): Mesh;
  57156. }
  57157. }
  57158. declare module BABYLON {
  57159. /**
  57160. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57161. * These values define a cone of light starting from the position, emitting toward the direction.
  57162. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57163. * and the exponent defines the speed of the decay of the light with distance (reach).
  57164. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57165. */
  57166. export class SpotLight extends ShadowLight {
  57167. private _angle;
  57168. private _innerAngle;
  57169. private _cosHalfAngle;
  57170. private _lightAngleScale;
  57171. private _lightAngleOffset;
  57172. /**
  57173. * Gets the cone angle of the spot light in Radians.
  57174. */
  57175. get angle(): number;
  57176. /**
  57177. * Sets the cone angle of the spot light in Radians.
  57178. */
  57179. set angle(value: number);
  57180. /**
  57181. * Only used in gltf falloff mode, this defines the angle where
  57182. * the directional falloff will start before cutting at angle which could be seen
  57183. * as outer angle.
  57184. */
  57185. get innerAngle(): number;
  57186. /**
  57187. * Only used in gltf falloff mode, this defines the angle where
  57188. * the directional falloff will start before cutting at angle which could be seen
  57189. * as outer angle.
  57190. */
  57191. set innerAngle(value: number);
  57192. private _shadowAngleScale;
  57193. /**
  57194. * Allows scaling the angle of the light for shadow generation only.
  57195. */
  57196. get shadowAngleScale(): number;
  57197. /**
  57198. * Allows scaling the angle of the light for shadow generation only.
  57199. */
  57200. set shadowAngleScale(value: number);
  57201. /**
  57202. * The light decay speed with the distance from the emission spot.
  57203. */
  57204. exponent: number;
  57205. private _projectionTextureMatrix;
  57206. /**
  57207. * Allows reading the projecton texture
  57208. */
  57209. get projectionTextureMatrix(): Matrix;
  57210. protected _projectionTextureLightNear: number;
  57211. /**
  57212. * Gets the near clip of the Spotlight for texture projection.
  57213. */
  57214. get projectionTextureLightNear(): number;
  57215. /**
  57216. * Sets the near clip of the Spotlight for texture projection.
  57217. */
  57218. set projectionTextureLightNear(value: number);
  57219. protected _projectionTextureLightFar: number;
  57220. /**
  57221. * Gets the far clip of the Spotlight for texture projection.
  57222. */
  57223. get projectionTextureLightFar(): number;
  57224. /**
  57225. * Sets the far clip of the Spotlight for texture projection.
  57226. */
  57227. set projectionTextureLightFar(value: number);
  57228. protected _projectionTextureUpDirection: Vector3;
  57229. /**
  57230. * Gets the Up vector of the Spotlight for texture projection.
  57231. */
  57232. get projectionTextureUpDirection(): Vector3;
  57233. /**
  57234. * Sets the Up vector of the Spotlight for texture projection.
  57235. */
  57236. set projectionTextureUpDirection(value: Vector3);
  57237. private _projectionTexture;
  57238. /**
  57239. * Gets the projection texture of the light.
  57240. */
  57241. get projectionTexture(): Nullable<BaseTexture>;
  57242. /**
  57243. * Sets the projection texture of the light.
  57244. */
  57245. set projectionTexture(value: Nullable<BaseTexture>);
  57246. private _projectionTextureViewLightDirty;
  57247. private _projectionTextureProjectionLightDirty;
  57248. private _projectionTextureDirty;
  57249. private _projectionTextureViewTargetVector;
  57250. private _projectionTextureViewLightMatrix;
  57251. private _projectionTextureProjectionLightMatrix;
  57252. private _projectionTextureScalingMatrix;
  57253. /**
  57254. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57255. * It can cast shadows.
  57256. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57257. * @param name The light friendly name
  57258. * @param position The position of the spot light in the scene
  57259. * @param direction The direction of the light in the scene
  57260. * @param angle The cone angle of the light in Radians
  57261. * @param exponent The light decay speed with the distance from the emission spot
  57262. * @param scene The scene the lights belongs to
  57263. */
  57264. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57265. /**
  57266. * Returns the string "SpotLight".
  57267. * @returns the class name
  57268. */
  57269. getClassName(): string;
  57270. /**
  57271. * Returns the integer 2.
  57272. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57273. */
  57274. getTypeID(): number;
  57275. /**
  57276. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57277. */
  57278. protected _setDirection(value: Vector3): void;
  57279. /**
  57280. * Overrides the position setter to recompute the projection texture view light Matrix.
  57281. */
  57282. protected _setPosition(value: Vector3): void;
  57283. /**
  57284. * 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.
  57285. * Returns the SpotLight.
  57286. */
  57287. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57288. protected _computeProjectionTextureViewLightMatrix(): void;
  57289. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57290. /**
  57291. * Main function for light texture projection matrix computing.
  57292. */
  57293. protected _computeProjectionTextureMatrix(): void;
  57294. protected _buildUniformLayout(): void;
  57295. private _computeAngleValues;
  57296. /**
  57297. * Sets the passed Effect "effect" with the Light textures.
  57298. * @param effect The effect to update
  57299. * @param lightIndex The index of the light in the effect to update
  57300. * @returns The light
  57301. */
  57302. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57303. /**
  57304. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57305. * @param effect The effect to update
  57306. * @param lightIndex The index of the light in the effect to update
  57307. * @returns The spot light
  57308. */
  57309. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57310. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57311. /**
  57312. * Disposes the light and the associated resources.
  57313. */
  57314. dispose(): void;
  57315. /**
  57316. * Prepares the list of defines specific to the light type.
  57317. * @param defines the list of defines
  57318. * @param lightIndex defines the index of the light for the effect
  57319. */
  57320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57321. }
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * Gizmo that enables viewing a light
  57326. */
  57327. export class LightGizmo extends Gizmo {
  57328. private _lightMesh;
  57329. private _material;
  57330. private _cachedPosition;
  57331. private _cachedForward;
  57332. private _attachedMeshParent;
  57333. private _pointerObserver;
  57334. /**
  57335. * Event that fires each time the gizmo is clicked
  57336. */
  57337. onClickedObservable: Observable<Light>;
  57338. /**
  57339. * Creates a LightGizmo
  57340. * @param gizmoLayer The utility layer the gizmo will be added to
  57341. */
  57342. constructor(gizmoLayer?: UtilityLayerRenderer);
  57343. private _light;
  57344. /**
  57345. * The light that the gizmo is attached to
  57346. */
  57347. set light(light: Nullable<Light>);
  57348. get light(): Nullable<Light>;
  57349. /**
  57350. * Gets the material used to render the light gizmo
  57351. */
  57352. get material(): StandardMaterial;
  57353. /**
  57354. * @hidden
  57355. * Updates the gizmo to match the attached mesh's position/rotation
  57356. */
  57357. protected _update(): void;
  57358. private static _Scale;
  57359. /**
  57360. * Creates the lines for a light mesh
  57361. */
  57362. private static _CreateLightLines;
  57363. /**
  57364. * Disposes of the light gizmo
  57365. */
  57366. dispose(): void;
  57367. private static _CreateHemisphericLightMesh;
  57368. private static _CreatePointLightMesh;
  57369. private static _CreateSpotLightMesh;
  57370. private static _CreateDirectionalLightMesh;
  57371. }
  57372. }
  57373. declare module BABYLON {
  57374. /**
  57375. * Gizmo that enables viewing a camera
  57376. */
  57377. export class CameraGizmo extends Gizmo {
  57378. private _cameraMesh;
  57379. private _cameraLinesMesh;
  57380. private _material;
  57381. private _pointerObserver;
  57382. /**
  57383. * Event that fires each time the gizmo is clicked
  57384. */
  57385. onClickedObservable: Observable<Camera>;
  57386. /**
  57387. * Creates a CameraGizmo
  57388. * @param gizmoLayer The utility layer the gizmo will be added to
  57389. */
  57390. constructor(gizmoLayer?: UtilityLayerRenderer);
  57391. private _camera;
  57392. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57393. get displayFrustum(): boolean;
  57394. set displayFrustum(value: boolean);
  57395. /**
  57396. * The camera that the gizmo is attached to
  57397. */
  57398. set camera(camera: Nullable<Camera>);
  57399. get camera(): Nullable<Camera>;
  57400. /**
  57401. * Gets the material used to render the camera gizmo
  57402. */
  57403. get material(): StandardMaterial;
  57404. /**
  57405. * @hidden
  57406. * Updates the gizmo to match the attached mesh's position/rotation
  57407. */
  57408. protected _update(): void;
  57409. private static _Scale;
  57410. private _invProjection;
  57411. /**
  57412. * Disposes of the camera gizmo
  57413. */
  57414. dispose(): void;
  57415. private static _CreateCameraMesh;
  57416. private static _CreateCameraFrustum;
  57417. }
  57418. }
  57419. declare module BABYLON {
  57420. /** @hidden */
  57421. export var backgroundFragmentDeclaration: {
  57422. name: string;
  57423. shader: string;
  57424. };
  57425. }
  57426. declare module BABYLON {
  57427. /** @hidden */
  57428. export var backgroundUboDeclaration: {
  57429. name: string;
  57430. shader: string;
  57431. };
  57432. }
  57433. declare module BABYLON {
  57434. /** @hidden */
  57435. export var backgroundPixelShader: {
  57436. name: string;
  57437. shader: string;
  57438. };
  57439. }
  57440. declare module BABYLON {
  57441. /** @hidden */
  57442. export var backgroundVertexDeclaration: {
  57443. name: string;
  57444. shader: string;
  57445. };
  57446. }
  57447. declare module BABYLON {
  57448. /** @hidden */
  57449. export var backgroundVertexShader: {
  57450. name: string;
  57451. shader: string;
  57452. };
  57453. }
  57454. declare module BABYLON {
  57455. /**
  57456. * Background material used to create an efficient environement around your scene.
  57457. */
  57458. export class BackgroundMaterial extends PushMaterial {
  57459. /**
  57460. * Standard reflectance value at parallel view angle.
  57461. */
  57462. static StandardReflectance0: number;
  57463. /**
  57464. * Standard reflectance value at grazing angle.
  57465. */
  57466. static StandardReflectance90: number;
  57467. protected _primaryColor: Color3;
  57468. /**
  57469. * Key light Color (multiply against the environement texture)
  57470. */
  57471. primaryColor: Color3;
  57472. protected __perceptualColor: Nullable<Color3>;
  57473. /**
  57474. * Experimental Internal Use Only.
  57475. *
  57476. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57477. * This acts as a helper to set the primary color to a more "human friendly" value.
  57478. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57479. * output color as close as possible from the chosen value.
  57480. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57481. * part of lighting setup.)
  57482. */
  57483. get _perceptualColor(): Nullable<Color3>;
  57484. set _perceptualColor(value: Nullable<Color3>);
  57485. protected _primaryColorShadowLevel: float;
  57486. /**
  57487. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57488. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57489. */
  57490. get primaryColorShadowLevel(): float;
  57491. set primaryColorShadowLevel(value: float);
  57492. protected _primaryColorHighlightLevel: float;
  57493. /**
  57494. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57495. * The primary color is used at the level chosen to define what the white area would look.
  57496. */
  57497. get primaryColorHighlightLevel(): float;
  57498. set primaryColorHighlightLevel(value: float);
  57499. protected _reflectionTexture: Nullable<BaseTexture>;
  57500. /**
  57501. * Reflection Texture used in the material.
  57502. * Should be author in a specific way for the best result (refer to the documentation).
  57503. */
  57504. reflectionTexture: Nullable<BaseTexture>;
  57505. protected _reflectionBlur: float;
  57506. /**
  57507. * Reflection Texture level of blur.
  57508. *
  57509. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57510. * texture twice.
  57511. */
  57512. reflectionBlur: float;
  57513. protected _diffuseTexture: Nullable<BaseTexture>;
  57514. /**
  57515. * Diffuse Texture used in the material.
  57516. * Should be author in a specific way for the best result (refer to the documentation).
  57517. */
  57518. diffuseTexture: Nullable<BaseTexture>;
  57519. protected _shadowLights: Nullable<IShadowLight[]>;
  57520. /**
  57521. * Specify the list of lights casting shadow on the material.
  57522. * All scene shadow lights will be included if null.
  57523. */
  57524. shadowLights: Nullable<IShadowLight[]>;
  57525. protected _shadowLevel: float;
  57526. /**
  57527. * Helps adjusting the shadow to a softer level if required.
  57528. * 0 means black shadows and 1 means no shadows.
  57529. */
  57530. shadowLevel: float;
  57531. protected _sceneCenter: Vector3;
  57532. /**
  57533. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57534. * It is usually zero but might be interesting to modify according to your setup.
  57535. */
  57536. sceneCenter: Vector3;
  57537. protected _opacityFresnel: boolean;
  57538. /**
  57539. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57540. * This helps ensuring a nice transition when the camera goes under the ground.
  57541. */
  57542. opacityFresnel: boolean;
  57543. protected _reflectionFresnel: boolean;
  57544. /**
  57545. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57546. * This helps adding a mirror texture on the ground.
  57547. */
  57548. reflectionFresnel: boolean;
  57549. protected _reflectionFalloffDistance: number;
  57550. /**
  57551. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57552. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57553. */
  57554. reflectionFalloffDistance: number;
  57555. protected _reflectionAmount: number;
  57556. /**
  57557. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57558. */
  57559. reflectionAmount: number;
  57560. protected _reflectionReflectance0: number;
  57561. /**
  57562. * This specifies the weight of the reflection at grazing angle.
  57563. */
  57564. reflectionReflectance0: number;
  57565. protected _reflectionReflectance90: number;
  57566. /**
  57567. * This specifies the weight of the reflection at a perpendicular point of view.
  57568. */
  57569. reflectionReflectance90: number;
  57570. /**
  57571. * Sets the reflection reflectance fresnel values according to the default standard
  57572. * empirically know to work well :-)
  57573. */
  57574. set reflectionStandardFresnelWeight(value: number);
  57575. protected _useRGBColor: boolean;
  57576. /**
  57577. * Helps to directly use the maps channels instead of their level.
  57578. */
  57579. useRGBColor: boolean;
  57580. protected _enableNoise: boolean;
  57581. /**
  57582. * This helps reducing the banding effect that could occur on the background.
  57583. */
  57584. enableNoise: boolean;
  57585. /**
  57586. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57587. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57588. * Recommended to be keep at 1.0 except for special cases.
  57589. */
  57590. get fovMultiplier(): number;
  57591. set fovMultiplier(value: number);
  57592. private _fovMultiplier;
  57593. /**
  57594. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57595. */
  57596. useEquirectangularFOV: boolean;
  57597. private _maxSimultaneousLights;
  57598. /**
  57599. * Number of Simultaneous lights allowed on the material.
  57600. */
  57601. maxSimultaneousLights: int;
  57602. private _shadowOnly;
  57603. /**
  57604. * Make the material only render shadows
  57605. */
  57606. shadowOnly: boolean;
  57607. /**
  57608. * Default configuration related to image processing available in the Background Material.
  57609. */
  57610. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57611. /**
  57612. * Keep track of the image processing observer to allow dispose and replace.
  57613. */
  57614. private _imageProcessingObserver;
  57615. /**
  57616. * Attaches a new image processing configuration to the PBR Material.
  57617. * @param configuration (if null the scene configuration will be use)
  57618. */
  57619. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57620. /**
  57621. * Gets the image processing configuration used either in this material.
  57622. */
  57623. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57624. /**
  57625. * Sets the Default image processing configuration used either in the this material.
  57626. *
  57627. * If sets to null, the scene one is in use.
  57628. */
  57629. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57630. /**
  57631. * Gets wether the color curves effect is enabled.
  57632. */
  57633. get cameraColorCurvesEnabled(): boolean;
  57634. /**
  57635. * Sets wether the color curves effect is enabled.
  57636. */
  57637. set cameraColorCurvesEnabled(value: boolean);
  57638. /**
  57639. * Gets wether the color grading effect is enabled.
  57640. */
  57641. get cameraColorGradingEnabled(): boolean;
  57642. /**
  57643. * Gets wether the color grading effect is enabled.
  57644. */
  57645. set cameraColorGradingEnabled(value: boolean);
  57646. /**
  57647. * Gets wether tonemapping is enabled or not.
  57648. */
  57649. get cameraToneMappingEnabled(): boolean;
  57650. /**
  57651. * Sets wether tonemapping is enabled or not
  57652. */
  57653. set cameraToneMappingEnabled(value: boolean);
  57654. /**
  57655. * The camera exposure used on this material.
  57656. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57657. * This corresponds to a photographic exposure.
  57658. */
  57659. get cameraExposure(): float;
  57660. /**
  57661. * The camera exposure used on this material.
  57662. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57663. * This corresponds to a photographic exposure.
  57664. */
  57665. set cameraExposure(value: float);
  57666. /**
  57667. * Gets The camera contrast used on this material.
  57668. */
  57669. get cameraContrast(): float;
  57670. /**
  57671. * Sets The camera contrast used on this material.
  57672. */
  57673. set cameraContrast(value: float);
  57674. /**
  57675. * Gets the Color Grading 2D Lookup Texture.
  57676. */
  57677. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57678. /**
  57679. * Sets the Color Grading 2D Lookup Texture.
  57680. */
  57681. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57682. /**
  57683. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57684. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57685. * 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;
  57686. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57687. */
  57688. get cameraColorCurves(): Nullable<ColorCurves>;
  57689. /**
  57690. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57691. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57692. * 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;
  57693. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57694. */
  57695. set cameraColorCurves(value: Nullable<ColorCurves>);
  57696. /**
  57697. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57698. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57699. */
  57700. switchToBGR: boolean;
  57701. private _renderTargets;
  57702. private _reflectionControls;
  57703. private _white;
  57704. private _primaryShadowColor;
  57705. private _primaryHighlightColor;
  57706. /**
  57707. * Instantiates a Background Material in the given scene
  57708. * @param name The friendly name of the material
  57709. * @param scene The scene to add the material to
  57710. */
  57711. constructor(name: string, scene: Scene);
  57712. /**
  57713. * Gets a boolean indicating that current material needs to register RTT
  57714. */
  57715. get hasRenderTargetTextures(): boolean;
  57716. /**
  57717. * The entire material has been created in order to prevent overdraw.
  57718. * @returns false
  57719. */
  57720. needAlphaTesting(): boolean;
  57721. /**
  57722. * The entire material has been created in order to prevent overdraw.
  57723. * @returns true if blending is enable
  57724. */
  57725. needAlphaBlending(): boolean;
  57726. /**
  57727. * Checks wether the material is ready to be rendered for a given mesh.
  57728. * @param mesh The mesh to render
  57729. * @param subMesh The submesh to check against
  57730. * @param useInstances Specify wether or not the material is used with instances
  57731. * @returns true if all the dependencies are ready (Textures, Effects...)
  57732. */
  57733. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57734. /**
  57735. * Compute the primary color according to the chosen perceptual color.
  57736. */
  57737. private _computePrimaryColorFromPerceptualColor;
  57738. /**
  57739. * Compute the highlights and shadow colors according to their chosen levels.
  57740. */
  57741. private _computePrimaryColors;
  57742. /**
  57743. * Build the uniform buffer used in the material.
  57744. */
  57745. buildUniformLayout(): void;
  57746. /**
  57747. * Unbind the material.
  57748. */
  57749. unbind(): void;
  57750. /**
  57751. * Bind only the world matrix to the material.
  57752. * @param world The world matrix to bind.
  57753. */
  57754. bindOnlyWorldMatrix(world: Matrix): void;
  57755. /**
  57756. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57757. * @param world The world matrix to bind.
  57758. * @param subMesh The submesh to bind for.
  57759. */
  57760. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57761. /**
  57762. * Checks to see if a texture is used in the material.
  57763. * @param texture - Base texture to use.
  57764. * @returns - Boolean specifying if a texture is used in the material.
  57765. */
  57766. hasTexture(texture: BaseTexture): boolean;
  57767. /**
  57768. * Dispose the material.
  57769. * @param forceDisposeEffect Force disposal of the associated effect.
  57770. * @param forceDisposeTextures Force disposal of the associated textures.
  57771. */
  57772. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57773. /**
  57774. * Clones the material.
  57775. * @param name The cloned name.
  57776. * @returns The cloned material.
  57777. */
  57778. clone(name: string): BackgroundMaterial;
  57779. /**
  57780. * Serializes the current material to its JSON representation.
  57781. * @returns The JSON representation.
  57782. */
  57783. serialize(): any;
  57784. /**
  57785. * Gets the class name of the material
  57786. * @returns "BackgroundMaterial"
  57787. */
  57788. getClassName(): string;
  57789. /**
  57790. * Parse a JSON input to create back a background material.
  57791. * @param source The JSON data to parse
  57792. * @param scene The scene to create the parsed material in
  57793. * @param rootUrl The root url of the assets the material depends upon
  57794. * @returns the instantiated BackgroundMaterial.
  57795. */
  57796. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57797. }
  57798. }
  57799. declare module BABYLON {
  57800. /**
  57801. * Represents the different options available during the creation of
  57802. * a Environment helper.
  57803. *
  57804. * This can control the default ground, skybox and image processing setup of your scene.
  57805. */
  57806. export interface IEnvironmentHelperOptions {
  57807. /**
  57808. * Specifies whether or not to create a ground.
  57809. * True by default.
  57810. */
  57811. createGround: boolean;
  57812. /**
  57813. * Specifies the ground size.
  57814. * 15 by default.
  57815. */
  57816. groundSize: number;
  57817. /**
  57818. * The texture used on the ground for the main color.
  57819. * Comes from the BabylonJS CDN by default.
  57820. *
  57821. * Remarks: Can be either a texture or a url.
  57822. */
  57823. groundTexture: string | BaseTexture;
  57824. /**
  57825. * The color mixed in the ground texture by default.
  57826. * BabylonJS clearColor by default.
  57827. */
  57828. groundColor: Color3;
  57829. /**
  57830. * Specifies the ground opacity.
  57831. * 1 by default.
  57832. */
  57833. groundOpacity: number;
  57834. /**
  57835. * Enables the ground to receive shadows.
  57836. * True by default.
  57837. */
  57838. enableGroundShadow: boolean;
  57839. /**
  57840. * Helps preventing the shadow to be fully black on the ground.
  57841. * 0.5 by default.
  57842. */
  57843. groundShadowLevel: number;
  57844. /**
  57845. * Creates a mirror texture attach to the ground.
  57846. * false by default.
  57847. */
  57848. enableGroundMirror: boolean;
  57849. /**
  57850. * Specifies the ground mirror size ratio.
  57851. * 0.3 by default as the default kernel is 64.
  57852. */
  57853. groundMirrorSizeRatio: number;
  57854. /**
  57855. * Specifies the ground mirror blur kernel size.
  57856. * 64 by default.
  57857. */
  57858. groundMirrorBlurKernel: number;
  57859. /**
  57860. * Specifies the ground mirror visibility amount.
  57861. * 1 by default
  57862. */
  57863. groundMirrorAmount: number;
  57864. /**
  57865. * Specifies the ground mirror reflectance weight.
  57866. * This uses the standard weight of the background material to setup the fresnel effect
  57867. * of the mirror.
  57868. * 1 by default.
  57869. */
  57870. groundMirrorFresnelWeight: number;
  57871. /**
  57872. * Specifies the ground mirror Falloff distance.
  57873. * This can helps reducing the size of the reflection.
  57874. * 0 by Default.
  57875. */
  57876. groundMirrorFallOffDistance: number;
  57877. /**
  57878. * Specifies the ground mirror texture type.
  57879. * Unsigned Int by Default.
  57880. */
  57881. groundMirrorTextureType: number;
  57882. /**
  57883. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57884. * the shown objects.
  57885. */
  57886. groundYBias: number;
  57887. /**
  57888. * Specifies whether or not to create a skybox.
  57889. * True by default.
  57890. */
  57891. createSkybox: boolean;
  57892. /**
  57893. * Specifies the skybox size.
  57894. * 20 by default.
  57895. */
  57896. skyboxSize: number;
  57897. /**
  57898. * The texture used on the skybox for the main color.
  57899. * Comes from the BabylonJS CDN by default.
  57900. *
  57901. * Remarks: Can be either a texture or a url.
  57902. */
  57903. skyboxTexture: string | BaseTexture;
  57904. /**
  57905. * The color mixed in the skybox texture by default.
  57906. * BabylonJS clearColor by default.
  57907. */
  57908. skyboxColor: Color3;
  57909. /**
  57910. * The background rotation around the Y axis of the scene.
  57911. * This helps aligning the key lights of your scene with the background.
  57912. * 0 by default.
  57913. */
  57914. backgroundYRotation: number;
  57915. /**
  57916. * Compute automatically the size of the elements to best fit with the scene.
  57917. */
  57918. sizeAuto: boolean;
  57919. /**
  57920. * Default position of the rootMesh if autoSize is not true.
  57921. */
  57922. rootPosition: Vector3;
  57923. /**
  57924. * Sets up the image processing in the scene.
  57925. * true by default.
  57926. */
  57927. setupImageProcessing: boolean;
  57928. /**
  57929. * The texture used as your environment texture in the scene.
  57930. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57931. *
  57932. * Remarks: Can be either a texture or a url.
  57933. */
  57934. environmentTexture: string | BaseTexture;
  57935. /**
  57936. * The value of the exposure to apply to the scene.
  57937. * 0.6 by default if setupImageProcessing is true.
  57938. */
  57939. cameraExposure: number;
  57940. /**
  57941. * The value of the contrast to apply to the scene.
  57942. * 1.6 by default if setupImageProcessing is true.
  57943. */
  57944. cameraContrast: number;
  57945. /**
  57946. * Specifies whether or not tonemapping should be enabled in the scene.
  57947. * true by default if setupImageProcessing is true.
  57948. */
  57949. toneMappingEnabled: boolean;
  57950. }
  57951. /**
  57952. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57953. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57954. * It also helps with the default setup of your imageProcessing configuration.
  57955. */
  57956. export class EnvironmentHelper {
  57957. /**
  57958. * Default ground texture URL.
  57959. */
  57960. private static _groundTextureCDNUrl;
  57961. /**
  57962. * Default skybox texture URL.
  57963. */
  57964. private static _skyboxTextureCDNUrl;
  57965. /**
  57966. * Default environment texture URL.
  57967. */
  57968. private static _environmentTextureCDNUrl;
  57969. /**
  57970. * Creates the default options for the helper.
  57971. */
  57972. private static _getDefaultOptions;
  57973. private _rootMesh;
  57974. /**
  57975. * Gets the root mesh created by the helper.
  57976. */
  57977. get rootMesh(): Mesh;
  57978. private _skybox;
  57979. /**
  57980. * Gets the skybox created by the helper.
  57981. */
  57982. get skybox(): Nullable<Mesh>;
  57983. private _skyboxTexture;
  57984. /**
  57985. * Gets the skybox texture created by the helper.
  57986. */
  57987. get skyboxTexture(): Nullable<BaseTexture>;
  57988. private _skyboxMaterial;
  57989. /**
  57990. * Gets the skybox material created by the helper.
  57991. */
  57992. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57993. private _ground;
  57994. /**
  57995. * Gets the ground mesh created by the helper.
  57996. */
  57997. get ground(): Nullable<Mesh>;
  57998. private _groundTexture;
  57999. /**
  58000. * Gets the ground texture created by the helper.
  58001. */
  58002. get groundTexture(): Nullable<BaseTexture>;
  58003. private _groundMirror;
  58004. /**
  58005. * Gets the ground mirror created by the helper.
  58006. */
  58007. get groundMirror(): Nullable<MirrorTexture>;
  58008. /**
  58009. * Gets the ground mirror render list to helps pushing the meshes
  58010. * you wish in the ground reflection.
  58011. */
  58012. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58013. private _groundMaterial;
  58014. /**
  58015. * Gets the ground material created by the helper.
  58016. */
  58017. get groundMaterial(): Nullable<BackgroundMaterial>;
  58018. /**
  58019. * Stores the creation options.
  58020. */
  58021. private readonly _scene;
  58022. private _options;
  58023. /**
  58024. * This observable will be notified with any error during the creation of the environment,
  58025. * mainly texture creation errors.
  58026. */
  58027. onErrorObservable: Observable<{
  58028. message?: string;
  58029. exception?: any;
  58030. }>;
  58031. /**
  58032. * constructor
  58033. * @param options Defines the options we want to customize the helper
  58034. * @param scene The scene to add the material to
  58035. */
  58036. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58037. /**
  58038. * Updates the background according to the new options
  58039. * @param options
  58040. */
  58041. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58042. /**
  58043. * Sets the primary color of all the available elements.
  58044. * @param color the main color to affect to the ground and the background
  58045. */
  58046. setMainColor(color: Color3): void;
  58047. /**
  58048. * Setup the image processing according to the specified options.
  58049. */
  58050. private _setupImageProcessing;
  58051. /**
  58052. * Setup the environment texture according to the specified options.
  58053. */
  58054. private _setupEnvironmentTexture;
  58055. /**
  58056. * Setup the background according to the specified options.
  58057. */
  58058. private _setupBackground;
  58059. /**
  58060. * Get the scene sizes according to the setup.
  58061. */
  58062. private _getSceneSize;
  58063. /**
  58064. * Setup the ground according to the specified options.
  58065. */
  58066. private _setupGround;
  58067. /**
  58068. * Setup the ground material according to the specified options.
  58069. */
  58070. private _setupGroundMaterial;
  58071. /**
  58072. * Setup the ground diffuse texture according to the specified options.
  58073. */
  58074. private _setupGroundDiffuseTexture;
  58075. /**
  58076. * Setup the ground mirror texture according to the specified options.
  58077. */
  58078. private _setupGroundMirrorTexture;
  58079. /**
  58080. * Setup the ground to receive the mirror texture.
  58081. */
  58082. private _setupMirrorInGroundMaterial;
  58083. /**
  58084. * Setup the skybox according to the specified options.
  58085. */
  58086. private _setupSkybox;
  58087. /**
  58088. * Setup the skybox material according to the specified options.
  58089. */
  58090. private _setupSkyboxMaterial;
  58091. /**
  58092. * Setup the skybox reflection texture according to the specified options.
  58093. */
  58094. private _setupSkyboxReflectionTexture;
  58095. private _errorHandler;
  58096. /**
  58097. * Dispose all the elements created by the Helper.
  58098. */
  58099. dispose(): void;
  58100. }
  58101. }
  58102. declare module BABYLON {
  58103. /**
  58104. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58105. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58106. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58107. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58108. */
  58109. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58110. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58111. /**
  58112. * Define the source as a Monoscopic panoramic 360/180.
  58113. */
  58114. static readonly MODE_MONOSCOPIC: number;
  58115. /**
  58116. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58117. */
  58118. static readonly MODE_TOPBOTTOM: number;
  58119. /**
  58120. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58121. */
  58122. static readonly MODE_SIDEBYSIDE: number;
  58123. private _halfDome;
  58124. private _crossEye;
  58125. protected _useDirectMapping: boolean;
  58126. /**
  58127. * The texture being displayed on the sphere
  58128. */
  58129. protected _texture: T;
  58130. /**
  58131. * Gets the texture being displayed on the sphere
  58132. */
  58133. get texture(): T;
  58134. /**
  58135. * Sets the texture being displayed on the sphere
  58136. */
  58137. set texture(newTexture: T);
  58138. /**
  58139. * The skybox material
  58140. */
  58141. protected _material: BackgroundMaterial;
  58142. /**
  58143. * The surface used for the dome
  58144. */
  58145. protected _mesh: Mesh;
  58146. /**
  58147. * Gets the mesh used for the dome.
  58148. */
  58149. get mesh(): Mesh;
  58150. /**
  58151. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58152. */
  58153. private _halfDomeMask;
  58154. /**
  58155. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58156. * Also see the options.resolution property.
  58157. */
  58158. get fovMultiplier(): number;
  58159. set fovMultiplier(value: number);
  58160. protected _textureMode: number;
  58161. /**
  58162. * Gets or set the current texture mode for the texture. It can be:
  58163. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58164. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58165. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58166. */
  58167. get textureMode(): number;
  58168. /**
  58169. * Sets the current texture mode for the texture. It can be:
  58170. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58171. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58172. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58173. */
  58174. set textureMode(value: number);
  58175. /**
  58176. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58177. */
  58178. get halfDome(): boolean;
  58179. /**
  58180. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58181. */
  58182. set halfDome(enabled: boolean);
  58183. /**
  58184. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58185. */
  58186. set crossEye(enabled: boolean);
  58187. /**
  58188. * Is it a cross-eye texture?
  58189. */
  58190. get crossEye(): boolean;
  58191. /**
  58192. * The background material of this dome.
  58193. */
  58194. get material(): BackgroundMaterial;
  58195. /**
  58196. * Oberserver used in Stereoscopic VR Mode.
  58197. */
  58198. private _onBeforeCameraRenderObserver;
  58199. /**
  58200. * Observable raised when an error occured while loading the 360 image
  58201. */
  58202. onLoadErrorObservable: Observable<string>;
  58203. /**
  58204. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58205. * @param name Element's name, child elements will append suffixes for their own names.
  58206. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58207. * @param options An object containing optional or exposed sub element properties
  58208. */
  58209. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58210. resolution?: number;
  58211. clickToPlay?: boolean;
  58212. autoPlay?: boolean;
  58213. loop?: boolean;
  58214. size?: number;
  58215. poster?: string;
  58216. faceForward?: boolean;
  58217. useDirectMapping?: boolean;
  58218. halfDomeMode?: boolean;
  58219. crossEyeMode?: boolean;
  58220. generateMipMaps?: boolean;
  58221. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58222. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58223. protected _changeTextureMode(value: number): void;
  58224. /**
  58225. * Releases resources associated with this node.
  58226. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58227. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58228. */
  58229. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58230. }
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58235. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58236. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58237. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58238. */
  58239. export class PhotoDome extends TextureDome<Texture> {
  58240. /**
  58241. * Define the image as a Monoscopic panoramic 360 image.
  58242. */
  58243. static readonly MODE_MONOSCOPIC: number;
  58244. /**
  58245. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58246. */
  58247. static readonly MODE_TOPBOTTOM: number;
  58248. /**
  58249. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58250. */
  58251. static readonly MODE_SIDEBYSIDE: number;
  58252. /**
  58253. * Gets or sets the texture being displayed on the sphere
  58254. */
  58255. get photoTexture(): Texture;
  58256. /**
  58257. * sets the texture being displayed on the sphere
  58258. */
  58259. set photoTexture(value: Texture);
  58260. /**
  58261. * Gets the current video mode for the video. It can be:
  58262. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58263. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58264. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58265. */
  58266. get imageMode(): number;
  58267. /**
  58268. * Sets the current video mode for the video. It can be:
  58269. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58270. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58271. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58272. */
  58273. set imageMode(value: number);
  58274. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * Direct draw surface info
  58280. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58281. */
  58282. export interface DDSInfo {
  58283. /**
  58284. * Width of the texture
  58285. */
  58286. width: number;
  58287. /**
  58288. * Width of the texture
  58289. */
  58290. height: number;
  58291. /**
  58292. * Number of Mipmaps for the texture
  58293. * @see https://en.wikipedia.org/wiki/Mipmap
  58294. */
  58295. mipmapCount: number;
  58296. /**
  58297. * If the textures format is a known fourCC format
  58298. * @see https://www.fourcc.org/
  58299. */
  58300. isFourCC: boolean;
  58301. /**
  58302. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58303. */
  58304. isRGB: boolean;
  58305. /**
  58306. * If the texture is a lumincance format
  58307. */
  58308. isLuminance: boolean;
  58309. /**
  58310. * If this is a cube texture
  58311. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58312. */
  58313. isCube: boolean;
  58314. /**
  58315. * If the texture is a compressed format eg. FOURCC_DXT1
  58316. */
  58317. isCompressed: boolean;
  58318. /**
  58319. * The dxgiFormat of the texture
  58320. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58321. */
  58322. dxgiFormat: number;
  58323. /**
  58324. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58325. */
  58326. textureType: number;
  58327. /**
  58328. * Sphericle polynomial created for the dds texture
  58329. */
  58330. sphericalPolynomial?: SphericalPolynomial;
  58331. }
  58332. /**
  58333. * Class used to provide DDS decompression tools
  58334. */
  58335. export class DDSTools {
  58336. /**
  58337. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58338. */
  58339. static StoreLODInAlphaChannel: boolean;
  58340. /**
  58341. * Gets DDS information from an array buffer
  58342. * @param data defines the array buffer view to read data from
  58343. * @returns the DDS information
  58344. */
  58345. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58346. private static _FloatView;
  58347. private static _Int32View;
  58348. private static _ToHalfFloat;
  58349. private static _FromHalfFloat;
  58350. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58351. private static _GetHalfFloatRGBAArrayBuffer;
  58352. private static _GetFloatRGBAArrayBuffer;
  58353. private static _GetFloatAsUIntRGBAArrayBuffer;
  58354. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58355. private static _GetRGBAArrayBuffer;
  58356. private static _ExtractLongWordOrder;
  58357. private static _GetRGBArrayBuffer;
  58358. private static _GetLuminanceArrayBuffer;
  58359. /**
  58360. * Uploads DDS Levels to a Babylon Texture
  58361. * @hidden
  58362. */
  58363. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58364. }
  58365. interface ThinEngine {
  58366. /**
  58367. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58368. * @param rootUrl defines the url where the file to load is located
  58369. * @param scene defines the current scene
  58370. * @param lodScale defines scale to apply to the mip map selection
  58371. * @param lodOffset defines offset to apply to the mip map selection
  58372. * @param onLoad defines an optional callback raised when the texture is loaded
  58373. * @param onError defines an optional callback raised if there is an issue to load the texture
  58374. * @param format defines the format of the data
  58375. * @param forcedExtension defines the extension to use to pick the right loader
  58376. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58377. * @returns the cube texture as an InternalTexture
  58378. */
  58379. 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;
  58380. }
  58381. }
  58382. declare module BABYLON {
  58383. /**
  58384. * Implementation of the DDS Texture Loader.
  58385. * @hidden
  58386. */
  58387. export class _DDSTextureLoader implements IInternalTextureLoader {
  58388. /**
  58389. * Defines wether the loader supports cascade loading the different faces.
  58390. */
  58391. readonly supportCascades: boolean;
  58392. /**
  58393. * This returns if the loader support the current file information.
  58394. * @param extension defines the file extension of the file being loaded
  58395. * @returns true if the loader can load the specified file
  58396. */
  58397. canLoad(extension: string): boolean;
  58398. /**
  58399. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58400. * @param data contains the texture data
  58401. * @param texture defines the BabylonJS internal texture
  58402. * @param createPolynomials will be true if polynomials have been requested
  58403. * @param onLoad defines the callback to trigger once the texture is ready
  58404. * @param onError defines the callback to trigger in case of error
  58405. */
  58406. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58407. /**
  58408. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58409. * @param data contains the texture data
  58410. * @param texture defines the BabylonJS internal texture
  58411. * @param callback defines the method to call once ready to upload
  58412. */
  58413. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58414. }
  58415. }
  58416. declare module BABYLON {
  58417. /**
  58418. * Implementation of the ENV Texture Loader.
  58419. * @hidden
  58420. */
  58421. export class _ENVTextureLoader implements IInternalTextureLoader {
  58422. /**
  58423. * Defines wether the loader supports cascade loading the different faces.
  58424. */
  58425. readonly supportCascades: boolean;
  58426. /**
  58427. * This returns if the loader support the current file information.
  58428. * @param extension defines the file extension of the file being loaded
  58429. * @returns true if the loader can load the specified file
  58430. */
  58431. canLoad(extension: string): boolean;
  58432. /**
  58433. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58434. * @param data contains the texture data
  58435. * @param texture defines the BabylonJS internal texture
  58436. * @param createPolynomials will be true if polynomials have been requested
  58437. * @param onLoad defines the callback to trigger once the texture is ready
  58438. * @param onError defines the callback to trigger in case of error
  58439. */
  58440. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58441. /**
  58442. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58443. * @param data contains the texture data
  58444. * @param texture defines the BabylonJS internal texture
  58445. * @param callback defines the method to call once ready to upload
  58446. */
  58447. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58448. }
  58449. }
  58450. declare module BABYLON {
  58451. /**
  58452. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58453. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58454. */
  58455. export class KhronosTextureContainer {
  58456. /** contents of the KTX container file */
  58457. data: ArrayBufferView;
  58458. private static HEADER_LEN;
  58459. private static COMPRESSED_2D;
  58460. private static COMPRESSED_3D;
  58461. private static TEX_2D;
  58462. private static TEX_3D;
  58463. /**
  58464. * Gets the openGL type
  58465. */
  58466. glType: number;
  58467. /**
  58468. * Gets the openGL type size
  58469. */
  58470. glTypeSize: number;
  58471. /**
  58472. * Gets the openGL format
  58473. */
  58474. glFormat: number;
  58475. /**
  58476. * Gets the openGL internal format
  58477. */
  58478. glInternalFormat: number;
  58479. /**
  58480. * Gets the base internal format
  58481. */
  58482. glBaseInternalFormat: number;
  58483. /**
  58484. * Gets image width in pixel
  58485. */
  58486. pixelWidth: number;
  58487. /**
  58488. * Gets image height in pixel
  58489. */
  58490. pixelHeight: number;
  58491. /**
  58492. * Gets image depth in pixels
  58493. */
  58494. pixelDepth: number;
  58495. /**
  58496. * Gets the number of array elements
  58497. */
  58498. numberOfArrayElements: number;
  58499. /**
  58500. * Gets the number of faces
  58501. */
  58502. numberOfFaces: number;
  58503. /**
  58504. * Gets the number of mipmap levels
  58505. */
  58506. numberOfMipmapLevels: number;
  58507. /**
  58508. * Gets the bytes of key value data
  58509. */
  58510. bytesOfKeyValueData: number;
  58511. /**
  58512. * Gets the load type
  58513. */
  58514. loadType: number;
  58515. /**
  58516. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58517. */
  58518. isInvalid: boolean;
  58519. /**
  58520. * Creates a new KhronosTextureContainer
  58521. * @param data contents of the KTX container file
  58522. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58523. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58524. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58525. */
  58526. constructor(
  58527. /** contents of the KTX container file */
  58528. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58529. /**
  58530. * Uploads KTX content to a Babylon Texture.
  58531. * It is assumed that the texture has already been created & is currently bound
  58532. * @hidden
  58533. */
  58534. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58535. private _upload2DCompressedLevels;
  58536. /**
  58537. * Checks if the given data starts with a KTX file identifier.
  58538. * @param data the data to check
  58539. * @returns true if the data is a KTX file or false otherwise
  58540. */
  58541. static IsValid(data: ArrayBufferView): boolean;
  58542. }
  58543. }
  58544. declare module BABYLON {
  58545. /**
  58546. * Helper class to push actions to a pool of workers.
  58547. */
  58548. export class WorkerPool implements IDisposable {
  58549. private _workerInfos;
  58550. private _pendingActions;
  58551. /**
  58552. * Constructor
  58553. * @param workers Array of workers to use for actions
  58554. */
  58555. constructor(workers: Array<Worker>);
  58556. /**
  58557. * Terminates all workers and clears any pending actions.
  58558. */
  58559. dispose(): void;
  58560. /**
  58561. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58562. * pended until a worker has completed its action.
  58563. * @param action The action to perform. Call onComplete when the action is complete.
  58564. */
  58565. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58566. private _execute;
  58567. }
  58568. }
  58569. declare module BABYLON {
  58570. /**
  58571. * Class for loading KTX2 files
  58572. */
  58573. export class KhronosTextureContainer2 {
  58574. private static _WorkerPoolPromise?;
  58575. private static _Initialized;
  58576. private static _Ktx2Decoder;
  58577. /**
  58578. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58579. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58580. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58581. * Urls you can change:
  58582. * URLConfig.jsDecoderModule
  58583. * URLConfig.wasmUASTCToASTC
  58584. * URLConfig.wasmUASTCToBC7
  58585. * URLConfig.jsMSCTranscoder
  58586. * URLConfig.wasmMSCTranscoder
  58587. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58588. */
  58589. static URLConfig: {
  58590. jsDecoderModule: string;
  58591. wasmUASTCToASTC: null;
  58592. wasmUASTCToBC7: null;
  58593. jsMSCTranscoder: null;
  58594. wasmMSCTranscoder: null;
  58595. };
  58596. /**
  58597. * Default number of workers used to handle data decoding
  58598. */
  58599. static DefaultNumWorkers: number;
  58600. private static GetDefaultNumWorkers;
  58601. private _engine;
  58602. private static _CreateWorkerPool;
  58603. /**
  58604. * Constructor
  58605. * @param engine The engine to use
  58606. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58607. */
  58608. constructor(engine: ThinEngine, numWorkers?: number);
  58609. /** @hidden */
  58610. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58611. /**
  58612. * Stop all async operations and release resources.
  58613. */
  58614. dispose(): void;
  58615. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58616. /**
  58617. * Checks if the given data starts with a KTX2 file identifier.
  58618. * @param data the data to check
  58619. * @returns true if the data is a KTX2 file or false otherwise
  58620. */
  58621. static IsValid(data: ArrayBufferView): boolean;
  58622. }
  58623. }
  58624. declare module BABYLON {
  58625. /**
  58626. * Implementation of the KTX Texture Loader.
  58627. * @hidden
  58628. */
  58629. export class _KTXTextureLoader implements IInternalTextureLoader {
  58630. /**
  58631. * Defines wether the loader supports cascade loading the different faces.
  58632. */
  58633. readonly supportCascades: boolean;
  58634. /**
  58635. * This returns if the loader support the current file information.
  58636. * @param extension defines the file extension of the file being loaded
  58637. * @param mimeType defines the optional mime type of the file being loaded
  58638. * @returns true if the loader can load the specified file
  58639. */
  58640. canLoad(extension: string, mimeType?: string): boolean;
  58641. /**
  58642. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58643. * @param data contains the texture data
  58644. * @param texture defines the BabylonJS internal texture
  58645. * @param createPolynomials will be true if polynomials have been requested
  58646. * @param onLoad defines the callback to trigger once the texture is ready
  58647. * @param onError defines the callback to trigger in case of error
  58648. */
  58649. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58650. /**
  58651. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58652. * @param data contains the texture data
  58653. * @param texture defines the BabylonJS internal texture
  58654. * @param callback defines the method to call once ready to upload
  58655. */
  58656. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. /** @hidden */
  58661. export var _forceSceneHelpersToBundle: boolean;
  58662. interface Scene {
  58663. /**
  58664. * Creates a default light for the scene.
  58665. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58666. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58667. */
  58668. createDefaultLight(replace?: boolean): void;
  58669. /**
  58670. * Creates a default camera for the scene.
  58671. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58672. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58673. * @param replace has default false, when true replaces the active camera in the scene
  58674. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58675. */
  58676. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58677. /**
  58678. * Creates a default camera and a default light.
  58679. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58680. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58681. * @param replace has the default false, when true replaces the active camera/light in the scene
  58682. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58683. */
  58684. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58685. /**
  58686. * Creates a new sky box
  58687. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58688. * @param environmentTexture defines the texture to use as environment texture
  58689. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58690. * @param scale defines the overall scale of the skybox
  58691. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58692. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58693. * @returns a new mesh holding the sky box
  58694. */
  58695. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58696. /**
  58697. * Creates a new environment
  58698. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58699. * @param options defines the options you can use to configure the environment
  58700. * @returns the new EnvironmentHelper
  58701. */
  58702. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58703. /**
  58704. * Creates a new VREXperienceHelper
  58705. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58706. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58707. * @returns a new VREXperienceHelper
  58708. */
  58709. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58710. /**
  58711. * Creates a new WebXRDefaultExperience
  58712. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58713. * @param options experience options
  58714. * @returns a promise for a new WebXRDefaultExperience
  58715. */
  58716. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58717. }
  58718. }
  58719. declare module BABYLON {
  58720. /**
  58721. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58722. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58723. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58724. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58725. */
  58726. export class VideoDome extends TextureDome<VideoTexture> {
  58727. /**
  58728. * Define the video source as a Monoscopic panoramic 360 video.
  58729. */
  58730. static readonly MODE_MONOSCOPIC: number;
  58731. /**
  58732. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58733. */
  58734. static readonly MODE_TOPBOTTOM: number;
  58735. /**
  58736. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58737. */
  58738. static readonly MODE_SIDEBYSIDE: number;
  58739. /**
  58740. * Get the video texture associated with this video dome
  58741. */
  58742. get videoTexture(): VideoTexture;
  58743. /**
  58744. * Get the video mode of this dome
  58745. */
  58746. get videoMode(): number;
  58747. /**
  58748. * Set the video mode of this dome.
  58749. * @see textureMode
  58750. */
  58751. set videoMode(value: number);
  58752. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58753. }
  58754. }
  58755. declare module BABYLON {
  58756. /**
  58757. * This class can be used to get instrumentation data from a Babylon engine
  58758. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58759. */
  58760. export class EngineInstrumentation implements IDisposable {
  58761. /**
  58762. * Define the instrumented engine.
  58763. */
  58764. engine: Engine;
  58765. private _captureGPUFrameTime;
  58766. private _gpuFrameTimeToken;
  58767. private _gpuFrameTime;
  58768. private _captureShaderCompilationTime;
  58769. private _shaderCompilationTime;
  58770. private _onBeginFrameObserver;
  58771. private _onEndFrameObserver;
  58772. private _onBeforeShaderCompilationObserver;
  58773. private _onAfterShaderCompilationObserver;
  58774. /**
  58775. * Gets the perf counter used for GPU frame time
  58776. */
  58777. get gpuFrameTimeCounter(): PerfCounter;
  58778. /**
  58779. * Gets the GPU frame time capture status
  58780. */
  58781. get captureGPUFrameTime(): boolean;
  58782. /**
  58783. * Enable or disable the GPU frame time capture
  58784. */
  58785. set captureGPUFrameTime(value: boolean);
  58786. /**
  58787. * Gets the perf counter used for shader compilation time
  58788. */
  58789. get shaderCompilationTimeCounter(): PerfCounter;
  58790. /**
  58791. * Gets the shader compilation time capture status
  58792. */
  58793. get captureShaderCompilationTime(): boolean;
  58794. /**
  58795. * Enable or disable the shader compilation time capture
  58796. */
  58797. set captureShaderCompilationTime(value: boolean);
  58798. /**
  58799. * Instantiates a new engine instrumentation.
  58800. * This class can be used to get instrumentation data from a Babylon engine
  58801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58802. * @param engine Defines the engine to instrument
  58803. */
  58804. constructor(
  58805. /**
  58806. * Define the instrumented engine.
  58807. */
  58808. engine: Engine);
  58809. /**
  58810. * Dispose and release associated resources.
  58811. */
  58812. dispose(): void;
  58813. }
  58814. }
  58815. declare module BABYLON {
  58816. /**
  58817. * This class can be used to get instrumentation data from a Babylon engine
  58818. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58819. */
  58820. export class SceneInstrumentation implements IDisposable {
  58821. /**
  58822. * Defines the scene to instrument
  58823. */
  58824. scene: Scene;
  58825. private _captureActiveMeshesEvaluationTime;
  58826. private _activeMeshesEvaluationTime;
  58827. private _captureRenderTargetsRenderTime;
  58828. private _renderTargetsRenderTime;
  58829. private _captureFrameTime;
  58830. private _frameTime;
  58831. private _captureRenderTime;
  58832. private _renderTime;
  58833. private _captureInterFrameTime;
  58834. private _interFrameTime;
  58835. private _captureParticlesRenderTime;
  58836. private _particlesRenderTime;
  58837. private _captureSpritesRenderTime;
  58838. private _spritesRenderTime;
  58839. private _capturePhysicsTime;
  58840. private _physicsTime;
  58841. private _captureAnimationsTime;
  58842. private _animationsTime;
  58843. private _captureCameraRenderTime;
  58844. private _cameraRenderTime;
  58845. private _onBeforeActiveMeshesEvaluationObserver;
  58846. private _onAfterActiveMeshesEvaluationObserver;
  58847. private _onBeforeRenderTargetsRenderObserver;
  58848. private _onAfterRenderTargetsRenderObserver;
  58849. private _onAfterRenderObserver;
  58850. private _onBeforeDrawPhaseObserver;
  58851. private _onAfterDrawPhaseObserver;
  58852. private _onBeforeAnimationsObserver;
  58853. private _onBeforeParticlesRenderingObserver;
  58854. private _onAfterParticlesRenderingObserver;
  58855. private _onBeforeSpritesRenderingObserver;
  58856. private _onAfterSpritesRenderingObserver;
  58857. private _onBeforePhysicsObserver;
  58858. private _onAfterPhysicsObserver;
  58859. private _onAfterAnimationsObserver;
  58860. private _onBeforeCameraRenderObserver;
  58861. private _onAfterCameraRenderObserver;
  58862. /**
  58863. * Gets the perf counter used for active meshes evaluation time
  58864. */
  58865. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58866. /**
  58867. * Gets the active meshes evaluation time capture status
  58868. */
  58869. get captureActiveMeshesEvaluationTime(): boolean;
  58870. /**
  58871. * Enable or disable the active meshes evaluation time capture
  58872. */
  58873. set captureActiveMeshesEvaluationTime(value: boolean);
  58874. /**
  58875. * Gets the perf counter used for render targets render time
  58876. */
  58877. get renderTargetsRenderTimeCounter(): PerfCounter;
  58878. /**
  58879. * Gets the render targets render time capture status
  58880. */
  58881. get captureRenderTargetsRenderTime(): boolean;
  58882. /**
  58883. * Enable or disable the render targets render time capture
  58884. */
  58885. set captureRenderTargetsRenderTime(value: boolean);
  58886. /**
  58887. * Gets the perf counter used for particles render time
  58888. */
  58889. get particlesRenderTimeCounter(): PerfCounter;
  58890. /**
  58891. * Gets the particles render time capture status
  58892. */
  58893. get captureParticlesRenderTime(): boolean;
  58894. /**
  58895. * Enable or disable the particles render time capture
  58896. */
  58897. set captureParticlesRenderTime(value: boolean);
  58898. /**
  58899. * Gets the perf counter used for sprites render time
  58900. */
  58901. get spritesRenderTimeCounter(): PerfCounter;
  58902. /**
  58903. * Gets the sprites render time capture status
  58904. */
  58905. get captureSpritesRenderTime(): boolean;
  58906. /**
  58907. * Enable or disable the sprites render time capture
  58908. */
  58909. set captureSpritesRenderTime(value: boolean);
  58910. /**
  58911. * Gets the perf counter used for physics time
  58912. */
  58913. get physicsTimeCounter(): PerfCounter;
  58914. /**
  58915. * Gets the physics time capture status
  58916. */
  58917. get capturePhysicsTime(): boolean;
  58918. /**
  58919. * Enable or disable the physics time capture
  58920. */
  58921. set capturePhysicsTime(value: boolean);
  58922. /**
  58923. * Gets the perf counter used for animations time
  58924. */
  58925. get animationsTimeCounter(): PerfCounter;
  58926. /**
  58927. * Gets the animations time capture status
  58928. */
  58929. get captureAnimationsTime(): boolean;
  58930. /**
  58931. * Enable or disable the animations time capture
  58932. */
  58933. set captureAnimationsTime(value: boolean);
  58934. /**
  58935. * Gets the perf counter used for frame time capture
  58936. */
  58937. get frameTimeCounter(): PerfCounter;
  58938. /**
  58939. * Gets the frame time capture status
  58940. */
  58941. get captureFrameTime(): boolean;
  58942. /**
  58943. * Enable or disable the frame time capture
  58944. */
  58945. set captureFrameTime(value: boolean);
  58946. /**
  58947. * Gets the perf counter used for inter-frames time capture
  58948. */
  58949. get interFrameTimeCounter(): PerfCounter;
  58950. /**
  58951. * Gets the inter-frames time capture status
  58952. */
  58953. get captureInterFrameTime(): boolean;
  58954. /**
  58955. * Enable or disable the inter-frames time capture
  58956. */
  58957. set captureInterFrameTime(value: boolean);
  58958. /**
  58959. * Gets the perf counter used for render time capture
  58960. */
  58961. get renderTimeCounter(): PerfCounter;
  58962. /**
  58963. * Gets the render time capture status
  58964. */
  58965. get captureRenderTime(): boolean;
  58966. /**
  58967. * Enable or disable the render time capture
  58968. */
  58969. set captureRenderTime(value: boolean);
  58970. /**
  58971. * Gets the perf counter used for camera render time capture
  58972. */
  58973. get cameraRenderTimeCounter(): PerfCounter;
  58974. /**
  58975. * Gets the camera render time capture status
  58976. */
  58977. get captureCameraRenderTime(): boolean;
  58978. /**
  58979. * Enable or disable the camera render time capture
  58980. */
  58981. set captureCameraRenderTime(value: boolean);
  58982. /**
  58983. * Gets the perf counter used for draw calls
  58984. */
  58985. get drawCallsCounter(): PerfCounter;
  58986. /**
  58987. * Instantiates a new scene instrumentation.
  58988. * This class can be used to get instrumentation data from a Babylon engine
  58989. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58990. * @param scene Defines the scene to instrument
  58991. */
  58992. constructor(
  58993. /**
  58994. * Defines the scene to instrument
  58995. */
  58996. scene: Scene);
  58997. /**
  58998. * Dispose and release associated resources.
  58999. */
  59000. dispose(): void;
  59001. }
  59002. }
  59003. declare module BABYLON {
  59004. /** @hidden */
  59005. export var glowMapGenerationPixelShader: {
  59006. name: string;
  59007. shader: string;
  59008. };
  59009. }
  59010. declare module BABYLON {
  59011. /** @hidden */
  59012. export var glowMapGenerationVertexShader: {
  59013. name: string;
  59014. shader: string;
  59015. };
  59016. }
  59017. declare module BABYLON {
  59018. /**
  59019. * Effect layer options. This helps customizing the behaviour
  59020. * of the effect layer.
  59021. */
  59022. export interface IEffectLayerOptions {
  59023. /**
  59024. * Multiplication factor apply to the canvas size to compute the render target size
  59025. * used to generated the objects (the smaller the faster).
  59026. */
  59027. mainTextureRatio: number;
  59028. /**
  59029. * Enforces a fixed size texture to ensure effect stability across devices.
  59030. */
  59031. mainTextureFixedSize?: number;
  59032. /**
  59033. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59034. */
  59035. alphaBlendingMode: number;
  59036. /**
  59037. * The camera attached to the layer.
  59038. */
  59039. camera: Nullable<Camera>;
  59040. /**
  59041. * The rendering group to draw the layer in.
  59042. */
  59043. renderingGroupId: number;
  59044. }
  59045. /**
  59046. * The effect layer Helps adding post process effect blended with the main pass.
  59047. *
  59048. * This can be for instance use to generate glow or higlight effects on the scene.
  59049. *
  59050. * The effect layer class can not be used directly and is intented to inherited from to be
  59051. * customized per effects.
  59052. */
  59053. export abstract class EffectLayer {
  59054. private _vertexBuffers;
  59055. private _indexBuffer;
  59056. private _cachedDefines;
  59057. private _effectLayerMapGenerationEffect;
  59058. private _effectLayerOptions;
  59059. private _mergeEffect;
  59060. protected _scene: Scene;
  59061. protected _engine: Engine;
  59062. protected _maxSize: number;
  59063. protected _mainTextureDesiredSize: ISize;
  59064. protected _mainTexture: RenderTargetTexture;
  59065. protected _shouldRender: boolean;
  59066. protected _postProcesses: PostProcess[];
  59067. protected _textures: BaseTexture[];
  59068. protected _emissiveTextureAndColor: {
  59069. texture: Nullable<BaseTexture>;
  59070. color: Color4;
  59071. };
  59072. /**
  59073. * The name of the layer
  59074. */
  59075. name: string;
  59076. /**
  59077. * The clear color of the texture used to generate the glow map.
  59078. */
  59079. neutralColor: Color4;
  59080. /**
  59081. * Specifies whether the highlight layer is enabled or not.
  59082. */
  59083. isEnabled: boolean;
  59084. /**
  59085. * Gets the camera attached to the layer.
  59086. */
  59087. get camera(): Nullable<Camera>;
  59088. /**
  59089. * Gets the rendering group id the layer should render in.
  59090. */
  59091. get renderingGroupId(): number;
  59092. set renderingGroupId(renderingGroupId: number);
  59093. /**
  59094. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59095. */
  59096. disableBoundingBoxesFromEffectLayer: boolean;
  59097. /**
  59098. * An event triggered when the effect layer has been disposed.
  59099. */
  59100. onDisposeObservable: Observable<EffectLayer>;
  59101. /**
  59102. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59103. */
  59104. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59105. /**
  59106. * An event triggered when the generated texture is being merged in the scene.
  59107. */
  59108. onBeforeComposeObservable: Observable<EffectLayer>;
  59109. /**
  59110. * An event triggered when the mesh is rendered into the effect render target.
  59111. */
  59112. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59113. /**
  59114. * An event triggered after the mesh has been rendered into the effect render target.
  59115. */
  59116. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59117. /**
  59118. * An event triggered when the generated texture has been merged in the scene.
  59119. */
  59120. onAfterComposeObservable: Observable<EffectLayer>;
  59121. /**
  59122. * An event triggered when the efffect layer changes its size.
  59123. */
  59124. onSizeChangedObservable: Observable<EffectLayer>;
  59125. /** @hidden */
  59126. static _SceneComponentInitialization: (scene: Scene) => void;
  59127. /**
  59128. * Instantiates a new effect Layer and references it in the scene.
  59129. * @param name The name of the layer
  59130. * @param scene The scene to use the layer in
  59131. */
  59132. constructor(
  59133. /** The Friendly of the effect in the scene */
  59134. name: string, scene: Scene);
  59135. /**
  59136. * Get the effect name of the layer.
  59137. * @return The effect name
  59138. */
  59139. abstract getEffectName(): string;
  59140. /**
  59141. * Checks for the readiness of the element composing the layer.
  59142. * @param subMesh the mesh to check for
  59143. * @param useInstances specify whether or not to use instances to render the mesh
  59144. * @return true if ready otherwise, false
  59145. */
  59146. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59147. /**
  59148. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59149. * @returns true if the effect requires stencil during the main canvas render pass.
  59150. */
  59151. abstract needStencil(): boolean;
  59152. /**
  59153. * Create the merge effect. This is the shader use to blit the information back
  59154. * to the main canvas at the end of the scene rendering.
  59155. * @returns The effect containing the shader used to merge the effect on the main canvas
  59156. */
  59157. protected abstract _createMergeEffect(): Effect;
  59158. /**
  59159. * Creates the render target textures and post processes used in the effect layer.
  59160. */
  59161. protected abstract _createTextureAndPostProcesses(): void;
  59162. /**
  59163. * Implementation specific of rendering the generating effect on the main canvas.
  59164. * @param effect The effect used to render through
  59165. */
  59166. protected abstract _internalRender(effect: Effect): void;
  59167. /**
  59168. * Sets the required values for both the emissive texture and and the main color.
  59169. */
  59170. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59171. /**
  59172. * Free any resources and references associated to a mesh.
  59173. * Internal use
  59174. * @param mesh The mesh to free.
  59175. */
  59176. abstract _disposeMesh(mesh: Mesh): void;
  59177. /**
  59178. * Serializes this layer (Glow or Highlight for example)
  59179. * @returns a serialized layer object
  59180. */
  59181. abstract serialize?(): any;
  59182. /**
  59183. * Initializes the effect layer with the required options.
  59184. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59185. */
  59186. protected _init(options: Partial<IEffectLayerOptions>): void;
  59187. /**
  59188. * Generates the index buffer of the full screen quad blending to the main canvas.
  59189. */
  59190. private _generateIndexBuffer;
  59191. /**
  59192. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59193. */
  59194. private _generateVertexBuffer;
  59195. /**
  59196. * Sets the main texture desired size which is the closest power of two
  59197. * of the engine canvas size.
  59198. */
  59199. private _setMainTextureSize;
  59200. /**
  59201. * Creates the main texture for the effect layer.
  59202. */
  59203. protected _createMainTexture(): void;
  59204. /**
  59205. * Adds specific effects defines.
  59206. * @param defines The defines to add specifics to.
  59207. */
  59208. protected _addCustomEffectDefines(defines: string[]): void;
  59209. /**
  59210. * Checks for the readiness of the element composing the layer.
  59211. * @param subMesh the mesh to check for
  59212. * @param useInstances specify whether or not to use instances to render the mesh
  59213. * @param emissiveTexture the associated emissive texture used to generate the glow
  59214. * @return true if ready otherwise, false
  59215. */
  59216. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59217. /**
  59218. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59219. */
  59220. render(): void;
  59221. /**
  59222. * Determine if a given mesh will be used in the current effect.
  59223. * @param mesh mesh to test
  59224. * @returns true if the mesh will be used
  59225. */
  59226. hasMesh(mesh: AbstractMesh): boolean;
  59227. /**
  59228. * Returns true if the layer contains information to display, otherwise false.
  59229. * @returns true if the glow layer should be rendered
  59230. */
  59231. shouldRender(): boolean;
  59232. /**
  59233. * Returns true if the mesh should render, otherwise false.
  59234. * @param mesh The mesh to render
  59235. * @returns true if it should render otherwise false
  59236. */
  59237. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59238. /**
  59239. * Returns true if the mesh can be rendered, otherwise false.
  59240. * @param mesh The mesh to render
  59241. * @param material The material used on the mesh
  59242. * @returns true if it can be rendered otherwise false
  59243. */
  59244. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59245. /**
  59246. * Returns true if the mesh should render, otherwise false.
  59247. * @param mesh The mesh to render
  59248. * @returns true if it should render otherwise false
  59249. */
  59250. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59251. /**
  59252. * Renders the submesh passed in parameter to the generation map.
  59253. */
  59254. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59255. /**
  59256. * Defines whether the current material of the mesh should be use to render the effect.
  59257. * @param mesh defines the current mesh to render
  59258. */
  59259. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59260. /**
  59261. * Rebuild the required buffers.
  59262. * @hidden Internal use only.
  59263. */
  59264. _rebuild(): void;
  59265. /**
  59266. * Dispose only the render target textures and post process.
  59267. */
  59268. private _disposeTextureAndPostProcesses;
  59269. /**
  59270. * Dispose the highlight layer and free resources.
  59271. */
  59272. dispose(): void;
  59273. /**
  59274. * Gets the class name of the effect layer
  59275. * @returns the string with the class name of the effect layer
  59276. */
  59277. getClassName(): string;
  59278. /**
  59279. * Creates an effect layer from parsed effect layer data
  59280. * @param parsedEffectLayer defines effect layer data
  59281. * @param scene defines the current scene
  59282. * @param rootUrl defines the root URL containing the effect layer information
  59283. * @returns a parsed effect Layer
  59284. */
  59285. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. interface AbstractScene {
  59290. /**
  59291. * The list of effect layers (highlights/glow) added to the scene
  59292. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59293. * @see https://doc.babylonjs.com/how_to/glow_layer
  59294. */
  59295. effectLayers: Array<EffectLayer>;
  59296. /**
  59297. * Removes the given effect layer from this scene.
  59298. * @param toRemove defines the effect layer to remove
  59299. * @returns the index of the removed effect layer
  59300. */
  59301. removeEffectLayer(toRemove: EffectLayer): number;
  59302. /**
  59303. * Adds the given effect layer to this scene
  59304. * @param newEffectLayer defines the effect layer to add
  59305. */
  59306. addEffectLayer(newEffectLayer: EffectLayer): void;
  59307. }
  59308. /**
  59309. * Defines the layer scene component responsible to manage any effect layers
  59310. * in a given scene.
  59311. */
  59312. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59313. /**
  59314. * The component name helpfull to identify the component in the list of scene components.
  59315. */
  59316. readonly name: string;
  59317. /**
  59318. * The scene the component belongs to.
  59319. */
  59320. scene: Scene;
  59321. private _engine;
  59322. private _renderEffects;
  59323. private _needStencil;
  59324. private _previousStencilState;
  59325. /**
  59326. * Creates a new instance of the component for the given scene
  59327. * @param scene Defines the scene to register the component in
  59328. */
  59329. constructor(scene: Scene);
  59330. /**
  59331. * Registers the component in a given scene
  59332. */
  59333. register(): void;
  59334. /**
  59335. * Rebuilds the elements related to this component in case of
  59336. * context lost for instance.
  59337. */
  59338. rebuild(): void;
  59339. /**
  59340. * Serializes the component data to the specified json object
  59341. * @param serializationObject The object to serialize to
  59342. */
  59343. serialize(serializationObject: any): void;
  59344. /**
  59345. * Adds all the elements from the container to the scene
  59346. * @param container the container holding the elements
  59347. */
  59348. addFromContainer(container: AbstractScene): void;
  59349. /**
  59350. * Removes all the elements in the container from the scene
  59351. * @param container contains the elements to remove
  59352. * @param dispose if the removed element should be disposed (default: false)
  59353. */
  59354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59355. /**
  59356. * Disposes the component and the associated ressources.
  59357. */
  59358. dispose(): void;
  59359. private _isReadyForMesh;
  59360. private _renderMainTexture;
  59361. private _setStencil;
  59362. private _setStencilBack;
  59363. private _draw;
  59364. private _drawCamera;
  59365. private _drawRenderingGroup;
  59366. }
  59367. }
  59368. declare module BABYLON {
  59369. /** @hidden */
  59370. export var glowMapMergePixelShader: {
  59371. name: string;
  59372. shader: string;
  59373. };
  59374. }
  59375. declare module BABYLON {
  59376. /** @hidden */
  59377. export var glowMapMergeVertexShader: {
  59378. name: string;
  59379. shader: string;
  59380. };
  59381. }
  59382. declare module BABYLON {
  59383. interface AbstractScene {
  59384. /**
  59385. * Return a the first highlight layer of the scene with a given name.
  59386. * @param name The name of the highlight layer to look for.
  59387. * @return The highlight layer if found otherwise null.
  59388. */
  59389. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59390. }
  59391. /**
  59392. * Glow layer options. This helps customizing the behaviour
  59393. * of the glow layer.
  59394. */
  59395. export interface IGlowLayerOptions {
  59396. /**
  59397. * Multiplication factor apply to the canvas size to compute the render target size
  59398. * used to generated the glowing objects (the smaller the faster).
  59399. */
  59400. mainTextureRatio: number;
  59401. /**
  59402. * Enforces a fixed size texture to ensure resize independant blur.
  59403. */
  59404. mainTextureFixedSize?: number;
  59405. /**
  59406. * How big is the kernel of the blur texture.
  59407. */
  59408. blurKernelSize: number;
  59409. /**
  59410. * The camera attached to the layer.
  59411. */
  59412. camera: Nullable<Camera>;
  59413. /**
  59414. * Enable MSAA by chosing the number of samples.
  59415. */
  59416. mainTextureSamples?: number;
  59417. /**
  59418. * The rendering group to draw the layer in.
  59419. */
  59420. renderingGroupId: number;
  59421. }
  59422. /**
  59423. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59424. *
  59425. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59426. *
  59427. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59428. */
  59429. export class GlowLayer extends EffectLayer {
  59430. /**
  59431. * Effect Name of the layer.
  59432. */
  59433. static readonly EffectName: string;
  59434. /**
  59435. * The default blur kernel size used for the glow.
  59436. */
  59437. static DefaultBlurKernelSize: number;
  59438. /**
  59439. * The default texture size ratio used for the glow.
  59440. */
  59441. static DefaultTextureRatio: number;
  59442. /**
  59443. * Sets the kernel size of the blur.
  59444. */
  59445. set blurKernelSize(value: number);
  59446. /**
  59447. * Gets the kernel size of the blur.
  59448. */
  59449. get blurKernelSize(): number;
  59450. /**
  59451. * Sets the glow intensity.
  59452. */
  59453. set intensity(value: number);
  59454. /**
  59455. * Gets the glow intensity.
  59456. */
  59457. get intensity(): number;
  59458. private _options;
  59459. private _intensity;
  59460. private _horizontalBlurPostprocess1;
  59461. private _verticalBlurPostprocess1;
  59462. private _horizontalBlurPostprocess2;
  59463. private _verticalBlurPostprocess2;
  59464. private _blurTexture1;
  59465. private _blurTexture2;
  59466. private _postProcesses1;
  59467. private _postProcesses2;
  59468. private _includedOnlyMeshes;
  59469. private _excludedMeshes;
  59470. private _meshesUsingTheirOwnMaterials;
  59471. /**
  59472. * Callback used to let the user override the color selection on a per mesh basis
  59473. */
  59474. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59475. /**
  59476. * Callback used to let the user override the texture selection on a per mesh basis
  59477. */
  59478. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59479. /**
  59480. * Instantiates a new glow Layer and references it to the scene.
  59481. * @param name The name of the layer
  59482. * @param scene The scene to use the layer in
  59483. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59484. */
  59485. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59486. /**
  59487. * Get the effect name of the layer.
  59488. * @return The effect name
  59489. */
  59490. getEffectName(): string;
  59491. /**
  59492. * Create the merge effect. This is the shader use to blit the information back
  59493. * to the main canvas at the end of the scene rendering.
  59494. */
  59495. protected _createMergeEffect(): Effect;
  59496. /**
  59497. * Creates the render target textures and post processes used in the glow layer.
  59498. */
  59499. protected _createTextureAndPostProcesses(): void;
  59500. /**
  59501. * Checks for the readiness of the element composing the layer.
  59502. * @param subMesh the mesh to check for
  59503. * @param useInstances specify wether or not to use instances to render the mesh
  59504. * @param emissiveTexture the associated emissive texture used to generate the glow
  59505. * @return true if ready otherwise, false
  59506. */
  59507. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59508. /**
  59509. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59510. */
  59511. needStencil(): boolean;
  59512. /**
  59513. * Returns true if the mesh can be rendered, otherwise false.
  59514. * @param mesh The mesh to render
  59515. * @param material The material used on the mesh
  59516. * @returns true if it can be rendered otherwise false
  59517. */
  59518. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59519. /**
  59520. * Implementation specific of rendering the generating effect on the main canvas.
  59521. * @param effect The effect used to render through
  59522. */
  59523. protected _internalRender(effect: Effect): void;
  59524. /**
  59525. * Sets the required values for both the emissive texture and and the main color.
  59526. */
  59527. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59528. /**
  59529. * Returns true if the mesh should render, otherwise false.
  59530. * @param mesh The mesh to render
  59531. * @returns true if it should render otherwise false
  59532. */
  59533. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59534. /**
  59535. * Adds specific effects defines.
  59536. * @param defines The defines to add specifics to.
  59537. */
  59538. protected _addCustomEffectDefines(defines: string[]): void;
  59539. /**
  59540. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59541. * @param mesh The mesh to exclude from the glow layer
  59542. */
  59543. addExcludedMesh(mesh: Mesh): void;
  59544. /**
  59545. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59546. * @param mesh The mesh to remove
  59547. */
  59548. removeExcludedMesh(mesh: Mesh): void;
  59549. /**
  59550. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59551. * @param mesh The mesh to include in the glow layer
  59552. */
  59553. addIncludedOnlyMesh(mesh: Mesh): void;
  59554. /**
  59555. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59556. * @param mesh The mesh to remove
  59557. */
  59558. removeIncludedOnlyMesh(mesh: Mesh): void;
  59559. /**
  59560. * Determine if a given mesh will be used in the glow layer
  59561. * @param mesh The mesh to test
  59562. * @returns true if the mesh will be highlighted by the current glow layer
  59563. */
  59564. hasMesh(mesh: AbstractMesh): boolean;
  59565. /**
  59566. * Defines whether the current material of the mesh should be use to render the effect.
  59567. * @param mesh defines the current mesh to render
  59568. */
  59569. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59570. /**
  59571. * Add a mesh to be rendered through its own material and not with emissive only.
  59572. * @param mesh The mesh for which we need to use its material
  59573. */
  59574. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59575. /**
  59576. * Remove a mesh from being rendered through its own material and not with emissive only.
  59577. * @param mesh The mesh for which we need to not use its material
  59578. */
  59579. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59580. /**
  59581. * Free any resources and references associated to a mesh.
  59582. * Internal use
  59583. * @param mesh The mesh to free.
  59584. * @hidden
  59585. */
  59586. _disposeMesh(mesh: Mesh): void;
  59587. /**
  59588. * Gets the class name of the effect layer
  59589. * @returns the string with the class name of the effect layer
  59590. */
  59591. getClassName(): string;
  59592. /**
  59593. * Serializes this glow layer
  59594. * @returns a serialized glow layer object
  59595. */
  59596. serialize(): any;
  59597. /**
  59598. * Creates a Glow Layer from parsed glow layer data
  59599. * @param parsedGlowLayer defines glow layer data
  59600. * @param scene defines the current scene
  59601. * @param rootUrl defines the root URL containing the glow layer information
  59602. * @returns a parsed Glow Layer
  59603. */
  59604. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59605. }
  59606. }
  59607. declare module BABYLON {
  59608. /** @hidden */
  59609. export var glowBlurPostProcessPixelShader: {
  59610. name: string;
  59611. shader: string;
  59612. };
  59613. }
  59614. declare module BABYLON {
  59615. interface AbstractScene {
  59616. /**
  59617. * Return a the first highlight layer of the scene with a given name.
  59618. * @param name The name of the highlight layer to look for.
  59619. * @return The highlight layer if found otherwise null.
  59620. */
  59621. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59622. }
  59623. /**
  59624. * Highlight layer options. This helps customizing the behaviour
  59625. * of the highlight layer.
  59626. */
  59627. export interface IHighlightLayerOptions {
  59628. /**
  59629. * Multiplication factor apply to the canvas size to compute the render target size
  59630. * used to generated the glowing objects (the smaller the faster).
  59631. */
  59632. mainTextureRatio: number;
  59633. /**
  59634. * Enforces a fixed size texture to ensure resize independant blur.
  59635. */
  59636. mainTextureFixedSize?: number;
  59637. /**
  59638. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59639. * of the picture to blur (the smaller the faster).
  59640. */
  59641. blurTextureSizeRatio: number;
  59642. /**
  59643. * How big in texel of the blur texture is the vertical blur.
  59644. */
  59645. blurVerticalSize: number;
  59646. /**
  59647. * How big in texel of the blur texture is the horizontal blur.
  59648. */
  59649. blurHorizontalSize: number;
  59650. /**
  59651. * Alpha blending mode used to apply the blur. Default is combine.
  59652. */
  59653. alphaBlendingMode: number;
  59654. /**
  59655. * The camera attached to the layer.
  59656. */
  59657. camera: Nullable<Camera>;
  59658. /**
  59659. * Should we display highlight as a solid stroke?
  59660. */
  59661. isStroke?: boolean;
  59662. /**
  59663. * The rendering group to draw the layer in.
  59664. */
  59665. renderingGroupId: number;
  59666. }
  59667. /**
  59668. * The highlight layer Helps adding a glow effect around a mesh.
  59669. *
  59670. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59671. * glowy meshes to your scene.
  59672. *
  59673. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59674. */
  59675. export class HighlightLayer extends EffectLayer {
  59676. name: string;
  59677. /**
  59678. * Effect Name of the highlight layer.
  59679. */
  59680. static readonly EffectName: string;
  59681. /**
  59682. * The neutral color used during the preparation of the glow effect.
  59683. * This is black by default as the blend operation is a blend operation.
  59684. */
  59685. static NeutralColor: Color4;
  59686. /**
  59687. * Stencil value used for glowing meshes.
  59688. */
  59689. static GlowingMeshStencilReference: number;
  59690. /**
  59691. * Stencil value used for the other meshes in the scene.
  59692. */
  59693. static NormalMeshStencilReference: number;
  59694. /**
  59695. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59696. */
  59697. innerGlow: boolean;
  59698. /**
  59699. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59700. */
  59701. outerGlow: boolean;
  59702. /**
  59703. * Specifies the horizontal size of the blur.
  59704. */
  59705. set blurHorizontalSize(value: number);
  59706. /**
  59707. * Specifies the vertical size of the blur.
  59708. */
  59709. set blurVerticalSize(value: number);
  59710. /**
  59711. * Gets the horizontal size of the blur.
  59712. */
  59713. get blurHorizontalSize(): number;
  59714. /**
  59715. * Gets the vertical size of the blur.
  59716. */
  59717. get blurVerticalSize(): number;
  59718. /**
  59719. * An event triggered when the highlight layer is being blurred.
  59720. */
  59721. onBeforeBlurObservable: Observable<HighlightLayer>;
  59722. /**
  59723. * An event triggered when the highlight layer has been blurred.
  59724. */
  59725. onAfterBlurObservable: Observable<HighlightLayer>;
  59726. private _instanceGlowingMeshStencilReference;
  59727. private _options;
  59728. private _downSamplePostprocess;
  59729. private _horizontalBlurPostprocess;
  59730. private _verticalBlurPostprocess;
  59731. private _blurTexture;
  59732. private _meshes;
  59733. private _excludedMeshes;
  59734. /**
  59735. * Instantiates a new highlight Layer and references it to the scene..
  59736. * @param name The name of the layer
  59737. * @param scene The scene to use the layer in
  59738. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59739. */
  59740. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59741. /**
  59742. * Get the effect name of the layer.
  59743. * @return The effect name
  59744. */
  59745. getEffectName(): string;
  59746. /**
  59747. * Create the merge effect. This is the shader use to blit the information back
  59748. * to the main canvas at the end of the scene rendering.
  59749. */
  59750. protected _createMergeEffect(): Effect;
  59751. /**
  59752. * Creates the render target textures and post processes used in the highlight layer.
  59753. */
  59754. protected _createTextureAndPostProcesses(): void;
  59755. /**
  59756. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59757. */
  59758. needStencil(): boolean;
  59759. /**
  59760. * Checks for the readiness of the element composing the layer.
  59761. * @param subMesh the mesh to check for
  59762. * @param useInstances specify wether or not to use instances to render the mesh
  59763. * @param emissiveTexture the associated emissive texture used to generate the glow
  59764. * @return true if ready otherwise, false
  59765. */
  59766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59767. /**
  59768. * Implementation specific of rendering the generating effect on the main canvas.
  59769. * @param effect The effect used to render through
  59770. */
  59771. protected _internalRender(effect: Effect): void;
  59772. /**
  59773. * Returns true if the layer contains information to display, otherwise false.
  59774. */
  59775. shouldRender(): boolean;
  59776. /**
  59777. * Returns true if the mesh should render, otherwise false.
  59778. * @param mesh The mesh to render
  59779. * @returns true if it should render otherwise false
  59780. */
  59781. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59782. /**
  59783. * Returns true if the mesh can be rendered, otherwise false.
  59784. * @param mesh The mesh to render
  59785. * @param material The material used on the mesh
  59786. * @returns true if it can be rendered otherwise false
  59787. */
  59788. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59789. /**
  59790. * Adds specific effects defines.
  59791. * @param defines The defines to add specifics to.
  59792. */
  59793. protected _addCustomEffectDefines(defines: string[]): void;
  59794. /**
  59795. * Sets the required values for both the emissive texture and and the main color.
  59796. */
  59797. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59798. /**
  59799. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59800. * @param mesh The mesh to exclude from the highlight layer
  59801. */
  59802. addExcludedMesh(mesh: Mesh): void;
  59803. /**
  59804. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59805. * @param mesh The mesh to highlight
  59806. */
  59807. removeExcludedMesh(mesh: Mesh): void;
  59808. /**
  59809. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59810. * @param mesh mesh to test
  59811. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59812. */
  59813. hasMesh(mesh: AbstractMesh): boolean;
  59814. /**
  59815. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59816. * @param mesh The mesh to highlight
  59817. * @param color The color of the highlight
  59818. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59819. */
  59820. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59821. /**
  59822. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59823. * @param mesh The mesh to highlight
  59824. */
  59825. removeMesh(mesh: Mesh): void;
  59826. /**
  59827. * Remove all the meshes currently referenced in the highlight layer
  59828. */
  59829. removeAllMeshes(): void;
  59830. /**
  59831. * Force the stencil to the normal expected value for none glowing parts
  59832. */
  59833. private _defaultStencilReference;
  59834. /**
  59835. * Free any resources and references associated to a mesh.
  59836. * Internal use
  59837. * @param mesh The mesh to free.
  59838. * @hidden
  59839. */
  59840. _disposeMesh(mesh: Mesh): void;
  59841. /**
  59842. * Dispose the highlight layer and free resources.
  59843. */
  59844. dispose(): void;
  59845. /**
  59846. * Gets the class name of the effect layer
  59847. * @returns the string with the class name of the effect layer
  59848. */
  59849. getClassName(): string;
  59850. /**
  59851. * Serializes this Highlight layer
  59852. * @returns a serialized Highlight layer object
  59853. */
  59854. serialize(): any;
  59855. /**
  59856. * Creates a Highlight layer from parsed Highlight layer data
  59857. * @param parsedHightlightLayer defines the Highlight layer data
  59858. * @param scene defines the current scene
  59859. * @param rootUrl defines the root URL containing the Highlight layer information
  59860. * @returns a parsed Highlight layer
  59861. */
  59862. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59863. }
  59864. }
  59865. declare module BABYLON {
  59866. interface AbstractScene {
  59867. /**
  59868. * The list of layers (background and foreground) of the scene
  59869. */
  59870. layers: Array<Layer>;
  59871. }
  59872. /**
  59873. * Defines the layer scene component responsible to manage any layers
  59874. * in a given scene.
  59875. */
  59876. export class LayerSceneComponent implements ISceneComponent {
  59877. /**
  59878. * The component name helpfull to identify the component in the list of scene components.
  59879. */
  59880. readonly name: string;
  59881. /**
  59882. * The scene the component belongs to.
  59883. */
  59884. scene: Scene;
  59885. private _engine;
  59886. /**
  59887. * Creates a new instance of the component for the given scene
  59888. * @param scene Defines the scene to register the component in
  59889. */
  59890. constructor(scene: Scene);
  59891. /**
  59892. * Registers the component in a given scene
  59893. */
  59894. register(): void;
  59895. /**
  59896. * Rebuilds the elements related to this component in case of
  59897. * context lost for instance.
  59898. */
  59899. rebuild(): void;
  59900. /**
  59901. * Disposes the component and the associated ressources.
  59902. */
  59903. dispose(): void;
  59904. private _draw;
  59905. private _drawCameraPredicate;
  59906. private _drawCameraBackground;
  59907. private _drawCameraForeground;
  59908. private _drawRenderTargetPredicate;
  59909. private _drawRenderTargetBackground;
  59910. private _drawRenderTargetForeground;
  59911. /**
  59912. * Adds all the elements from the container to the scene
  59913. * @param container the container holding the elements
  59914. */
  59915. addFromContainer(container: AbstractScene): void;
  59916. /**
  59917. * Removes all the elements in the container from the scene
  59918. * @param container contains the elements to remove
  59919. * @param dispose if the removed element should be disposed (default: false)
  59920. */
  59921. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59922. }
  59923. }
  59924. declare module BABYLON {
  59925. /** @hidden */
  59926. export var layerPixelShader: {
  59927. name: string;
  59928. shader: string;
  59929. };
  59930. }
  59931. declare module BABYLON {
  59932. /** @hidden */
  59933. export var layerVertexShader: {
  59934. name: string;
  59935. shader: string;
  59936. };
  59937. }
  59938. declare module BABYLON {
  59939. /**
  59940. * This represents a full screen 2d layer.
  59941. * This can be useful to display a picture in the background of your scene for instance.
  59942. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59943. */
  59944. export class Layer {
  59945. /**
  59946. * Define the name of the layer.
  59947. */
  59948. name: string;
  59949. /**
  59950. * Define the texture the layer should display.
  59951. */
  59952. texture: Nullable<Texture>;
  59953. /**
  59954. * Is the layer in background or foreground.
  59955. */
  59956. isBackground: boolean;
  59957. /**
  59958. * Define the color of the layer (instead of texture).
  59959. */
  59960. color: Color4;
  59961. /**
  59962. * Define the scale of the layer in order to zoom in out of the texture.
  59963. */
  59964. scale: Vector2;
  59965. /**
  59966. * Define an offset for the layer in order to shift the texture.
  59967. */
  59968. offset: Vector2;
  59969. /**
  59970. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59971. */
  59972. alphaBlendingMode: number;
  59973. /**
  59974. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59975. * Alpha test will not mix with the background color in case of transparency.
  59976. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59977. */
  59978. alphaTest: boolean;
  59979. /**
  59980. * Define a mask to restrict the layer to only some of the scene cameras.
  59981. */
  59982. layerMask: number;
  59983. /**
  59984. * Define the list of render target the layer is visible into.
  59985. */
  59986. renderTargetTextures: RenderTargetTexture[];
  59987. /**
  59988. * Define if the layer is only used in renderTarget or if it also
  59989. * renders in the main frame buffer of the canvas.
  59990. */
  59991. renderOnlyInRenderTargetTextures: boolean;
  59992. private _scene;
  59993. private _vertexBuffers;
  59994. private _indexBuffer;
  59995. private _effect;
  59996. private _previousDefines;
  59997. /**
  59998. * An event triggered when the layer is disposed.
  59999. */
  60000. onDisposeObservable: Observable<Layer>;
  60001. private _onDisposeObserver;
  60002. /**
  60003. * Back compatibility with callback before the onDisposeObservable existed.
  60004. * The set callback will be triggered when the layer has been disposed.
  60005. */
  60006. set onDispose(callback: () => void);
  60007. /**
  60008. * An event triggered before rendering the scene
  60009. */
  60010. onBeforeRenderObservable: Observable<Layer>;
  60011. private _onBeforeRenderObserver;
  60012. /**
  60013. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60014. * The set callback will be triggered just before rendering the layer.
  60015. */
  60016. set onBeforeRender(callback: () => void);
  60017. /**
  60018. * An event triggered after rendering the scene
  60019. */
  60020. onAfterRenderObservable: Observable<Layer>;
  60021. private _onAfterRenderObserver;
  60022. /**
  60023. * Back compatibility with callback before the onAfterRenderObservable existed.
  60024. * The set callback will be triggered just after rendering the layer.
  60025. */
  60026. set onAfterRender(callback: () => void);
  60027. /**
  60028. * Instantiates a new layer.
  60029. * This represents a full screen 2d layer.
  60030. * This can be useful to display a picture in the background of your scene for instance.
  60031. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60032. * @param name Define the name of the layer in the scene
  60033. * @param imgUrl Define the url of the texture to display in the layer
  60034. * @param scene Define the scene the layer belongs to
  60035. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60036. * @param color Defines a color for the layer
  60037. */
  60038. constructor(
  60039. /**
  60040. * Define the name of the layer.
  60041. */
  60042. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60043. private _createIndexBuffer;
  60044. /** @hidden */
  60045. _rebuild(): void;
  60046. /**
  60047. * Renders the layer in the scene.
  60048. */
  60049. render(): void;
  60050. /**
  60051. * Disposes and releases the associated ressources.
  60052. */
  60053. dispose(): void;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /** @hidden */
  60058. export var lensFlarePixelShader: {
  60059. name: string;
  60060. shader: string;
  60061. };
  60062. }
  60063. declare module BABYLON {
  60064. /** @hidden */
  60065. export var lensFlareVertexShader: {
  60066. name: string;
  60067. shader: string;
  60068. };
  60069. }
  60070. declare module BABYLON {
  60071. /**
  60072. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60073. * It is usually composed of several `lensFlare`.
  60074. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60075. */
  60076. export class LensFlareSystem {
  60077. /**
  60078. * Define the name of the lens flare system
  60079. */
  60080. name: string;
  60081. /**
  60082. * List of lens flares used in this system.
  60083. */
  60084. lensFlares: LensFlare[];
  60085. /**
  60086. * Define a limit from the border the lens flare can be visible.
  60087. */
  60088. borderLimit: number;
  60089. /**
  60090. * Define a viewport border we do not want to see the lens flare in.
  60091. */
  60092. viewportBorder: number;
  60093. /**
  60094. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60095. */
  60096. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60097. /**
  60098. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60099. */
  60100. layerMask: number;
  60101. /**
  60102. * Define the id of the lens flare system in the scene.
  60103. * (equal to name by default)
  60104. */
  60105. id: string;
  60106. private _scene;
  60107. private _emitter;
  60108. private _vertexBuffers;
  60109. private _indexBuffer;
  60110. private _effect;
  60111. private _positionX;
  60112. private _positionY;
  60113. private _isEnabled;
  60114. /** @hidden */
  60115. static _SceneComponentInitialization: (scene: Scene) => void;
  60116. /**
  60117. * Instantiates a lens flare system.
  60118. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60119. * It is usually composed of several `lensFlare`.
  60120. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60121. * @param name Define the name of the lens flare system in the scene
  60122. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60123. * @param scene Define the scene the lens flare system belongs to
  60124. */
  60125. constructor(
  60126. /**
  60127. * Define the name of the lens flare system
  60128. */
  60129. name: string, emitter: any, scene: Scene);
  60130. /**
  60131. * Define if the lens flare system is enabled.
  60132. */
  60133. get isEnabled(): boolean;
  60134. set isEnabled(value: boolean);
  60135. /**
  60136. * Get the scene the effects belongs to.
  60137. * @returns the scene holding the lens flare system
  60138. */
  60139. getScene(): Scene;
  60140. /**
  60141. * Get the emitter of the lens flare system.
  60142. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60143. * @returns the emitter of the lens flare system
  60144. */
  60145. getEmitter(): any;
  60146. /**
  60147. * Set the emitter of the lens flare system.
  60148. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60149. * @param newEmitter Define the new emitter of the system
  60150. */
  60151. setEmitter(newEmitter: any): void;
  60152. /**
  60153. * Get the lens flare system emitter position.
  60154. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60155. * @returns the position
  60156. */
  60157. getEmitterPosition(): Vector3;
  60158. /**
  60159. * @hidden
  60160. */
  60161. computeEffectivePosition(globalViewport: Viewport): boolean;
  60162. /** @hidden */
  60163. _isVisible(): boolean;
  60164. /**
  60165. * @hidden
  60166. */
  60167. render(): boolean;
  60168. /**
  60169. * Dispose and release the lens flare with its associated resources.
  60170. */
  60171. dispose(): void;
  60172. /**
  60173. * Parse a lens flare system from a JSON repressentation
  60174. * @param parsedLensFlareSystem Define the JSON to parse
  60175. * @param scene Define the scene the parsed system should be instantiated in
  60176. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60177. * @returns the parsed system
  60178. */
  60179. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60180. /**
  60181. * Serialize the current Lens Flare System into a JSON representation.
  60182. * @returns the serialized JSON
  60183. */
  60184. serialize(): any;
  60185. }
  60186. }
  60187. declare module BABYLON {
  60188. /**
  60189. * This represents one of the lens effect in a `lensFlareSystem`.
  60190. * It controls one of the indiviual texture used in the effect.
  60191. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60192. */
  60193. export class LensFlare {
  60194. /**
  60195. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60196. */
  60197. size: number;
  60198. /**
  60199. * 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.
  60200. */
  60201. position: number;
  60202. /**
  60203. * Define the lens color.
  60204. */
  60205. color: Color3;
  60206. /**
  60207. * Define the lens texture.
  60208. */
  60209. texture: Nullable<Texture>;
  60210. /**
  60211. * Define the alpha mode to render this particular lens.
  60212. */
  60213. alphaMode: number;
  60214. private _system;
  60215. /**
  60216. * Creates a new Lens Flare.
  60217. * This represents one of the lens effect in a `lensFlareSystem`.
  60218. * It controls one of the indiviual texture used in the effect.
  60219. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60220. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60221. * @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.
  60222. * @param color Define the lens color
  60223. * @param imgUrl Define the lens texture url
  60224. * @param system Define the `lensFlareSystem` this flare is part of
  60225. * @returns The newly created Lens Flare
  60226. */
  60227. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60228. /**
  60229. * Instantiates a new Lens Flare.
  60230. * This represents one of the lens effect in a `lensFlareSystem`.
  60231. * It controls one of the indiviual texture used in the effect.
  60232. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60233. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60234. * @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.
  60235. * @param color Define the lens color
  60236. * @param imgUrl Define the lens texture url
  60237. * @param system Define the `lensFlareSystem` this flare is part of
  60238. */
  60239. constructor(
  60240. /**
  60241. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60242. */
  60243. size: number,
  60244. /**
  60245. * 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.
  60246. */
  60247. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60248. /**
  60249. * Dispose and release the lens flare with its associated resources.
  60250. */
  60251. dispose(): void;
  60252. }
  60253. }
  60254. declare module BABYLON {
  60255. interface AbstractScene {
  60256. /**
  60257. * The list of lens flare system added to the scene
  60258. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60259. */
  60260. lensFlareSystems: Array<LensFlareSystem>;
  60261. /**
  60262. * Removes the given lens flare system from this scene.
  60263. * @param toRemove The lens flare system to remove
  60264. * @returns The index of the removed lens flare system
  60265. */
  60266. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60267. /**
  60268. * Adds the given lens flare system to this scene
  60269. * @param newLensFlareSystem The lens flare system to add
  60270. */
  60271. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60272. /**
  60273. * Gets a lens flare system using its name
  60274. * @param name defines the name to look for
  60275. * @returns the lens flare system or null if not found
  60276. */
  60277. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60278. /**
  60279. * Gets a lens flare system using its id
  60280. * @param id defines the id to look for
  60281. * @returns the lens flare system or null if not found
  60282. */
  60283. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60284. }
  60285. /**
  60286. * Defines the lens flare scene component responsible to manage any lens flares
  60287. * in a given scene.
  60288. */
  60289. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60290. /**
  60291. * The component name helpfull to identify the component in the list of scene components.
  60292. */
  60293. readonly name: string;
  60294. /**
  60295. * The scene the component belongs to.
  60296. */
  60297. scene: Scene;
  60298. /**
  60299. * Creates a new instance of the component for the given scene
  60300. * @param scene Defines the scene to register the component in
  60301. */
  60302. constructor(scene: Scene);
  60303. /**
  60304. * Registers the component in a given scene
  60305. */
  60306. register(): void;
  60307. /**
  60308. * Rebuilds the elements related to this component in case of
  60309. * context lost for instance.
  60310. */
  60311. rebuild(): void;
  60312. /**
  60313. * Adds all the elements from the container to the scene
  60314. * @param container the container holding the elements
  60315. */
  60316. addFromContainer(container: AbstractScene): void;
  60317. /**
  60318. * Removes all the elements in the container from the scene
  60319. * @param container contains the elements to remove
  60320. * @param dispose if the removed element should be disposed (default: false)
  60321. */
  60322. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60323. /**
  60324. * Serializes the component data to the specified json object
  60325. * @param serializationObject The object to serialize to
  60326. */
  60327. serialize(serializationObject: any): void;
  60328. /**
  60329. * Disposes the component and the associated ressources.
  60330. */
  60331. dispose(): void;
  60332. private _draw;
  60333. }
  60334. }
  60335. declare module BABYLON {
  60336. /** @hidden */
  60337. export var depthPixelShader: {
  60338. name: string;
  60339. shader: string;
  60340. };
  60341. }
  60342. declare module BABYLON {
  60343. /** @hidden */
  60344. export var depthVertexShader: {
  60345. name: string;
  60346. shader: string;
  60347. };
  60348. }
  60349. declare module BABYLON {
  60350. /**
  60351. * This represents a depth renderer in Babylon.
  60352. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60353. */
  60354. export class DepthRenderer {
  60355. private _scene;
  60356. private _depthMap;
  60357. private _effect;
  60358. private readonly _storeNonLinearDepth;
  60359. private readonly _clearColor;
  60360. /** Get if the depth renderer is using packed depth or not */
  60361. readonly isPacked: boolean;
  60362. private _cachedDefines;
  60363. private _camera;
  60364. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60365. enabled: boolean;
  60366. /**
  60367. * Specifiess that the depth renderer will only be used within
  60368. * the camera it is created for.
  60369. * This can help forcing its rendering during the camera processing.
  60370. */
  60371. useOnlyInActiveCamera: boolean;
  60372. /** @hidden */
  60373. static _SceneComponentInitialization: (scene: Scene) => void;
  60374. /**
  60375. * Instantiates a depth renderer
  60376. * @param scene The scene the renderer belongs to
  60377. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60378. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60379. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60380. */
  60381. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60382. /**
  60383. * Creates the depth rendering effect and checks if the effect is ready.
  60384. * @param subMesh The submesh to be used to render the depth map of
  60385. * @param useInstances If multiple world instances should be used
  60386. * @returns if the depth renderer is ready to render the depth map
  60387. */
  60388. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60389. /**
  60390. * Gets the texture which the depth map will be written to.
  60391. * @returns The depth map texture
  60392. */
  60393. getDepthMap(): RenderTargetTexture;
  60394. /**
  60395. * Disposes of the depth renderer.
  60396. */
  60397. dispose(): void;
  60398. }
  60399. }
  60400. declare module BABYLON {
  60401. /** @hidden */
  60402. export var minmaxReduxPixelShader: {
  60403. name: string;
  60404. shader: string;
  60405. };
  60406. }
  60407. declare module BABYLON {
  60408. /**
  60409. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60410. * and maximum values from all values of the texture.
  60411. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60412. * The source values are read from the red channel of the texture.
  60413. */
  60414. export class MinMaxReducer {
  60415. /**
  60416. * Observable triggered when the computation has been performed
  60417. */
  60418. onAfterReductionPerformed: Observable<{
  60419. min: number;
  60420. max: number;
  60421. }>;
  60422. protected _camera: Camera;
  60423. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60424. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60425. protected _postProcessManager: PostProcessManager;
  60426. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60427. protected _forceFullscreenViewport: boolean;
  60428. /**
  60429. * Creates a min/max reducer
  60430. * @param camera The camera to use for the post processes
  60431. */
  60432. constructor(camera: Camera);
  60433. /**
  60434. * Gets the texture used to read the values from.
  60435. */
  60436. get sourceTexture(): Nullable<RenderTargetTexture>;
  60437. /**
  60438. * Sets the source texture to read the values from.
  60439. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60440. * because in such textures '1' value must not be taken into account to compute the maximum
  60441. * as this value is used to clear the texture.
  60442. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60443. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60444. * @param depthRedux Indicates if the texture is a depth texture or not
  60445. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60446. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60447. */
  60448. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60449. /**
  60450. * Defines the refresh rate of the computation.
  60451. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60452. */
  60453. get refreshRate(): number;
  60454. set refreshRate(value: number);
  60455. protected _activated: boolean;
  60456. /**
  60457. * Gets the activation status of the reducer
  60458. */
  60459. get activated(): boolean;
  60460. /**
  60461. * Activates the reduction computation.
  60462. * When activated, the observers registered in onAfterReductionPerformed are
  60463. * called after the compuation is performed
  60464. */
  60465. activate(): void;
  60466. /**
  60467. * Deactivates the reduction computation.
  60468. */
  60469. deactivate(): void;
  60470. /**
  60471. * Disposes the min/max reducer
  60472. * @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.
  60473. */
  60474. dispose(disposeAll?: boolean): void;
  60475. }
  60476. }
  60477. declare module BABYLON {
  60478. /**
  60479. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60480. */
  60481. export class DepthReducer extends MinMaxReducer {
  60482. private _depthRenderer;
  60483. private _depthRendererId;
  60484. /**
  60485. * Gets the depth renderer used for the computation.
  60486. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60487. */
  60488. get depthRenderer(): Nullable<DepthRenderer>;
  60489. /**
  60490. * Creates a depth reducer
  60491. * @param camera The camera used to render the depth texture
  60492. */
  60493. constructor(camera: Camera);
  60494. /**
  60495. * Sets the depth renderer to use to generate the depth map
  60496. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60497. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60498. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60499. */
  60500. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60501. /** @hidden */
  60502. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60503. /**
  60504. * Activates the reduction computation.
  60505. * When activated, the observers registered in onAfterReductionPerformed are
  60506. * called after the compuation is performed
  60507. */
  60508. activate(): void;
  60509. /**
  60510. * Deactivates the reduction computation.
  60511. */
  60512. deactivate(): void;
  60513. /**
  60514. * Disposes the depth reducer
  60515. * @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.
  60516. */
  60517. dispose(disposeAll?: boolean): void;
  60518. }
  60519. }
  60520. declare module BABYLON {
  60521. /**
  60522. * A CSM implementation allowing casting shadows on large scenes.
  60523. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60524. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60525. */
  60526. export class CascadedShadowGenerator extends ShadowGenerator {
  60527. private static readonly frustumCornersNDCSpace;
  60528. /**
  60529. * Name of the CSM class
  60530. */
  60531. static CLASSNAME: string;
  60532. /**
  60533. * Defines the default number of cascades used by the CSM.
  60534. */
  60535. static readonly DEFAULT_CASCADES_COUNT: number;
  60536. /**
  60537. * Defines the minimum number of cascades used by the CSM.
  60538. */
  60539. static readonly MIN_CASCADES_COUNT: number;
  60540. /**
  60541. * Defines the maximum number of cascades used by the CSM.
  60542. */
  60543. static readonly MAX_CASCADES_COUNT: number;
  60544. protected _validateFilter(filter: number): number;
  60545. /**
  60546. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60547. */
  60548. penumbraDarkness: number;
  60549. private _numCascades;
  60550. /**
  60551. * Gets or set the number of cascades used by the CSM.
  60552. */
  60553. get numCascades(): number;
  60554. set numCascades(value: number);
  60555. /**
  60556. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60557. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60558. */
  60559. stabilizeCascades: boolean;
  60560. private _freezeShadowCastersBoundingInfo;
  60561. private _freezeShadowCastersBoundingInfoObservable;
  60562. /**
  60563. * Enables or disables the shadow casters bounding info computation.
  60564. * If your shadow casters don't move, you can disable this feature.
  60565. * If it is enabled, the bounding box computation is done every frame.
  60566. */
  60567. get freezeShadowCastersBoundingInfo(): boolean;
  60568. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60569. private _scbiMin;
  60570. private _scbiMax;
  60571. protected _computeShadowCastersBoundingInfo(): void;
  60572. protected _shadowCastersBoundingInfo: BoundingInfo;
  60573. /**
  60574. * Gets or sets the shadow casters bounding info.
  60575. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60576. * so that the system won't overwrite the bounds you provide
  60577. */
  60578. get shadowCastersBoundingInfo(): BoundingInfo;
  60579. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60580. protected _breaksAreDirty: boolean;
  60581. protected _minDistance: number;
  60582. protected _maxDistance: number;
  60583. /**
  60584. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60585. *
  60586. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60587. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60588. * @param min minimal distance for the breaks (default to 0.)
  60589. * @param max maximal distance for the breaks (default to 1.)
  60590. */
  60591. setMinMaxDistance(min: number, max: number): void;
  60592. /** Gets the minimal distance used in the cascade break computation */
  60593. get minDistance(): number;
  60594. /** Gets the maximal distance used in the cascade break computation */
  60595. get maxDistance(): number;
  60596. /**
  60597. * Gets the class name of that object
  60598. * @returns "CascadedShadowGenerator"
  60599. */
  60600. getClassName(): string;
  60601. private _cascadeMinExtents;
  60602. private _cascadeMaxExtents;
  60603. /**
  60604. * Gets a cascade minimum extents
  60605. * @param cascadeIndex index of the cascade
  60606. * @returns the minimum cascade extents
  60607. */
  60608. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60609. /**
  60610. * Gets a cascade maximum extents
  60611. * @param cascadeIndex index of the cascade
  60612. * @returns the maximum cascade extents
  60613. */
  60614. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60615. private _cascades;
  60616. private _currentLayer;
  60617. private _viewSpaceFrustumsZ;
  60618. private _viewMatrices;
  60619. private _projectionMatrices;
  60620. private _transformMatrices;
  60621. private _transformMatricesAsArray;
  60622. private _frustumLengths;
  60623. private _lightSizeUVCorrection;
  60624. private _depthCorrection;
  60625. private _frustumCornersWorldSpace;
  60626. private _frustumCenter;
  60627. private _shadowCameraPos;
  60628. private _shadowMaxZ;
  60629. /**
  60630. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60631. * It defaults to camera.maxZ
  60632. */
  60633. get shadowMaxZ(): number;
  60634. /**
  60635. * Sets the shadow max z distance.
  60636. */
  60637. set shadowMaxZ(value: number);
  60638. protected _debug: boolean;
  60639. /**
  60640. * Gets or sets the debug flag.
  60641. * When enabled, the cascades are materialized by different colors on the screen.
  60642. */
  60643. get debug(): boolean;
  60644. set debug(dbg: boolean);
  60645. private _depthClamp;
  60646. /**
  60647. * Gets or sets the depth clamping value.
  60648. *
  60649. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60650. * to account for the shadow casters far away.
  60651. *
  60652. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60653. */
  60654. get depthClamp(): boolean;
  60655. set depthClamp(value: boolean);
  60656. private _cascadeBlendPercentage;
  60657. /**
  60658. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60659. * It defaults to 0.1 (10% blending).
  60660. */
  60661. get cascadeBlendPercentage(): number;
  60662. set cascadeBlendPercentage(value: number);
  60663. private _lambda;
  60664. /**
  60665. * Gets or set the lambda parameter.
  60666. * This parameter is used to split the camera frustum and create the cascades.
  60667. * 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.
  60668. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60669. */
  60670. get lambda(): number;
  60671. set lambda(value: number);
  60672. /**
  60673. * Gets the view matrix corresponding to a given cascade
  60674. * @param cascadeNum cascade to retrieve the view matrix from
  60675. * @returns the cascade view matrix
  60676. */
  60677. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60678. /**
  60679. * Gets the projection matrix corresponding to a given cascade
  60680. * @param cascadeNum cascade to retrieve the projection matrix from
  60681. * @returns the cascade projection matrix
  60682. */
  60683. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60684. /**
  60685. * Gets the transformation matrix corresponding to a given cascade
  60686. * @param cascadeNum cascade to retrieve the transformation matrix from
  60687. * @returns the cascade transformation matrix
  60688. */
  60689. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60690. private _depthRenderer;
  60691. /**
  60692. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60693. *
  60694. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60695. *
  60696. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60697. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60698. * @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
  60699. */
  60700. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60701. private _depthReducer;
  60702. private _autoCalcDepthBounds;
  60703. /**
  60704. * Gets or sets the autoCalcDepthBounds property.
  60705. *
  60706. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60707. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60708. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60709. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60710. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60711. */
  60712. get autoCalcDepthBounds(): boolean;
  60713. set autoCalcDepthBounds(value: boolean);
  60714. /**
  60715. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60716. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60717. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60718. * for setting the refresh rate on the renderer yourself!
  60719. */
  60720. get autoCalcDepthBoundsRefreshRate(): number;
  60721. set autoCalcDepthBoundsRefreshRate(value: number);
  60722. /**
  60723. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60724. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60725. * you change the camera near/far planes!
  60726. */
  60727. splitFrustum(): void;
  60728. private _splitFrustum;
  60729. private _computeMatrices;
  60730. private _computeFrustumInWorldSpace;
  60731. private _computeCascadeFrustum;
  60732. /**
  60733. * Support test.
  60734. */
  60735. static get IsSupported(): boolean;
  60736. /** @hidden */
  60737. static _SceneComponentInitialization: (scene: Scene) => void;
  60738. /**
  60739. * Creates a Cascaded Shadow Generator object.
  60740. * A ShadowGenerator is the required tool to use the shadows.
  60741. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60742. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60743. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60744. * @param light The directional light object generating the shadows.
  60745. * @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.
  60746. */
  60747. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60748. protected _initializeGenerator(): void;
  60749. protected _createTargetRenderTexture(): void;
  60750. protected _initializeShadowMap(): void;
  60751. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60752. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60753. /**
  60754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60755. * @param defines Defines of the material we want to update
  60756. * @param lightIndex Index of the light in the enabled light list of the material
  60757. */
  60758. prepareDefines(defines: any, lightIndex: number): void;
  60759. /**
  60760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60761. * defined in the generator but impacting the effect).
  60762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60763. * @param effect The effect we are binfing the information for
  60764. */
  60765. bindShadowLight(lightIndex: string, effect: Effect): void;
  60766. /**
  60767. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60768. * (eq to view projection * shadow projection matrices)
  60769. * @returns The transform matrix used to create the shadow map
  60770. */
  60771. getTransformMatrix(): Matrix;
  60772. /**
  60773. * Disposes the ShadowGenerator.
  60774. * Returns nothing.
  60775. */
  60776. dispose(): void;
  60777. /**
  60778. * Serializes the shadow generator setup to a json object.
  60779. * @returns The serialized JSON object
  60780. */
  60781. serialize(): any;
  60782. /**
  60783. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60784. * @param parsedShadowGenerator The JSON object to parse
  60785. * @param scene The scene to create the shadow map for
  60786. * @returns The parsed shadow generator
  60787. */
  60788. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60789. }
  60790. }
  60791. declare module BABYLON {
  60792. /**
  60793. * Defines the shadow generator component responsible to manage any shadow generators
  60794. * in a given scene.
  60795. */
  60796. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60797. /**
  60798. * The component name helpfull to identify the component in the list of scene components.
  60799. */
  60800. readonly name: string;
  60801. /**
  60802. * The scene the component belongs to.
  60803. */
  60804. scene: Scene;
  60805. /**
  60806. * Creates a new instance of the component for the given scene
  60807. * @param scene Defines the scene to register the component in
  60808. */
  60809. constructor(scene: Scene);
  60810. /**
  60811. * Registers the component in a given scene
  60812. */
  60813. register(): void;
  60814. /**
  60815. * Rebuilds the elements related to this component in case of
  60816. * context lost for instance.
  60817. */
  60818. rebuild(): void;
  60819. /**
  60820. * Serializes the component data to the specified json object
  60821. * @param serializationObject The object to serialize to
  60822. */
  60823. serialize(serializationObject: any): void;
  60824. /**
  60825. * Adds all the elements from the container to the scene
  60826. * @param container the container holding the elements
  60827. */
  60828. addFromContainer(container: AbstractScene): void;
  60829. /**
  60830. * Removes all the elements in the container from the scene
  60831. * @param container contains the elements to remove
  60832. * @param dispose if the removed element should be disposed (default: false)
  60833. */
  60834. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60835. /**
  60836. * Rebuilds the elements related to this component in case of
  60837. * context lost for instance.
  60838. */
  60839. dispose(): void;
  60840. private _gatherRenderTargets;
  60841. }
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * A point light is a light defined by an unique point in world space.
  60846. * The light is emitted in every direction from this point.
  60847. * A good example of a point light is a standard light bulb.
  60848. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60849. */
  60850. export class PointLight extends ShadowLight {
  60851. private _shadowAngle;
  60852. /**
  60853. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60854. * This specifies what angle the shadow will use to be created.
  60855. *
  60856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60857. */
  60858. get shadowAngle(): number;
  60859. /**
  60860. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60861. * This specifies what angle the shadow will use to be created.
  60862. *
  60863. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60864. */
  60865. set shadowAngle(value: number);
  60866. /**
  60867. * Gets the direction if it has been set.
  60868. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60869. */
  60870. get direction(): Vector3;
  60871. /**
  60872. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60873. */
  60874. set direction(value: Vector3);
  60875. /**
  60876. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60877. * A PointLight emits the light in every direction.
  60878. * It can cast shadows.
  60879. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60880. * ```javascript
  60881. * var pointLight = new PointLight("pl", camera.position, scene);
  60882. * ```
  60883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60884. * @param name The light friendly name
  60885. * @param position The position of the point light in the scene
  60886. * @param scene The scene the lights belongs to
  60887. */
  60888. constructor(name: string, position: Vector3, scene: Scene);
  60889. /**
  60890. * Returns the string "PointLight"
  60891. * @returns the class name
  60892. */
  60893. getClassName(): string;
  60894. /**
  60895. * Returns the integer 0.
  60896. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60897. */
  60898. getTypeID(): number;
  60899. /**
  60900. * Specifies wether or not the shadowmap should be a cube texture.
  60901. * @returns true if the shadowmap needs to be a cube texture.
  60902. */
  60903. needCube(): boolean;
  60904. /**
  60905. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60906. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60907. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60908. */
  60909. getShadowDirection(faceIndex?: number): Vector3;
  60910. /**
  60911. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60912. * - fov = PI / 2
  60913. * - aspect ratio : 1.0
  60914. * - z-near and far equal to the active camera minZ and maxZ.
  60915. * Returns the PointLight.
  60916. */
  60917. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60918. protected _buildUniformLayout(): void;
  60919. /**
  60920. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60921. * @param effect The effect to update
  60922. * @param lightIndex The index of the light in the effect to update
  60923. * @returns The point light
  60924. */
  60925. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60926. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60927. /**
  60928. * Prepares the list of defines specific to the light type.
  60929. * @param defines the list of defines
  60930. * @param lightIndex defines the index of the light for the effect
  60931. */
  60932. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /**
  60937. * Header information of HDR texture files.
  60938. */
  60939. export interface HDRInfo {
  60940. /**
  60941. * The height of the texture in pixels.
  60942. */
  60943. height: number;
  60944. /**
  60945. * The width of the texture in pixels.
  60946. */
  60947. width: number;
  60948. /**
  60949. * The index of the beginning of the data in the binary file.
  60950. */
  60951. dataPosition: number;
  60952. }
  60953. /**
  60954. * This groups tools to convert HDR texture to native colors array.
  60955. */
  60956. export class HDRTools {
  60957. private static Ldexp;
  60958. private static Rgbe2float;
  60959. private static readStringLine;
  60960. /**
  60961. * Reads header information from an RGBE texture stored in a native array.
  60962. * More information on this format are available here:
  60963. * https://en.wikipedia.org/wiki/RGBE_image_format
  60964. *
  60965. * @param uint8array The binary file stored in native array.
  60966. * @return The header information.
  60967. */
  60968. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60969. /**
  60970. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60971. * This RGBE texture needs to store the information as a panorama.
  60972. *
  60973. * More information on this format are available here:
  60974. * https://en.wikipedia.org/wiki/RGBE_image_format
  60975. *
  60976. * @param buffer The binary file stored in an array buffer.
  60977. * @param size The expected size of the extracted cubemap.
  60978. * @return The Cube Map information.
  60979. */
  60980. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60981. /**
  60982. * Returns the pixels data extracted from an RGBE texture.
  60983. * This pixels will be stored left to right up to down in the R G B order in one array.
  60984. *
  60985. * More information on this format are available here:
  60986. * https://en.wikipedia.org/wiki/RGBE_image_format
  60987. *
  60988. * @param uint8array The binary file stored in an array buffer.
  60989. * @param hdrInfo The header information of the file.
  60990. * @return The pixels data in RGB right to left up to down order.
  60991. */
  60992. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60993. private static RGBE_ReadPixels_RLE;
  60994. private static RGBE_ReadPixels_NOT_RLE;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Effect Render Options
  61000. */
  61001. export interface IEffectRendererOptions {
  61002. /**
  61003. * Defines the vertices positions.
  61004. */
  61005. positions?: number[];
  61006. /**
  61007. * Defines the indices.
  61008. */
  61009. indices?: number[];
  61010. }
  61011. /**
  61012. * Helper class to render one or more effects.
  61013. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61014. */
  61015. export class EffectRenderer {
  61016. private engine;
  61017. private static _DefaultOptions;
  61018. private _vertexBuffers;
  61019. private _indexBuffer;
  61020. private _fullscreenViewport;
  61021. /**
  61022. * Creates an effect renderer
  61023. * @param engine the engine to use for rendering
  61024. * @param options defines the options of the effect renderer
  61025. */
  61026. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61027. /**
  61028. * Sets the current viewport in normalized coordinates 0-1
  61029. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61030. */
  61031. setViewport(viewport?: Viewport): void;
  61032. /**
  61033. * Binds the embedded attributes buffer to the effect.
  61034. * @param effect Defines the effect to bind the attributes for
  61035. */
  61036. bindBuffers(effect: Effect): void;
  61037. /**
  61038. * Sets the current effect wrapper to use during draw.
  61039. * The effect needs to be ready before calling this api.
  61040. * This also sets the default full screen position attribute.
  61041. * @param effectWrapper Defines the effect to draw with
  61042. */
  61043. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61044. /**
  61045. * Restores engine states
  61046. */
  61047. restoreStates(): void;
  61048. /**
  61049. * Draws a full screen quad.
  61050. */
  61051. draw(): void;
  61052. private isRenderTargetTexture;
  61053. /**
  61054. * renders one or more effects to a specified texture
  61055. * @param effectWrapper the effect to renderer
  61056. * @param outputTexture texture to draw to, if null it will render to the screen.
  61057. */
  61058. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61059. /**
  61060. * Disposes of the effect renderer
  61061. */
  61062. dispose(): void;
  61063. }
  61064. /**
  61065. * Options to create an EffectWrapper
  61066. */
  61067. interface EffectWrapperCreationOptions {
  61068. /**
  61069. * Engine to use to create the effect
  61070. */
  61071. engine: ThinEngine;
  61072. /**
  61073. * Fragment shader for the effect
  61074. */
  61075. fragmentShader: string;
  61076. /**
  61077. * Use the shader store instead of direct source code
  61078. */
  61079. useShaderStore?: boolean;
  61080. /**
  61081. * Vertex shader for the effect
  61082. */
  61083. vertexShader?: string;
  61084. /**
  61085. * Attributes to use in the shader
  61086. */
  61087. attributeNames?: Array<string>;
  61088. /**
  61089. * Uniforms to use in the shader
  61090. */
  61091. uniformNames?: Array<string>;
  61092. /**
  61093. * Texture sampler names to use in the shader
  61094. */
  61095. samplerNames?: Array<string>;
  61096. /**
  61097. * Defines to use in the shader
  61098. */
  61099. defines?: Array<string>;
  61100. /**
  61101. * Callback when effect is compiled
  61102. */
  61103. onCompiled?: Nullable<(effect: Effect) => void>;
  61104. /**
  61105. * The friendly name of the effect displayed in Spector.
  61106. */
  61107. name?: string;
  61108. }
  61109. /**
  61110. * Wraps an effect to be used for rendering
  61111. */
  61112. export class EffectWrapper {
  61113. /**
  61114. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61115. */
  61116. onApplyObservable: Observable<{}>;
  61117. /**
  61118. * The underlying effect
  61119. */
  61120. effect: Effect;
  61121. /**
  61122. * Creates an effect to be renderer
  61123. * @param creationOptions options to create the effect
  61124. */
  61125. constructor(creationOptions: EffectWrapperCreationOptions);
  61126. /**
  61127. * Disposes of the effect wrapper
  61128. */
  61129. dispose(): void;
  61130. }
  61131. }
  61132. declare module BABYLON {
  61133. /** @hidden */
  61134. export var hdrFilteringVertexShader: {
  61135. name: string;
  61136. shader: string;
  61137. };
  61138. }
  61139. declare module BABYLON {
  61140. /** @hidden */
  61141. export var hdrFilteringPixelShader: {
  61142. name: string;
  61143. shader: string;
  61144. };
  61145. }
  61146. declare module BABYLON {
  61147. /**
  61148. * Options for texture filtering
  61149. */
  61150. interface IHDRFilteringOptions {
  61151. /**
  61152. * Scales pixel intensity for the input HDR map.
  61153. */
  61154. hdrScale?: number;
  61155. /**
  61156. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61157. */
  61158. quality?: number;
  61159. }
  61160. /**
  61161. * Filters HDR maps to get correct renderings of PBR reflections
  61162. */
  61163. export class HDRFiltering {
  61164. private _engine;
  61165. private _effectRenderer;
  61166. private _effectWrapper;
  61167. private _lodGenerationOffset;
  61168. private _lodGenerationScale;
  61169. /**
  61170. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61171. * you care about baking speed.
  61172. */
  61173. quality: number;
  61174. /**
  61175. * Scales pixel intensity for the input HDR map.
  61176. */
  61177. hdrScale: number;
  61178. /**
  61179. * Instantiates HDR filter for reflection maps
  61180. *
  61181. * @param engine Thin engine
  61182. * @param options Options
  61183. */
  61184. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61185. private _createRenderTarget;
  61186. private _prefilterInternal;
  61187. private _createEffect;
  61188. /**
  61189. * Get a value indicating if the filter is ready to be used
  61190. * @param texture Texture to filter
  61191. * @returns true if the filter is ready
  61192. */
  61193. isReady(texture: BaseTexture): boolean;
  61194. /**
  61195. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61196. * Prefiltering will be invoked at the end of next rendering pass.
  61197. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61198. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61199. * @param texture Texture to filter
  61200. * @param onFinished Callback when filtering is done
  61201. * @return Promise called when prefiltering is done
  61202. */
  61203. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61204. }
  61205. }
  61206. declare module BABYLON {
  61207. /**
  61208. * This represents a texture coming from an HDR input.
  61209. *
  61210. * The only supported format is currently panorama picture stored in RGBE format.
  61211. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61212. */
  61213. export class HDRCubeTexture extends BaseTexture {
  61214. private static _facesMapping;
  61215. private _generateHarmonics;
  61216. private _noMipmap;
  61217. private _prefilterOnLoad;
  61218. private _textureMatrix;
  61219. private _size;
  61220. private _onLoad;
  61221. private _onError;
  61222. /**
  61223. * The texture URL.
  61224. */
  61225. url: string;
  61226. protected _isBlocking: boolean;
  61227. /**
  61228. * Sets wether or not the texture is blocking during loading.
  61229. */
  61230. set isBlocking(value: boolean);
  61231. /**
  61232. * Gets wether or not the texture is blocking during loading.
  61233. */
  61234. get isBlocking(): boolean;
  61235. protected _rotationY: number;
  61236. /**
  61237. * Sets texture matrix rotation angle around Y axis in radians.
  61238. */
  61239. set rotationY(value: number);
  61240. /**
  61241. * Gets texture matrix rotation angle around Y axis radians.
  61242. */
  61243. get rotationY(): number;
  61244. /**
  61245. * Gets or sets the center of the bounding box associated with the cube texture
  61246. * It must define where the camera used to render the texture was set
  61247. */
  61248. boundingBoxPosition: Vector3;
  61249. private _boundingBoxSize;
  61250. /**
  61251. * Gets or sets the size of the bounding box associated with the cube texture
  61252. * When defined, the cubemap will switch to local mode
  61253. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61254. * @example https://www.babylonjs-playground.com/#RNASML
  61255. */
  61256. set boundingBoxSize(value: Vector3);
  61257. get boundingBoxSize(): Vector3;
  61258. /**
  61259. * Instantiates an HDRTexture from the following parameters.
  61260. *
  61261. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61262. * @param sceneOrEngine The scene or engine the texture will be used in
  61263. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61264. * @param noMipmap Forces to not generate the mipmap if true
  61265. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61266. * @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)
  61267. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61268. */
  61269. 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>);
  61270. /**
  61271. * Get the current class name of the texture useful for serialization or dynamic coding.
  61272. * @returns "HDRCubeTexture"
  61273. */
  61274. getClassName(): string;
  61275. /**
  61276. * Occurs when the file is raw .hdr file.
  61277. */
  61278. private loadTexture;
  61279. clone(): HDRCubeTexture;
  61280. delayLoad(): void;
  61281. /**
  61282. * Get the texture reflection matrix used to rotate/transform the reflection.
  61283. * @returns the reflection matrix
  61284. */
  61285. getReflectionTextureMatrix(): Matrix;
  61286. /**
  61287. * Set the texture reflection matrix used to rotate/transform the reflection.
  61288. * @param value Define the reflection matrix to set
  61289. */
  61290. setReflectionTextureMatrix(value: Matrix): void;
  61291. /**
  61292. * Parses a JSON representation of an HDR Texture in order to create the texture
  61293. * @param parsedTexture Define the JSON representation
  61294. * @param scene Define the scene the texture should be created in
  61295. * @param rootUrl Define the root url in case we need to load relative dependencies
  61296. * @returns the newly created texture after parsing
  61297. */
  61298. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61299. serialize(): any;
  61300. }
  61301. }
  61302. declare module BABYLON {
  61303. /**
  61304. * Class used to control physics engine
  61305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61306. */
  61307. export class PhysicsEngine implements IPhysicsEngine {
  61308. private _physicsPlugin;
  61309. /**
  61310. * Global value used to control the smallest number supported by the simulation
  61311. */
  61312. static Epsilon: number;
  61313. private _impostors;
  61314. private _joints;
  61315. private _subTimeStep;
  61316. /**
  61317. * Gets the gravity vector used by the simulation
  61318. */
  61319. gravity: Vector3;
  61320. /**
  61321. * Factory used to create the default physics plugin.
  61322. * @returns The default physics plugin
  61323. */
  61324. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61325. /**
  61326. * Creates a new Physics Engine
  61327. * @param gravity defines the gravity vector used by the simulation
  61328. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61329. */
  61330. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61331. /**
  61332. * Sets the gravity vector used by the simulation
  61333. * @param gravity defines the gravity vector to use
  61334. */
  61335. setGravity(gravity: Vector3): void;
  61336. /**
  61337. * Set the time step of the physics engine.
  61338. * Default is 1/60.
  61339. * To slow it down, enter 1/600 for example.
  61340. * To speed it up, 1/30
  61341. * @param newTimeStep defines the new timestep to apply to this world.
  61342. */
  61343. setTimeStep(newTimeStep?: number): void;
  61344. /**
  61345. * Get the time step of the physics engine.
  61346. * @returns the current time step
  61347. */
  61348. getTimeStep(): number;
  61349. /**
  61350. * Set the sub time step of the physics engine.
  61351. * Default is 0 meaning there is no sub steps
  61352. * To increase physics resolution precision, set a small value (like 1 ms)
  61353. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61354. */
  61355. setSubTimeStep(subTimeStep?: number): void;
  61356. /**
  61357. * Get the sub time step of the physics engine.
  61358. * @returns the current sub time step
  61359. */
  61360. getSubTimeStep(): number;
  61361. /**
  61362. * Release all resources
  61363. */
  61364. dispose(): void;
  61365. /**
  61366. * Gets the name of the current physics plugin
  61367. * @returns the name of the plugin
  61368. */
  61369. getPhysicsPluginName(): string;
  61370. /**
  61371. * Adding a new impostor for the impostor tracking.
  61372. * This will be done by the impostor itself.
  61373. * @param impostor the impostor to add
  61374. */
  61375. addImpostor(impostor: PhysicsImpostor): void;
  61376. /**
  61377. * Remove an impostor from the engine.
  61378. * This impostor and its mesh will not longer be updated by the physics engine.
  61379. * @param impostor the impostor to remove
  61380. */
  61381. removeImpostor(impostor: PhysicsImpostor): void;
  61382. /**
  61383. * Add a joint to the physics engine
  61384. * @param mainImpostor defines the main impostor to which the joint is added.
  61385. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61386. * @param joint defines the joint that will connect both impostors.
  61387. */
  61388. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61389. /**
  61390. * Removes a joint from the simulation
  61391. * @param mainImpostor defines the impostor used with the joint
  61392. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61393. * @param joint defines the joint to remove
  61394. */
  61395. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61396. /**
  61397. * Called by the scene. No need to call it.
  61398. * @param delta defines the timespam between frames
  61399. */
  61400. _step(delta: number): void;
  61401. /**
  61402. * Gets the current plugin used to run the simulation
  61403. * @returns current plugin
  61404. */
  61405. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61406. /**
  61407. * Gets the list of physic impostors
  61408. * @returns an array of PhysicsImpostor
  61409. */
  61410. getImpostors(): Array<PhysicsImpostor>;
  61411. /**
  61412. * Gets the impostor for a physics enabled object
  61413. * @param object defines the object impersonated by the impostor
  61414. * @returns the PhysicsImpostor or null if not found
  61415. */
  61416. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61417. /**
  61418. * Gets the impostor for a physics body object
  61419. * @param body defines physics body used by the impostor
  61420. * @returns the PhysicsImpostor or null if not found
  61421. */
  61422. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61423. /**
  61424. * Does a raycast in the physics world
  61425. * @param from when should the ray start?
  61426. * @param to when should the ray end?
  61427. * @returns PhysicsRaycastResult
  61428. */
  61429. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61430. }
  61431. }
  61432. declare module BABYLON {
  61433. /** @hidden */
  61434. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61435. private _useDeltaForWorldStep;
  61436. world: any;
  61437. name: string;
  61438. private _physicsMaterials;
  61439. private _fixedTimeStep;
  61440. private _cannonRaycastResult;
  61441. private _raycastResult;
  61442. private _physicsBodysToRemoveAfterStep;
  61443. private _firstFrame;
  61444. BJSCANNON: any;
  61445. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61446. setGravity(gravity: Vector3): void;
  61447. setTimeStep(timeStep: number): void;
  61448. getTimeStep(): number;
  61449. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61450. private _removeMarkedPhysicsBodiesFromWorld;
  61451. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61452. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61453. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61454. private _processChildMeshes;
  61455. removePhysicsBody(impostor: PhysicsImpostor): void;
  61456. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61457. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61458. private _addMaterial;
  61459. private _checkWithEpsilon;
  61460. private _createShape;
  61461. private _createHeightmap;
  61462. private _minus90X;
  61463. private _plus90X;
  61464. private _tmpPosition;
  61465. private _tmpDeltaPosition;
  61466. private _tmpUnityRotation;
  61467. private _updatePhysicsBodyTransformation;
  61468. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61469. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61470. isSupported(): boolean;
  61471. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61472. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61473. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61474. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61475. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61476. getBodyMass(impostor: PhysicsImpostor): number;
  61477. getBodyFriction(impostor: PhysicsImpostor): number;
  61478. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61479. getBodyRestitution(impostor: PhysicsImpostor): number;
  61480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61481. sleepBody(impostor: PhysicsImpostor): void;
  61482. wakeUpBody(impostor: PhysicsImpostor): void;
  61483. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61484. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61485. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61486. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61487. getRadius(impostor: PhysicsImpostor): number;
  61488. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61489. dispose(): void;
  61490. private _extendNamespace;
  61491. /**
  61492. * Does a raycast in the physics world
  61493. * @param from when should the ray start?
  61494. * @param to when should the ray end?
  61495. * @returns PhysicsRaycastResult
  61496. */
  61497. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61498. }
  61499. }
  61500. declare module BABYLON {
  61501. /** @hidden */
  61502. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61503. private _useDeltaForWorldStep;
  61504. world: any;
  61505. name: string;
  61506. BJSOIMO: any;
  61507. private _raycastResult;
  61508. private _fixedTimeStep;
  61509. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61510. setGravity(gravity: Vector3): void;
  61511. setTimeStep(timeStep: number): void;
  61512. getTimeStep(): number;
  61513. private _tmpImpostorsArray;
  61514. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61515. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61516. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61517. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61518. private _tmpPositionVector;
  61519. removePhysicsBody(impostor: PhysicsImpostor): void;
  61520. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61521. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61522. isSupported(): boolean;
  61523. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61524. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61525. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61526. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61527. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61528. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61529. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61530. getBodyMass(impostor: PhysicsImpostor): number;
  61531. getBodyFriction(impostor: PhysicsImpostor): number;
  61532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61533. getBodyRestitution(impostor: PhysicsImpostor): number;
  61534. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61535. sleepBody(impostor: PhysicsImpostor): void;
  61536. wakeUpBody(impostor: PhysicsImpostor): void;
  61537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61538. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61540. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61541. getRadius(impostor: PhysicsImpostor): number;
  61542. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61543. dispose(): void;
  61544. /**
  61545. * Does a raycast in the physics world
  61546. * @param from when should the ray start?
  61547. * @param to when should the ray end?
  61548. * @returns PhysicsRaycastResult
  61549. */
  61550. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61551. }
  61552. }
  61553. declare module BABYLON {
  61554. /**
  61555. * AmmoJS Physics plugin
  61556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61557. * @see https://github.com/kripken/ammo.js/
  61558. */
  61559. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61560. private _useDeltaForWorldStep;
  61561. /**
  61562. * Reference to the Ammo library
  61563. */
  61564. bjsAMMO: any;
  61565. /**
  61566. * Created ammoJS world which physics bodies are added to
  61567. */
  61568. world: any;
  61569. /**
  61570. * Name of the plugin
  61571. */
  61572. name: string;
  61573. private _timeStep;
  61574. private _fixedTimeStep;
  61575. private _maxSteps;
  61576. private _tmpQuaternion;
  61577. private _tmpAmmoTransform;
  61578. private _tmpAmmoQuaternion;
  61579. private _tmpAmmoConcreteContactResultCallback;
  61580. private _collisionConfiguration;
  61581. private _dispatcher;
  61582. private _overlappingPairCache;
  61583. private _solver;
  61584. private _softBodySolver;
  61585. private _tmpAmmoVectorA;
  61586. private _tmpAmmoVectorB;
  61587. private _tmpAmmoVectorC;
  61588. private _tmpAmmoVectorD;
  61589. private _tmpContactCallbackResult;
  61590. private _tmpAmmoVectorRCA;
  61591. private _tmpAmmoVectorRCB;
  61592. private _raycastResult;
  61593. private _tmpContactPoint;
  61594. private static readonly DISABLE_COLLISION_FLAG;
  61595. private static readonly KINEMATIC_FLAG;
  61596. private static readonly DISABLE_DEACTIVATION_FLAG;
  61597. /**
  61598. * Initializes the ammoJS plugin
  61599. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61600. * @param ammoInjection can be used to inject your own ammo reference
  61601. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61602. */
  61603. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61604. /**
  61605. * Sets the gravity of the physics world (m/(s^2))
  61606. * @param gravity Gravity to set
  61607. */
  61608. setGravity(gravity: Vector3): void;
  61609. /**
  61610. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61611. * @param timeStep timestep to use in seconds
  61612. */
  61613. setTimeStep(timeStep: number): void;
  61614. /**
  61615. * 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)
  61616. * @param fixedTimeStep fixedTimeStep to use in seconds
  61617. */
  61618. setFixedTimeStep(fixedTimeStep: number): void;
  61619. /**
  61620. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61621. * @param maxSteps the maximum number of steps by the physics engine per frame
  61622. */
  61623. setMaxSteps(maxSteps: number): void;
  61624. /**
  61625. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61626. * @returns the current timestep in seconds
  61627. */
  61628. getTimeStep(): number;
  61629. /**
  61630. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61631. */
  61632. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61633. private _isImpostorInContact;
  61634. private _isImpostorPairInContact;
  61635. private _stepSimulation;
  61636. /**
  61637. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61638. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61639. * After the step the babylon meshes are set to the position of the physics imposters
  61640. * @param delta amount of time to step forward
  61641. * @param impostors array of imposters to update before/after the step
  61642. */
  61643. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61644. /**
  61645. * Update babylon mesh to match physics world object
  61646. * @param impostor imposter to match
  61647. */
  61648. private _afterSoftStep;
  61649. /**
  61650. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61651. * @param impostor imposter to match
  61652. */
  61653. private _ropeStep;
  61654. /**
  61655. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61656. * @param impostor imposter to match
  61657. */
  61658. private _softbodyOrClothStep;
  61659. private _tmpMatrix;
  61660. /**
  61661. * Applies an impulse on the imposter
  61662. * @param impostor imposter to apply impulse to
  61663. * @param force amount of force to be applied to the imposter
  61664. * @param contactPoint the location to apply the impulse on the imposter
  61665. */
  61666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61667. /**
  61668. * Applies a force on the imposter
  61669. * @param impostor imposter to apply force
  61670. * @param force amount of force to be applied to the imposter
  61671. * @param contactPoint the location to apply the force on the imposter
  61672. */
  61673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61674. /**
  61675. * Creates a physics body using the plugin
  61676. * @param impostor the imposter to create the physics body on
  61677. */
  61678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61679. /**
  61680. * Removes the physics body from the imposter and disposes of the body's memory
  61681. * @param impostor imposter to remove the physics body from
  61682. */
  61683. removePhysicsBody(impostor: PhysicsImpostor): void;
  61684. /**
  61685. * Generates a joint
  61686. * @param impostorJoint the imposter joint to create the joint with
  61687. */
  61688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61689. /**
  61690. * Removes a joint
  61691. * @param impostorJoint the imposter joint to remove the joint from
  61692. */
  61693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61694. private _addMeshVerts;
  61695. /**
  61696. * Initialise the soft body vertices to match its object's (mesh) vertices
  61697. * Softbody vertices (nodes) are in world space and to match this
  61698. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61699. * @param impostor to create the softbody for
  61700. */
  61701. private _softVertexData;
  61702. /**
  61703. * Create an impostor's soft body
  61704. * @param impostor to create the softbody for
  61705. */
  61706. private _createSoftbody;
  61707. /**
  61708. * Create cloth for an impostor
  61709. * @param impostor to create the softbody for
  61710. */
  61711. private _createCloth;
  61712. /**
  61713. * Create rope for an impostor
  61714. * @param impostor to create the softbody for
  61715. */
  61716. private _createRope;
  61717. /**
  61718. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61719. * @param impostor to create the custom physics shape for
  61720. */
  61721. private _createCustom;
  61722. private _addHullVerts;
  61723. private _createShape;
  61724. /**
  61725. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61726. * @param impostor imposter containing the physics body and babylon object
  61727. */
  61728. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61729. /**
  61730. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61731. * @param impostor imposter containing the physics body and babylon object
  61732. * @param newPosition new position
  61733. * @param newRotation new rotation
  61734. */
  61735. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61736. /**
  61737. * If this plugin is supported
  61738. * @returns true if its supported
  61739. */
  61740. isSupported(): boolean;
  61741. /**
  61742. * Sets the linear velocity of the physics body
  61743. * @param impostor imposter to set the velocity on
  61744. * @param velocity velocity to set
  61745. */
  61746. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61747. /**
  61748. * Sets the angular velocity of the physics body
  61749. * @param impostor imposter to set the velocity on
  61750. * @param velocity velocity to set
  61751. */
  61752. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61753. /**
  61754. * gets the linear velocity
  61755. * @param impostor imposter to get linear velocity from
  61756. * @returns linear velocity
  61757. */
  61758. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61759. /**
  61760. * gets the angular velocity
  61761. * @param impostor imposter to get angular velocity from
  61762. * @returns angular velocity
  61763. */
  61764. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61765. /**
  61766. * Sets the mass of physics body
  61767. * @param impostor imposter to set the mass on
  61768. * @param mass mass to set
  61769. */
  61770. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61771. /**
  61772. * Gets the mass of the physics body
  61773. * @param impostor imposter to get the mass from
  61774. * @returns mass
  61775. */
  61776. getBodyMass(impostor: PhysicsImpostor): number;
  61777. /**
  61778. * Gets friction of the impostor
  61779. * @param impostor impostor to get friction from
  61780. * @returns friction value
  61781. */
  61782. getBodyFriction(impostor: PhysicsImpostor): number;
  61783. /**
  61784. * Sets friction of the impostor
  61785. * @param impostor impostor to set friction on
  61786. * @param friction friction value
  61787. */
  61788. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61789. /**
  61790. * Gets restitution of the impostor
  61791. * @param impostor impostor to get restitution from
  61792. * @returns restitution value
  61793. */
  61794. getBodyRestitution(impostor: PhysicsImpostor): number;
  61795. /**
  61796. * Sets resitution of the impostor
  61797. * @param impostor impostor to set resitution on
  61798. * @param restitution resitution value
  61799. */
  61800. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61801. /**
  61802. * Gets pressure inside the impostor
  61803. * @param impostor impostor to get pressure from
  61804. * @returns pressure value
  61805. */
  61806. getBodyPressure(impostor: PhysicsImpostor): number;
  61807. /**
  61808. * Sets pressure inside a soft body impostor
  61809. * Cloth and rope must remain 0 pressure
  61810. * @param impostor impostor to set pressure on
  61811. * @param pressure pressure value
  61812. */
  61813. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61814. /**
  61815. * Gets stiffness of the impostor
  61816. * @param impostor impostor to get stiffness from
  61817. * @returns pressure value
  61818. */
  61819. getBodyStiffness(impostor: PhysicsImpostor): number;
  61820. /**
  61821. * Sets stiffness of the impostor
  61822. * @param impostor impostor to set stiffness on
  61823. * @param stiffness stiffness value from 0 to 1
  61824. */
  61825. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61826. /**
  61827. * Gets velocityIterations of the impostor
  61828. * @param impostor impostor to get velocity iterations from
  61829. * @returns velocityIterations value
  61830. */
  61831. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61832. /**
  61833. * Sets velocityIterations of the impostor
  61834. * @param impostor impostor to set velocity iterations on
  61835. * @param velocityIterations velocityIterations value
  61836. */
  61837. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61838. /**
  61839. * Gets positionIterations of the impostor
  61840. * @param impostor impostor to get position iterations from
  61841. * @returns positionIterations value
  61842. */
  61843. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61844. /**
  61845. * Sets positionIterations of the impostor
  61846. * @param impostor impostor to set position on
  61847. * @param positionIterations positionIterations value
  61848. */
  61849. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61850. /**
  61851. * Append an anchor to a cloth object
  61852. * @param impostor is the cloth impostor to add anchor to
  61853. * @param otherImpostor is the rigid impostor to anchor to
  61854. * @param width ratio across width from 0 to 1
  61855. * @param height ratio up height from 0 to 1
  61856. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61857. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61858. */
  61859. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61860. /**
  61861. * Append an hook to a rope object
  61862. * @param impostor is the rope impostor to add hook to
  61863. * @param otherImpostor is the rigid impostor to hook to
  61864. * @param length ratio along the rope from 0 to 1
  61865. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61866. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61867. */
  61868. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61869. /**
  61870. * Sleeps the physics body and stops it from being active
  61871. * @param impostor impostor to sleep
  61872. */
  61873. sleepBody(impostor: PhysicsImpostor): void;
  61874. /**
  61875. * Activates the physics body
  61876. * @param impostor impostor to activate
  61877. */
  61878. wakeUpBody(impostor: PhysicsImpostor): void;
  61879. /**
  61880. * Updates the distance parameters of the joint
  61881. * @param joint joint to update
  61882. * @param maxDistance maximum distance of the joint
  61883. * @param minDistance minimum distance of the joint
  61884. */
  61885. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61886. /**
  61887. * Sets a motor on the joint
  61888. * @param joint joint to set motor on
  61889. * @param speed speed of the motor
  61890. * @param maxForce maximum force of the motor
  61891. * @param motorIndex index of the motor
  61892. */
  61893. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61894. /**
  61895. * Sets the motors limit
  61896. * @param joint joint to set limit on
  61897. * @param upperLimit upper limit
  61898. * @param lowerLimit lower limit
  61899. */
  61900. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61901. /**
  61902. * Syncs the position and rotation of a mesh with the impostor
  61903. * @param mesh mesh to sync
  61904. * @param impostor impostor to update the mesh with
  61905. */
  61906. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61907. /**
  61908. * Gets the radius of the impostor
  61909. * @param impostor impostor to get radius from
  61910. * @returns the radius
  61911. */
  61912. getRadius(impostor: PhysicsImpostor): number;
  61913. /**
  61914. * Gets the box size of the impostor
  61915. * @param impostor impostor to get box size from
  61916. * @param result the resulting box size
  61917. */
  61918. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61919. /**
  61920. * Disposes of the impostor
  61921. */
  61922. dispose(): void;
  61923. /**
  61924. * Does a raycast in the physics world
  61925. * @param from when should the ray start?
  61926. * @param to when should the ray end?
  61927. * @returns PhysicsRaycastResult
  61928. */
  61929. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. interface AbstractScene {
  61934. /**
  61935. * The list of reflection probes added to the scene
  61936. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61937. */
  61938. reflectionProbes: Array<ReflectionProbe>;
  61939. /**
  61940. * Removes the given reflection probe from this scene.
  61941. * @param toRemove The reflection probe to remove
  61942. * @returns The index of the removed reflection probe
  61943. */
  61944. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61945. /**
  61946. * Adds the given reflection probe to this scene.
  61947. * @param newReflectionProbe The reflection probe to add
  61948. */
  61949. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61950. }
  61951. /**
  61952. * Class used to generate realtime reflection / refraction cube textures
  61953. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61954. */
  61955. export class ReflectionProbe {
  61956. /** defines the name of the probe */
  61957. name: string;
  61958. private _scene;
  61959. private _renderTargetTexture;
  61960. private _projectionMatrix;
  61961. private _viewMatrix;
  61962. private _target;
  61963. private _add;
  61964. private _attachedMesh;
  61965. private _invertYAxis;
  61966. /** Gets or sets probe position (center of the cube map) */
  61967. position: Vector3;
  61968. /**
  61969. * Creates a new reflection probe
  61970. * @param name defines the name of the probe
  61971. * @param size defines the texture resolution (for each face)
  61972. * @param scene defines the hosting scene
  61973. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61974. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61975. */
  61976. constructor(
  61977. /** defines the name of the probe */
  61978. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61979. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61980. get samples(): number;
  61981. set samples(value: number);
  61982. /** Gets or sets the refresh rate to use (on every frame by default) */
  61983. get refreshRate(): number;
  61984. set refreshRate(value: number);
  61985. /**
  61986. * Gets the hosting scene
  61987. * @returns a Scene
  61988. */
  61989. getScene(): Scene;
  61990. /** Gets the internal CubeTexture used to render to */
  61991. get cubeTexture(): RenderTargetTexture;
  61992. /** Gets the list of meshes to render */
  61993. get renderList(): Nullable<AbstractMesh[]>;
  61994. /**
  61995. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61996. * @param mesh defines the mesh to attach to
  61997. */
  61998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61999. /**
  62000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62001. * @param renderingGroupId The rendering group id corresponding to its index
  62002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62003. */
  62004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62005. /**
  62006. * Clean all associated resources
  62007. */
  62008. dispose(): void;
  62009. /**
  62010. * Converts the reflection probe information to a readable string for debug purpose.
  62011. * @param fullDetails Supports for multiple levels of logging within scene loading
  62012. * @returns the human readable reflection probe info
  62013. */
  62014. toString(fullDetails?: boolean): string;
  62015. /**
  62016. * Get the class name of the relfection probe.
  62017. * @returns "ReflectionProbe"
  62018. */
  62019. getClassName(): string;
  62020. /**
  62021. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62022. * @returns The JSON representation of the texture
  62023. */
  62024. serialize(): any;
  62025. /**
  62026. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62027. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62028. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62029. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62030. * @returns The parsed reflection probe if successful
  62031. */
  62032. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62033. }
  62034. }
  62035. declare module BABYLON {
  62036. /** @hidden */
  62037. export var _BabylonLoaderRegistered: boolean;
  62038. /**
  62039. * Helps setting up some configuration for the babylon file loader.
  62040. */
  62041. export class BabylonFileLoaderConfiguration {
  62042. /**
  62043. * The loader does not allow injecting custom physix engine into the plugins.
  62044. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62045. * So you could set this variable to your engine import to make it work.
  62046. */
  62047. static LoaderInjectedPhysicsEngine: any;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * The Physically based simple base material of BJS.
  62053. *
  62054. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62055. * It is used as the base class for both the specGloss and metalRough conventions.
  62056. */
  62057. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62058. /**
  62059. * Number of Simultaneous lights allowed on the material.
  62060. */
  62061. maxSimultaneousLights: number;
  62062. /**
  62063. * If sets to true, disables all the lights affecting the material.
  62064. */
  62065. disableLighting: boolean;
  62066. /**
  62067. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62068. */
  62069. environmentTexture: BaseTexture;
  62070. /**
  62071. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62072. */
  62073. invertNormalMapX: boolean;
  62074. /**
  62075. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62076. */
  62077. invertNormalMapY: boolean;
  62078. /**
  62079. * Normal map used in the model.
  62080. */
  62081. normalTexture: BaseTexture;
  62082. /**
  62083. * Emissivie color used to self-illuminate the model.
  62084. */
  62085. emissiveColor: Color3;
  62086. /**
  62087. * Emissivie texture used to self-illuminate the model.
  62088. */
  62089. emissiveTexture: BaseTexture;
  62090. /**
  62091. * Occlusion Channel Strenght.
  62092. */
  62093. occlusionStrength: number;
  62094. /**
  62095. * Occlusion Texture of the material (adding extra occlusion effects).
  62096. */
  62097. occlusionTexture: BaseTexture;
  62098. /**
  62099. * Defines the alpha limits in alpha test mode.
  62100. */
  62101. alphaCutOff: number;
  62102. /**
  62103. * Gets the current double sided mode.
  62104. */
  62105. get doubleSided(): boolean;
  62106. /**
  62107. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62108. */
  62109. set doubleSided(value: boolean);
  62110. /**
  62111. * Stores the pre-calculated light information of a mesh in a texture.
  62112. */
  62113. lightmapTexture: BaseTexture;
  62114. /**
  62115. * If true, the light map contains occlusion information instead of lighting info.
  62116. */
  62117. useLightmapAsShadowmap: boolean;
  62118. /**
  62119. * Instantiates a new PBRMaterial instance.
  62120. *
  62121. * @param name The material name
  62122. * @param scene The scene the material will be use in.
  62123. */
  62124. constructor(name: string, scene: Scene);
  62125. getClassName(): string;
  62126. }
  62127. }
  62128. declare module BABYLON {
  62129. /**
  62130. * The PBR material of BJS following the metal roughness convention.
  62131. *
  62132. * This fits to the PBR convention in the GLTF definition:
  62133. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62134. */
  62135. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62136. /**
  62137. * The base color has two different interpretations depending on the value of metalness.
  62138. * When the material is a metal, the base color is the specific measured reflectance value
  62139. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62140. * of the material.
  62141. */
  62142. baseColor: Color3;
  62143. /**
  62144. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62145. * well as opacity information in the alpha channel.
  62146. */
  62147. baseTexture: BaseTexture;
  62148. /**
  62149. * Specifies the metallic scalar value of the material.
  62150. * Can also be used to scale the metalness values of the metallic texture.
  62151. */
  62152. metallic: number;
  62153. /**
  62154. * Specifies the roughness scalar value of the material.
  62155. * Can also be used to scale the roughness values of the metallic texture.
  62156. */
  62157. roughness: number;
  62158. /**
  62159. * Texture containing both the metallic value in the B channel and the
  62160. * roughness value in the G channel to keep better precision.
  62161. */
  62162. metallicRoughnessTexture: BaseTexture;
  62163. /**
  62164. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62165. *
  62166. * @param name The material name
  62167. * @param scene The scene the material will be use in.
  62168. */
  62169. constructor(name: string, scene: Scene);
  62170. /**
  62171. * Return the currrent class name of the material.
  62172. */
  62173. getClassName(): string;
  62174. /**
  62175. * Makes a duplicate of the current material.
  62176. * @param name - name to use for the new material.
  62177. */
  62178. clone(name: string): PBRMetallicRoughnessMaterial;
  62179. /**
  62180. * Serialize the material to a parsable JSON object.
  62181. */
  62182. serialize(): any;
  62183. /**
  62184. * Parses a JSON object correponding to the serialize function.
  62185. */
  62186. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62187. }
  62188. }
  62189. declare module BABYLON {
  62190. /**
  62191. * The PBR material of BJS following the specular glossiness convention.
  62192. *
  62193. * This fits to the PBR convention in the GLTF definition:
  62194. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62195. */
  62196. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62197. /**
  62198. * Specifies the diffuse color of the material.
  62199. */
  62200. diffuseColor: Color3;
  62201. /**
  62202. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62203. * channel.
  62204. */
  62205. diffuseTexture: BaseTexture;
  62206. /**
  62207. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62208. */
  62209. specularColor: Color3;
  62210. /**
  62211. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62212. */
  62213. glossiness: number;
  62214. /**
  62215. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62216. */
  62217. specularGlossinessTexture: BaseTexture;
  62218. /**
  62219. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62220. *
  62221. * @param name The material name
  62222. * @param scene The scene the material will be use in.
  62223. */
  62224. constructor(name: string, scene: Scene);
  62225. /**
  62226. * Return the currrent class name of the material.
  62227. */
  62228. getClassName(): string;
  62229. /**
  62230. * Makes a duplicate of the current material.
  62231. * @param name - name to use for the new material.
  62232. */
  62233. clone(name: string): PBRSpecularGlossinessMaterial;
  62234. /**
  62235. * Serialize the material to a parsable JSON object.
  62236. */
  62237. serialize(): any;
  62238. /**
  62239. * Parses a JSON object correponding to the serialize function.
  62240. */
  62241. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62242. }
  62243. }
  62244. declare module BABYLON {
  62245. /**
  62246. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62247. * It can help converting any input color in a desired output one. This can then be used to create effects
  62248. * from sepia, black and white to sixties or futuristic rendering...
  62249. *
  62250. * The only supported format is currently 3dl.
  62251. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62252. */
  62253. export class ColorGradingTexture extends BaseTexture {
  62254. /**
  62255. * The texture URL.
  62256. */
  62257. url: string;
  62258. /**
  62259. * Empty line regex stored for GC.
  62260. */
  62261. private static _noneEmptyLineRegex;
  62262. private _textureMatrix;
  62263. private _onLoad;
  62264. /**
  62265. * Instantiates a ColorGradingTexture from the following parameters.
  62266. *
  62267. * @param url The location of the color gradind data (currently only supporting 3dl)
  62268. * @param sceneOrEngine The scene or engine the texture will be used in
  62269. * @param onLoad defines a callback triggered when the texture has been loaded
  62270. */
  62271. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62272. /**
  62273. * Fires the onload event from the constructor if requested.
  62274. */
  62275. private _triggerOnLoad;
  62276. /**
  62277. * Returns the texture matrix used in most of the material.
  62278. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62279. */
  62280. getTextureMatrix(): Matrix;
  62281. /**
  62282. * Occurs when the file being loaded is a .3dl LUT file.
  62283. */
  62284. private load3dlTexture;
  62285. /**
  62286. * Starts the loading process of the texture.
  62287. */
  62288. private loadTexture;
  62289. /**
  62290. * Clones the color gradind texture.
  62291. */
  62292. clone(): ColorGradingTexture;
  62293. /**
  62294. * Called during delayed load for textures.
  62295. */
  62296. delayLoad(): void;
  62297. /**
  62298. * Parses a color grading texture serialized by Babylon.
  62299. * @param parsedTexture The texture information being parsedTexture
  62300. * @param scene The scene to load the texture in
  62301. * @param rootUrl The root url of the data assets to load
  62302. * @return A color gradind texture
  62303. */
  62304. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62305. /**
  62306. * Serializes the LUT texture to json format.
  62307. */
  62308. serialize(): any;
  62309. }
  62310. }
  62311. declare module BABYLON {
  62312. /**
  62313. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62314. */
  62315. export class EquiRectangularCubeTexture extends BaseTexture {
  62316. /** The six faces of the cube. */
  62317. private static _FacesMapping;
  62318. private _noMipmap;
  62319. private _onLoad;
  62320. private _onError;
  62321. /** The size of the cubemap. */
  62322. private _size;
  62323. /** The buffer of the image. */
  62324. private _buffer;
  62325. /** The width of the input image. */
  62326. private _width;
  62327. /** The height of the input image. */
  62328. private _height;
  62329. /** The URL to the image. */
  62330. url: string;
  62331. /**
  62332. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62333. * @param url The location of the image
  62334. * @param scene The scene the texture will be used in
  62335. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62336. * @param noMipmap Forces to not generate the mipmap if true
  62337. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62338. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62339. * @param onLoad — defines a callback called when texture is loaded
  62340. * @param onError — defines a callback called if there is an error
  62341. */
  62342. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62343. /**
  62344. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62345. */
  62346. private loadImage;
  62347. /**
  62348. * Convert the image buffer into a cubemap and create a CubeTexture.
  62349. */
  62350. private loadTexture;
  62351. /**
  62352. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62353. * @param buffer The ArrayBuffer that should be converted.
  62354. * @returns The buffer as Float32Array.
  62355. */
  62356. private getFloat32ArrayFromArrayBuffer;
  62357. /**
  62358. * Get the current class name of the texture useful for serialization or dynamic coding.
  62359. * @returns "EquiRectangularCubeTexture"
  62360. */
  62361. getClassName(): string;
  62362. /**
  62363. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62364. * @returns A clone of the current EquiRectangularCubeTexture.
  62365. */
  62366. clone(): EquiRectangularCubeTexture;
  62367. }
  62368. }
  62369. declare module BABYLON {
  62370. /**
  62371. * Defines the options related to the creation of an HtmlElementTexture
  62372. */
  62373. export interface IHtmlElementTextureOptions {
  62374. /**
  62375. * Defines wether mip maps should be created or not.
  62376. */
  62377. generateMipMaps?: boolean;
  62378. /**
  62379. * Defines the sampling mode of the texture.
  62380. */
  62381. samplingMode?: number;
  62382. /**
  62383. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62384. */
  62385. engine: Nullable<ThinEngine>;
  62386. /**
  62387. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62388. */
  62389. scene: Nullable<Scene>;
  62390. }
  62391. /**
  62392. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62393. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62394. * is automatically managed.
  62395. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62396. * in your application.
  62397. *
  62398. * As the update is not automatic, you need to call them manually.
  62399. */
  62400. export class HtmlElementTexture extends BaseTexture {
  62401. /**
  62402. * The texture URL.
  62403. */
  62404. element: HTMLVideoElement | HTMLCanvasElement;
  62405. private static readonly DefaultOptions;
  62406. private _textureMatrix;
  62407. private _isVideo;
  62408. private _generateMipMaps;
  62409. private _samplingMode;
  62410. /**
  62411. * Instantiates a HtmlElementTexture from the following parameters.
  62412. *
  62413. * @param name Defines the name of the texture
  62414. * @param element Defines the video or canvas the texture is filled with
  62415. * @param options Defines the other none mandatory texture creation options
  62416. */
  62417. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62418. private _createInternalTexture;
  62419. /**
  62420. * Returns the texture matrix used in most of the material.
  62421. */
  62422. getTextureMatrix(): Matrix;
  62423. /**
  62424. * Updates the content of the texture.
  62425. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62426. */
  62427. update(invertY?: Nullable<boolean>): void;
  62428. }
  62429. }
  62430. declare module BABYLON {
  62431. /**
  62432. * Based on jsTGALoader - Javascript loader for TGA file
  62433. * By Vincent Thibault
  62434. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62435. */
  62436. export class TGATools {
  62437. private static _TYPE_INDEXED;
  62438. private static _TYPE_RGB;
  62439. private static _TYPE_GREY;
  62440. private static _TYPE_RLE_INDEXED;
  62441. private static _TYPE_RLE_RGB;
  62442. private static _TYPE_RLE_GREY;
  62443. private static _ORIGIN_MASK;
  62444. private static _ORIGIN_SHIFT;
  62445. private static _ORIGIN_BL;
  62446. private static _ORIGIN_BR;
  62447. private static _ORIGIN_UL;
  62448. private static _ORIGIN_UR;
  62449. /**
  62450. * Gets the header of a TGA file
  62451. * @param data defines the TGA data
  62452. * @returns the header
  62453. */
  62454. static GetTGAHeader(data: Uint8Array): any;
  62455. /**
  62456. * Uploads TGA content to a Babylon Texture
  62457. * @hidden
  62458. */
  62459. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62460. /** @hidden */
  62461. 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;
  62462. /** @hidden */
  62463. 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;
  62464. /** @hidden */
  62465. 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;
  62466. /** @hidden */
  62467. 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;
  62468. /** @hidden */
  62469. 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;
  62470. /** @hidden */
  62471. 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;
  62472. }
  62473. }
  62474. declare module BABYLON {
  62475. /**
  62476. * Implementation of the TGA Texture Loader.
  62477. * @hidden
  62478. */
  62479. export class _TGATextureLoader implements IInternalTextureLoader {
  62480. /**
  62481. * Defines wether the loader supports cascade loading the different faces.
  62482. */
  62483. readonly supportCascades: boolean;
  62484. /**
  62485. * This returns if the loader support the current file information.
  62486. * @param extension defines the file extension of the file being loaded
  62487. * @returns true if the loader can load the specified file
  62488. */
  62489. canLoad(extension: string): boolean;
  62490. /**
  62491. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62492. * @param data contains the texture data
  62493. * @param texture defines the BabylonJS internal texture
  62494. * @param createPolynomials will be true if polynomials have been requested
  62495. * @param onLoad defines the callback to trigger once the texture is ready
  62496. * @param onError defines the callback to trigger in case of error
  62497. */
  62498. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62499. /**
  62500. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62501. * @param data contains the texture data
  62502. * @param texture defines the BabylonJS internal texture
  62503. * @param callback defines the method to call once ready to upload
  62504. */
  62505. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62506. }
  62507. }
  62508. declare module BABYLON {
  62509. /**
  62510. * Info about the .basis files
  62511. */
  62512. class BasisFileInfo {
  62513. /**
  62514. * If the file has alpha
  62515. */
  62516. hasAlpha: boolean;
  62517. /**
  62518. * Info about each image of the basis file
  62519. */
  62520. images: Array<{
  62521. levels: Array<{
  62522. width: number;
  62523. height: number;
  62524. transcodedPixels: ArrayBufferView;
  62525. }>;
  62526. }>;
  62527. }
  62528. /**
  62529. * Result of transcoding a basis file
  62530. */
  62531. class TranscodeResult {
  62532. /**
  62533. * Info about the .basis file
  62534. */
  62535. fileInfo: BasisFileInfo;
  62536. /**
  62537. * Format to use when loading the file
  62538. */
  62539. format: number;
  62540. }
  62541. /**
  62542. * Configuration options for the Basis transcoder
  62543. */
  62544. export class BasisTranscodeConfiguration {
  62545. /**
  62546. * Supported compression formats used to determine the supported output format of the transcoder
  62547. */
  62548. supportedCompressionFormats?: {
  62549. /**
  62550. * etc1 compression format
  62551. */
  62552. etc1?: boolean;
  62553. /**
  62554. * s3tc compression format
  62555. */
  62556. s3tc?: boolean;
  62557. /**
  62558. * pvrtc compression format
  62559. */
  62560. pvrtc?: boolean;
  62561. /**
  62562. * etc2 compression format
  62563. */
  62564. etc2?: boolean;
  62565. };
  62566. /**
  62567. * If mipmap levels should be loaded for transcoded images (Default: true)
  62568. */
  62569. loadMipmapLevels?: boolean;
  62570. /**
  62571. * Index of a single image to load (Default: all images)
  62572. */
  62573. loadSingleImage?: number;
  62574. }
  62575. /**
  62576. * Used to load .Basis files
  62577. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62578. */
  62579. export class BasisTools {
  62580. private static _IgnoreSupportedFormats;
  62581. /**
  62582. * URL to use when loading the basis transcoder
  62583. */
  62584. static JSModuleURL: string;
  62585. /**
  62586. * URL to use when loading the wasm module for the transcoder
  62587. */
  62588. static WasmModuleURL: string;
  62589. /**
  62590. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62591. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62592. * @returns internal format corresponding to the Basis format
  62593. */
  62594. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62595. private static _WorkerPromise;
  62596. private static _Worker;
  62597. private static _actionId;
  62598. private static _CreateWorkerAsync;
  62599. /**
  62600. * Transcodes a loaded image file to compressed pixel data
  62601. * @param data image data to transcode
  62602. * @param config configuration options for the transcoding
  62603. * @returns a promise resulting in the transcoded image
  62604. */
  62605. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62606. /**
  62607. * Loads a texture from the transcode result
  62608. * @param texture texture load to
  62609. * @param transcodeResult the result of transcoding the basis file to load from
  62610. */
  62611. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * Loader for .basis file format
  62617. */
  62618. export class _BasisTextureLoader implements IInternalTextureLoader {
  62619. /**
  62620. * Defines whether the loader supports cascade loading the different faces.
  62621. */
  62622. readonly supportCascades: boolean;
  62623. /**
  62624. * This returns if the loader support the current file information.
  62625. * @param extension defines the file extension of the file being loaded
  62626. * @returns true if the loader can load the specified file
  62627. */
  62628. canLoad(extension: string): boolean;
  62629. /**
  62630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62631. * @param data contains the texture data
  62632. * @param texture defines the BabylonJS internal texture
  62633. * @param createPolynomials will be true if polynomials have been requested
  62634. * @param onLoad defines the callback to trigger once the texture is ready
  62635. * @param onError defines the callback to trigger in case of error
  62636. */
  62637. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62638. /**
  62639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62640. * @param data contains the texture data
  62641. * @param texture defines the BabylonJS internal texture
  62642. * @param callback defines the method to call once ready to upload
  62643. */
  62644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62645. }
  62646. }
  62647. declare module BABYLON {
  62648. /**
  62649. * Defines the basic options interface of a TexturePacker Frame
  62650. */
  62651. export interface ITexturePackerFrame {
  62652. /**
  62653. * The frame ID
  62654. */
  62655. id: number;
  62656. /**
  62657. * The frames Scale
  62658. */
  62659. scale: Vector2;
  62660. /**
  62661. * The Frames offset
  62662. */
  62663. offset: Vector2;
  62664. }
  62665. /**
  62666. * This is a support class for frame Data on texture packer sets.
  62667. */
  62668. export class TexturePackerFrame implements ITexturePackerFrame {
  62669. /**
  62670. * The frame ID
  62671. */
  62672. id: number;
  62673. /**
  62674. * The frames Scale
  62675. */
  62676. scale: Vector2;
  62677. /**
  62678. * The Frames offset
  62679. */
  62680. offset: Vector2;
  62681. /**
  62682. * Initializes a texture package frame.
  62683. * @param id The numerical frame identifier
  62684. * @param scale Scalar Vector2 for UV frame
  62685. * @param offset Vector2 for the frame position in UV units.
  62686. * @returns TexturePackerFrame
  62687. */
  62688. constructor(id: number, scale: Vector2, offset: Vector2);
  62689. }
  62690. }
  62691. declare module BABYLON {
  62692. /**
  62693. * Defines the basic options interface of a TexturePacker
  62694. */
  62695. export interface ITexturePackerOptions {
  62696. /**
  62697. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62698. */
  62699. map?: string[];
  62700. /**
  62701. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62702. */
  62703. uvsIn?: string;
  62704. /**
  62705. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62706. */
  62707. uvsOut?: string;
  62708. /**
  62709. * number representing the layout style. Defaults to LAYOUT_STRIP
  62710. */
  62711. layout?: number;
  62712. /**
  62713. * number of columns if using custom column count layout(2). This defaults to 4.
  62714. */
  62715. colnum?: number;
  62716. /**
  62717. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62718. */
  62719. updateInputMeshes?: boolean;
  62720. /**
  62721. * boolean flag to dispose all the source textures. Defaults to true.
  62722. */
  62723. disposeSources?: boolean;
  62724. /**
  62725. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62726. */
  62727. fillBlanks?: boolean;
  62728. /**
  62729. * string value representing the context fill style color. Defaults to 'black'.
  62730. */
  62731. customFillColor?: string;
  62732. /**
  62733. * Width and Height Value of each Frame in the TexturePacker Sets
  62734. */
  62735. frameSize?: number;
  62736. /**
  62737. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62738. */
  62739. paddingRatio?: number;
  62740. /**
  62741. * Number that declares the fill method for the padding gutter.
  62742. */
  62743. paddingMode?: number;
  62744. /**
  62745. * If in SUBUV_COLOR padding mode what color to use.
  62746. */
  62747. paddingColor?: Color3 | Color4;
  62748. }
  62749. /**
  62750. * Defines the basic interface of a TexturePacker JSON File
  62751. */
  62752. export interface ITexturePackerJSON {
  62753. /**
  62754. * The frame ID
  62755. */
  62756. name: string;
  62757. /**
  62758. * The base64 channel data
  62759. */
  62760. sets: any;
  62761. /**
  62762. * The options of the Packer
  62763. */
  62764. options: ITexturePackerOptions;
  62765. /**
  62766. * The frame data of the Packer
  62767. */
  62768. frames: Array<number>;
  62769. }
  62770. /**
  62771. * This is a support class that generates a series of packed texture sets.
  62772. * @see https://doc.babylonjs.com/babylon101/materials
  62773. */
  62774. export class TexturePacker {
  62775. /** Packer Layout Constant 0 */
  62776. static readonly LAYOUT_STRIP: number;
  62777. /** Packer Layout Constant 1 */
  62778. static readonly LAYOUT_POWER2: number;
  62779. /** Packer Layout Constant 2 */
  62780. static readonly LAYOUT_COLNUM: number;
  62781. /** Packer Layout Constant 0 */
  62782. static readonly SUBUV_WRAP: number;
  62783. /** Packer Layout Constant 1 */
  62784. static readonly SUBUV_EXTEND: number;
  62785. /** Packer Layout Constant 2 */
  62786. static readonly SUBUV_COLOR: number;
  62787. /** The Name of the Texture Package */
  62788. name: string;
  62789. /** The scene scope of the TexturePacker */
  62790. scene: Scene;
  62791. /** The Meshes to target */
  62792. meshes: AbstractMesh[];
  62793. /** Arguments passed with the Constructor */
  62794. options: ITexturePackerOptions;
  62795. /** The promise that is started upon initialization */
  62796. promise: Nullable<Promise<TexturePacker | string>>;
  62797. /** The Container object for the channel sets that are generated */
  62798. sets: object;
  62799. /** The Container array for the frames that are generated */
  62800. frames: TexturePackerFrame[];
  62801. /** The expected number of textures the system is parsing. */
  62802. private _expecting;
  62803. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62804. private _paddingValue;
  62805. /**
  62806. * Initializes a texture package series from an array of meshes or a single mesh.
  62807. * @param name The name of the package
  62808. * @param meshes The target meshes to compose the package from
  62809. * @param options The arguments that texture packer should follow while building.
  62810. * @param scene The scene which the textures are scoped to.
  62811. * @returns TexturePacker
  62812. */
  62813. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62814. /**
  62815. * Starts the package process
  62816. * @param resolve The promises resolution function
  62817. * @returns TexturePacker
  62818. */
  62819. private _createFrames;
  62820. /**
  62821. * Calculates the Size of the Channel Sets
  62822. * @returns Vector2
  62823. */
  62824. private _calculateSize;
  62825. /**
  62826. * Calculates the UV data for the frames.
  62827. * @param baseSize the base frameSize
  62828. * @param padding the base frame padding
  62829. * @param dtSize size of the Dynamic Texture for that channel
  62830. * @param dtUnits is 1/dtSize
  62831. * @param update flag to update the input meshes
  62832. */
  62833. private _calculateMeshUVFrames;
  62834. /**
  62835. * Calculates the frames Offset.
  62836. * @param index of the frame
  62837. * @returns Vector2
  62838. */
  62839. private _getFrameOffset;
  62840. /**
  62841. * Updates a Mesh to the frame data
  62842. * @param mesh that is the target
  62843. * @param frameID or the frame index
  62844. */
  62845. private _updateMeshUV;
  62846. /**
  62847. * Updates a Meshes materials to use the texture packer channels
  62848. * @param m is the mesh to target
  62849. * @param force all channels on the packer to be set.
  62850. */
  62851. private _updateTextureReferences;
  62852. /**
  62853. * Public method to set a Mesh to a frame
  62854. * @param m that is the target
  62855. * @param frameID or the frame index
  62856. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62857. */
  62858. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62859. /**
  62860. * Starts the async promise to compile the texture packer.
  62861. * @returns Promise<void>
  62862. */
  62863. processAsync(): Promise<void>;
  62864. /**
  62865. * Disposes all textures associated with this packer
  62866. */
  62867. dispose(): void;
  62868. /**
  62869. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62870. * @param imageType is the image type to use.
  62871. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62872. */
  62873. download(imageType?: string, quality?: number): void;
  62874. /**
  62875. * Public method to load a texturePacker JSON file.
  62876. * @param data of the JSON file in string format.
  62877. */
  62878. updateFromJSON(data: string): void;
  62879. }
  62880. }
  62881. declare module BABYLON {
  62882. /**
  62883. * 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.
  62884. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62885. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62886. */
  62887. export class CustomProceduralTexture extends ProceduralTexture {
  62888. private _animate;
  62889. private _time;
  62890. private _config;
  62891. private _texturePath;
  62892. /**
  62893. * Instantiates a new Custom Procedural Texture.
  62894. * 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.
  62895. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62896. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62897. * @param name Define the name of the texture
  62898. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62899. * @param size Define the size of the texture to create
  62900. * @param scene Define the scene the texture belongs to
  62901. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62902. * @param generateMipMaps Define if the texture should creates mip maps or not
  62903. */
  62904. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62905. private _loadJson;
  62906. /**
  62907. * Is the texture ready to be used ? (rendered at least once)
  62908. * @returns true if ready, otherwise, false.
  62909. */
  62910. isReady(): boolean;
  62911. /**
  62912. * Render the texture to its associated render target.
  62913. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62914. */
  62915. render(useCameraPostProcess?: boolean): void;
  62916. /**
  62917. * Update the list of dependant textures samplers in the shader.
  62918. */
  62919. updateTextures(): void;
  62920. /**
  62921. * Update the uniform values of the procedural texture in the shader.
  62922. */
  62923. updateShaderUniforms(): void;
  62924. /**
  62925. * Define if the texture animates or not.
  62926. */
  62927. get animate(): boolean;
  62928. set animate(value: boolean);
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /** @hidden */
  62933. export var noisePixelShader: {
  62934. name: string;
  62935. shader: string;
  62936. };
  62937. }
  62938. declare module BABYLON {
  62939. /**
  62940. * Class used to generate noise procedural textures
  62941. */
  62942. export class NoiseProceduralTexture extends ProceduralTexture {
  62943. /** Gets or sets the start time (default is 0) */
  62944. time: number;
  62945. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62946. brightness: number;
  62947. /** Defines the number of octaves to process */
  62948. octaves: number;
  62949. /** Defines the level of persistence (0.8 by default) */
  62950. persistence: number;
  62951. /** Gets or sets animation speed factor (default is 1) */
  62952. animationSpeedFactor: number;
  62953. /**
  62954. * Creates a new NoiseProceduralTexture
  62955. * @param name defines the name fo the texture
  62956. * @param size defines the size of the texture (default is 256)
  62957. * @param scene defines the hosting scene
  62958. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62959. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62960. */
  62961. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62962. private _updateShaderUniforms;
  62963. protected _getDefines(): string;
  62964. /** Generate the current state of the procedural texture */
  62965. render(useCameraPostProcess?: boolean): void;
  62966. /**
  62967. * Serializes this noise procedural texture
  62968. * @returns a serialized noise procedural texture object
  62969. */
  62970. serialize(): any;
  62971. /**
  62972. * Clone the texture.
  62973. * @returns the cloned texture
  62974. */
  62975. clone(): NoiseProceduralTexture;
  62976. /**
  62977. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62978. * @param parsedTexture defines parsed texture data
  62979. * @param scene defines the current scene
  62980. * @param rootUrl defines the root URL containing noise procedural texture information
  62981. * @returns a parsed NoiseProceduralTexture
  62982. */
  62983. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62984. }
  62985. }
  62986. declare module BABYLON {
  62987. /**
  62988. * Raw cube texture where the raw buffers are passed in
  62989. */
  62990. export class RawCubeTexture extends CubeTexture {
  62991. /**
  62992. * Creates a cube texture where the raw buffers are passed in.
  62993. * @param scene defines the scene the texture is attached to
  62994. * @param data defines the array of data to use to create each face
  62995. * @param size defines the size of the textures
  62996. * @param format defines the format of the data
  62997. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62998. * @param generateMipMaps defines if the engine should generate the mip levels
  62999. * @param invertY defines if data must be stored with Y axis inverted
  63000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63001. * @param compression defines the compression used (null by default)
  63002. */
  63003. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63004. /**
  63005. * Updates the raw cube texture.
  63006. * @param data defines the data to store
  63007. * @param format defines the data format
  63008. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63009. * @param invertY defines if data must be stored with Y axis inverted
  63010. * @param compression defines the compression used (null by default)
  63011. * @param level defines which level of the texture to update
  63012. */
  63013. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63014. /**
  63015. * Updates a raw cube texture with RGBD encoded data.
  63016. * @param data defines the array of data [mipmap][face] to use to create each face
  63017. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63018. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63019. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63020. * @returns a promsie that resolves when the operation is complete
  63021. */
  63022. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63023. /**
  63024. * Clones the raw cube texture.
  63025. * @return a new cube texture
  63026. */
  63027. clone(): CubeTexture;
  63028. /** @hidden */
  63029. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * Class used to store 2D array textures containing user data
  63035. */
  63036. export class RawTexture2DArray extends Texture {
  63037. /** Gets or sets the texture format to use */
  63038. format: number;
  63039. /**
  63040. * Create a new RawTexture2DArray
  63041. * @param data defines the data of the texture
  63042. * @param width defines the width of the texture
  63043. * @param height defines the height of the texture
  63044. * @param depth defines the number of layers of the texture
  63045. * @param format defines the texture format to use
  63046. * @param scene defines the hosting scene
  63047. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63048. * @param invertY defines if texture must be stored with Y axis inverted
  63049. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63050. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63051. */
  63052. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63053. /** Gets or sets the texture format to use */
  63054. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63055. /**
  63056. * Update the texture with new data
  63057. * @param data defines the data to store in the texture
  63058. */
  63059. update(data: ArrayBufferView): void;
  63060. }
  63061. }
  63062. declare module BABYLON {
  63063. /**
  63064. * Class used to store 3D textures containing user data
  63065. */
  63066. export class RawTexture3D extends Texture {
  63067. /** Gets or sets the texture format to use */
  63068. format: number;
  63069. /**
  63070. * Create a new RawTexture3D
  63071. * @param data defines the data of the texture
  63072. * @param width defines the width of the texture
  63073. * @param height defines the height of the texture
  63074. * @param depth defines the depth of the texture
  63075. * @param format defines the texture format to use
  63076. * @param scene defines the hosting scene
  63077. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63078. * @param invertY defines if texture must be stored with Y axis inverted
  63079. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63080. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63081. */
  63082. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63083. /** Gets or sets the texture format to use */
  63084. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63085. /**
  63086. * Update the texture with new data
  63087. * @param data defines the data to store in the texture
  63088. */
  63089. update(data: ArrayBufferView): void;
  63090. }
  63091. }
  63092. declare module BABYLON {
  63093. /**
  63094. * Creates a refraction texture used by refraction channel of the standard material.
  63095. * It is like a mirror but to see through a material.
  63096. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63097. */
  63098. export class RefractionTexture extends RenderTargetTexture {
  63099. /**
  63100. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63101. * 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.
  63102. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63103. */
  63104. refractionPlane: Plane;
  63105. /**
  63106. * Define how deep under the surface we should see.
  63107. */
  63108. depth: number;
  63109. /**
  63110. * Creates a refraction texture used by refraction channel of the standard material.
  63111. * It is like a mirror but to see through a material.
  63112. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63113. * @param name Define the texture name
  63114. * @param size Define the size of the underlying texture
  63115. * @param scene Define the scene the refraction belongs to
  63116. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63117. */
  63118. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63119. /**
  63120. * Clone the refraction texture.
  63121. * @returns the cloned texture
  63122. */
  63123. clone(): RefractionTexture;
  63124. /**
  63125. * Serialize the texture to a JSON representation you could use in Parse later on
  63126. * @returns the serialized JSON representation
  63127. */
  63128. serialize(): any;
  63129. }
  63130. }
  63131. declare module BABYLON {
  63132. /**
  63133. * Block used to add support for vertex skinning (bones)
  63134. */
  63135. export class BonesBlock extends NodeMaterialBlock {
  63136. /**
  63137. * Creates a new BonesBlock
  63138. * @param name defines the block name
  63139. */
  63140. constructor(name: string);
  63141. /**
  63142. * Initialize the block and prepare the context for build
  63143. * @param state defines the state that will be used for the build
  63144. */
  63145. initialize(state: NodeMaterialBuildState): void;
  63146. /**
  63147. * Gets the current class name
  63148. * @returns the class name
  63149. */
  63150. getClassName(): string;
  63151. /**
  63152. * Gets the matrix indices input component
  63153. */
  63154. get matricesIndices(): NodeMaterialConnectionPoint;
  63155. /**
  63156. * Gets the matrix weights input component
  63157. */
  63158. get matricesWeights(): NodeMaterialConnectionPoint;
  63159. /**
  63160. * Gets the extra matrix indices input component
  63161. */
  63162. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63163. /**
  63164. * Gets the extra matrix weights input component
  63165. */
  63166. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the world input component
  63169. */
  63170. get world(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the output component
  63173. */
  63174. get output(): NodeMaterialConnectionPoint;
  63175. autoConfigure(material: NodeMaterial): void;
  63176. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63179. protected _buildBlock(state: NodeMaterialBuildState): this;
  63180. }
  63181. }
  63182. declare module BABYLON {
  63183. /**
  63184. * Block used to add support for instances
  63185. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63186. */
  63187. export class InstancesBlock extends NodeMaterialBlock {
  63188. /**
  63189. * Creates a new InstancesBlock
  63190. * @param name defines the block name
  63191. */
  63192. constructor(name: string);
  63193. /**
  63194. * Gets the current class name
  63195. * @returns the class name
  63196. */
  63197. getClassName(): string;
  63198. /**
  63199. * Gets the first world row input component
  63200. */
  63201. get world0(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the second world row input component
  63204. */
  63205. get world1(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the third world row input component
  63208. */
  63209. get world2(): NodeMaterialConnectionPoint;
  63210. /**
  63211. * Gets the forth world row input component
  63212. */
  63213. get world3(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the world input component
  63216. */
  63217. get world(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the output component
  63220. */
  63221. get output(): NodeMaterialConnectionPoint;
  63222. /**
  63223. * Gets the isntanceID component
  63224. */
  63225. get instanceID(): NodeMaterialConnectionPoint;
  63226. autoConfigure(material: NodeMaterial): void;
  63227. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63228. protected _buildBlock(state: NodeMaterialBuildState): this;
  63229. }
  63230. }
  63231. declare module BABYLON {
  63232. /**
  63233. * Block used to add morph targets support to vertex shader
  63234. */
  63235. export class MorphTargetsBlock extends NodeMaterialBlock {
  63236. private _repeatableContentAnchor;
  63237. /**
  63238. * Create a new MorphTargetsBlock
  63239. * @param name defines the block name
  63240. */
  63241. constructor(name: string);
  63242. /**
  63243. * Gets the current class name
  63244. * @returns the class name
  63245. */
  63246. getClassName(): string;
  63247. /**
  63248. * Gets the position input component
  63249. */
  63250. get position(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the normal input component
  63253. */
  63254. get normal(): NodeMaterialConnectionPoint;
  63255. /**
  63256. * Gets the tangent input component
  63257. */
  63258. get tangent(): NodeMaterialConnectionPoint;
  63259. /**
  63260. * Gets the tangent input component
  63261. */
  63262. get uv(): NodeMaterialConnectionPoint;
  63263. /**
  63264. * Gets the position output component
  63265. */
  63266. get positionOutput(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the normal output component
  63269. */
  63270. get normalOutput(): NodeMaterialConnectionPoint;
  63271. /**
  63272. * Gets the tangent output component
  63273. */
  63274. get tangentOutput(): NodeMaterialConnectionPoint;
  63275. /**
  63276. * Gets the tangent output component
  63277. */
  63278. get uvOutput(): NodeMaterialConnectionPoint;
  63279. initialize(state: NodeMaterialBuildState): void;
  63280. autoConfigure(material: NodeMaterial): void;
  63281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63283. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63284. protected _buildBlock(state: NodeMaterialBuildState): this;
  63285. }
  63286. }
  63287. declare module BABYLON {
  63288. /**
  63289. * Block used to get data information from a light
  63290. */
  63291. export class LightInformationBlock extends NodeMaterialBlock {
  63292. private _lightDataUniformName;
  63293. private _lightColorUniformName;
  63294. private _lightTypeDefineName;
  63295. /**
  63296. * Gets or sets the light associated with this block
  63297. */
  63298. light: Nullable<Light>;
  63299. /**
  63300. * Creates a new LightInformationBlock
  63301. * @param name defines the block name
  63302. */
  63303. constructor(name: string);
  63304. /**
  63305. * Gets the current class name
  63306. * @returns the class name
  63307. */
  63308. getClassName(): string;
  63309. /**
  63310. * Gets the world position input component
  63311. */
  63312. get worldPosition(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the direction output component
  63315. */
  63316. get direction(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the direction output component
  63319. */
  63320. get color(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the direction output component
  63323. */
  63324. get intensity(): NodeMaterialConnectionPoint;
  63325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63327. protected _buildBlock(state: NodeMaterialBuildState): this;
  63328. serialize(): any;
  63329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63330. }
  63331. }
  63332. declare module BABYLON {
  63333. /**
  63334. * Block used to add image processing support to fragment shader
  63335. */
  63336. export class ImageProcessingBlock extends NodeMaterialBlock {
  63337. /**
  63338. * Create a new ImageProcessingBlock
  63339. * @param name defines the block name
  63340. */
  63341. constructor(name: string);
  63342. /**
  63343. * Gets the current class name
  63344. * @returns the class name
  63345. */
  63346. getClassName(): string;
  63347. /**
  63348. * Gets the color input component
  63349. */
  63350. get color(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the output component
  63353. */
  63354. get output(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Initialize the block and prepare the context for build
  63357. * @param state defines the state that will be used for the build
  63358. */
  63359. initialize(state: NodeMaterialBuildState): void;
  63360. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63363. protected _buildBlock(state: NodeMaterialBuildState): this;
  63364. }
  63365. }
  63366. declare module BABYLON {
  63367. /**
  63368. * Block used to pertub normals based on a normal map
  63369. */
  63370. export class PerturbNormalBlock extends NodeMaterialBlock {
  63371. private _tangentSpaceParameterName;
  63372. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63373. invertX: boolean;
  63374. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63375. invertY: boolean;
  63376. /**
  63377. * Create a new PerturbNormalBlock
  63378. * @param name defines the block name
  63379. */
  63380. constructor(name: string);
  63381. /**
  63382. * Gets the current class name
  63383. * @returns the class name
  63384. */
  63385. getClassName(): string;
  63386. /**
  63387. * Gets the world position input component
  63388. */
  63389. get worldPosition(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the world normal input component
  63392. */
  63393. get worldNormal(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the world tangent input component
  63396. */
  63397. get worldTangent(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the uv input component
  63400. */
  63401. get uv(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the normal map color input component
  63404. */
  63405. get normalMapColor(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the strength input component
  63408. */
  63409. get strength(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the output component
  63412. */
  63413. get output(): NodeMaterialConnectionPoint;
  63414. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63416. autoConfigure(material: NodeMaterial): void;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. protected _dumpPropertiesCode(): string;
  63419. serialize(): any;
  63420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. /**
  63425. * Block used to discard a pixel if a value is smaller than a cutoff
  63426. */
  63427. export class DiscardBlock extends NodeMaterialBlock {
  63428. /**
  63429. * Create a new DiscardBlock
  63430. * @param name defines the block name
  63431. */
  63432. constructor(name: string);
  63433. /**
  63434. * Gets the current class name
  63435. * @returns the class name
  63436. */
  63437. getClassName(): string;
  63438. /**
  63439. * Gets the color input component
  63440. */
  63441. get value(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the cutoff input component
  63444. */
  63445. get cutoff(): NodeMaterialConnectionPoint;
  63446. protected _buildBlock(state: NodeMaterialBuildState): this;
  63447. }
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * Block used to test if the fragment shader is front facing
  63452. */
  63453. export class FrontFacingBlock extends NodeMaterialBlock {
  63454. /**
  63455. * Creates a new FrontFacingBlock
  63456. * @param name defines the block name
  63457. */
  63458. constructor(name: string);
  63459. /**
  63460. * Gets the current class name
  63461. * @returns the class name
  63462. */
  63463. getClassName(): string;
  63464. /**
  63465. * Gets the output component
  63466. */
  63467. get output(): NodeMaterialConnectionPoint;
  63468. protected _buildBlock(state: NodeMaterialBuildState): this;
  63469. }
  63470. }
  63471. declare module BABYLON {
  63472. /**
  63473. * Block used to get the derivative value on x and y of a given input
  63474. */
  63475. export class DerivativeBlock extends NodeMaterialBlock {
  63476. /**
  63477. * Create a new DerivativeBlock
  63478. * @param name defines the block name
  63479. */
  63480. constructor(name: string);
  63481. /**
  63482. * Gets the current class name
  63483. * @returns the class name
  63484. */
  63485. getClassName(): string;
  63486. /**
  63487. * Gets the input component
  63488. */
  63489. get input(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the derivative output on x
  63492. */
  63493. get dx(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the derivative output on y
  63496. */
  63497. get dy(): NodeMaterialConnectionPoint;
  63498. protected _buildBlock(state: NodeMaterialBuildState): this;
  63499. }
  63500. }
  63501. declare module BABYLON {
  63502. /**
  63503. * Block used to make gl_FragCoord available
  63504. */
  63505. export class FragCoordBlock extends NodeMaterialBlock {
  63506. /**
  63507. * Creates a new FragCoordBlock
  63508. * @param name defines the block name
  63509. */
  63510. constructor(name: string);
  63511. /**
  63512. * Gets the current class name
  63513. * @returns the class name
  63514. */
  63515. getClassName(): string;
  63516. /**
  63517. * Gets the xy component
  63518. */
  63519. get xy(): NodeMaterialConnectionPoint;
  63520. /**
  63521. * Gets the xyz component
  63522. */
  63523. get xyz(): NodeMaterialConnectionPoint;
  63524. /**
  63525. * Gets the xyzw component
  63526. */
  63527. get xyzw(): NodeMaterialConnectionPoint;
  63528. /**
  63529. * Gets the x component
  63530. */
  63531. get x(): NodeMaterialConnectionPoint;
  63532. /**
  63533. * Gets the y component
  63534. */
  63535. get y(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the z component
  63538. */
  63539. get z(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the w component
  63542. */
  63543. get output(): NodeMaterialConnectionPoint;
  63544. protected writeOutputs(state: NodeMaterialBuildState): string;
  63545. protected _buildBlock(state: NodeMaterialBuildState): this;
  63546. }
  63547. }
  63548. declare module BABYLON {
  63549. /**
  63550. * Block used to get the screen sizes
  63551. */
  63552. export class ScreenSizeBlock extends NodeMaterialBlock {
  63553. private _varName;
  63554. private _scene;
  63555. /**
  63556. * Creates a new ScreenSizeBlock
  63557. * @param name defines the block name
  63558. */
  63559. constructor(name: string);
  63560. /**
  63561. * Gets the current class name
  63562. * @returns the class name
  63563. */
  63564. getClassName(): string;
  63565. /**
  63566. * Gets the xy component
  63567. */
  63568. get xy(): NodeMaterialConnectionPoint;
  63569. /**
  63570. * Gets the x component
  63571. */
  63572. get x(): NodeMaterialConnectionPoint;
  63573. /**
  63574. * Gets the y component
  63575. */
  63576. get y(): NodeMaterialConnectionPoint;
  63577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63578. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63579. protected _buildBlock(state: NodeMaterialBuildState): this;
  63580. }
  63581. }
  63582. declare module BABYLON {
  63583. /**
  63584. * Block used to add support for scene fog
  63585. */
  63586. export class FogBlock extends NodeMaterialBlock {
  63587. private _fogDistanceName;
  63588. private _fogParameters;
  63589. /**
  63590. * Create a new FogBlock
  63591. * @param name defines the block name
  63592. */
  63593. constructor(name: string);
  63594. /**
  63595. * Gets the current class name
  63596. * @returns the class name
  63597. */
  63598. getClassName(): string;
  63599. /**
  63600. * Gets the world position input component
  63601. */
  63602. get worldPosition(): NodeMaterialConnectionPoint;
  63603. /**
  63604. * Gets the view input component
  63605. */
  63606. get view(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the color input component
  63609. */
  63610. get input(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the fog color input component
  63613. */
  63614. get fogColor(): NodeMaterialConnectionPoint;
  63615. /**
  63616. * Gets the output component
  63617. */
  63618. get output(): NodeMaterialConnectionPoint;
  63619. autoConfigure(material: NodeMaterial): void;
  63620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63622. protected _buildBlock(state: NodeMaterialBuildState): this;
  63623. }
  63624. }
  63625. declare module BABYLON {
  63626. /**
  63627. * Block used to add light in the fragment shader
  63628. */
  63629. export class LightBlock extends NodeMaterialBlock {
  63630. private _lightId;
  63631. /**
  63632. * Gets or sets the light associated with this block
  63633. */
  63634. light: Nullable<Light>;
  63635. /**
  63636. * Create a new LightBlock
  63637. * @param name defines the block name
  63638. */
  63639. constructor(name: string);
  63640. /**
  63641. * Gets the current class name
  63642. * @returns the class name
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * Gets the world position input component
  63647. */
  63648. get worldPosition(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the world normal input component
  63651. */
  63652. get worldNormal(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the camera (or eye) position component
  63655. */
  63656. get cameraPosition(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the glossiness component
  63659. */
  63660. get glossiness(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the glossinness power component
  63663. */
  63664. get glossPower(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the diffuse color component
  63667. */
  63668. get diffuseColor(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the specular color component
  63671. */
  63672. get specularColor(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the view matrix component
  63675. */
  63676. get view(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the diffuse output component
  63679. */
  63680. get diffuseOutput(): NodeMaterialConnectionPoint;
  63681. /**
  63682. * Gets the specular output component
  63683. */
  63684. get specularOutput(): NodeMaterialConnectionPoint;
  63685. /**
  63686. * Gets the shadow output component
  63687. */
  63688. get shadow(): NodeMaterialConnectionPoint;
  63689. autoConfigure(material: NodeMaterial): void;
  63690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63691. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63692. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63693. private _injectVertexCode;
  63694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63695. serialize(): any;
  63696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63697. }
  63698. }
  63699. declare module BABYLON {
  63700. /**
  63701. * Block used to read a reflection texture from a sampler
  63702. */
  63703. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63704. /**
  63705. * Create a new ReflectionTextureBlock
  63706. * @param name defines the block name
  63707. */
  63708. constructor(name: string);
  63709. /**
  63710. * Gets the current class name
  63711. * @returns the class name
  63712. */
  63713. getClassName(): string;
  63714. /**
  63715. * Gets the world position input component
  63716. */
  63717. get position(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the world position input component
  63720. */
  63721. get worldPosition(): NodeMaterialConnectionPoint;
  63722. /**
  63723. * Gets the world normal input component
  63724. */
  63725. get worldNormal(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the world input component
  63728. */
  63729. get world(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the camera (or eye) position component
  63732. */
  63733. get cameraPosition(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the view input component
  63736. */
  63737. get view(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the rgb output component
  63740. */
  63741. get rgb(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the rgba output component
  63744. */
  63745. get rgba(): NodeMaterialConnectionPoint;
  63746. /**
  63747. * Gets the r output component
  63748. */
  63749. get r(): NodeMaterialConnectionPoint;
  63750. /**
  63751. * Gets the g output component
  63752. */
  63753. get g(): NodeMaterialConnectionPoint;
  63754. /**
  63755. * Gets the b output component
  63756. */
  63757. get b(): NodeMaterialConnectionPoint;
  63758. /**
  63759. * Gets the a output component
  63760. */
  63761. get a(): NodeMaterialConnectionPoint;
  63762. autoConfigure(material: NodeMaterial): void;
  63763. protected _buildBlock(state: NodeMaterialBuildState): this;
  63764. }
  63765. }
  63766. declare module BABYLON {
  63767. /**
  63768. * Block used to add 2 vectors
  63769. */
  63770. export class AddBlock extends NodeMaterialBlock {
  63771. /**
  63772. * Creates a new AddBlock
  63773. * @param name defines the block name
  63774. */
  63775. constructor(name: string);
  63776. /**
  63777. * Gets the current class name
  63778. * @returns the class name
  63779. */
  63780. getClassName(): string;
  63781. /**
  63782. * Gets the left operand input component
  63783. */
  63784. get left(): NodeMaterialConnectionPoint;
  63785. /**
  63786. * Gets the right operand input component
  63787. */
  63788. get right(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the output component
  63791. */
  63792. get output(): NodeMaterialConnectionPoint;
  63793. protected _buildBlock(state: NodeMaterialBuildState): this;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /**
  63798. * Block used to scale a vector by a float
  63799. */
  63800. export class ScaleBlock extends NodeMaterialBlock {
  63801. /**
  63802. * Creates a new ScaleBlock
  63803. * @param name defines the block name
  63804. */
  63805. constructor(name: string);
  63806. /**
  63807. * Gets the current class name
  63808. * @returns the class name
  63809. */
  63810. getClassName(): string;
  63811. /**
  63812. * Gets the input component
  63813. */
  63814. get input(): NodeMaterialConnectionPoint;
  63815. /**
  63816. * Gets the factor input component
  63817. */
  63818. get factor(): NodeMaterialConnectionPoint;
  63819. /**
  63820. * Gets the output component
  63821. */
  63822. get output(): NodeMaterialConnectionPoint;
  63823. protected _buildBlock(state: NodeMaterialBuildState): this;
  63824. }
  63825. }
  63826. declare module BABYLON {
  63827. /**
  63828. * Block used to clamp a float
  63829. */
  63830. export class ClampBlock extends NodeMaterialBlock {
  63831. /** Gets or sets the minimum range */
  63832. minimum: number;
  63833. /** Gets or sets the maximum range */
  63834. maximum: number;
  63835. /**
  63836. * Creates a new ClampBlock
  63837. * @param name defines the block name
  63838. */
  63839. constructor(name: string);
  63840. /**
  63841. * Gets the current class name
  63842. * @returns the class name
  63843. */
  63844. getClassName(): string;
  63845. /**
  63846. * Gets the value input component
  63847. */
  63848. get value(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Gets the output component
  63851. */
  63852. get output(): NodeMaterialConnectionPoint;
  63853. protected _buildBlock(state: NodeMaterialBuildState): this;
  63854. protected _dumpPropertiesCode(): string;
  63855. serialize(): any;
  63856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63857. }
  63858. }
  63859. declare module BABYLON {
  63860. /**
  63861. * Block used to apply a cross product between 2 vectors
  63862. */
  63863. export class CrossBlock extends NodeMaterialBlock {
  63864. /**
  63865. * Creates a new CrossBlock
  63866. * @param name defines the block name
  63867. */
  63868. constructor(name: string);
  63869. /**
  63870. * Gets the current class name
  63871. * @returns the class name
  63872. */
  63873. getClassName(): string;
  63874. /**
  63875. * Gets the left operand input component
  63876. */
  63877. get left(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the right operand input component
  63880. */
  63881. get right(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the output component
  63884. */
  63885. get output(): NodeMaterialConnectionPoint;
  63886. protected _buildBlock(state: NodeMaterialBuildState): this;
  63887. }
  63888. }
  63889. declare module BABYLON {
  63890. /**
  63891. * Block used to apply a dot product between 2 vectors
  63892. */
  63893. export class DotBlock extends NodeMaterialBlock {
  63894. /**
  63895. * Creates a new DotBlock
  63896. * @param name defines the block name
  63897. */
  63898. constructor(name: string);
  63899. /**
  63900. * Gets the current class name
  63901. * @returns the class name
  63902. */
  63903. getClassName(): string;
  63904. /**
  63905. * Gets the left operand input component
  63906. */
  63907. get left(): NodeMaterialConnectionPoint;
  63908. /**
  63909. * Gets the right operand input component
  63910. */
  63911. get right(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the output component
  63914. */
  63915. get output(): NodeMaterialConnectionPoint;
  63916. protected _buildBlock(state: NodeMaterialBuildState): this;
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. /**
  63921. * Block used to normalize a vector
  63922. */
  63923. export class NormalizeBlock extends NodeMaterialBlock {
  63924. /**
  63925. * Creates a new NormalizeBlock
  63926. * @param name defines the block name
  63927. */
  63928. constructor(name: string);
  63929. /**
  63930. * Gets the current class name
  63931. * @returns the class name
  63932. */
  63933. getClassName(): string;
  63934. /**
  63935. * Gets the input component
  63936. */
  63937. get input(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the output component
  63940. */
  63941. get output(): NodeMaterialConnectionPoint;
  63942. protected _buildBlock(state: NodeMaterialBuildState): this;
  63943. }
  63944. }
  63945. declare module BABYLON {
  63946. /**
  63947. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63948. */
  63949. export class ColorMergerBlock extends NodeMaterialBlock {
  63950. /**
  63951. * Create a new ColorMergerBlock
  63952. * @param name defines the block name
  63953. */
  63954. constructor(name: string);
  63955. /**
  63956. * Gets the current class name
  63957. * @returns the class name
  63958. */
  63959. getClassName(): string;
  63960. /**
  63961. * Gets the rgb component (input)
  63962. */
  63963. get rgbIn(): NodeMaterialConnectionPoint;
  63964. /**
  63965. * Gets the r component (input)
  63966. */
  63967. get r(): NodeMaterialConnectionPoint;
  63968. /**
  63969. * Gets the g component (input)
  63970. */
  63971. get g(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the b component (input)
  63974. */
  63975. get b(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the a component (input)
  63978. */
  63979. get a(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the rgba component (output)
  63982. */
  63983. get rgba(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the rgb component (output)
  63986. */
  63987. get rgbOut(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the rgb component (output)
  63990. * @deprecated Please use rgbOut instead.
  63991. */
  63992. get rgb(): NodeMaterialConnectionPoint;
  63993. protected _buildBlock(state: NodeMaterialBuildState): this;
  63994. }
  63995. }
  63996. declare module BABYLON {
  63997. /**
  63998. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63999. */
  64000. export class VectorSplitterBlock extends NodeMaterialBlock {
  64001. /**
  64002. * Create a new VectorSplitterBlock
  64003. * @param name defines the block name
  64004. */
  64005. constructor(name: string);
  64006. /**
  64007. * Gets the current class name
  64008. * @returns the class name
  64009. */
  64010. getClassName(): string;
  64011. /**
  64012. * Gets the xyzw component (input)
  64013. */
  64014. get xyzw(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the xyz component (input)
  64017. */
  64018. get xyzIn(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the xy component (input)
  64021. */
  64022. get xyIn(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the xyz component (output)
  64025. */
  64026. get xyzOut(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the xy component (output)
  64029. */
  64030. get xyOut(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the x component (output)
  64033. */
  64034. get x(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the y component (output)
  64037. */
  64038. get y(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the z component (output)
  64041. */
  64042. get z(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the w component (output)
  64045. */
  64046. get w(): NodeMaterialConnectionPoint;
  64047. protected _inputRename(name: string): string;
  64048. protected _outputRename(name: string): string;
  64049. protected _buildBlock(state: NodeMaterialBuildState): this;
  64050. }
  64051. }
  64052. declare module BABYLON {
  64053. /**
  64054. * Block used to lerp between 2 values
  64055. */
  64056. export class LerpBlock extends NodeMaterialBlock {
  64057. /**
  64058. * Creates a new LerpBlock
  64059. * @param name defines the block name
  64060. */
  64061. constructor(name: string);
  64062. /**
  64063. * Gets the current class name
  64064. * @returns the class name
  64065. */
  64066. getClassName(): string;
  64067. /**
  64068. * Gets the left operand input component
  64069. */
  64070. get left(): NodeMaterialConnectionPoint;
  64071. /**
  64072. * Gets the right operand input component
  64073. */
  64074. get right(): NodeMaterialConnectionPoint;
  64075. /**
  64076. * Gets the gradient operand input component
  64077. */
  64078. get gradient(): NodeMaterialConnectionPoint;
  64079. /**
  64080. * Gets the output component
  64081. */
  64082. get output(): NodeMaterialConnectionPoint;
  64083. protected _buildBlock(state: NodeMaterialBuildState): this;
  64084. }
  64085. }
  64086. declare module BABYLON {
  64087. /**
  64088. * Block used to divide 2 vectors
  64089. */
  64090. export class DivideBlock extends NodeMaterialBlock {
  64091. /**
  64092. * Creates a new DivideBlock
  64093. * @param name defines the block name
  64094. */
  64095. constructor(name: string);
  64096. /**
  64097. * Gets the current class name
  64098. * @returns the class name
  64099. */
  64100. getClassName(): string;
  64101. /**
  64102. * Gets the left operand input component
  64103. */
  64104. get left(): NodeMaterialConnectionPoint;
  64105. /**
  64106. * Gets the right operand input component
  64107. */
  64108. get right(): NodeMaterialConnectionPoint;
  64109. /**
  64110. * Gets the output component
  64111. */
  64112. get output(): NodeMaterialConnectionPoint;
  64113. protected _buildBlock(state: NodeMaterialBuildState): this;
  64114. }
  64115. }
  64116. declare module BABYLON {
  64117. /**
  64118. * Block used to subtract 2 vectors
  64119. */
  64120. export class SubtractBlock extends NodeMaterialBlock {
  64121. /**
  64122. * Creates a new SubtractBlock
  64123. * @param name defines the block name
  64124. */
  64125. constructor(name: string);
  64126. /**
  64127. * Gets the current class name
  64128. * @returns the class name
  64129. */
  64130. getClassName(): string;
  64131. /**
  64132. * Gets the left operand input component
  64133. */
  64134. get left(): NodeMaterialConnectionPoint;
  64135. /**
  64136. * Gets the right operand input component
  64137. */
  64138. get right(): NodeMaterialConnectionPoint;
  64139. /**
  64140. * Gets the output component
  64141. */
  64142. get output(): NodeMaterialConnectionPoint;
  64143. protected _buildBlock(state: NodeMaterialBuildState): this;
  64144. }
  64145. }
  64146. declare module BABYLON {
  64147. /**
  64148. * Block used to step a value
  64149. */
  64150. export class StepBlock extends NodeMaterialBlock {
  64151. /**
  64152. * Creates a new StepBlock
  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 operand input component
  64163. */
  64164. get value(): NodeMaterialConnectionPoint;
  64165. /**
  64166. * Gets the edge operand input component
  64167. */
  64168. get edge(): 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. * Block used to get the opposite (1 - x) of a value
  64179. */
  64180. export class OneMinusBlock extends NodeMaterialBlock {
  64181. /**
  64182. * Creates a new OneMinusBlock
  64183. * @param name defines the block name
  64184. */
  64185. constructor(name: string);
  64186. /**
  64187. * Gets the current class name
  64188. * @returns the class name
  64189. */
  64190. getClassName(): string;
  64191. /**
  64192. * Gets the input component
  64193. */
  64194. get input(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the output component
  64197. */
  64198. get output(): NodeMaterialConnectionPoint;
  64199. protected _buildBlock(state: NodeMaterialBuildState): this;
  64200. }
  64201. }
  64202. declare module BABYLON {
  64203. /**
  64204. * Block used to get the view direction
  64205. */
  64206. export class ViewDirectionBlock extends NodeMaterialBlock {
  64207. /**
  64208. * Creates a new ViewDirectionBlock
  64209. * @param name defines the block name
  64210. */
  64211. constructor(name: string);
  64212. /**
  64213. * Gets the current class name
  64214. * @returns the class name
  64215. */
  64216. getClassName(): string;
  64217. /**
  64218. * Gets the world position component
  64219. */
  64220. get worldPosition(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Gets the camera position component
  64223. */
  64224. get cameraPosition(): NodeMaterialConnectionPoint;
  64225. /**
  64226. * Gets the output component
  64227. */
  64228. get output(): NodeMaterialConnectionPoint;
  64229. autoConfigure(material: NodeMaterial): void;
  64230. protected _buildBlock(state: NodeMaterialBuildState): this;
  64231. }
  64232. }
  64233. declare module BABYLON {
  64234. /**
  64235. * Block used to compute fresnel value
  64236. */
  64237. export class FresnelBlock extends NodeMaterialBlock {
  64238. /**
  64239. * Create a new FresnelBlock
  64240. * @param name defines the block name
  64241. */
  64242. constructor(name: string);
  64243. /**
  64244. * Gets the current class name
  64245. * @returns the class name
  64246. */
  64247. getClassName(): string;
  64248. /**
  64249. * Gets the world normal input component
  64250. */
  64251. get worldNormal(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the view direction input component
  64254. */
  64255. get viewDirection(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the bias input component
  64258. */
  64259. get bias(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the camera (or eye) position component
  64262. */
  64263. get power(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the fresnel output component
  64266. */
  64267. get fresnel(): NodeMaterialConnectionPoint;
  64268. autoConfigure(material: NodeMaterial): void;
  64269. protected _buildBlock(state: NodeMaterialBuildState): this;
  64270. }
  64271. }
  64272. declare module BABYLON {
  64273. /**
  64274. * Block used to get the max of 2 values
  64275. */
  64276. export class MaxBlock extends NodeMaterialBlock {
  64277. /**
  64278. * Creates a new MaxBlock
  64279. * @param name defines the block name
  64280. */
  64281. constructor(name: string);
  64282. /**
  64283. * Gets the current class name
  64284. * @returns the class name
  64285. */
  64286. getClassName(): string;
  64287. /**
  64288. * Gets the left operand input component
  64289. */
  64290. get left(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the right operand input component
  64293. */
  64294. get right(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the output component
  64297. */
  64298. get output(): NodeMaterialConnectionPoint;
  64299. protected _buildBlock(state: NodeMaterialBuildState): this;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * Block used to get the min of 2 values
  64305. */
  64306. export class MinBlock extends NodeMaterialBlock {
  64307. /**
  64308. * Creates a new MinBlock
  64309. * @param name defines the block name
  64310. */
  64311. constructor(name: string);
  64312. /**
  64313. * Gets the current class name
  64314. * @returns the class name
  64315. */
  64316. getClassName(): string;
  64317. /**
  64318. * Gets the left operand input component
  64319. */
  64320. get left(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the right operand input component
  64323. */
  64324. get right(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the output component
  64327. */
  64328. get output(): NodeMaterialConnectionPoint;
  64329. protected _buildBlock(state: NodeMaterialBuildState): this;
  64330. }
  64331. }
  64332. declare module BABYLON {
  64333. /**
  64334. * Block used to get the distance between 2 values
  64335. */
  64336. export class DistanceBlock extends NodeMaterialBlock {
  64337. /**
  64338. * Creates a new DistanceBlock
  64339. * @param name defines the block name
  64340. */
  64341. constructor(name: string);
  64342. /**
  64343. * Gets the current class name
  64344. * @returns the class name
  64345. */
  64346. getClassName(): string;
  64347. /**
  64348. * Gets the left operand input component
  64349. */
  64350. get left(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the right operand input component
  64353. */
  64354. get right(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the output component
  64357. */
  64358. get output(): NodeMaterialConnectionPoint;
  64359. protected _buildBlock(state: NodeMaterialBuildState): this;
  64360. }
  64361. }
  64362. declare module BABYLON {
  64363. /**
  64364. * Block used to get the length of a vector
  64365. */
  64366. export class LengthBlock extends NodeMaterialBlock {
  64367. /**
  64368. * Creates a new LengthBlock
  64369. * @param name defines the block name
  64370. */
  64371. constructor(name: string);
  64372. /**
  64373. * Gets the current class name
  64374. * @returns the class name
  64375. */
  64376. getClassName(): string;
  64377. /**
  64378. * Gets the value input component
  64379. */
  64380. get value(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the output component
  64383. */
  64384. get output(): NodeMaterialConnectionPoint;
  64385. protected _buildBlock(state: NodeMaterialBuildState): this;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Block used to get negative version of a value (i.e. x * -1)
  64391. */
  64392. export class NegateBlock extends NodeMaterialBlock {
  64393. /**
  64394. * Creates a new NegateBlock
  64395. * @param name defines the block name
  64396. */
  64397. constructor(name: string);
  64398. /**
  64399. * Gets the current class name
  64400. * @returns the class name
  64401. */
  64402. getClassName(): string;
  64403. /**
  64404. * Gets the value input component
  64405. */
  64406. get value(): NodeMaterialConnectionPoint;
  64407. /**
  64408. * Gets the output component
  64409. */
  64410. get output(): NodeMaterialConnectionPoint;
  64411. protected _buildBlock(state: NodeMaterialBuildState): this;
  64412. }
  64413. }
  64414. declare module BABYLON {
  64415. /**
  64416. * Block used to get the value of the first parameter raised to the power of the second
  64417. */
  64418. export class PowBlock extends NodeMaterialBlock {
  64419. /**
  64420. * Creates a new PowBlock
  64421. * @param name defines the block name
  64422. */
  64423. constructor(name: string);
  64424. /**
  64425. * Gets the current class name
  64426. * @returns the class name
  64427. */
  64428. getClassName(): string;
  64429. /**
  64430. * Gets the value operand input component
  64431. */
  64432. get value(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the power operand input component
  64435. */
  64436. get power(): NodeMaterialConnectionPoint;
  64437. /**
  64438. * Gets the output component
  64439. */
  64440. get output(): NodeMaterialConnectionPoint;
  64441. protected _buildBlock(state: NodeMaterialBuildState): this;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Block used to get a random number
  64447. */
  64448. export class RandomNumberBlock extends NodeMaterialBlock {
  64449. /**
  64450. * Creates a new RandomNumberBlock
  64451. * @param name defines the block name
  64452. */
  64453. constructor(name: string);
  64454. /**
  64455. * Gets the current class name
  64456. * @returns the class name
  64457. */
  64458. getClassName(): string;
  64459. /**
  64460. * Gets the seed input component
  64461. */
  64462. get seed(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the output component
  64465. */
  64466. get output(): NodeMaterialConnectionPoint;
  64467. protected _buildBlock(state: NodeMaterialBuildState): this;
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. /**
  64472. * Block used to compute arc tangent of 2 values
  64473. */
  64474. export class ArcTan2Block extends NodeMaterialBlock {
  64475. /**
  64476. * Creates a new ArcTan2Block
  64477. * @param name defines the block name
  64478. */
  64479. constructor(name: string);
  64480. /**
  64481. * Gets the current class name
  64482. * @returns the class name
  64483. */
  64484. getClassName(): string;
  64485. /**
  64486. * Gets the x operand input component
  64487. */
  64488. get x(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the y operand input component
  64491. */
  64492. get y(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the output component
  64495. */
  64496. get output(): NodeMaterialConnectionPoint;
  64497. protected _buildBlock(state: NodeMaterialBuildState): this;
  64498. }
  64499. }
  64500. declare module BABYLON {
  64501. /**
  64502. * Block used to smooth step a value
  64503. */
  64504. export class SmoothStepBlock extends NodeMaterialBlock {
  64505. /**
  64506. * Creates a new SmoothStepBlock
  64507. * @param name defines the block name
  64508. */
  64509. constructor(name: string);
  64510. /**
  64511. * Gets the current class name
  64512. * @returns the class name
  64513. */
  64514. getClassName(): string;
  64515. /**
  64516. * Gets the value operand input component
  64517. */
  64518. get value(): NodeMaterialConnectionPoint;
  64519. /**
  64520. * Gets the first edge operand input component
  64521. */
  64522. get edge0(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the second edge operand input component
  64525. */
  64526. get edge1(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the output component
  64529. */
  64530. get output(): NodeMaterialConnectionPoint;
  64531. protected _buildBlock(state: NodeMaterialBuildState): this;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Block used to get the reciprocal (1 / x) of a value
  64537. */
  64538. export class ReciprocalBlock extends NodeMaterialBlock {
  64539. /**
  64540. * Creates a new ReciprocalBlock
  64541. * @param name defines the block name
  64542. */
  64543. constructor(name: string);
  64544. /**
  64545. * Gets the current class name
  64546. * @returns the class name
  64547. */
  64548. getClassName(): string;
  64549. /**
  64550. * Gets the input component
  64551. */
  64552. get input(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the output component
  64555. */
  64556. get output(): NodeMaterialConnectionPoint;
  64557. protected _buildBlock(state: NodeMaterialBuildState): this;
  64558. }
  64559. }
  64560. declare module BABYLON {
  64561. /**
  64562. * Block used to replace a color by another one
  64563. */
  64564. export class ReplaceColorBlock extends NodeMaterialBlock {
  64565. /**
  64566. * Creates a new ReplaceColorBlock
  64567. * @param name defines the block name
  64568. */
  64569. constructor(name: string);
  64570. /**
  64571. * Gets the current class name
  64572. * @returns the class name
  64573. */
  64574. getClassName(): string;
  64575. /**
  64576. * Gets the value input component
  64577. */
  64578. get value(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the reference input component
  64581. */
  64582. get reference(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the distance input component
  64585. */
  64586. get distance(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the replacement input component
  64589. */
  64590. get replacement(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the output component
  64593. */
  64594. get output(): NodeMaterialConnectionPoint;
  64595. protected _buildBlock(state: NodeMaterialBuildState): this;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * Block used to posterize a value
  64601. * @see https://en.wikipedia.org/wiki/Posterization
  64602. */
  64603. export class PosterizeBlock extends NodeMaterialBlock {
  64604. /**
  64605. * Creates a new PosterizeBlock
  64606. * @param name defines the block name
  64607. */
  64608. constructor(name: string);
  64609. /**
  64610. * Gets the current class name
  64611. * @returns the class name
  64612. */
  64613. getClassName(): string;
  64614. /**
  64615. * Gets the value input component
  64616. */
  64617. get value(): NodeMaterialConnectionPoint;
  64618. /**
  64619. * Gets the steps input component
  64620. */
  64621. get steps(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the output component
  64624. */
  64625. get output(): NodeMaterialConnectionPoint;
  64626. protected _buildBlock(state: NodeMaterialBuildState): this;
  64627. }
  64628. }
  64629. declare module BABYLON {
  64630. /**
  64631. * Operations supported by the Wave block
  64632. */
  64633. export enum WaveBlockKind {
  64634. /** SawTooth */
  64635. SawTooth = 0,
  64636. /** Square */
  64637. Square = 1,
  64638. /** Triangle */
  64639. Triangle = 2
  64640. }
  64641. /**
  64642. * Block used to apply wave operation to floats
  64643. */
  64644. export class WaveBlock extends NodeMaterialBlock {
  64645. /**
  64646. * Gets or sets the kibnd of wave to be applied by the block
  64647. */
  64648. kind: WaveBlockKind;
  64649. /**
  64650. * Creates a new WaveBlock
  64651. * @param name defines the block name
  64652. */
  64653. constructor(name: string);
  64654. /**
  64655. * Gets the current class name
  64656. * @returns the class name
  64657. */
  64658. getClassName(): string;
  64659. /**
  64660. * Gets the input component
  64661. */
  64662. get input(): NodeMaterialConnectionPoint;
  64663. /**
  64664. * Gets the output component
  64665. */
  64666. get output(): NodeMaterialConnectionPoint;
  64667. protected _buildBlock(state: NodeMaterialBuildState): this;
  64668. serialize(): any;
  64669. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64670. }
  64671. }
  64672. declare module BABYLON {
  64673. /**
  64674. * Class used to store a color step for the GradientBlock
  64675. */
  64676. export class GradientBlockColorStep {
  64677. private _step;
  64678. /**
  64679. * Gets value indicating which step this color is associated with (between 0 and 1)
  64680. */
  64681. get step(): number;
  64682. /**
  64683. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64684. */
  64685. set step(val: number);
  64686. private _color;
  64687. /**
  64688. * Gets the color associated with this step
  64689. */
  64690. get color(): Color3;
  64691. /**
  64692. * Sets the color associated with this step
  64693. */
  64694. set color(val: Color3);
  64695. /**
  64696. * Creates a new GradientBlockColorStep
  64697. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64698. * @param color defines the color associated with this step
  64699. */
  64700. constructor(step: number, color: Color3);
  64701. }
  64702. /**
  64703. * Block used to return a color from a gradient based on an input value between 0 and 1
  64704. */
  64705. export class GradientBlock extends NodeMaterialBlock {
  64706. /**
  64707. * Gets or sets the list of color steps
  64708. */
  64709. colorSteps: GradientBlockColorStep[];
  64710. /** Gets an observable raised when the value is changed */
  64711. onValueChangedObservable: Observable<GradientBlock>;
  64712. /** calls observable when the value is changed*/
  64713. colorStepsUpdated(): void;
  64714. /**
  64715. * Creates a new GradientBlock
  64716. * @param name defines the block name
  64717. */
  64718. constructor(name: string);
  64719. /**
  64720. * Gets the current class name
  64721. * @returns the class name
  64722. */
  64723. getClassName(): string;
  64724. /**
  64725. * Gets the gradient input component
  64726. */
  64727. get gradient(): NodeMaterialConnectionPoint;
  64728. /**
  64729. * Gets the output component
  64730. */
  64731. get output(): NodeMaterialConnectionPoint;
  64732. private _writeColorConstant;
  64733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64734. serialize(): any;
  64735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64736. protected _dumpPropertiesCode(): string;
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /**
  64741. * Block used to normalize lerp between 2 values
  64742. */
  64743. export class NLerpBlock extends NodeMaterialBlock {
  64744. /**
  64745. * Creates a new NLerpBlock
  64746. * @param name defines the block name
  64747. */
  64748. constructor(name: string);
  64749. /**
  64750. * Gets the current class name
  64751. * @returns the class name
  64752. */
  64753. getClassName(): string;
  64754. /**
  64755. * Gets the left operand input component
  64756. */
  64757. get left(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the right operand input component
  64760. */
  64761. get right(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the gradient operand input component
  64764. */
  64765. get gradient(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the output component
  64768. */
  64769. get output(): NodeMaterialConnectionPoint;
  64770. protected _buildBlock(state: NodeMaterialBuildState): this;
  64771. }
  64772. }
  64773. declare module BABYLON {
  64774. /**
  64775. * block used to Generate a Worley Noise 3D Noise Pattern
  64776. */
  64777. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64778. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64779. manhattanDistance: boolean;
  64780. /**
  64781. * Creates a new WorleyNoise3DBlock
  64782. * @param name defines the block name
  64783. */
  64784. constructor(name: string);
  64785. /**
  64786. * Gets the current class name
  64787. * @returns the class name
  64788. */
  64789. getClassName(): string;
  64790. /**
  64791. * Gets the seed input component
  64792. */
  64793. get seed(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the jitter input component
  64796. */
  64797. get jitter(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the output component
  64800. */
  64801. get output(): NodeMaterialConnectionPoint;
  64802. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64803. /**
  64804. * Exposes the properties to the UI?
  64805. */
  64806. protected _dumpPropertiesCode(): string;
  64807. /**
  64808. * Exposes the properties to the Seralize?
  64809. */
  64810. serialize(): any;
  64811. /**
  64812. * Exposes the properties to the deseralize?
  64813. */
  64814. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64815. }
  64816. }
  64817. declare module BABYLON {
  64818. /**
  64819. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64820. */
  64821. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64822. /**
  64823. * Creates a new SimplexPerlin3DBlock
  64824. * @param name defines the block name
  64825. */
  64826. constructor(name: string);
  64827. /**
  64828. * Gets the current class name
  64829. * @returns the class name
  64830. */
  64831. getClassName(): string;
  64832. /**
  64833. * Gets the seed operand input component
  64834. */
  64835. get seed(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the output component
  64838. */
  64839. get output(): NodeMaterialConnectionPoint;
  64840. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64841. }
  64842. }
  64843. declare module BABYLON {
  64844. /**
  64845. * Block used to blend normals
  64846. */
  64847. export class NormalBlendBlock extends NodeMaterialBlock {
  64848. /**
  64849. * Creates a new NormalBlendBlock
  64850. * @param name defines the block name
  64851. */
  64852. constructor(name: string);
  64853. /**
  64854. * Gets the current class name
  64855. * @returns the class name
  64856. */
  64857. getClassName(): string;
  64858. /**
  64859. * Gets the first input component
  64860. */
  64861. get normalMap0(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the second input component
  64864. */
  64865. get normalMap1(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the output component
  64868. */
  64869. get output(): NodeMaterialConnectionPoint;
  64870. protected _buildBlock(state: NodeMaterialBuildState): this;
  64871. }
  64872. }
  64873. declare module BABYLON {
  64874. /**
  64875. * Block used to rotate a 2d vector by a given angle
  64876. */
  64877. export class Rotate2dBlock extends NodeMaterialBlock {
  64878. /**
  64879. * Creates a new Rotate2dBlock
  64880. * @param name defines the block name
  64881. */
  64882. constructor(name: string);
  64883. /**
  64884. * Gets the current class name
  64885. * @returns the class name
  64886. */
  64887. getClassName(): string;
  64888. /**
  64889. * Gets the input vector
  64890. */
  64891. get input(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the input angle
  64894. */
  64895. get angle(): NodeMaterialConnectionPoint;
  64896. /**
  64897. * Gets the output component
  64898. */
  64899. get output(): NodeMaterialConnectionPoint;
  64900. autoConfigure(material: NodeMaterial): void;
  64901. protected _buildBlock(state: NodeMaterialBuildState): this;
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * Block used to get the reflected vector from a direction and a normal
  64907. */
  64908. export class ReflectBlock extends NodeMaterialBlock {
  64909. /**
  64910. * Creates a new ReflectBlock
  64911. * @param name defines the block name
  64912. */
  64913. constructor(name: string);
  64914. /**
  64915. * Gets the current class name
  64916. * @returns the class name
  64917. */
  64918. getClassName(): string;
  64919. /**
  64920. * Gets the incident component
  64921. */
  64922. get incident(): NodeMaterialConnectionPoint;
  64923. /**
  64924. * Gets the normal component
  64925. */
  64926. get normal(): NodeMaterialConnectionPoint;
  64927. /**
  64928. * Gets the output component
  64929. */
  64930. get output(): NodeMaterialConnectionPoint;
  64931. protected _buildBlock(state: NodeMaterialBuildState): this;
  64932. }
  64933. }
  64934. declare module BABYLON {
  64935. /**
  64936. * Block used to get the refracted vector from a direction and a normal
  64937. */
  64938. export class RefractBlock extends NodeMaterialBlock {
  64939. /**
  64940. * Creates a new RefractBlock
  64941. * @param name defines the block name
  64942. */
  64943. constructor(name: string);
  64944. /**
  64945. * Gets the current class name
  64946. * @returns the class name
  64947. */
  64948. getClassName(): string;
  64949. /**
  64950. * Gets the incident component
  64951. */
  64952. get incident(): NodeMaterialConnectionPoint;
  64953. /**
  64954. * Gets the normal component
  64955. */
  64956. get normal(): NodeMaterialConnectionPoint;
  64957. /**
  64958. * Gets the index of refraction component
  64959. */
  64960. get ior(): NodeMaterialConnectionPoint;
  64961. /**
  64962. * Gets the output component
  64963. */
  64964. get output(): NodeMaterialConnectionPoint;
  64965. protected _buildBlock(state: NodeMaterialBuildState): this;
  64966. }
  64967. }
  64968. declare module BABYLON {
  64969. /**
  64970. * Block used to desaturate a color
  64971. */
  64972. export class DesaturateBlock extends NodeMaterialBlock {
  64973. /**
  64974. * Creates a new DesaturateBlock
  64975. * @param name defines the block name
  64976. */
  64977. constructor(name: string);
  64978. /**
  64979. * Gets the current class name
  64980. * @returns the class name
  64981. */
  64982. getClassName(): string;
  64983. /**
  64984. * Gets the color operand input component
  64985. */
  64986. get color(): NodeMaterialConnectionPoint;
  64987. /**
  64988. * Gets the level operand input component
  64989. */
  64990. get level(): NodeMaterialConnectionPoint;
  64991. /**
  64992. * Gets the output component
  64993. */
  64994. get output(): NodeMaterialConnectionPoint;
  64995. protected _buildBlock(state: NodeMaterialBuildState): this;
  64996. }
  64997. }
  64998. declare module BABYLON {
  64999. /**
  65000. * Block used to implement the ambient occlusion module of the PBR material
  65001. */
  65002. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65003. /**
  65004. * Create a new AmbientOcclusionBlock
  65005. * @param name defines the block name
  65006. */
  65007. constructor(name: string);
  65008. /**
  65009. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65010. */
  65011. useAmbientInGrayScale: boolean;
  65012. /**
  65013. * Initialize the block and prepare the context for build
  65014. * @param state defines the state that will be used for the build
  65015. */
  65016. initialize(state: NodeMaterialBuildState): void;
  65017. /**
  65018. * Gets the current class name
  65019. * @returns the class name
  65020. */
  65021. getClassName(): string;
  65022. /**
  65023. * Gets the texture input component
  65024. */
  65025. get texture(): NodeMaterialConnectionPoint;
  65026. /**
  65027. * Gets the texture intensity component
  65028. */
  65029. get intensity(): NodeMaterialConnectionPoint;
  65030. /**
  65031. * Gets the direct light intensity input component
  65032. */
  65033. get directLightIntensity(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the ambient occlusion object output component
  65036. */
  65037. get ambientOcc(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the main code of the block (fragment side)
  65040. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65041. * @returns the shader code
  65042. */
  65043. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65045. protected _buildBlock(state: NodeMaterialBuildState): this;
  65046. protected _dumpPropertiesCode(): string;
  65047. serialize(): any;
  65048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65049. }
  65050. }
  65051. declare module BABYLON {
  65052. /**
  65053. * Block used to implement the reflection module of the PBR material
  65054. */
  65055. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65056. /** @hidden */
  65057. _defineLODReflectionAlpha: string;
  65058. /** @hidden */
  65059. _defineLinearSpecularReflection: string;
  65060. private _vEnvironmentIrradianceName;
  65061. /** @hidden */
  65062. _vReflectionMicrosurfaceInfosName: string;
  65063. /** @hidden */
  65064. _vReflectionInfosName: string;
  65065. /** @hidden */
  65066. _vReflectionFilteringInfoName: string;
  65067. private _scene;
  65068. /**
  65069. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65070. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65071. * It's less burden on the user side in the editor part.
  65072. */
  65073. /** @hidden */
  65074. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65075. /** @hidden */
  65076. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65077. /** @hidden */
  65078. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65079. /**
  65080. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65081. * diffuse part of the IBL.
  65082. */
  65083. useSphericalHarmonics: boolean;
  65084. /**
  65085. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65086. */
  65087. forceIrradianceInFragment: boolean;
  65088. /**
  65089. * Create a new ReflectionBlock
  65090. * @param name defines the block name
  65091. */
  65092. constructor(name: string);
  65093. /**
  65094. * Gets the current class name
  65095. * @returns the class name
  65096. */
  65097. getClassName(): string;
  65098. /**
  65099. * Gets the position input component
  65100. */
  65101. get position(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the world position input component
  65104. */
  65105. get worldPosition(): NodeMaterialConnectionPoint;
  65106. /**
  65107. * Gets the world normal input component
  65108. */
  65109. get worldNormal(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the world input component
  65112. */
  65113. get world(): NodeMaterialConnectionPoint;
  65114. /**
  65115. * Gets the camera (or eye) position component
  65116. */
  65117. get cameraPosition(): NodeMaterialConnectionPoint;
  65118. /**
  65119. * Gets the view input component
  65120. */
  65121. get view(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the color input component
  65124. */
  65125. get color(): NodeMaterialConnectionPoint;
  65126. /**
  65127. * Gets the reflection object output component
  65128. */
  65129. get reflection(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65132. */
  65133. get hasTexture(): boolean;
  65134. /**
  65135. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65136. */
  65137. get reflectionColor(): string;
  65138. protected _getTexture(): Nullable<BaseTexture>;
  65139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65141. /**
  65142. * Gets the code to inject in the vertex shader
  65143. * @param state current state of the node material building
  65144. * @returns the shader code
  65145. */
  65146. handleVertexSide(state: NodeMaterialBuildState): string;
  65147. /**
  65148. * Gets the main code of the block (fragment side)
  65149. * @param state current state of the node material building
  65150. * @param normalVarName name of the existing variable corresponding to the normal
  65151. * @returns the shader code
  65152. */
  65153. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65154. protected _buildBlock(state: NodeMaterialBuildState): this;
  65155. protected _dumpPropertiesCode(): string;
  65156. serialize(): any;
  65157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * Block used to implement the sheen module of the PBR material
  65163. */
  65164. export class SheenBlock extends NodeMaterialBlock {
  65165. /**
  65166. * Create a new SheenBlock
  65167. * @param name defines the block name
  65168. */
  65169. constructor(name: string);
  65170. /**
  65171. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65172. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65173. * making it easier to setup and tweak the effect
  65174. */
  65175. albedoScaling: boolean;
  65176. /**
  65177. * Defines if the sheen is linked to the sheen color.
  65178. */
  65179. linkSheenWithAlbedo: boolean;
  65180. /**
  65181. * Initialize the block and prepare the context for build
  65182. * @param state defines the state that will be used for the build
  65183. */
  65184. initialize(state: NodeMaterialBuildState): void;
  65185. /**
  65186. * Gets the current class name
  65187. * @returns the class name
  65188. */
  65189. getClassName(): string;
  65190. /**
  65191. * Gets the intensity input component
  65192. */
  65193. get intensity(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the color input component
  65196. */
  65197. get color(): NodeMaterialConnectionPoint;
  65198. /**
  65199. * Gets the roughness input component
  65200. */
  65201. get roughness(): NodeMaterialConnectionPoint;
  65202. /**
  65203. * Gets the sheen object output component
  65204. */
  65205. get sheen(): NodeMaterialConnectionPoint;
  65206. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65207. /**
  65208. * Gets the main code of the block (fragment side)
  65209. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65210. * @returns the shader code
  65211. */
  65212. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65213. protected _buildBlock(state: NodeMaterialBuildState): this;
  65214. protected _dumpPropertiesCode(): string;
  65215. serialize(): any;
  65216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65217. }
  65218. }
  65219. declare module BABYLON {
  65220. /**
  65221. * Block used to implement the reflectivity module of the PBR material
  65222. */
  65223. export class ReflectivityBlock extends NodeMaterialBlock {
  65224. private _metallicReflectanceColor;
  65225. private _metallicF0Factor;
  65226. /** @hidden */
  65227. _vMetallicReflectanceFactorsName: string;
  65228. /**
  65229. * The property below is set by the main PBR block prior to calling methods of this class.
  65230. */
  65231. /** @hidden */
  65232. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65233. /**
  65234. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65235. */
  65236. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65237. /**
  65238. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65239. */
  65240. useMetallnessFromMetallicTextureBlue: boolean;
  65241. /**
  65242. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65243. */
  65244. useRoughnessFromMetallicTextureAlpha: boolean;
  65245. /**
  65246. * Specifies if the metallic texture contains the roughness information in its green channel.
  65247. */
  65248. useRoughnessFromMetallicTextureGreen: boolean;
  65249. /**
  65250. * Create a new ReflectivityBlock
  65251. * @param name defines the block name
  65252. */
  65253. constructor(name: string);
  65254. /**
  65255. * Initialize the block and prepare the context for build
  65256. * @param state defines the state that will be used for the build
  65257. */
  65258. initialize(state: NodeMaterialBuildState): void;
  65259. /**
  65260. * Gets the current class name
  65261. * @returns the class name
  65262. */
  65263. getClassName(): string;
  65264. /**
  65265. * Gets the metallic input component
  65266. */
  65267. get metallic(): NodeMaterialConnectionPoint;
  65268. /**
  65269. * Gets the roughness input component
  65270. */
  65271. get roughness(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the texture input component
  65274. */
  65275. get texture(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the reflectivity object output component
  65278. */
  65279. get reflectivity(): NodeMaterialConnectionPoint;
  65280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65281. /**
  65282. * Gets the main code of the block (fragment side)
  65283. * @param state current state of the node material building
  65284. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65285. * @returns the shader code
  65286. */
  65287. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65289. protected _buildBlock(state: NodeMaterialBuildState): this;
  65290. protected _dumpPropertiesCode(): string;
  65291. serialize(): any;
  65292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65293. }
  65294. }
  65295. declare module BABYLON {
  65296. /**
  65297. * Block used to implement the anisotropy module of the PBR material
  65298. */
  65299. export class AnisotropyBlock extends NodeMaterialBlock {
  65300. /**
  65301. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65302. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65303. * It's less burden on the user side in the editor part.
  65304. */
  65305. /** @hidden */
  65306. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65307. /** @hidden */
  65308. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65309. /**
  65310. * Create a new AnisotropyBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Initialize the block and prepare the context for build
  65316. * @param state defines the state that will be used for the build
  65317. */
  65318. initialize(state: NodeMaterialBuildState): void;
  65319. /**
  65320. * Gets the current class name
  65321. * @returns the class name
  65322. */
  65323. getClassName(): string;
  65324. /**
  65325. * Gets the intensity input component
  65326. */
  65327. get intensity(): NodeMaterialConnectionPoint;
  65328. /**
  65329. * Gets the direction input component
  65330. */
  65331. get direction(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the texture input component
  65334. */
  65335. get texture(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the uv input component
  65338. */
  65339. get uv(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the worldTangent input component
  65342. */
  65343. get worldTangent(): NodeMaterialConnectionPoint;
  65344. /**
  65345. * Gets the anisotropy object output component
  65346. */
  65347. get anisotropy(): NodeMaterialConnectionPoint;
  65348. private _generateTBNSpace;
  65349. /**
  65350. * Gets the main code of the block (fragment side)
  65351. * @param state current state of the node material building
  65352. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65353. * @returns the shader code
  65354. */
  65355. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65356. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65357. protected _buildBlock(state: NodeMaterialBuildState): this;
  65358. }
  65359. }
  65360. declare module BABYLON {
  65361. /**
  65362. * Block used to implement the clear coat module of the PBR material
  65363. */
  65364. export class ClearCoatBlock extends NodeMaterialBlock {
  65365. private _scene;
  65366. /**
  65367. * Create a new ClearCoatBlock
  65368. * @param name defines the block name
  65369. */
  65370. constructor(name: string);
  65371. /**
  65372. * Initialize the block and prepare the context for build
  65373. * @param state defines the state that will be used for the build
  65374. */
  65375. initialize(state: NodeMaterialBuildState): void;
  65376. /**
  65377. * Gets the current class name
  65378. * @returns the class name
  65379. */
  65380. getClassName(): string;
  65381. /**
  65382. * Gets the intensity input component
  65383. */
  65384. get intensity(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the roughness input component
  65387. */
  65388. get roughness(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the ior input component
  65391. */
  65392. get ior(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the texture input component
  65395. */
  65396. get texture(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the bump texture input component
  65399. */
  65400. get bumpTexture(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the uv input component
  65403. */
  65404. get uv(): NodeMaterialConnectionPoint;
  65405. /**
  65406. * Gets the tint color input component
  65407. */
  65408. get tintColor(): NodeMaterialConnectionPoint;
  65409. /**
  65410. * Gets the tint "at distance" input component
  65411. */
  65412. get tintAtDistance(): NodeMaterialConnectionPoint;
  65413. /**
  65414. * Gets the tint thickness input component
  65415. */
  65416. get tintThickness(): NodeMaterialConnectionPoint;
  65417. /**
  65418. * Gets the world tangent input component
  65419. */
  65420. get worldTangent(): NodeMaterialConnectionPoint;
  65421. /**
  65422. * Gets the clear coat object output component
  65423. */
  65424. get clearcoat(): NodeMaterialConnectionPoint;
  65425. autoConfigure(material: NodeMaterial): void;
  65426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65428. private _generateTBNSpace;
  65429. /**
  65430. * Gets the main code of the block (fragment side)
  65431. * @param state current state of the node material building
  65432. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65433. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65434. * @param worldPosVarName name of the variable holding the world position
  65435. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65436. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65437. * @param worldNormalVarName name of the variable holding the world normal
  65438. * @returns the shader code
  65439. */
  65440. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65441. protected _buildBlock(state: NodeMaterialBuildState): this;
  65442. }
  65443. }
  65444. declare module BABYLON {
  65445. /**
  65446. * Block used to implement the sub surface module of the PBR material
  65447. */
  65448. export class SubSurfaceBlock extends NodeMaterialBlock {
  65449. /**
  65450. * Create a new SubSurfaceBlock
  65451. * @param name defines the block name
  65452. */
  65453. constructor(name: string);
  65454. /**
  65455. * Stores the intensity of the different subsurface effects in the thickness texture.
  65456. * * the green channel is the translucency intensity.
  65457. * * the blue channel is the scattering intensity.
  65458. * * the alpha channel is the refraction intensity.
  65459. */
  65460. useMaskFromThicknessTexture: boolean;
  65461. /**
  65462. * Initialize the block and prepare the context for build
  65463. * @param state defines the state that will be used for the build
  65464. */
  65465. initialize(state: NodeMaterialBuildState): void;
  65466. /**
  65467. * Gets the current class name
  65468. * @returns the class name
  65469. */
  65470. getClassName(): string;
  65471. /**
  65472. * Gets the min thickness input component
  65473. */
  65474. get minThickness(): NodeMaterialConnectionPoint;
  65475. /**
  65476. * Gets the max thickness input component
  65477. */
  65478. get maxThickness(): NodeMaterialConnectionPoint;
  65479. /**
  65480. * Gets the thickness texture component
  65481. */
  65482. get thicknessTexture(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the tint color input component
  65485. */
  65486. get tintColor(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the translucency intensity input component
  65489. */
  65490. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65491. /**
  65492. * Gets the translucency diffusion distance input component
  65493. */
  65494. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the refraction object parameters
  65497. */
  65498. get refraction(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the sub surface object output component
  65501. */
  65502. get subsurface(): NodeMaterialConnectionPoint;
  65503. autoConfigure(material: NodeMaterial): void;
  65504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65505. /**
  65506. * Gets the main code of the block (fragment side)
  65507. * @param state current state of the node material building
  65508. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65509. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65510. * @param worldPosVarName name of the variable holding the world position
  65511. * @returns the shader code
  65512. */
  65513. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65514. protected _buildBlock(state: NodeMaterialBuildState): this;
  65515. }
  65516. }
  65517. declare module BABYLON {
  65518. /**
  65519. * Block used to implement the PBR metallic/roughness model
  65520. */
  65521. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65522. /**
  65523. * Gets or sets the light associated with this block
  65524. */
  65525. light: Nullable<Light>;
  65526. private _lightId;
  65527. private _scene;
  65528. private _environmentBRDFTexture;
  65529. private _environmentBrdfSamplerName;
  65530. private _vNormalWName;
  65531. private _invertNormalName;
  65532. /**
  65533. * Create a new ReflectionBlock
  65534. * @param name defines the block name
  65535. */
  65536. constructor(name: string);
  65537. /**
  65538. * Intensity of the direct lights e.g. the four lights available in your scene.
  65539. * This impacts both the direct diffuse and specular highlights.
  65540. */
  65541. directIntensity: number;
  65542. /**
  65543. * Intensity of the environment e.g. how much the environment will light the object
  65544. * either through harmonics for rough material or through the refelction for shiny ones.
  65545. */
  65546. environmentIntensity: number;
  65547. /**
  65548. * This is a special control allowing the reduction of the specular highlights coming from the
  65549. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65550. */
  65551. specularIntensity: number;
  65552. /**
  65553. * Defines the falloff type used in this material.
  65554. * It by default is Physical.
  65555. */
  65556. lightFalloff: number;
  65557. /**
  65558. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65559. */
  65560. useAlphaFromAlbedoTexture: boolean;
  65561. /**
  65562. * Specifies that alpha test should be used
  65563. */
  65564. useAlphaTest: boolean;
  65565. /**
  65566. * Defines the alpha limits in alpha test mode.
  65567. */
  65568. alphaTestCutoff: number;
  65569. /**
  65570. * Specifies that alpha blending should be used
  65571. */
  65572. useAlphaBlending: boolean;
  65573. /**
  65574. * Defines if the alpha value should be determined via the rgb values.
  65575. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65576. */
  65577. opacityRGB: boolean;
  65578. /**
  65579. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65580. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65581. */
  65582. useRadianceOverAlpha: boolean;
  65583. /**
  65584. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65585. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65586. */
  65587. useSpecularOverAlpha: boolean;
  65588. /**
  65589. * Enables specular anti aliasing in the PBR shader.
  65590. * It will both interacts on the Geometry for analytical and IBL lighting.
  65591. * It also prefilter the roughness map based on the bump values.
  65592. */
  65593. enableSpecularAntiAliasing: boolean;
  65594. /**
  65595. * Enables realtime filtering on the texture.
  65596. */
  65597. realTimeFiltering: boolean;
  65598. /**
  65599. * Quality switch for realtime filtering
  65600. */
  65601. realTimeFilteringQuality: number;
  65602. /**
  65603. * Defines if the material uses energy conservation.
  65604. */
  65605. useEnergyConservation: boolean;
  65606. /**
  65607. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65608. * too much the area relying on ambient texture to define their ambient occlusion.
  65609. */
  65610. useRadianceOcclusion: boolean;
  65611. /**
  65612. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65613. * makes the reflect vector face the model (under horizon).
  65614. */
  65615. useHorizonOcclusion: boolean;
  65616. /**
  65617. * If set to true, no lighting calculations will be applied.
  65618. */
  65619. unlit: boolean;
  65620. /**
  65621. * Force normal to face away from face.
  65622. */
  65623. forceNormalForward: boolean;
  65624. /**
  65625. * Defines the material debug mode.
  65626. * It helps seeing only some components of the material while troubleshooting.
  65627. */
  65628. debugMode: number;
  65629. /**
  65630. * Specify from where on screen the debug mode should start.
  65631. * The value goes from -1 (full screen) to 1 (not visible)
  65632. * It helps with side by side comparison against the final render
  65633. * This defaults to 0
  65634. */
  65635. debugLimit: number;
  65636. /**
  65637. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65638. * You can use the factor to better multiply the final value.
  65639. */
  65640. debugFactor: number;
  65641. /**
  65642. * Initialize the block and prepare the context for build
  65643. * @param state defines the state that will be used for the build
  65644. */
  65645. initialize(state: NodeMaterialBuildState): void;
  65646. /**
  65647. * Gets the current class name
  65648. * @returns the class name
  65649. */
  65650. getClassName(): string;
  65651. /**
  65652. * Gets the world position input component
  65653. */
  65654. get worldPosition(): NodeMaterialConnectionPoint;
  65655. /**
  65656. * Gets the world normal input component
  65657. */
  65658. get worldNormal(): NodeMaterialConnectionPoint;
  65659. /**
  65660. * Gets the perturbed normal input component
  65661. */
  65662. get perturbedNormal(): NodeMaterialConnectionPoint;
  65663. /**
  65664. * Gets the camera position input component
  65665. */
  65666. get cameraPosition(): NodeMaterialConnectionPoint;
  65667. /**
  65668. * Gets the base color input component
  65669. */
  65670. get baseColor(): NodeMaterialConnectionPoint;
  65671. /**
  65672. * Gets the opacity texture input component
  65673. */
  65674. get opacityTexture(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the ambient color input component
  65677. */
  65678. get ambientColor(): NodeMaterialConnectionPoint;
  65679. /**
  65680. * Gets the reflectivity object parameters
  65681. */
  65682. get reflectivity(): NodeMaterialConnectionPoint;
  65683. /**
  65684. * Gets the ambient occlusion object parameters
  65685. */
  65686. get ambientOcc(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the reflection object parameters
  65689. */
  65690. get reflection(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the sheen object parameters
  65693. */
  65694. get sheen(): NodeMaterialConnectionPoint;
  65695. /**
  65696. * Gets the clear coat object parameters
  65697. */
  65698. get clearcoat(): NodeMaterialConnectionPoint;
  65699. /**
  65700. * Gets the sub surface object parameters
  65701. */
  65702. get subsurface(): NodeMaterialConnectionPoint;
  65703. /**
  65704. * Gets the anisotropy object parameters
  65705. */
  65706. get anisotropy(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the view matrix parameter
  65709. */
  65710. get view(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the ambient output component
  65713. */
  65714. get ambient(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the diffuse output component
  65717. */
  65718. get diffuse(): NodeMaterialConnectionPoint;
  65719. /**
  65720. * Gets the specular output component
  65721. */
  65722. get specular(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the sheen output component
  65725. */
  65726. get sheenDir(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the clear coat output component
  65729. */
  65730. get clearcoatDir(): NodeMaterialConnectionPoint;
  65731. /**
  65732. * Gets the indirect diffuse output component
  65733. */
  65734. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65735. /**
  65736. * Gets the indirect specular output component
  65737. */
  65738. get specularIndirect(): NodeMaterialConnectionPoint;
  65739. /**
  65740. * Gets the indirect sheen output component
  65741. */
  65742. get sheenIndirect(): NodeMaterialConnectionPoint;
  65743. /**
  65744. * Gets the indirect clear coat output component
  65745. */
  65746. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65747. /**
  65748. * Gets the refraction output component
  65749. */
  65750. get refraction(): NodeMaterialConnectionPoint;
  65751. /**
  65752. * Gets the global lighting output component
  65753. */
  65754. get lighting(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the shadow output component
  65757. */
  65758. get shadow(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the alpha output component
  65761. */
  65762. get alpha(): NodeMaterialConnectionPoint;
  65763. autoConfigure(material: NodeMaterial): void;
  65764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65765. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65767. private _injectVertexCode;
  65768. /**
  65769. * Gets the code corresponding to the albedo/opacity module
  65770. * @returns the shader code
  65771. */
  65772. getAlbedoOpacityCode(): string;
  65773. protected _buildBlock(state: NodeMaterialBuildState): this;
  65774. protected _dumpPropertiesCode(): string;
  65775. serialize(): any;
  65776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65777. }
  65778. }
  65779. declare module BABYLON {
  65780. /**
  65781. * Block used to compute value of one parameter modulo another
  65782. */
  65783. export class ModBlock extends NodeMaterialBlock {
  65784. /**
  65785. * Creates a new ModBlock
  65786. * @param name defines the block name
  65787. */
  65788. constructor(name: string);
  65789. /**
  65790. * Gets the current class name
  65791. * @returns the class name
  65792. */
  65793. getClassName(): string;
  65794. /**
  65795. * Gets the left operand input component
  65796. */
  65797. get left(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the right operand input component
  65800. */
  65801. get right(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the output component
  65804. */
  65805. get output(): NodeMaterialConnectionPoint;
  65806. protected _buildBlock(state: NodeMaterialBuildState): this;
  65807. }
  65808. }
  65809. declare module BABYLON {
  65810. /**
  65811. * Configuration for Draco compression
  65812. */
  65813. export interface IDracoCompressionConfiguration {
  65814. /**
  65815. * Configuration for the decoder.
  65816. */
  65817. decoder: {
  65818. /**
  65819. * The url to the WebAssembly module.
  65820. */
  65821. wasmUrl?: string;
  65822. /**
  65823. * The url to the WebAssembly binary.
  65824. */
  65825. wasmBinaryUrl?: string;
  65826. /**
  65827. * The url to the fallback JavaScript module.
  65828. */
  65829. fallbackUrl?: string;
  65830. };
  65831. }
  65832. /**
  65833. * Draco compression (https://google.github.io/draco/)
  65834. *
  65835. * This class wraps the Draco module.
  65836. *
  65837. * **Encoder**
  65838. *
  65839. * The encoder is not currently implemented.
  65840. *
  65841. * **Decoder**
  65842. *
  65843. * 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.
  65844. *
  65845. * To update the configuration, use the following code:
  65846. * ```javascript
  65847. * DracoCompression.Configuration = {
  65848. * decoder: {
  65849. * wasmUrl: "<url to the WebAssembly library>",
  65850. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65851. * fallbackUrl: "<url to the fallback JavaScript library>",
  65852. * }
  65853. * };
  65854. * ```
  65855. *
  65856. * 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.
  65857. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65858. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65859. *
  65860. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65861. * ```javascript
  65862. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65863. * ```
  65864. *
  65865. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65866. */
  65867. export class DracoCompression implements IDisposable {
  65868. private _workerPoolPromise?;
  65869. private _decoderModulePromise?;
  65870. /**
  65871. * The configuration. Defaults to the following urls:
  65872. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65873. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65874. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65875. */
  65876. static Configuration: IDracoCompressionConfiguration;
  65877. /**
  65878. * Returns true if the decoder configuration is available.
  65879. */
  65880. static get DecoderAvailable(): boolean;
  65881. /**
  65882. * Default number of workers to create when creating the draco compression object.
  65883. */
  65884. static DefaultNumWorkers: number;
  65885. private static GetDefaultNumWorkers;
  65886. private static _Default;
  65887. /**
  65888. * Default instance for the draco compression object.
  65889. */
  65890. static get Default(): DracoCompression;
  65891. /**
  65892. * Constructor
  65893. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65894. */
  65895. constructor(numWorkers?: number);
  65896. /**
  65897. * Stop all async operations and release resources.
  65898. */
  65899. dispose(): void;
  65900. /**
  65901. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65902. * @returns a promise that resolves when ready
  65903. */
  65904. whenReadyAsync(): Promise<void>;
  65905. /**
  65906. * Decode Draco compressed mesh data to vertex data.
  65907. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65908. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65909. * @returns A promise that resolves with the decoded vertex data
  65910. */
  65911. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65912. [kind: string]: number;
  65913. }): Promise<VertexData>;
  65914. }
  65915. }
  65916. declare module BABYLON {
  65917. /**
  65918. * Class for building Constructive Solid Geometry
  65919. */
  65920. export class CSG {
  65921. private polygons;
  65922. /**
  65923. * The world matrix
  65924. */
  65925. matrix: Matrix;
  65926. /**
  65927. * Stores the position
  65928. */
  65929. position: Vector3;
  65930. /**
  65931. * Stores the rotation
  65932. */
  65933. rotation: Vector3;
  65934. /**
  65935. * Stores the rotation quaternion
  65936. */
  65937. rotationQuaternion: Nullable<Quaternion>;
  65938. /**
  65939. * Stores the scaling vector
  65940. */
  65941. scaling: Vector3;
  65942. /**
  65943. * Convert the Mesh to CSG
  65944. * @param mesh The Mesh to convert to CSG
  65945. * @returns A new CSG from the Mesh
  65946. */
  65947. static FromMesh(mesh: Mesh): CSG;
  65948. /**
  65949. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65950. * @param polygons Polygons used to construct a CSG solid
  65951. */
  65952. private static FromPolygons;
  65953. /**
  65954. * Clones, or makes a deep copy, of the CSG
  65955. * @returns A new CSG
  65956. */
  65957. clone(): CSG;
  65958. /**
  65959. * Unions this CSG with another CSG
  65960. * @param csg The CSG to union against this CSG
  65961. * @returns The unioned CSG
  65962. */
  65963. union(csg: CSG): CSG;
  65964. /**
  65965. * Unions this CSG with another CSG in place
  65966. * @param csg The CSG to union against this CSG
  65967. */
  65968. unionInPlace(csg: CSG): void;
  65969. /**
  65970. * Subtracts this CSG with another CSG
  65971. * @param csg The CSG to subtract against this CSG
  65972. * @returns A new CSG
  65973. */
  65974. subtract(csg: CSG): CSG;
  65975. /**
  65976. * Subtracts this CSG with another CSG in place
  65977. * @param csg The CSG to subtact against this CSG
  65978. */
  65979. subtractInPlace(csg: CSG): void;
  65980. /**
  65981. * Intersect this CSG with another CSG
  65982. * @param csg The CSG to intersect against this CSG
  65983. * @returns A new CSG
  65984. */
  65985. intersect(csg: CSG): CSG;
  65986. /**
  65987. * Intersects this CSG with another CSG in place
  65988. * @param csg The CSG to intersect against this CSG
  65989. */
  65990. intersectInPlace(csg: CSG): void;
  65991. /**
  65992. * Return a new CSG solid with solid and empty space switched. This solid is
  65993. * not modified.
  65994. * @returns A new CSG solid with solid and empty space switched
  65995. */
  65996. inverse(): CSG;
  65997. /**
  65998. * Inverses the CSG in place
  65999. */
  66000. inverseInPlace(): void;
  66001. /**
  66002. * This is used to keep meshes transformations so they can be restored
  66003. * when we build back a Babylon Mesh
  66004. * NB : All CSG operations are performed in world coordinates
  66005. * @param csg The CSG to copy the transform attributes from
  66006. * @returns This CSG
  66007. */
  66008. copyTransformAttributes(csg: CSG): CSG;
  66009. /**
  66010. * Build Raw mesh from CSG
  66011. * Coordinates here are in world space
  66012. * @param name The name of the mesh geometry
  66013. * @param scene The Scene
  66014. * @param keepSubMeshes Specifies if the submeshes should be kept
  66015. * @returns A new Mesh
  66016. */
  66017. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66018. /**
  66019. * Build Mesh from CSG taking material and transforms into account
  66020. * @param name The name of the Mesh
  66021. * @param material The material of the Mesh
  66022. * @param scene The Scene
  66023. * @param keepSubMeshes Specifies if submeshes should be kept
  66024. * @returns The new Mesh
  66025. */
  66026. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66027. }
  66028. }
  66029. declare module BABYLON {
  66030. /**
  66031. * Class used to create a trail following a mesh
  66032. */
  66033. export class TrailMesh extends Mesh {
  66034. private _generator;
  66035. private _autoStart;
  66036. private _running;
  66037. private _diameter;
  66038. private _length;
  66039. private _sectionPolygonPointsCount;
  66040. private _sectionVectors;
  66041. private _sectionNormalVectors;
  66042. private _beforeRenderObserver;
  66043. /**
  66044. * @constructor
  66045. * @param name The value used by scene.getMeshByName() to do a lookup.
  66046. * @param generator The mesh or transform node to generate a trail.
  66047. * @param scene The scene to add this mesh to.
  66048. * @param diameter Diameter of trailing mesh. Default is 1.
  66049. * @param length Length of trailing mesh. Default is 60.
  66050. * @param autoStart Automatically start trailing mesh. Default true.
  66051. */
  66052. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66053. /**
  66054. * "TrailMesh"
  66055. * @returns "TrailMesh"
  66056. */
  66057. getClassName(): string;
  66058. private _createMesh;
  66059. /**
  66060. * Start trailing mesh.
  66061. */
  66062. start(): void;
  66063. /**
  66064. * Stop trailing mesh.
  66065. */
  66066. stop(): void;
  66067. /**
  66068. * Update trailing mesh geometry.
  66069. */
  66070. update(): void;
  66071. /**
  66072. * Returns a new TrailMesh object.
  66073. * @param name is a string, the name given to the new mesh
  66074. * @param newGenerator use new generator object for cloned trail mesh
  66075. * @returns a new mesh
  66076. */
  66077. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66078. /**
  66079. * Serializes this trail mesh
  66080. * @param serializationObject object to write serialization to
  66081. */
  66082. serialize(serializationObject: any): void;
  66083. /**
  66084. * Parses a serialized trail mesh
  66085. * @param parsedMesh the serialized mesh
  66086. * @param scene the scene to create the trail mesh in
  66087. * @returns the created trail mesh
  66088. */
  66089. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66090. }
  66091. }
  66092. declare module BABYLON {
  66093. /**
  66094. * Class containing static functions to help procedurally build meshes
  66095. */
  66096. export class TiledBoxBuilder {
  66097. /**
  66098. * Creates a box mesh
  66099. * 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)
  66100. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66102. * * 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
  66103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66104. * @param name defines the name of the mesh
  66105. * @param options defines the options used to create the mesh
  66106. * @param scene defines the hosting scene
  66107. * @returns the box mesh
  66108. */
  66109. static CreateTiledBox(name: string, options: {
  66110. pattern?: number;
  66111. width?: number;
  66112. height?: number;
  66113. depth?: number;
  66114. tileSize?: number;
  66115. tileWidth?: number;
  66116. tileHeight?: number;
  66117. alignHorizontal?: number;
  66118. alignVertical?: number;
  66119. faceUV?: Vector4[];
  66120. faceColors?: Color4[];
  66121. sideOrientation?: number;
  66122. updatable?: boolean;
  66123. }, scene?: Nullable<Scene>): Mesh;
  66124. }
  66125. }
  66126. declare module BABYLON {
  66127. /**
  66128. * Class containing static functions to help procedurally build meshes
  66129. */
  66130. export class TorusKnotBuilder {
  66131. /**
  66132. * Creates a torus knot mesh
  66133. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66134. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66135. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66136. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66138. * * 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
  66139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66140. * @param name defines the name of the mesh
  66141. * @param options defines the options used to create the mesh
  66142. * @param scene defines the hosting scene
  66143. * @returns the torus knot mesh
  66144. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66145. */
  66146. static CreateTorusKnot(name: string, options: {
  66147. radius?: number;
  66148. tube?: number;
  66149. radialSegments?: number;
  66150. tubularSegments?: number;
  66151. p?: number;
  66152. q?: number;
  66153. updatable?: boolean;
  66154. sideOrientation?: number;
  66155. frontUVs?: Vector4;
  66156. backUVs?: Vector4;
  66157. }, scene: any): Mesh;
  66158. }
  66159. }
  66160. declare module BABYLON {
  66161. /**
  66162. * Polygon
  66163. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66164. */
  66165. export class Polygon {
  66166. /**
  66167. * Creates a rectangle
  66168. * @param xmin bottom X coord
  66169. * @param ymin bottom Y coord
  66170. * @param xmax top X coord
  66171. * @param ymax top Y coord
  66172. * @returns points that make the resulting rectation
  66173. */
  66174. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66175. /**
  66176. * Creates a circle
  66177. * @param radius radius of circle
  66178. * @param cx scale in x
  66179. * @param cy scale in y
  66180. * @param numberOfSides number of sides that make up the circle
  66181. * @returns points that make the resulting circle
  66182. */
  66183. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66184. /**
  66185. * Creates a polygon from input string
  66186. * @param input Input polygon data
  66187. * @returns the parsed points
  66188. */
  66189. static Parse(input: string): Vector2[];
  66190. /**
  66191. * Starts building a polygon from x and y coordinates
  66192. * @param x x coordinate
  66193. * @param y y coordinate
  66194. * @returns the started path2
  66195. */
  66196. static StartingAt(x: number, y: number): Path2;
  66197. }
  66198. /**
  66199. * Builds a polygon
  66200. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66201. */
  66202. export class PolygonMeshBuilder {
  66203. private _points;
  66204. private _outlinepoints;
  66205. private _holes;
  66206. private _name;
  66207. private _scene;
  66208. private _epoints;
  66209. private _eholes;
  66210. private _addToepoint;
  66211. /**
  66212. * Babylon reference to the earcut plugin.
  66213. */
  66214. bjsEarcut: any;
  66215. /**
  66216. * Creates a PolygonMeshBuilder
  66217. * @param name name of the builder
  66218. * @param contours Path of the polygon
  66219. * @param scene scene to add to when creating the mesh
  66220. * @param earcutInjection can be used to inject your own earcut reference
  66221. */
  66222. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66223. /**
  66224. * Adds a whole within the polygon
  66225. * @param hole Array of points defining the hole
  66226. * @returns this
  66227. */
  66228. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66229. /**
  66230. * Creates the polygon
  66231. * @param updatable If the mesh should be updatable
  66232. * @param depth The depth of the mesh created
  66233. * @returns the created mesh
  66234. */
  66235. build(updatable?: boolean, depth?: number): Mesh;
  66236. /**
  66237. * Creates the polygon
  66238. * @param depth The depth of the mesh created
  66239. * @returns the created VertexData
  66240. */
  66241. buildVertexData(depth?: number): VertexData;
  66242. /**
  66243. * Adds a side to the polygon
  66244. * @param positions points that make the polygon
  66245. * @param normals normals of the polygon
  66246. * @param uvs uvs of the polygon
  66247. * @param indices indices of the polygon
  66248. * @param bounds bounds of the polygon
  66249. * @param points points of the polygon
  66250. * @param depth depth of the polygon
  66251. * @param flip flip of the polygon
  66252. */
  66253. private addSide;
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /**
  66258. * Class containing static functions to help procedurally build meshes
  66259. */
  66260. export class PolygonBuilder {
  66261. /**
  66262. * Creates a polygon mesh
  66263. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66264. * * 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
  66265. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66267. * * 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)
  66268. * * Remember you can only change the shape positions, not their number when updating a polygon
  66269. * @param name defines the name of the mesh
  66270. * @param options defines the options used to create the mesh
  66271. * @param scene defines the hosting scene
  66272. * @param earcutInjection can be used to inject your own earcut reference
  66273. * @returns the polygon mesh
  66274. */
  66275. static CreatePolygon(name: string, options: {
  66276. shape: Vector3[];
  66277. holes?: Vector3[][];
  66278. depth?: number;
  66279. faceUV?: Vector4[];
  66280. faceColors?: Color4[];
  66281. updatable?: boolean;
  66282. sideOrientation?: number;
  66283. frontUVs?: Vector4;
  66284. backUVs?: Vector4;
  66285. wrap?: boolean;
  66286. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66287. /**
  66288. * Creates an extruded polygon mesh, with depth in the Y direction.
  66289. * * 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)
  66290. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66291. * @param name defines the name of the mesh
  66292. * @param options defines the options used to create the mesh
  66293. * @param scene defines the hosting scene
  66294. * @param earcutInjection can be used to inject your own earcut reference
  66295. * @returns the polygon mesh
  66296. */
  66297. static ExtrudePolygon(name: string, options: {
  66298. shape: Vector3[];
  66299. holes?: Vector3[][];
  66300. depth?: number;
  66301. faceUV?: Vector4[];
  66302. faceColors?: Color4[];
  66303. updatable?: boolean;
  66304. sideOrientation?: number;
  66305. frontUVs?: Vector4;
  66306. backUVs?: Vector4;
  66307. wrap?: boolean;
  66308. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66309. }
  66310. }
  66311. declare module BABYLON {
  66312. /**
  66313. * Class containing static functions to help procedurally build meshes
  66314. */
  66315. export class LatheBuilder {
  66316. /**
  66317. * Creates lathe mesh.
  66318. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66319. * * 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
  66320. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66321. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66322. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66323. * * 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
  66324. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66325. * * 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
  66326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66327. * * 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
  66328. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66330. * @param name defines the name of the mesh
  66331. * @param options defines the options used to create the mesh
  66332. * @param scene defines the hosting scene
  66333. * @returns the lathe mesh
  66334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66335. */
  66336. static CreateLathe(name: string, options: {
  66337. shape: Vector3[];
  66338. radius?: number;
  66339. tessellation?: number;
  66340. clip?: number;
  66341. arc?: number;
  66342. closed?: boolean;
  66343. updatable?: boolean;
  66344. sideOrientation?: number;
  66345. frontUVs?: Vector4;
  66346. backUVs?: Vector4;
  66347. cap?: number;
  66348. invertUV?: boolean;
  66349. }, scene?: Nullable<Scene>): Mesh;
  66350. }
  66351. }
  66352. declare module BABYLON {
  66353. /**
  66354. * Class containing static functions to help procedurally build meshes
  66355. */
  66356. export class TiledPlaneBuilder {
  66357. /**
  66358. * Creates a tiled plane mesh
  66359. * * The parameter `pattern` will, depending on value, do nothing or
  66360. * * * flip (reflect about central vertical) alternate tiles across and up
  66361. * * * flip every tile on alternate rows
  66362. * * * rotate (180 degs) alternate tiles across and up
  66363. * * * rotate every tile on alternate rows
  66364. * * * flip and rotate alternate tiles across and up
  66365. * * * flip and rotate every tile on alternate rows
  66366. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66367. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66368. * * 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
  66369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66370. * * 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)
  66371. * * 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)
  66372. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66373. * @param name defines the name of the mesh
  66374. * @param options defines the options used to create the mesh
  66375. * @param scene defines the hosting scene
  66376. * @returns the box mesh
  66377. */
  66378. static CreateTiledPlane(name: string, options: {
  66379. pattern?: number;
  66380. tileSize?: number;
  66381. tileWidth?: number;
  66382. tileHeight?: number;
  66383. size?: number;
  66384. width?: number;
  66385. height?: number;
  66386. alignHorizontal?: number;
  66387. alignVertical?: number;
  66388. sideOrientation?: number;
  66389. frontUVs?: Vector4;
  66390. backUVs?: Vector4;
  66391. updatable?: boolean;
  66392. }, scene?: Nullable<Scene>): Mesh;
  66393. }
  66394. }
  66395. declare module BABYLON {
  66396. /**
  66397. * Class containing static functions to help procedurally build meshes
  66398. */
  66399. export class TubeBuilder {
  66400. /**
  66401. * Creates a tube mesh.
  66402. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66403. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66404. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66405. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66406. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66407. * * 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)
  66408. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66409. * * 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
  66410. * * 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
  66411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66412. * * 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
  66413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66415. * @param name defines the name of the mesh
  66416. * @param options defines the options used to create the mesh
  66417. * @param scene defines the hosting scene
  66418. * @returns the tube mesh
  66419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66420. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66421. */
  66422. static CreateTube(name: string, options: {
  66423. path: Vector3[];
  66424. radius?: number;
  66425. tessellation?: number;
  66426. radiusFunction?: {
  66427. (i: number, distance: number): number;
  66428. };
  66429. cap?: number;
  66430. arc?: number;
  66431. updatable?: boolean;
  66432. sideOrientation?: number;
  66433. frontUVs?: Vector4;
  66434. backUVs?: Vector4;
  66435. instance?: Mesh;
  66436. invertUV?: boolean;
  66437. }, scene?: Nullable<Scene>): Mesh;
  66438. }
  66439. }
  66440. declare module BABYLON {
  66441. /**
  66442. * Class containing static functions to help procedurally build meshes
  66443. */
  66444. export class IcoSphereBuilder {
  66445. /**
  66446. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66447. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66448. * * 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`)
  66449. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66450. * * 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
  66451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66452. * * 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
  66453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66454. * @param name defines the name of the mesh
  66455. * @param options defines the options used to create the mesh
  66456. * @param scene defines the hosting scene
  66457. * @returns the icosahedron mesh
  66458. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66459. */
  66460. static CreateIcoSphere(name: string, options: {
  66461. radius?: number;
  66462. radiusX?: number;
  66463. radiusY?: number;
  66464. radiusZ?: number;
  66465. flat?: boolean;
  66466. subdivisions?: number;
  66467. sideOrientation?: number;
  66468. frontUVs?: Vector4;
  66469. backUVs?: Vector4;
  66470. updatable?: boolean;
  66471. }, scene?: Nullable<Scene>): Mesh;
  66472. }
  66473. }
  66474. declare module BABYLON {
  66475. /**
  66476. * Class containing static functions to help procedurally build meshes
  66477. */
  66478. export class DecalBuilder {
  66479. /**
  66480. * Creates a decal mesh.
  66481. * 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
  66482. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66483. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66484. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66485. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66486. * @param name defines the name of the mesh
  66487. * @param sourceMesh defines the mesh where the decal must be applied
  66488. * @param options defines the options used to create the mesh
  66489. * @param scene defines the hosting scene
  66490. * @returns the decal mesh
  66491. * @see https://doc.babylonjs.com/how_to/decals
  66492. */
  66493. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66494. position?: Vector3;
  66495. normal?: Vector3;
  66496. size?: Vector3;
  66497. angle?: number;
  66498. }): Mesh;
  66499. }
  66500. }
  66501. declare module BABYLON {
  66502. /**
  66503. * Class containing static functions to help procedurally build meshes
  66504. */
  66505. export class MeshBuilder {
  66506. /**
  66507. * Creates a box mesh
  66508. * * The parameter `size` sets the size (float) of each box side (default 1)
  66509. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66510. * * 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)
  66511. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66513. * * 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
  66514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66515. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66516. * @param name defines the name of the mesh
  66517. * @param options defines the options used to create the mesh
  66518. * @param scene defines the hosting scene
  66519. * @returns the box mesh
  66520. */
  66521. static CreateBox(name: string, options: {
  66522. size?: number;
  66523. width?: number;
  66524. height?: number;
  66525. depth?: number;
  66526. faceUV?: Vector4[];
  66527. faceColors?: Color4[];
  66528. sideOrientation?: number;
  66529. frontUVs?: Vector4;
  66530. backUVs?: Vector4;
  66531. wrap?: boolean;
  66532. topBaseAt?: number;
  66533. bottomBaseAt?: number;
  66534. updatable?: boolean;
  66535. }, scene?: Nullable<Scene>): Mesh;
  66536. /**
  66537. * Creates a tiled box mesh
  66538. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66540. * @param name defines the name of the mesh
  66541. * @param options defines the options used to create the mesh
  66542. * @param scene defines the hosting scene
  66543. * @returns the tiled box mesh
  66544. */
  66545. static CreateTiledBox(name: string, options: {
  66546. pattern?: number;
  66547. size?: number;
  66548. width?: number;
  66549. height?: number;
  66550. depth: number;
  66551. tileSize?: number;
  66552. tileWidth?: number;
  66553. tileHeight?: number;
  66554. faceUV?: Vector4[];
  66555. faceColors?: Color4[];
  66556. alignHorizontal?: number;
  66557. alignVertical?: number;
  66558. sideOrientation?: number;
  66559. updatable?: boolean;
  66560. }, scene?: Nullable<Scene>): Mesh;
  66561. /**
  66562. * Creates a sphere mesh
  66563. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66564. * * 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`)
  66565. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66566. * * 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
  66567. * * 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)
  66568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66569. * * 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
  66570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66571. * @param name defines the name of the mesh
  66572. * @param options defines the options used to create the mesh
  66573. * @param scene defines the hosting scene
  66574. * @returns the sphere mesh
  66575. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66576. */
  66577. static CreateSphere(name: string, options: {
  66578. segments?: number;
  66579. diameter?: number;
  66580. diameterX?: number;
  66581. diameterY?: number;
  66582. diameterZ?: number;
  66583. arc?: number;
  66584. slice?: number;
  66585. sideOrientation?: number;
  66586. frontUVs?: Vector4;
  66587. backUVs?: Vector4;
  66588. updatable?: boolean;
  66589. }, scene?: Nullable<Scene>): Mesh;
  66590. /**
  66591. * Creates a plane polygonal mesh. By default, this is a disc
  66592. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66593. * * 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
  66594. * * 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
  66595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66596. * * 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
  66597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66598. * @param name defines the name of the mesh
  66599. * @param options defines the options used to create the mesh
  66600. * @param scene defines the hosting scene
  66601. * @returns the plane polygonal mesh
  66602. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66603. */
  66604. static CreateDisc(name: string, options: {
  66605. radius?: number;
  66606. tessellation?: number;
  66607. arc?: number;
  66608. updatable?: boolean;
  66609. sideOrientation?: number;
  66610. frontUVs?: Vector4;
  66611. backUVs?: Vector4;
  66612. }, scene?: Nullable<Scene>): Mesh;
  66613. /**
  66614. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66615. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66616. * * 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`)
  66617. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66618. * * 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
  66619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66620. * * 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
  66621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66622. * @param name defines the name of the mesh
  66623. * @param options defines the options used to create the mesh
  66624. * @param scene defines the hosting scene
  66625. * @returns the icosahedron mesh
  66626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66627. */
  66628. static CreateIcoSphere(name: string, options: {
  66629. radius?: number;
  66630. radiusX?: number;
  66631. radiusY?: number;
  66632. radiusZ?: number;
  66633. flat?: boolean;
  66634. subdivisions?: number;
  66635. sideOrientation?: number;
  66636. frontUVs?: Vector4;
  66637. backUVs?: Vector4;
  66638. updatable?: boolean;
  66639. }, scene?: Nullable<Scene>): Mesh;
  66640. /**
  66641. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66642. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66643. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66644. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66645. * * 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
  66646. * * 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
  66647. * * 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
  66648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66649. * * 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
  66650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66651. * * 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
  66652. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66653. * * 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
  66654. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66656. * @param name defines the name of the mesh
  66657. * @param options defines the options used to create the mesh
  66658. * @param scene defines the hosting scene
  66659. * @returns the ribbon mesh
  66660. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66661. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66662. */
  66663. static CreateRibbon(name: string, options: {
  66664. pathArray: Vector3[][];
  66665. closeArray?: boolean;
  66666. closePath?: boolean;
  66667. offset?: number;
  66668. updatable?: boolean;
  66669. sideOrientation?: number;
  66670. frontUVs?: Vector4;
  66671. backUVs?: Vector4;
  66672. instance?: Mesh;
  66673. invertUV?: boolean;
  66674. uvs?: Vector2[];
  66675. colors?: Color4[];
  66676. }, scene?: Nullable<Scene>): Mesh;
  66677. /**
  66678. * Creates a cylinder or a cone mesh
  66679. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66680. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66681. * * 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.
  66682. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66683. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66684. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66685. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66686. * * 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).
  66687. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66688. * * 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).
  66689. * * 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
  66690. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66691. * * 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
  66692. * * 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.
  66693. * * If `enclose` is false, a ring surface is one element.
  66694. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66695. * * 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
  66696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66697. * * 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
  66698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66699. * @param name defines the name of the mesh
  66700. * @param options defines the options used to create the mesh
  66701. * @param scene defines the hosting scene
  66702. * @returns the cylinder mesh
  66703. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66704. */
  66705. static CreateCylinder(name: string, options: {
  66706. height?: number;
  66707. diameterTop?: number;
  66708. diameterBottom?: number;
  66709. diameter?: number;
  66710. tessellation?: number;
  66711. subdivisions?: number;
  66712. arc?: number;
  66713. faceColors?: Color4[];
  66714. faceUV?: Vector4[];
  66715. updatable?: boolean;
  66716. hasRings?: boolean;
  66717. enclose?: boolean;
  66718. cap?: number;
  66719. sideOrientation?: number;
  66720. frontUVs?: Vector4;
  66721. backUVs?: Vector4;
  66722. }, scene?: Nullable<Scene>): Mesh;
  66723. /**
  66724. * Creates a torus mesh
  66725. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66726. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66727. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66729. * * 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
  66730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66731. * @param name defines the name of the mesh
  66732. * @param options defines the options used to create the mesh
  66733. * @param scene defines the hosting scene
  66734. * @returns the torus mesh
  66735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66736. */
  66737. static CreateTorus(name: string, options: {
  66738. diameter?: number;
  66739. thickness?: number;
  66740. tessellation?: number;
  66741. updatable?: boolean;
  66742. sideOrientation?: number;
  66743. frontUVs?: Vector4;
  66744. backUVs?: Vector4;
  66745. }, scene?: Nullable<Scene>): Mesh;
  66746. /**
  66747. * Creates a torus knot mesh
  66748. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66749. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66750. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66751. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66753. * * 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
  66754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66755. * @param name defines the name of the mesh
  66756. * @param options defines the options used to create the mesh
  66757. * @param scene defines the hosting scene
  66758. * @returns the torus knot mesh
  66759. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66760. */
  66761. static CreateTorusKnot(name: string, options: {
  66762. radius?: number;
  66763. tube?: number;
  66764. radialSegments?: number;
  66765. tubularSegments?: number;
  66766. p?: number;
  66767. q?: number;
  66768. updatable?: boolean;
  66769. sideOrientation?: number;
  66770. frontUVs?: Vector4;
  66771. backUVs?: Vector4;
  66772. }, scene?: Nullable<Scene>): Mesh;
  66773. /**
  66774. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66775. * * 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
  66776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66777. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66778. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66779. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66780. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66781. * * 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
  66782. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66785. * @param name defines the name of the new line system
  66786. * @param options defines the options used to create the line system
  66787. * @param scene defines the hosting scene
  66788. * @returns a new line system mesh
  66789. */
  66790. static CreateLineSystem(name: string, options: {
  66791. lines: Vector3[][];
  66792. updatable?: boolean;
  66793. instance?: Nullable<LinesMesh>;
  66794. colors?: Nullable<Color4[][]>;
  66795. useVertexAlpha?: boolean;
  66796. }, scene: Nullable<Scene>): LinesMesh;
  66797. /**
  66798. * Creates a line mesh
  66799. * 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
  66800. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66801. * * The parameter `points` is an array successive Vector3
  66802. * * 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
  66803. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66804. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66805. * * When updating an instance, remember that only point positions can change, not the number of points
  66806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66808. * @param name defines the name of the new line system
  66809. * @param options defines the options used to create the line system
  66810. * @param scene defines the hosting scene
  66811. * @returns a new line mesh
  66812. */
  66813. static CreateLines(name: string, options: {
  66814. points: Vector3[];
  66815. updatable?: boolean;
  66816. instance?: Nullable<LinesMesh>;
  66817. colors?: Color4[];
  66818. useVertexAlpha?: boolean;
  66819. }, scene?: Nullable<Scene>): LinesMesh;
  66820. /**
  66821. * Creates a dashed line mesh
  66822. * * 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
  66823. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66824. * * The parameter `points` is an array successive Vector3
  66825. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66826. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66827. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66828. * * 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
  66829. * * When updating an instance, remember that only point positions can change, not the number of points
  66830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66831. * @param name defines the name of the mesh
  66832. * @param options defines the options used to create the mesh
  66833. * @param scene defines the hosting scene
  66834. * @returns the dashed line mesh
  66835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66836. */
  66837. static CreateDashedLines(name: string, options: {
  66838. points: Vector3[];
  66839. dashSize?: number;
  66840. gapSize?: number;
  66841. dashNb?: number;
  66842. updatable?: boolean;
  66843. instance?: LinesMesh;
  66844. }, scene?: Nullable<Scene>): LinesMesh;
  66845. /**
  66846. * 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.
  66847. * * 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.
  66848. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66849. * * 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.
  66850. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66851. * * 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
  66852. * * 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
  66853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66855. * * 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
  66856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66858. * @param name defines the name of the mesh
  66859. * @param options defines the options used to create the mesh
  66860. * @param scene defines the hosting scene
  66861. * @returns the extruded shape mesh
  66862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66864. */
  66865. static ExtrudeShape(name: string, options: {
  66866. shape: Vector3[];
  66867. path: Vector3[];
  66868. scale?: number;
  66869. rotation?: number;
  66870. cap?: number;
  66871. updatable?: boolean;
  66872. sideOrientation?: number;
  66873. frontUVs?: Vector4;
  66874. backUVs?: Vector4;
  66875. instance?: Mesh;
  66876. invertUV?: boolean;
  66877. }, scene?: Nullable<Scene>): Mesh;
  66878. /**
  66879. * Creates an custom extruded shape mesh.
  66880. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66881. * * 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.
  66882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66883. * * 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
  66884. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66885. * * 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
  66886. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66887. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66888. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66889. * * 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
  66890. * * 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
  66891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66893. * * 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
  66894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66896. * @param name defines the name of the mesh
  66897. * @param options defines the options used to create the mesh
  66898. * @param scene defines the hosting scene
  66899. * @returns the custom extruded shape mesh
  66900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66903. */
  66904. static ExtrudeShapeCustom(name: string, options: {
  66905. shape: Vector3[];
  66906. path: Vector3[];
  66907. scaleFunction?: any;
  66908. rotationFunction?: any;
  66909. ribbonCloseArray?: boolean;
  66910. ribbonClosePath?: boolean;
  66911. cap?: number;
  66912. updatable?: boolean;
  66913. sideOrientation?: number;
  66914. frontUVs?: Vector4;
  66915. backUVs?: Vector4;
  66916. instance?: Mesh;
  66917. invertUV?: boolean;
  66918. }, scene?: Nullable<Scene>): Mesh;
  66919. /**
  66920. * Creates lathe mesh.
  66921. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66922. * * 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
  66923. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66924. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66925. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66926. * * 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
  66927. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66928. * * 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
  66929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66933. * @param name defines the name of the mesh
  66934. * @param options defines the options used to create the mesh
  66935. * @param scene defines the hosting scene
  66936. * @returns the lathe mesh
  66937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66938. */
  66939. static CreateLathe(name: string, options: {
  66940. shape: Vector3[];
  66941. radius?: number;
  66942. tessellation?: number;
  66943. clip?: number;
  66944. arc?: number;
  66945. closed?: boolean;
  66946. updatable?: boolean;
  66947. sideOrientation?: number;
  66948. frontUVs?: Vector4;
  66949. backUVs?: Vector4;
  66950. cap?: number;
  66951. invertUV?: boolean;
  66952. }, scene?: Nullable<Scene>): Mesh;
  66953. /**
  66954. * Creates a tiled plane mesh
  66955. * * You can set a limited pattern arrangement with the tiles
  66956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66957. * * 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
  66958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66959. * @param name defines the name of the mesh
  66960. * @param options defines the options used to create the mesh
  66961. * @param scene defines the hosting scene
  66962. * @returns the plane mesh
  66963. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66964. */
  66965. static CreateTiledPlane(name: string, options: {
  66966. pattern?: number;
  66967. tileSize?: number;
  66968. tileWidth?: number;
  66969. tileHeight?: number;
  66970. size?: number;
  66971. width?: number;
  66972. height?: number;
  66973. alignHorizontal?: number;
  66974. alignVertical?: number;
  66975. sideOrientation?: number;
  66976. frontUVs?: Vector4;
  66977. backUVs?: Vector4;
  66978. updatable?: boolean;
  66979. }, scene?: Nullable<Scene>): Mesh;
  66980. /**
  66981. * Creates a plane mesh
  66982. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66983. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66984. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66986. * * 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
  66987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66988. * @param name defines the name of the mesh
  66989. * @param options defines the options used to create the mesh
  66990. * @param scene defines the hosting scene
  66991. * @returns the plane mesh
  66992. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66993. */
  66994. static CreatePlane(name: string, options: {
  66995. size?: number;
  66996. width?: number;
  66997. height?: number;
  66998. sideOrientation?: number;
  66999. frontUVs?: Vector4;
  67000. backUVs?: Vector4;
  67001. updatable?: boolean;
  67002. sourcePlane?: Plane;
  67003. }, scene?: Nullable<Scene>): Mesh;
  67004. /**
  67005. * Creates a ground mesh
  67006. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67007. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67009. * @param name defines the name of the mesh
  67010. * @param options defines the options used to create the mesh
  67011. * @param scene defines the hosting scene
  67012. * @returns the ground mesh
  67013. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67014. */
  67015. static CreateGround(name: string, options: {
  67016. width?: number;
  67017. height?: number;
  67018. subdivisions?: number;
  67019. subdivisionsX?: number;
  67020. subdivisionsY?: number;
  67021. updatable?: boolean;
  67022. }, scene?: Nullable<Scene>): Mesh;
  67023. /**
  67024. * Creates a tiled ground mesh
  67025. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67026. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67027. * * 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
  67028. * * 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
  67029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67030. * @param name defines the name of the mesh
  67031. * @param options defines the options used to create the mesh
  67032. * @param scene defines the hosting scene
  67033. * @returns the tiled ground mesh
  67034. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67035. */
  67036. static CreateTiledGround(name: string, options: {
  67037. xmin: number;
  67038. zmin: number;
  67039. xmax: number;
  67040. zmax: number;
  67041. subdivisions?: {
  67042. w: number;
  67043. h: number;
  67044. };
  67045. precision?: {
  67046. w: number;
  67047. h: number;
  67048. };
  67049. updatable?: boolean;
  67050. }, scene?: Nullable<Scene>): Mesh;
  67051. /**
  67052. * Creates a ground mesh from a height map
  67053. * * The parameter `url` sets the URL of the height map image resource.
  67054. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67055. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67056. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67057. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67058. * * 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.
  67059. * * 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).
  67060. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67062. * @param name defines the name of the mesh
  67063. * @param url defines the url to the height map
  67064. * @param options defines the options used to create the mesh
  67065. * @param scene defines the hosting scene
  67066. * @returns the ground mesh
  67067. * @see https://doc.babylonjs.com/babylon101/height_map
  67068. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67069. */
  67070. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67071. width?: number;
  67072. height?: number;
  67073. subdivisions?: number;
  67074. minHeight?: number;
  67075. maxHeight?: number;
  67076. colorFilter?: Color3;
  67077. alphaFilter?: number;
  67078. updatable?: boolean;
  67079. onReady?: (mesh: GroundMesh) => void;
  67080. }, scene?: Nullable<Scene>): GroundMesh;
  67081. /**
  67082. * Creates a polygon mesh
  67083. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67084. * * 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
  67085. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67087. * * 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)
  67088. * * Remember you can only change the shape positions, not their number when updating a polygon
  67089. * @param name defines the name of the mesh
  67090. * @param options defines the options used to create the mesh
  67091. * @param scene defines the hosting scene
  67092. * @param earcutInjection can be used to inject your own earcut reference
  67093. * @returns the polygon mesh
  67094. */
  67095. static CreatePolygon(name: string, options: {
  67096. shape: Vector3[];
  67097. holes?: Vector3[][];
  67098. depth?: number;
  67099. faceUV?: Vector4[];
  67100. faceColors?: Color4[];
  67101. updatable?: boolean;
  67102. sideOrientation?: number;
  67103. frontUVs?: Vector4;
  67104. backUVs?: Vector4;
  67105. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67106. /**
  67107. * Creates an extruded polygon mesh, with depth in the Y direction.
  67108. * * 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)
  67109. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67110. * @param name defines the name of the mesh
  67111. * @param options defines the options used to create the mesh
  67112. * @param scene defines the hosting scene
  67113. * @param earcutInjection can be used to inject your own earcut reference
  67114. * @returns the polygon mesh
  67115. */
  67116. static ExtrudePolygon(name: string, options: {
  67117. shape: Vector3[];
  67118. holes?: Vector3[][];
  67119. depth?: number;
  67120. faceUV?: Vector4[];
  67121. faceColors?: Color4[];
  67122. updatable?: boolean;
  67123. sideOrientation?: number;
  67124. frontUVs?: Vector4;
  67125. backUVs?: Vector4;
  67126. wrap?: boolean;
  67127. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67128. /**
  67129. * Creates a tube mesh.
  67130. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67131. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67132. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67133. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67134. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67135. * * 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)
  67136. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67137. * * 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
  67138. * * 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
  67139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67140. * * 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
  67141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67143. * @param name defines the name of the mesh
  67144. * @param options defines the options used to create the mesh
  67145. * @param scene defines the hosting scene
  67146. * @returns the tube mesh
  67147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67148. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67149. */
  67150. static CreateTube(name: string, options: {
  67151. path: Vector3[];
  67152. radius?: number;
  67153. tessellation?: number;
  67154. radiusFunction?: {
  67155. (i: number, distance: number): number;
  67156. };
  67157. cap?: number;
  67158. arc?: number;
  67159. updatable?: boolean;
  67160. sideOrientation?: number;
  67161. frontUVs?: Vector4;
  67162. backUVs?: Vector4;
  67163. instance?: Mesh;
  67164. invertUV?: boolean;
  67165. }, scene?: Nullable<Scene>): Mesh;
  67166. /**
  67167. * Creates a polyhedron mesh
  67168. * * 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
  67169. * * The parameter `size` (positive float, default 1) sets the polygon size
  67170. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67171. * * 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`
  67172. * * 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
  67173. * * 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)`)
  67174. * * 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
  67175. * * 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
  67176. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67177. * * 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
  67178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67179. * @param name defines the name of the mesh
  67180. * @param options defines the options used to create the mesh
  67181. * @param scene defines the hosting scene
  67182. * @returns the polyhedron mesh
  67183. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67184. */
  67185. static CreatePolyhedron(name: string, options: {
  67186. type?: number;
  67187. size?: number;
  67188. sizeX?: number;
  67189. sizeY?: number;
  67190. sizeZ?: number;
  67191. custom?: any;
  67192. faceUV?: Vector4[];
  67193. faceColors?: Color4[];
  67194. flat?: boolean;
  67195. updatable?: boolean;
  67196. sideOrientation?: number;
  67197. frontUVs?: Vector4;
  67198. backUVs?: Vector4;
  67199. }, scene?: Nullable<Scene>): Mesh;
  67200. /**
  67201. * Creates a decal mesh.
  67202. * 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
  67203. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67204. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67205. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67206. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67207. * @param name defines the name of the mesh
  67208. * @param sourceMesh defines the mesh where the decal must be applied
  67209. * @param options defines the options used to create the mesh
  67210. * @param scene defines the hosting scene
  67211. * @returns the decal mesh
  67212. * @see https://doc.babylonjs.com/how_to/decals
  67213. */
  67214. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67215. position?: Vector3;
  67216. normal?: Vector3;
  67217. size?: Vector3;
  67218. angle?: number;
  67219. }): Mesh;
  67220. /**
  67221. * Creates a Capsule Mesh
  67222. * @param name defines the name of the mesh.
  67223. * @param options the constructors options used to shape the mesh.
  67224. * @param scene defines the scene the mesh is scoped to.
  67225. * @returns the capsule mesh
  67226. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67227. */
  67228. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * A simplifier interface for future simplification implementations
  67234. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67235. */
  67236. export interface ISimplifier {
  67237. /**
  67238. * Simplification of a given mesh according to the given settings.
  67239. * Since this requires computation, it is assumed that the function runs async.
  67240. * @param settings The settings of the simplification, including quality and distance
  67241. * @param successCallback A callback that will be called after the mesh was simplified.
  67242. * @param errorCallback in case of an error, this callback will be called. optional.
  67243. */
  67244. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67245. }
  67246. /**
  67247. * Expected simplification settings.
  67248. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67249. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67250. */
  67251. export interface ISimplificationSettings {
  67252. /**
  67253. * Gets or sets the expected quality
  67254. */
  67255. quality: number;
  67256. /**
  67257. * Gets or sets the distance when this optimized version should be used
  67258. */
  67259. distance: number;
  67260. /**
  67261. * Gets an already optimized mesh
  67262. */
  67263. optimizeMesh?: boolean;
  67264. }
  67265. /**
  67266. * Class used to specify simplification options
  67267. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67268. */
  67269. export class SimplificationSettings implements ISimplificationSettings {
  67270. /** expected quality */
  67271. quality: number;
  67272. /** distance when this optimized version should be used */
  67273. distance: number;
  67274. /** already optimized mesh */
  67275. optimizeMesh?: boolean | undefined;
  67276. /**
  67277. * Creates a SimplificationSettings
  67278. * @param quality expected quality
  67279. * @param distance distance when this optimized version should be used
  67280. * @param optimizeMesh already optimized mesh
  67281. */
  67282. constructor(
  67283. /** expected quality */
  67284. quality: number,
  67285. /** distance when this optimized version should be used */
  67286. distance: number,
  67287. /** already optimized mesh */
  67288. optimizeMesh?: boolean | undefined);
  67289. }
  67290. /**
  67291. * Interface used to define a simplification task
  67292. */
  67293. export interface ISimplificationTask {
  67294. /**
  67295. * Array of settings
  67296. */
  67297. settings: Array<ISimplificationSettings>;
  67298. /**
  67299. * Simplification type
  67300. */
  67301. simplificationType: SimplificationType;
  67302. /**
  67303. * Mesh to simplify
  67304. */
  67305. mesh: Mesh;
  67306. /**
  67307. * Callback called on success
  67308. */
  67309. successCallback?: () => void;
  67310. /**
  67311. * Defines if parallel processing can be used
  67312. */
  67313. parallelProcessing: boolean;
  67314. }
  67315. /**
  67316. * Queue used to order the simplification tasks
  67317. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67318. */
  67319. export class SimplificationQueue {
  67320. private _simplificationArray;
  67321. /**
  67322. * Gets a boolean indicating that the process is still running
  67323. */
  67324. running: boolean;
  67325. /**
  67326. * Creates a new queue
  67327. */
  67328. constructor();
  67329. /**
  67330. * Adds a new simplification task
  67331. * @param task defines a task to add
  67332. */
  67333. addTask(task: ISimplificationTask): void;
  67334. /**
  67335. * Execute next task
  67336. */
  67337. executeNext(): void;
  67338. /**
  67339. * Execute a simplification task
  67340. * @param task defines the task to run
  67341. */
  67342. runSimplification(task: ISimplificationTask): void;
  67343. private getSimplifier;
  67344. }
  67345. /**
  67346. * The implemented types of simplification
  67347. * At the moment only Quadratic Error Decimation is implemented
  67348. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67349. */
  67350. export enum SimplificationType {
  67351. /** Quadratic error decimation */
  67352. QUADRATIC = 0
  67353. }
  67354. /**
  67355. * An implementation of the Quadratic Error simplification algorithm.
  67356. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67357. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67358. * @author RaananW
  67359. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67360. */
  67361. export class QuadraticErrorSimplification implements ISimplifier {
  67362. private _mesh;
  67363. private triangles;
  67364. private vertices;
  67365. private references;
  67366. private _reconstructedMesh;
  67367. /** Gets or sets the number pf sync interations */
  67368. syncIterations: number;
  67369. /** Gets or sets the aggressiveness of the simplifier */
  67370. aggressiveness: number;
  67371. /** Gets or sets the number of allowed iterations for decimation */
  67372. decimationIterations: number;
  67373. /** Gets or sets the espilon to use for bounding box computation */
  67374. boundingBoxEpsilon: number;
  67375. /**
  67376. * Creates a new QuadraticErrorSimplification
  67377. * @param _mesh defines the target mesh
  67378. */
  67379. constructor(_mesh: Mesh);
  67380. /**
  67381. * Simplification of a given mesh according to the given settings.
  67382. * Since this requires computation, it is assumed that the function runs async.
  67383. * @param settings The settings of the simplification, including quality and distance
  67384. * @param successCallback A callback that will be called after the mesh was simplified.
  67385. */
  67386. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67387. private runDecimation;
  67388. private initWithMesh;
  67389. private init;
  67390. private reconstructMesh;
  67391. private initDecimatedMesh;
  67392. private isFlipped;
  67393. private updateTriangles;
  67394. private identifyBorder;
  67395. private updateMesh;
  67396. private vertexError;
  67397. private calculateError;
  67398. }
  67399. }
  67400. declare module BABYLON {
  67401. interface Scene {
  67402. /** @hidden (Backing field) */
  67403. _simplificationQueue: SimplificationQueue;
  67404. /**
  67405. * Gets or sets the simplification queue attached to the scene
  67406. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67407. */
  67408. simplificationQueue: SimplificationQueue;
  67409. }
  67410. interface Mesh {
  67411. /**
  67412. * Simplify the mesh according to the given array of settings.
  67413. * Function will return immediately and will simplify async
  67414. * @param settings a collection of simplification settings
  67415. * @param parallelProcessing should all levels calculate parallel or one after the other
  67416. * @param simplificationType the type of simplification to run
  67417. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67418. * @returns the current mesh
  67419. */
  67420. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67421. }
  67422. /**
  67423. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67424. * created in a scene
  67425. */
  67426. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67427. /**
  67428. * The component name helpfull to identify the component in the list of scene components.
  67429. */
  67430. readonly name: string;
  67431. /**
  67432. * The scene the component belongs to.
  67433. */
  67434. scene: Scene;
  67435. /**
  67436. * Creates a new instance of the component for the given scene
  67437. * @param scene Defines the scene to register the component in
  67438. */
  67439. constructor(scene: Scene);
  67440. /**
  67441. * Registers the component in a given scene
  67442. */
  67443. register(): void;
  67444. /**
  67445. * Rebuilds the elements related to this component in case of
  67446. * context lost for instance.
  67447. */
  67448. rebuild(): void;
  67449. /**
  67450. * Disposes the component and the associated ressources
  67451. */
  67452. dispose(): void;
  67453. private _beforeCameraUpdate;
  67454. }
  67455. }
  67456. declare module BABYLON {
  67457. interface Mesh {
  67458. /**
  67459. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67460. */
  67461. thinInstanceEnablePicking: boolean;
  67462. /**
  67463. * Creates a new thin instance
  67464. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67465. * @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
  67466. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67467. */
  67468. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67469. /**
  67470. * Adds the transformation (matrix) of the current mesh as a thin instance
  67471. * @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
  67472. * @returns the thin instance index number
  67473. */
  67474. thinInstanceAddSelf(refresh: boolean): number;
  67475. /**
  67476. * Registers a custom attribute to be used with thin instances
  67477. * @param kind name of the attribute
  67478. * @param stride size in floats of the attribute
  67479. */
  67480. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67481. /**
  67482. * Sets the matrix of a thin instance
  67483. * @param index index of the thin instance
  67484. * @param matrix matrix to set
  67485. * @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
  67486. */
  67487. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67488. /**
  67489. * Sets the value of a custom attribute for a thin instance
  67490. * @param kind name of the attribute
  67491. * @param index index of the thin instance
  67492. * @param value value to set
  67493. * @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
  67494. */
  67495. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67496. /**
  67497. * 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.
  67498. */
  67499. thinInstanceCount: number;
  67500. /**
  67501. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67502. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67503. * @param buffer buffer to set
  67504. * @param stride size in floats of each value of the buffer
  67505. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67506. */
  67507. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67508. /**
  67509. * Gets the list of world matrices
  67510. * @return an array containing all the world matrices from the thin instances
  67511. */
  67512. thinInstanceGetWorldMatrices(): Matrix[];
  67513. /**
  67514. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67515. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67516. */
  67517. thinInstanceBufferUpdated(kind: string): void;
  67518. /**
  67519. * Applies a partial update to a buffer directly on the GPU
  67520. * 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
  67521. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67522. * @param data the data to set in the GPU buffer
  67523. * @param offset the offset in the GPU buffer where to update the data
  67524. */
  67525. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67526. /**
  67527. * Refreshes the bounding info, taking into account all the thin instances defined
  67528. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67529. */
  67530. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67531. /** @hidden */
  67532. _thinInstanceInitializeUserStorage(): void;
  67533. /** @hidden */
  67534. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67535. /** @hidden */
  67536. _userThinInstanceBuffersStorage: {
  67537. data: {
  67538. [key: string]: Float32Array;
  67539. };
  67540. sizes: {
  67541. [key: string]: number;
  67542. };
  67543. vertexBuffers: {
  67544. [key: string]: Nullable<VertexBuffer>;
  67545. };
  67546. strides: {
  67547. [key: string]: number;
  67548. };
  67549. };
  67550. }
  67551. }
  67552. declare module BABYLON {
  67553. /**
  67554. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67555. */
  67556. export interface INavigationEnginePlugin {
  67557. /**
  67558. * plugin name
  67559. */
  67560. name: string;
  67561. /**
  67562. * Creates a navigation mesh
  67563. * @param meshes array of all the geometry used to compute the navigatio mesh
  67564. * @param parameters bunch of parameters used to filter geometry
  67565. */
  67566. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67567. /**
  67568. * Create a navigation mesh debug mesh
  67569. * @param scene is where the mesh will be added
  67570. * @returns debug display mesh
  67571. */
  67572. createDebugNavMesh(scene: Scene): Mesh;
  67573. /**
  67574. * Get a navigation mesh constrained position, closest to the parameter position
  67575. * @param position world position
  67576. * @returns the closest point to position constrained by the navigation mesh
  67577. */
  67578. getClosestPoint(position: Vector3): Vector3;
  67579. /**
  67580. * Get a navigation mesh constrained position, closest to the parameter position
  67581. * @param position world position
  67582. * @param result output the closest point to position constrained by the navigation mesh
  67583. */
  67584. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67585. /**
  67586. * Get a navigation mesh constrained position, within a particular radius
  67587. * @param position world position
  67588. * @param maxRadius the maximum distance to the constrained world position
  67589. * @returns the closest point to position constrained by the navigation mesh
  67590. */
  67591. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67592. /**
  67593. * Get a navigation mesh constrained position, within a particular radius
  67594. * @param position world position
  67595. * @param maxRadius the maximum distance to the constrained world position
  67596. * @param result output the closest point to position constrained by the navigation mesh
  67597. */
  67598. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67599. /**
  67600. * Compute the final position from a segment made of destination-position
  67601. * @param position world position
  67602. * @param destination world position
  67603. * @returns the resulting point along the navmesh
  67604. */
  67605. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67606. /**
  67607. * Compute the final position from a segment made of destination-position
  67608. * @param position world position
  67609. * @param destination world position
  67610. * @param result output the resulting point along the navmesh
  67611. */
  67612. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67613. /**
  67614. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67615. * @param start world position
  67616. * @param end world position
  67617. * @returns array containing world position composing the path
  67618. */
  67619. computePath(start: Vector3, end: Vector3): Vector3[];
  67620. /**
  67621. * If this plugin is supported
  67622. * @returns true if plugin is supported
  67623. */
  67624. isSupported(): boolean;
  67625. /**
  67626. * Create a new Crowd so you can add agents
  67627. * @param maxAgents the maximum agent count in the crowd
  67628. * @param maxAgentRadius the maximum radius an agent can have
  67629. * @param scene to attach the crowd to
  67630. * @returns the crowd you can add agents to
  67631. */
  67632. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67633. /**
  67634. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67635. * The queries will try to find a solution within those bounds
  67636. * default is (1,1,1)
  67637. * @param extent x,y,z value that define the extent around the queries point of reference
  67638. */
  67639. setDefaultQueryExtent(extent: Vector3): void;
  67640. /**
  67641. * Get the Bounding box extent specified by setDefaultQueryExtent
  67642. * @returns the box extent values
  67643. */
  67644. getDefaultQueryExtent(): Vector3;
  67645. /**
  67646. * build the navmesh from a previously saved state using getNavmeshData
  67647. * @param data the Uint8Array returned by getNavmeshData
  67648. */
  67649. buildFromNavmeshData(data: Uint8Array): void;
  67650. /**
  67651. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67652. * @returns data the Uint8Array that can be saved and reused
  67653. */
  67654. getNavmeshData(): Uint8Array;
  67655. /**
  67656. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67657. * @param result output the box extent values
  67658. */
  67659. getDefaultQueryExtentToRef(result: Vector3): void;
  67660. /**
  67661. * Release all resources
  67662. */
  67663. dispose(): void;
  67664. }
  67665. /**
  67666. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67667. */
  67668. export interface ICrowd {
  67669. /**
  67670. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67671. * You can attach anything to that node. The node position is updated in the scene update tick.
  67672. * @param pos world position that will be constrained by the navigation mesh
  67673. * @param parameters agent parameters
  67674. * @param transform hooked to the agent that will be update by the scene
  67675. * @returns agent index
  67676. */
  67677. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67678. /**
  67679. * Returns the agent position in world space
  67680. * @param index agent index returned by addAgent
  67681. * @returns world space position
  67682. */
  67683. getAgentPosition(index: number): Vector3;
  67684. /**
  67685. * Gets the agent position result in world space
  67686. * @param index agent index returned by addAgent
  67687. * @param result output world space position
  67688. */
  67689. getAgentPositionToRef(index: number, result: Vector3): void;
  67690. /**
  67691. * Gets the agent velocity in world space
  67692. * @param index agent index returned by addAgent
  67693. * @returns world space velocity
  67694. */
  67695. getAgentVelocity(index: number): Vector3;
  67696. /**
  67697. * Gets the agent velocity result in world space
  67698. * @param index agent index returned by addAgent
  67699. * @param result output world space velocity
  67700. */
  67701. getAgentVelocityToRef(index: number, result: Vector3): void;
  67702. /**
  67703. * remove a particular agent previously created
  67704. * @param index agent index returned by addAgent
  67705. */
  67706. removeAgent(index: number): void;
  67707. /**
  67708. * get the list of all agents attached to this crowd
  67709. * @returns list of agent indices
  67710. */
  67711. getAgents(): number[];
  67712. /**
  67713. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67714. * @param deltaTime in seconds
  67715. */
  67716. update(deltaTime: number): void;
  67717. /**
  67718. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67719. * @param index agent index returned by addAgent
  67720. * @param destination targeted world position
  67721. */
  67722. agentGoto(index: number, destination: Vector3): void;
  67723. /**
  67724. * Teleport the agent to a new position
  67725. * @param index agent index returned by addAgent
  67726. * @param destination targeted world position
  67727. */
  67728. agentTeleport(index: number, destination: Vector3): void;
  67729. /**
  67730. * Update agent parameters
  67731. * @param index agent index returned by addAgent
  67732. * @param parameters agent parameters
  67733. */
  67734. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67735. /**
  67736. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67737. * The queries will try to find a solution within those bounds
  67738. * default is (1,1,1)
  67739. * @param extent x,y,z value that define the extent around the queries point of reference
  67740. */
  67741. setDefaultQueryExtent(extent: Vector3): void;
  67742. /**
  67743. * Get the Bounding box extent specified by setDefaultQueryExtent
  67744. * @returns the box extent values
  67745. */
  67746. getDefaultQueryExtent(): Vector3;
  67747. /**
  67748. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67749. * @param result output the box extent values
  67750. */
  67751. getDefaultQueryExtentToRef(result: Vector3): void;
  67752. /**
  67753. * Release all resources
  67754. */
  67755. dispose(): void;
  67756. }
  67757. /**
  67758. * Configures an agent
  67759. */
  67760. export interface IAgentParameters {
  67761. /**
  67762. * Agent radius. [Limit: >= 0]
  67763. */
  67764. radius: number;
  67765. /**
  67766. * Agent height. [Limit: > 0]
  67767. */
  67768. height: number;
  67769. /**
  67770. * Maximum allowed acceleration. [Limit: >= 0]
  67771. */
  67772. maxAcceleration: number;
  67773. /**
  67774. * Maximum allowed speed. [Limit: >= 0]
  67775. */
  67776. maxSpeed: number;
  67777. /**
  67778. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67779. */
  67780. collisionQueryRange: number;
  67781. /**
  67782. * The path visibility optimization range. [Limit: > 0]
  67783. */
  67784. pathOptimizationRange: number;
  67785. /**
  67786. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67787. */
  67788. separationWeight: number;
  67789. }
  67790. /**
  67791. * Configures the navigation mesh creation
  67792. */
  67793. export interface INavMeshParameters {
  67794. /**
  67795. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67796. */
  67797. cs: number;
  67798. /**
  67799. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67800. */
  67801. ch: number;
  67802. /**
  67803. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67804. */
  67805. walkableSlopeAngle: number;
  67806. /**
  67807. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67808. * be considered walkable. [Limit: >= 3] [Units: vx]
  67809. */
  67810. walkableHeight: number;
  67811. /**
  67812. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67813. */
  67814. walkableClimb: number;
  67815. /**
  67816. * The distance to erode/shrink the walkable area of the heightfield away from
  67817. * obstructions. [Limit: >=0] [Units: vx]
  67818. */
  67819. walkableRadius: number;
  67820. /**
  67821. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67822. */
  67823. maxEdgeLen: number;
  67824. /**
  67825. * The maximum distance a simplfied contour's border edges should deviate
  67826. * the original raw contour. [Limit: >=0] [Units: vx]
  67827. */
  67828. maxSimplificationError: number;
  67829. /**
  67830. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67831. */
  67832. minRegionArea: number;
  67833. /**
  67834. * Any regions with a span count smaller than this value will, if possible,
  67835. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67836. */
  67837. mergeRegionArea: number;
  67838. /**
  67839. * The maximum number of vertices allowed for polygons generated during the
  67840. * contour to polygon conversion process. [Limit: >= 3]
  67841. */
  67842. maxVertsPerPoly: number;
  67843. /**
  67844. * Sets the sampling distance to use when generating the detail mesh.
  67845. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67846. */
  67847. detailSampleDist: number;
  67848. /**
  67849. * The maximum distance the detail mesh surface should deviate from heightfield
  67850. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67851. */
  67852. detailSampleMaxError: number;
  67853. }
  67854. }
  67855. declare module BABYLON {
  67856. /**
  67857. * RecastJS navigation plugin
  67858. */
  67859. export class RecastJSPlugin implements INavigationEnginePlugin {
  67860. /**
  67861. * Reference to the Recast library
  67862. */
  67863. bjsRECAST: any;
  67864. /**
  67865. * plugin name
  67866. */
  67867. name: string;
  67868. /**
  67869. * the first navmesh created. We might extend this to support multiple navmeshes
  67870. */
  67871. navMesh: any;
  67872. /**
  67873. * Initializes the recastJS plugin
  67874. * @param recastInjection can be used to inject your own recast reference
  67875. */
  67876. constructor(recastInjection?: any);
  67877. /**
  67878. * Creates a navigation mesh
  67879. * @param meshes array of all the geometry used to compute the navigatio mesh
  67880. * @param parameters bunch of parameters used to filter geometry
  67881. */
  67882. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67883. /**
  67884. * Create a navigation mesh debug mesh
  67885. * @param scene is where the mesh will be added
  67886. * @returns debug display mesh
  67887. */
  67888. createDebugNavMesh(scene: Scene): Mesh;
  67889. /**
  67890. * Get a navigation mesh constrained position, closest to the parameter position
  67891. * @param position world position
  67892. * @returns the closest point to position constrained by the navigation mesh
  67893. */
  67894. getClosestPoint(position: Vector3): Vector3;
  67895. /**
  67896. * Get a navigation mesh constrained position, closest to the parameter position
  67897. * @param position world position
  67898. * @param result output the closest point to position constrained by the navigation mesh
  67899. */
  67900. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67901. /**
  67902. * Get a navigation mesh constrained position, within a particular radius
  67903. * @param position world position
  67904. * @param maxRadius the maximum distance to the constrained world position
  67905. * @returns the closest point to position constrained by the navigation mesh
  67906. */
  67907. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67908. /**
  67909. * Get a navigation mesh constrained position, within a particular radius
  67910. * @param position world position
  67911. * @param maxRadius the maximum distance to the constrained world position
  67912. * @param result output the closest point to position constrained by the navigation mesh
  67913. */
  67914. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67915. /**
  67916. * Compute the final position from a segment made of destination-position
  67917. * @param position world position
  67918. * @param destination world position
  67919. * @returns the resulting point along the navmesh
  67920. */
  67921. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67922. /**
  67923. * Compute the final position from a segment made of destination-position
  67924. * @param position world position
  67925. * @param destination world position
  67926. * @param result output the resulting point along the navmesh
  67927. */
  67928. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67929. /**
  67930. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67931. * @param start world position
  67932. * @param end world position
  67933. * @returns array containing world position composing the path
  67934. */
  67935. computePath(start: Vector3, end: Vector3): Vector3[];
  67936. /**
  67937. * Create a new Crowd so you can add agents
  67938. * @param maxAgents the maximum agent count in the crowd
  67939. * @param maxAgentRadius the maximum radius an agent can have
  67940. * @param scene to attach the crowd to
  67941. * @returns the crowd you can add agents to
  67942. */
  67943. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67944. /**
  67945. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67946. * The queries will try to find a solution within those bounds
  67947. * default is (1,1,1)
  67948. * @param extent x,y,z value that define the extent around the queries point of reference
  67949. */
  67950. setDefaultQueryExtent(extent: Vector3): void;
  67951. /**
  67952. * Get the Bounding box extent specified by setDefaultQueryExtent
  67953. * @returns the box extent values
  67954. */
  67955. getDefaultQueryExtent(): Vector3;
  67956. /**
  67957. * build the navmesh from a previously saved state using getNavmeshData
  67958. * @param data the Uint8Array returned by getNavmeshData
  67959. */
  67960. buildFromNavmeshData(data: Uint8Array): void;
  67961. /**
  67962. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67963. * @returns data the Uint8Array that can be saved and reused
  67964. */
  67965. getNavmeshData(): Uint8Array;
  67966. /**
  67967. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67968. * @param result output the box extent values
  67969. */
  67970. getDefaultQueryExtentToRef(result: Vector3): void;
  67971. /**
  67972. * Disposes
  67973. */
  67974. dispose(): void;
  67975. /**
  67976. * If this plugin is supported
  67977. * @returns true if plugin is supported
  67978. */
  67979. isSupported(): boolean;
  67980. }
  67981. /**
  67982. * Recast detour crowd implementation
  67983. */
  67984. export class RecastJSCrowd implements ICrowd {
  67985. /**
  67986. * Recast/detour plugin
  67987. */
  67988. bjsRECASTPlugin: RecastJSPlugin;
  67989. /**
  67990. * Link to the detour crowd
  67991. */
  67992. recastCrowd: any;
  67993. /**
  67994. * One transform per agent
  67995. */
  67996. transforms: TransformNode[];
  67997. /**
  67998. * All agents created
  67999. */
  68000. agents: number[];
  68001. /**
  68002. * Link to the scene is kept to unregister the crowd from the scene
  68003. */
  68004. private _scene;
  68005. /**
  68006. * Observer for crowd updates
  68007. */
  68008. private _onBeforeAnimationsObserver;
  68009. /**
  68010. * Constructor
  68011. * @param plugin recastJS plugin
  68012. * @param maxAgents the maximum agent count in the crowd
  68013. * @param maxAgentRadius the maximum radius an agent can have
  68014. * @param scene to attach the crowd to
  68015. * @returns the crowd you can add agents to
  68016. */
  68017. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68018. /**
  68019. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68020. * You can attach anything to that node. The node position is updated in the scene update tick.
  68021. * @param pos world position that will be constrained by the navigation mesh
  68022. * @param parameters agent parameters
  68023. * @param transform hooked to the agent that will be update by the scene
  68024. * @returns agent index
  68025. */
  68026. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68027. /**
  68028. * Returns the agent position in world space
  68029. * @param index agent index returned by addAgent
  68030. * @returns world space position
  68031. */
  68032. getAgentPosition(index: number): Vector3;
  68033. /**
  68034. * Returns the agent position result in world space
  68035. * @param index agent index returned by addAgent
  68036. * @param result output world space position
  68037. */
  68038. getAgentPositionToRef(index: number, result: Vector3): void;
  68039. /**
  68040. * Returns the agent velocity in world space
  68041. * @param index agent index returned by addAgent
  68042. * @returns world space velocity
  68043. */
  68044. getAgentVelocity(index: number): Vector3;
  68045. /**
  68046. * Returns the agent velocity result in world space
  68047. * @param index agent index returned by addAgent
  68048. * @param result output world space velocity
  68049. */
  68050. getAgentVelocityToRef(index: number, result: Vector3): void;
  68051. /**
  68052. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68053. * @param index agent index returned by addAgent
  68054. * @param destination targeted world position
  68055. */
  68056. agentGoto(index: number, destination: Vector3): void;
  68057. /**
  68058. * Teleport the agent to a new position
  68059. * @param index agent index returned by addAgent
  68060. * @param destination targeted world position
  68061. */
  68062. agentTeleport(index: number, destination: Vector3): void;
  68063. /**
  68064. * Update agent parameters
  68065. * @param index agent index returned by addAgent
  68066. * @param parameters agent parameters
  68067. */
  68068. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68069. /**
  68070. * remove a particular agent previously created
  68071. * @param index agent index returned by addAgent
  68072. */
  68073. removeAgent(index: number): void;
  68074. /**
  68075. * get the list of all agents attached to this crowd
  68076. * @returns list of agent indices
  68077. */
  68078. getAgents(): number[];
  68079. /**
  68080. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68081. * @param deltaTime in seconds
  68082. */
  68083. update(deltaTime: number): void;
  68084. /**
  68085. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68086. * The queries will try to find a solution within those bounds
  68087. * default is (1,1,1)
  68088. * @param extent x,y,z value that define the extent around the queries point of reference
  68089. */
  68090. setDefaultQueryExtent(extent: Vector3): void;
  68091. /**
  68092. * Get the Bounding box extent specified by setDefaultQueryExtent
  68093. * @returns the box extent values
  68094. */
  68095. getDefaultQueryExtent(): Vector3;
  68096. /**
  68097. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68098. * @param result output the box extent values
  68099. */
  68100. getDefaultQueryExtentToRef(result: Vector3): void;
  68101. /**
  68102. * Release all resources
  68103. */
  68104. dispose(): void;
  68105. }
  68106. }
  68107. declare module BABYLON {
  68108. /**
  68109. * Class used to enable access to IndexedDB
  68110. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68111. */
  68112. export class Database implements IOfflineProvider {
  68113. private _callbackManifestChecked;
  68114. private _currentSceneUrl;
  68115. private _db;
  68116. private _enableSceneOffline;
  68117. private _enableTexturesOffline;
  68118. private _manifestVersionFound;
  68119. private _mustUpdateRessources;
  68120. private _hasReachedQuota;
  68121. private _isSupported;
  68122. private _idbFactory;
  68123. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68124. private static IsUASupportingBlobStorage;
  68125. /**
  68126. * Gets a boolean indicating if Database storate is enabled (off by default)
  68127. */
  68128. static IDBStorageEnabled: boolean;
  68129. /**
  68130. * Gets a boolean indicating if scene must be saved in the database
  68131. */
  68132. get enableSceneOffline(): boolean;
  68133. /**
  68134. * Gets a boolean indicating if textures must be saved in the database
  68135. */
  68136. get enableTexturesOffline(): boolean;
  68137. /**
  68138. * Creates a new Database
  68139. * @param urlToScene defines the url to load the scene
  68140. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68141. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68142. */
  68143. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68144. private static _ParseURL;
  68145. private static _ReturnFullUrlLocation;
  68146. private _checkManifestFile;
  68147. /**
  68148. * Open the database and make it available
  68149. * @param successCallback defines the callback to call on success
  68150. * @param errorCallback defines the callback to call on error
  68151. */
  68152. open(successCallback: () => void, errorCallback: () => void): void;
  68153. /**
  68154. * Loads an image from the database
  68155. * @param url defines the url to load from
  68156. * @param image defines the target DOM image
  68157. */
  68158. loadImage(url: string, image: HTMLImageElement): void;
  68159. private _loadImageFromDBAsync;
  68160. private _saveImageIntoDBAsync;
  68161. private _checkVersionFromDB;
  68162. private _loadVersionFromDBAsync;
  68163. private _saveVersionIntoDBAsync;
  68164. /**
  68165. * Loads a file from database
  68166. * @param url defines the URL to load from
  68167. * @param sceneLoaded defines a callback to call on success
  68168. * @param progressCallBack defines a callback to call when progress changed
  68169. * @param errorCallback defines a callback to call on error
  68170. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68171. */
  68172. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68173. private _loadFileAsync;
  68174. private _saveFileAsync;
  68175. /**
  68176. * Validates if xhr data is correct
  68177. * @param xhr defines the request to validate
  68178. * @param dataType defines the expected data type
  68179. * @returns true if data is correct
  68180. */
  68181. private static _ValidateXHRData;
  68182. }
  68183. }
  68184. declare module BABYLON {
  68185. /** @hidden */
  68186. export var gpuUpdateParticlesPixelShader: {
  68187. name: string;
  68188. shader: string;
  68189. };
  68190. }
  68191. declare module BABYLON {
  68192. /** @hidden */
  68193. export var gpuUpdateParticlesVertexShader: {
  68194. name: string;
  68195. shader: string;
  68196. };
  68197. }
  68198. declare module BABYLON {
  68199. /** @hidden */
  68200. export var clipPlaneFragmentDeclaration2: {
  68201. name: string;
  68202. shader: string;
  68203. };
  68204. }
  68205. declare module BABYLON {
  68206. /** @hidden */
  68207. export var gpuRenderParticlesPixelShader: {
  68208. name: string;
  68209. shader: string;
  68210. };
  68211. }
  68212. declare module BABYLON {
  68213. /** @hidden */
  68214. export var clipPlaneVertexDeclaration2: {
  68215. name: string;
  68216. shader: string;
  68217. };
  68218. }
  68219. declare module BABYLON {
  68220. /** @hidden */
  68221. export var gpuRenderParticlesVertexShader: {
  68222. name: string;
  68223. shader: string;
  68224. };
  68225. }
  68226. declare module BABYLON {
  68227. /**
  68228. * This represents a GPU particle system in Babylon
  68229. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68230. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68231. */
  68232. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68233. /**
  68234. * The layer mask we are rendering the particles through.
  68235. */
  68236. layerMask: number;
  68237. private _capacity;
  68238. private _activeCount;
  68239. private _currentActiveCount;
  68240. private _accumulatedCount;
  68241. private _renderEffect;
  68242. private _updateEffect;
  68243. private _buffer0;
  68244. private _buffer1;
  68245. private _spriteBuffer;
  68246. private _updateVAO;
  68247. private _renderVAO;
  68248. private _targetIndex;
  68249. private _sourceBuffer;
  68250. private _targetBuffer;
  68251. private _currentRenderId;
  68252. private _started;
  68253. private _stopped;
  68254. private _timeDelta;
  68255. private _randomTexture;
  68256. private _randomTexture2;
  68257. private _attributesStrideSize;
  68258. private _updateEffectOptions;
  68259. private _randomTextureSize;
  68260. private _actualFrame;
  68261. private _customEffect;
  68262. private readonly _rawTextureWidth;
  68263. /**
  68264. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68265. */
  68266. static get IsSupported(): boolean;
  68267. /**
  68268. * An event triggered when the system is disposed.
  68269. */
  68270. onDisposeObservable: Observable<IParticleSystem>;
  68271. /**
  68272. * An event triggered when the system is stopped
  68273. */
  68274. onStoppedObservable: Observable<IParticleSystem>;
  68275. /**
  68276. * Gets the maximum number of particles active at the same time.
  68277. * @returns The max number of active particles.
  68278. */
  68279. getCapacity(): number;
  68280. /**
  68281. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68282. * to override the particles.
  68283. */
  68284. forceDepthWrite: boolean;
  68285. /**
  68286. * Gets or set the number of active particles
  68287. */
  68288. get activeParticleCount(): number;
  68289. set activeParticleCount(value: number);
  68290. private _preWarmDone;
  68291. /**
  68292. * Specifies if the particles are updated in emitter local space or world space.
  68293. */
  68294. isLocal: boolean;
  68295. /** Gets or sets a matrix to use to compute projection */
  68296. defaultProjectionMatrix: Matrix;
  68297. /**
  68298. * Is this system ready to be used/rendered
  68299. * @return true if the system is ready
  68300. */
  68301. isReady(): boolean;
  68302. /**
  68303. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68304. * @returns True if it has been started, otherwise false.
  68305. */
  68306. isStarted(): boolean;
  68307. /**
  68308. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68309. * @returns True if it has been stopped, otherwise false.
  68310. */
  68311. isStopped(): boolean;
  68312. /**
  68313. * Gets a boolean indicating that the system is stopping
  68314. * @returns true if the system is currently stopping
  68315. */
  68316. isStopping(): boolean;
  68317. /**
  68318. * Gets the number of particles active at the same time.
  68319. * @returns The number of active particles.
  68320. */
  68321. getActiveCount(): number;
  68322. /**
  68323. * Starts the particle system and begins to emit
  68324. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68325. */
  68326. start(delay?: number): void;
  68327. /**
  68328. * Stops the particle system.
  68329. */
  68330. stop(): void;
  68331. /**
  68332. * Remove all active particles
  68333. */
  68334. reset(): void;
  68335. /**
  68336. * Returns the string "GPUParticleSystem"
  68337. * @returns a string containing the class name
  68338. */
  68339. getClassName(): string;
  68340. /**
  68341. * Gets the custom effect used to render the particles
  68342. * @param blendMode Blend mode for which the effect should be retrieved
  68343. * @returns The effect
  68344. */
  68345. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68346. /**
  68347. * Sets the custom effect used to render the particles
  68348. * @param effect The effect to set
  68349. * @param blendMode Blend mode for which the effect should be set
  68350. */
  68351. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68352. /** @hidden */
  68353. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68354. /**
  68355. * Observable that will be called just before the particles are drawn
  68356. */
  68357. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68358. /**
  68359. * Gets the name of the particle vertex shader
  68360. */
  68361. get vertexShaderName(): string;
  68362. private _colorGradientsTexture;
  68363. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68364. /**
  68365. * Adds a new color gradient
  68366. * @param gradient defines the gradient to use (between 0 and 1)
  68367. * @param color1 defines the color to affect to the specified gradient
  68368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68369. * @returns the current particle system
  68370. */
  68371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68372. private _refreshColorGradient;
  68373. /** Force the system to rebuild all gradients that need to be resync */
  68374. forceRefreshGradients(): void;
  68375. /**
  68376. * Remove a specific color gradient
  68377. * @param gradient defines the gradient to remove
  68378. * @returns the current particle system
  68379. */
  68380. removeColorGradient(gradient: number): GPUParticleSystem;
  68381. private _angularSpeedGradientsTexture;
  68382. private _sizeGradientsTexture;
  68383. private _velocityGradientsTexture;
  68384. private _limitVelocityGradientsTexture;
  68385. private _dragGradientsTexture;
  68386. private _addFactorGradient;
  68387. /**
  68388. * Adds a new size gradient
  68389. * @param gradient defines the gradient to use (between 0 and 1)
  68390. * @param factor defines the size factor to affect to the specified gradient
  68391. * @returns the current particle system
  68392. */
  68393. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68394. /**
  68395. * Remove a specific size gradient
  68396. * @param gradient defines the gradient to remove
  68397. * @returns the current particle system
  68398. */
  68399. removeSizeGradient(gradient: number): GPUParticleSystem;
  68400. private _refreshFactorGradient;
  68401. /**
  68402. * Adds a new angular speed gradient
  68403. * @param gradient defines the gradient to use (between 0 and 1)
  68404. * @param factor defines the angular speed to affect to the specified gradient
  68405. * @returns the current particle system
  68406. */
  68407. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68408. /**
  68409. * Remove a specific angular speed gradient
  68410. * @param gradient defines the gradient to remove
  68411. * @returns the current particle system
  68412. */
  68413. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68414. /**
  68415. * Adds a new velocity gradient
  68416. * @param gradient defines the gradient to use (between 0 and 1)
  68417. * @param factor defines the velocity to affect to the specified gradient
  68418. * @returns the current particle system
  68419. */
  68420. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68421. /**
  68422. * Remove a specific velocity gradient
  68423. * @param gradient defines the gradient to remove
  68424. * @returns the current particle system
  68425. */
  68426. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68427. /**
  68428. * Adds a new limit velocity gradient
  68429. * @param gradient defines the gradient to use (between 0 and 1)
  68430. * @param factor defines the limit velocity value to affect to the specified gradient
  68431. * @returns the current particle system
  68432. */
  68433. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68434. /**
  68435. * Remove a specific limit velocity gradient
  68436. * @param gradient defines the gradient to remove
  68437. * @returns the current particle system
  68438. */
  68439. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68440. /**
  68441. * Adds a new drag gradient
  68442. * @param gradient defines the gradient to use (between 0 and 1)
  68443. * @param factor defines the drag value to affect to the specified gradient
  68444. * @returns the current particle system
  68445. */
  68446. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68447. /**
  68448. * Remove a specific drag gradient
  68449. * @param gradient defines the gradient to remove
  68450. * @returns the current particle system
  68451. */
  68452. removeDragGradient(gradient: number): GPUParticleSystem;
  68453. /**
  68454. * Not supported by GPUParticleSystem
  68455. * @param gradient defines the gradient to use (between 0 and 1)
  68456. * @param factor defines the emit rate value to affect to the specified gradient
  68457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68458. * @returns the current particle system
  68459. */
  68460. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68461. /**
  68462. * Not supported by GPUParticleSystem
  68463. * @param gradient defines the gradient to remove
  68464. * @returns the current particle system
  68465. */
  68466. removeEmitRateGradient(gradient: number): IParticleSystem;
  68467. /**
  68468. * Not supported by GPUParticleSystem
  68469. * @param gradient defines the gradient to use (between 0 and 1)
  68470. * @param factor defines the start size value to affect to the specified gradient
  68471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68472. * @returns the current particle system
  68473. */
  68474. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68475. /**
  68476. * Not supported by GPUParticleSystem
  68477. * @param gradient defines the gradient to remove
  68478. * @returns the current particle system
  68479. */
  68480. removeStartSizeGradient(gradient: number): IParticleSystem;
  68481. /**
  68482. * Not supported by GPUParticleSystem
  68483. * @param gradient defines the gradient to use (between 0 and 1)
  68484. * @param min defines the color remap minimal range
  68485. * @param max defines the color remap maximal range
  68486. * @returns the current particle system
  68487. */
  68488. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68489. /**
  68490. * Not supported by GPUParticleSystem
  68491. * @param gradient defines the gradient to remove
  68492. * @returns the current particle system
  68493. */
  68494. removeColorRemapGradient(): IParticleSystem;
  68495. /**
  68496. * Not supported by GPUParticleSystem
  68497. * @param gradient defines the gradient to use (between 0 and 1)
  68498. * @param min defines the alpha remap minimal range
  68499. * @param max defines the alpha remap maximal range
  68500. * @returns the current particle system
  68501. */
  68502. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68503. /**
  68504. * Not supported by GPUParticleSystem
  68505. * @param gradient defines the gradient to remove
  68506. * @returns the current particle system
  68507. */
  68508. removeAlphaRemapGradient(): IParticleSystem;
  68509. /**
  68510. * Not supported by GPUParticleSystem
  68511. * @param gradient defines the gradient to use (between 0 and 1)
  68512. * @param color defines the color to affect to the specified gradient
  68513. * @returns the current particle system
  68514. */
  68515. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68516. /**
  68517. * Not supported by GPUParticleSystem
  68518. * @param gradient defines the gradient to remove
  68519. * @returns the current particle system
  68520. */
  68521. removeRampGradient(): IParticleSystem;
  68522. /**
  68523. * Not supported by GPUParticleSystem
  68524. * @returns the list of ramp gradients
  68525. */
  68526. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68527. /**
  68528. * Not supported by GPUParticleSystem
  68529. * Gets or sets a boolean indicating that ramp gradients must be used
  68530. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68531. */
  68532. get useRampGradients(): boolean;
  68533. set useRampGradients(value: boolean);
  68534. /**
  68535. * Not supported by GPUParticleSystem
  68536. * @param gradient defines the gradient to use (between 0 and 1)
  68537. * @param factor defines the life time factor to affect to the specified gradient
  68538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68539. * @returns the current particle system
  68540. */
  68541. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68542. /**
  68543. * Not supported by GPUParticleSystem
  68544. * @param gradient defines the gradient to remove
  68545. * @returns the current particle system
  68546. */
  68547. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68548. /**
  68549. * Instantiates a GPU particle system.
  68550. * 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.
  68551. * @param name The name of the particle system
  68552. * @param options The options used to create the system
  68553. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68554. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68555. * @param customEffect a custom effect used to change the way particles are rendered by default
  68556. */
  68557. constructor(name: string, options: Partial<{
  68558. capacity: number;
  68559. randomTextureSize: number;
  68560. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68561. protected _reset(): void;
  68562. private _createUpdateVAO;
  68563. private _createRenderVAO;
  68564. private _initialize;
  68565. /** @hidden */
  68566. _recreateUpdateEffect(): void;
  68567. private _getEffect;
  68568. /**
  68569. * Fill the defines array according to the current settings of the particle system
  68570. * @param defines Array to be updated
  68571. * @param blendMode blend mode to take into account when updating the array
  68572. */
  68573. fillDefines(defines: Array<string>, blendMode?: number): void;
  68574. /**
  68575. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68576. * @param uniforms Uniforms array to fill
  68577. * @param attributes Attributes array to fill
  68578. * @param samplers Samplers array to fill
  68579. */
  68580. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68581. /** @hidden */
  68582. _recreateRenderEffect(): Effect;
  68583. /**
  68584. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68585. * @param preWarm defines if we are in the pre-warmimg phase
  68586. */
  68587. animate(preWarm?: boolean): void;
  68588. private _createFactorGradientTexture;
  68589. private _createSizeGradientTexture;
  68590. private _createAngularSpeedGradientTexture;
  68591. private _createVelocityGradientTexture;
  68592. private _createLimitVelocityGradientTexture;
  68593. private _createDragGradientTexture;
  68594. private _createColorGradientTexture;
  68595. /**
  68596. * Renders the particle system in its current state
  68597. * @param preWarm defines if the system should only update the particles but not render them
  68598. * @returns the current number of particles
  68599. */
  68600. render(preWarm?: boolean): number;
  68601. /**
  68602. * Rebuilds the particle system
  68603. */
  68604. rebuild(): void;
  68605. private _releaseBuffers;
  68606. private _releaseVAOs;
  68607. /**
  68608. * Disposes the particle system and free the associated resources
  68609. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68610. */
  68611. dispose(disposeTexture?: boolean): void;
  68612. /**
  68613. * Clones the particle system.
  68614. * @param name The name of the cloned object
  68615. * @param newEmitter The new emitter to use
  68616. * @returns the cloned particle system
  68617. */
  68618. clone(name: string, newEmitter: any): GPUParticleSystem;
  68619. /**
  68620. * Serializes the particle system to a JSON object
  68621. * @param serializeTexture defines if the texture must be serialized as well
  68622. * @returns the JSON object
  68623. */
  68624. serialize(serializeTexture?: boolean): any;
  68625. /**
  68626. * Parses a JSON object to create a GPU particle system.
  68627. * @param parsedParticleSystem The JSON object to parse
  68628. * @param sceneOrEngine The scene or the engine to create the particle system in
  68629. * @param rootUrl The root url to use to load external dependencies like texture
  68630. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68631. * @returns the parsed GPU particle system
  68632. */
  68633. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68634. }
  68635. }
  68636. declare module BABYLON {
  68637. /**
  68638. * Represents a set of particle systems working together to create a specific effect
  68639. */
  68640. export class ParticleSystemSet implements IDisposable {
  68641. /**
  68642. * Gets or sets base Assets URL
  68643. */
  68644. static BaseAssetsUrl: string;
  68645. private _emitterCreationOptions;
  68646. private _emitterNode;
  68647. /**
  68648. * Gets the particle system list
  68649. */
  68650. systems: IParticleSystem[];
  68651. /**
  68652. * Gets the emitter node used with this set
  68653. */
  68654. get emitterNode(): Nullable<TransformNode>;
  68655. /**
  68656. * Creates a new emitter mesh as a sphere
  68657. * @param options defines the options used to create the sphere
  68658. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68659. * @param scene defines the hosting scene
  68660. */
  68661. setEmitterAsSphere(options: {
  68662. diameter: number;
  68663. segments: number;
  68664. color: Color3;
  68665. }, renderingGroupId: number, scene: Scene): void;
  68666. /**
  68667. * Starts all particle systems of the set
  68668. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68669. */
  68670. start(emitter?: AbstractMesh): void;
  68671. /**
  68672. * Release all associated resources
  68673. */
  68674. dispose(): void;
  68675. /**
  68676. * Serialize the set into a JSON compatible object
  68677. * @param serializeTexture defines if the texture must be serialized as well
  68678. * @returns a JSON compatible representation of the set
  68679. */
  68680. serialize(serializeTexture?: boolean): any;
  68681. /**
  68682. * Parse a new ParticleSystemSet from a serialized source
  68683. * @param data defines a JSON compatible representation of the set
  68684. * @param scene defines the hosting scene
  68685. * @param gpu defines if we want GPU particles or CPU particles
  68686. * @returns a new ParticleSystemSet
  68687. */
  68688. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /**
  68693. * This class is made for on one-liner static method to help creating particle system set.
  68694. */
  68695. export class ParticleHelper {
  68696. /**
  68697. * Gets or sets base Assets URL
  68698. */
  68699. static BaseAssetsUrl: string;
  68700. /** Define the Url to load snippets */
  68701. static SnippetUrl: string;
  68702. /**
  68703. * Create a default particle system that you can tweak
  68704. * @param emitter defines the emitter to use
  68705. * @param capacity defines the system capacity (default is 500 particles)
  68706. * @param scene defines the hosting scene
  68707. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68708. * @returns the new Particle system
  68709. */
  68710. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68711. /**
  68712. * This is the main static method (one-liner) of this helper to create different particle systems
  68713. * @param type This string represents the type to the particle system to create
  68714. * @param scene The scene where the particle system should live
  68715. * @param gpu If the system will use gpu
  68716. * @returns the ParticleSystemSet created
  68717. */
  68718. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68719. /**
  68720. * Static function used to export a particle system to a ParticleSystemSet variable.
  68721. * Please note that the emitter shape is not exported
  68722. * @param systems defines the particle systems to export
  68723. * @returns the created particle system set
  68724. */
  68725. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68726. /**
  68727. * Creates a particle system from a snippet saved in a remote file
  68728. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68729. * @param url defines the url to load from
  68730. * @param scene defines the hosting scene
  68731. * @param gpu If the system will use gpu
  68732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68733. * @returns a promise that will resolve to the new particle system
  68734. */
  68735. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68736. /**
  68737. * Creates a particle system from a snippet saved by the particle system editor
  68738. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68739. * @param scene defines the hosting scene
  68740. * @param gpu If the system will use gpu
  68741. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68742. * @returns a promise that will resolve to the new particle system
  68743. */
  68744. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68745. }
  68746. }
  68747. declare module BABYLON {
  68748. interface Engine {
  68749. /**
  68750. * Create an effect to use with particle systems.
  68751. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68752. * the particle system for which you want to create a custom effect in the last parameter
  68753. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68754. * @param uniformsNames defines a list of attribute names
  68755. * @param samplers defines an array of string used to represent textures
  68756. * @param defines defines the string containing the defines to use to compile the shaders
  68757. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68758. * @param onCompiled defines a function to call when the effect creation is successful
  68759. * @param onError defines a function to call when the effect creation has failed
  68760. * @param particleSystem the particle system you want to create the effect for
  68761. * @returns the new Effect
  68762. */
  68763. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68764. }
  68765. interface Mesh {
  68766. /**
  68767. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68768. * @returns an array of IParticleSystem
  68769. */
  68770. getEmittedParticleSystems(): IParticleSystem[];
  68771. /**
  68772. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68773. * @returns an array of IParticleSystem
  68774. */
  68775. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. /** Defines the 4 color options */
  68780. export enum PointColor {
  68781. /** color value */
  68782. Color = 2,
  68783. /** uv value */
  68784. UV = 1,
  68785. /** random value */
  68786. Random = 0,
  68787. /** stated value */
  68788. Stated = 3
  68789. }
  68790. /**
  68791. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68792. * 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.
  68793. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68794. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68795. *
  68796. * Full documentation here : TO BE ENTERED
  68797. */
  68798. export class PointsCloudSystem implements IDisposable {
  68799. /**
  68800. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68801. * Example : var p = SPS.particles[i];
  68802. */
  68803. particles: CloudPoint[];
  68804. /**
  68805. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68806. */
  68807. nbParticles: number;
  68808. /**
  68809. * This a counter for your own usage. It's not set by any SPS functions.
  68810. */
  68811. counter: number;
  68812. /**
  68813. * The PCS name. This name is also given to the underlying mesh.
  68814. */
  68815. name: string;
  68816. /**
  68817. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68818. */
  68819. mesh: Mesh;
  68820. /**
  68821. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68822. * Please read :
  68823. */
  68824. vars: any;
  68825. /**
  68826. * @hidden
  68827. */
  68828. _size: number;
  68829. private _scene;
  68830. private _promises;
  68831. private _positions;
  68832. private _indices;
  68833. private _normals;
  68834. private _colors;
  68835. private _uvs;
  68836. private _indices32;
  68837. private _positions32;
  68838. private _colors32;
  68839. private _uvs32;
  68840. private _updatable;
  68841. private _isVisibilityBoxLocked;
  68842. private _alwaysVisible;
  68843. private _groups;
  68844. private _groupCounter;
  68845. private _computeParticleColor;
  68846. private _computeParticleTexture;
  68847. private _computeParticleRotation;
  68848. private _computeBoundingBox;
  68849. private _isReady;
  68850. /**
  68851. * Creates a PCS (Points Cloud System) object
  68852. * @param name (String) is the PCS name, this will be the underlying mesh name
  68853. * @param pointSize (number) is the size for each point
  68854. * @param scene (Scene) is the scene in which the PCS is added
  68855. * @param options defines the options of the PCS e.g.
  68856. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68857. */
  68858. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68859. updatable?: boolean;
  68860. });
  68861. /**
  68862. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68863. * If no points were added to the PCS, the returned mesh is just a single point.
  68864. * @returns a promise for the created mesh
  68865. */
  68866. buildMeshAsync(): Promise<Mesh>;
  68867. /**
  68868. * @hidden
  68869. */
  68870. private _buildMesh;
  68871. private _addParticle;
  68872. private _randomUnitVector;
  68873. private _getColorIndicesForCoord;
  68874. private _setPointsColorOrUV;
  68875. private _colorFromTexture;
  68876. private _calculateDensity;
  68877. /**
  68878. * Adds points to the PCS in random positions within a unit sphere
  68879. * @param nb (positive integer) the number of particles to be created from this model
  68880. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68881. * @returns the number of groups in the system
  68882. */
  68883. addPoints(nb: number, pointFunction?: any): number;
  68884. /**
  68885. * Adds points to the PCS from the surface of the model shape
  68886. * @param mesh is any Mesh object that will be used as a surface model for the points
  68887. * @param nb (positive integer) the number of particles to be created from this model
  68888. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68889. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68890. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68891. * @returns the number of groups in the system
  68892. */
  68893. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68894. /**
  68895. * Adds points to the PCS inside the model shape
  68896. * @param mesh is any Mesh object that will be used as a surface model for the points
  68897. * @param nb (positive integer) the number of particles to be created from this model
  68898. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68899. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68900. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68901. * @returns the number of groups in the system
  68902. */
  68903. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68904. /**
  68905. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68906. * This method calls `updateParticle()` for each particle of the SPS.
  68907. * For an animated SPS, it is usually called within the render loop.
  68908. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68909. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68910. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68911. * @returns the PCS.
  68912. */
  68913. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68914. /**
  68915. * Disposes the PCS.
  68916. */
  68917. dispose(): void;
  68918. /**
  68919. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68920. * doc :
  68921. * @returns the PCS.
  68922. */
  68923. refreshVisibleSize(): PointsCloudSystem;
  68924. /**
  68925. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68926. * @param size the size (float) of the visibility box
  68927. * note : this doesn't lock the PCS mesh bounding box.
  68928. * doc :
  68929. */
  68930. setVisibilityBox(size: number): void;
  68931. /**
  68932. * Gets whether the PCS is always visible or not
  68933. * doc :
  68934. */
  68935. get isAlwaysVisible(): boolean;
  68936. /**
  68937. * Sets the PCS as always visible or not
  68938. * doc :
  68939. */
  68940. set isAlwaysVisible(val: boolean);
  68941. /**
  68942. * Tells to `setParticles()` to compute the particle rotations or not
  68943. * Default value : false. The PCS is faster when it's set to false
  68944. * Note : particle rotations are only applied to parent particles
  68945. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68946. */
  68947. set computeParticleRotation(val: boolean);
  68948. /**
  68949. * Tells to `setParticles()` to compute the particle colors or not.
  68950. * Default value : true. The PCS is faster when it's set to false.
  68951. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68952. */
  68953. set computeParticleColor(val: boolean);
  68954. set computeParticleTexture(val: boolean);
  68955. /**
  68956. * Gets if `setParticles()` computes the particle colors or not.
  68957. * Default value : false. The PCS is faster when it's set to false.
  68958. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68959. */
  68960. get computeParticleColor(): boolean;
  68961. /**
  68962. * Gets if `setParticles()` computes the particle textures or not.
  68963. * Default value : false. The PCS is faster when it's set to false.
  68964. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68965. */
  68966. get computeParticleTexture(): boolean;
  68967. /**
  68968. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68969. */
  68970. set computeBoundingBox(val: boolean);
  68971. /**
  68972. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68973. */
  68974. get computeBoundingBox(): boolean;
  68975. /**
  68976. * This function does nothing. It may be overwritten to set all the particle first values.
  68977. * The PCS doesn't call this function, you may have to call it by your own.
  68978. * doc :
  68979. */
  68980. initParticles(): void;
  68981. /**
  68982. * This function does nothing. It may be overwritten to recycle a particle
  68983. * The PCS doesn't call this function, you can to call it
  68984. * doc :
  68985. * @param particle The particle to recycle
  68986. * @returns the recycled particle
  68987. */
  68988. recycleParticle(particle: CloudPoint): CloudPoint;
  68989. /**
  68990. * Updates a particle : this function should be overwritten by the user.
  68991. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68992. * doc :
  68993. * @example : just set a particle position or velocity and recycle conditions
  68994. * @param particle The particle to update
  68995. * @returns the updated particle
  68996. */
  68997. updateParticle(particle: CloudPoint): CloudPoint;
  68998. /**
  68999. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69000. * This does nothing and may be overwritten by the user.
  69001. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69002. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69003. * @param update the boolean update value actually passed to setParticles()
  69004. */
  69005. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69006. /**
  69007. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69008. * This will be passed three parameters.
  69009. * This does nothing and may be overwritten by the user.
  69010. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69011. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69012. * @param update the boolean update value actually passed to setParticles()
  69013. */
  69014. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69015. }
  69016. }
  69017. declare module BABYLON {
  69018. /**
  69019. * Represents one particle of a points cloud system.
  69020. */
  69021. export class CloudPoint {
  69022. /**
  69023. * particle global index
  69024. */
  69025. idx: number;
  69026. /**
  69027. * The color of the particle
  69028. */
  69029. color: Nullable<Color4>;
  69030. /**
  69031. * The world space position of the particle.
  69032. */
  69033. position: Vector3;
  69034. /**
  69035. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69036. */
  69037. rotation: Vector3;
  69038. /**
  69039. * The world space rotation quaternion of the particle.
  69040. */
  69041. rotationQuaternion: Nullable<Quaternion>;
  69042. /**
  69043. * The uv of the particle.
  69044. */
  69045. uv: Nullable<Vector2>;
  69046. /**
  69047. * The current speed of the particle.
  69048. */
  69049. velocity: Vector3;
  69050. /**
  69051. * The pivot point in the particle local space.
  69052. */
  69053. pivot: Vector3;
  69054. /**
  69055. * Must the particle be translated from its pivot point in its local space ?
  69056. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69057. * Default : false
  69058. */
  69059. translateFromPivot: boolean;
  69060. /**
  69061. * Index of this particle in the global "positions" array (Internal use)
  69062. * @hidden
  69063. */
  69064. _pos: number;
  69065. /**
  69066. * @hidden Index of this particle in the global "indices" array (Internal use)
  69067. */
  69068. _ind: number;
  69069. /**
  69070. * Group this particle belongs to
  69071. */
  69072. _group: PointsGroup;
  69073. /**
  69074. * Group id of this particle
  69075. */
  69076. groupId: number;
  69077. /**
  69078. * Index of the particle in its group id (Internal use)
  69079. */
  69080. idxInGroup: number;
  69081. /**
  69082. * @hidden Particle BoundingInfo object (Internal use)
  69083. */
  69084. _boundingInfo: BoundingInfo;
  69085. /**
  69086. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69087. */
  69088. _pcs: PointsCloudSystem;
  69089. /**
  69090. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69091. */
  69092. _stillInvisible: boolean;
  69093. /**
  69094. * @hidden Last computed particle rotation matrix
  69095. */
  69096. _rotationMatrix: number[];
  69097. /**
  69098. * Parent particle Id, if any.
  69099. * Default null.
  69100. */
  69101. parentId: Nullable<number>;
  69102. /**
  69103. * @hidden Internal global position in the PCS.
  69104. */
  69105. _globalPosition: Vector3;
  69106. /**
  69107. * Creates a Point Cloud object.
  69108. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69109. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69110. * @param group (PointsGroup) is the group the particle belongs to
  69111. * @param groupId (integer) is the group identifier in the PCS.
  69112. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69113. * @param pcs defines the PCS it is associated to
  69114. */
  69115. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69116. /**
  69117. * get point size
  69118. */
  69119. get size(): Vector3;
  69120. /**
  69121. * Set point size
  69122. */
  69123. set size(scale: Vector3);
  69124. /**
  69125. * Legacy support, changed quaternion to rotationQuaternion
  69126. */
  69127. get quaternion(): Nullable<Quaternion>;
  69128. /**
  69129. * Legacy support, changed quaternion to rotationQuaternion
  69130. */
  69131. set quaternion(q: Nullable<Quaternion>);
  69132. /**
  69133. * Returns a boolean. True if the particle intersects a mesh, else false
  69134. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69135. * @param target is the object (point or mesh) what the intersection is computed against
  69136. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69137. * @returns true if it intersects
  69138. */
  69139. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69140. /**
  69141. * get the rotation matrix of the particle
  69142. * @hidden
  69143. */
  69144. getRotationMatrix(m: Matrix): void;
  69145. }
  69146. /**
  69147. * Represents a group of points in a points cloud system
  69148. * * PCS internal tool, don't use it manually.
  69149. */
  69150. export class PointsGroup {
  69151. /**
  69152. * The group id
  69153. * @hidden
  69154. */
  69155. groupID: number;
  69156. /**
  69157. * image data for group (internal use)
  69158. * @hidden
  69159. */
  69160. _groupImageData: Nullable<ArrayBufferView>;
  69161. /**
  69162. * Image Width (internal use)
  69163. * @hidden
  69164. */
  69165. _groupImgWidth: number;
  69166. /**
  69167. * Image Height (internal use)
  69168. * @hidden
  69169. */
  69170. _groupImgHeight: number;
  69171. /**
  69172. * Custom position function (internal use)
  69173. * @hidden
  69174. */
  69175. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69176. /**
  69177. * density per facet for surface points
  69178. * @hidden
  69179. */
  69180. _groupDensity: number[];
  69181. /**
  69182. * Only when points are colored by texture carries pointer to texture list array
  69183. * @hidden
  69184. */
  69185. _textureNb: number;
  69186. /**
  69187. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69188. * PCS internal tool, don't use it manually.
  69189. * @hidden
  69190. */
  69191. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69192. }
  69193. }
  69194. declare module BABYLON {
  69195. interface Scene {
  69196. /** @hidden (Backing field) */
  69197. _physicsEngine: Nullable<IPhysicsEngine>;
  69198. /** @hidden */
  69199. _physicsTimeAccumulator: number;
  69200. /**
  69201. * Gets the current physics engine
  69202. * @returns a IPhysicsEngine or null if none attached
  69203. */
  69204. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69205. /**
  69206. * Enables physics to the current scene
  69207. * @param gravity defines the scene's gravity for the physics engine
  69208. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69209. * @return a boolean indicating if the physics engine was initialized
  69210. */
  69211. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69212. /**
  69213. * Disables and disposes the physics engine associated with the scene
  69214. */
  69215. disablePhysicsEngine(): void;
  69216. /**
  69217. * Gets a boolean indicating if there is an active physics engine
  69218. * @returns a boolean indicating if there is an active physics engine
  69219. */
  69220. isPhysicsEnabled(): boolean;
  69221. /**
  69222. * Deletes a physics compound impostor
  69223. * @param compound defines the compound to delete
  69224. */
  69225. deleteCompoundImpostor(compound: any): void;
  69226. /**
  69227. * An event triggered when physic simulation is about to be run
  69228. */
  69229. onBeforePhysicsObservable: Observable<Scene>;
  69230. /**
  69231. * An event triggered when physic simulation has been done
  69232. */
  69233. onAfterPhysicsObservable: Observable<Scene>;
  69234. }
  69235. interface AbstractMesh {
  69236. /** @hidden */
  69237. _physicsImpostor: Nullable<PhysicsImpostor>;
  69238. /**
  69239. * Gets or sets impostor used for physic simulation
  69240. * @see https://doc.babylonjs.com/features/physics_engine
  69241. */
  69242. physicsImpostor: Nullable<PhysicsImpostor>;
  69243. /**
  69244. * Gets the current physics impostor
  69245. * @see https://doc.babylonjs.com/features/physics_engine
  69246. * @returns a physics impostor or null
  69247. */
  69248. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69249. /** Apply a physic impulse to the mesh
  69250. * @param force defines the force to apply
  69251. * @param contactPoint defines where to apply the force
  69252. * @returns the current mesh
  69253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69254. */
  69255. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69256. /**
  69257. * Creates a physic joint between two meshes
  69258. * @param otherMesh defines the other mesh to use
  69259. * @param pivot1 defines the pivot to use on this mesh
  69260. * @param pivot2 defines the pivot to use on the other mesh
  69261. * @param options defines additional options (can be plugin dependent)
  69262. * @returns the current mesh
  69263. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69264. */
  69265. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69266. /** @hidden */
  69267. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69268. }
  69269. /**
  69270. * Defines the physics engine scene component responsible to manage a physics engine
  69271. */
  69272. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69273. /**
  69274. * The component name helpful to identify the component in the list of scene components.
  69275. */
  69276. readonly name: string;
  69277. /**
  69278. * The scene the component belongs to.
  69279. */
  69280. scene: Scene;
  69281. /**
  69282. * Creates a new instance of the component for the given scene
  69283. * @param scene Defines the scene to register the component in
  69284. */
  69285. constructor(scene: Scene);
  69286. /**
  69287. * Registers the component in a given scene
  69288. */
  69289. register(): void;
  69290. /**
  69291. * Rebuilds the elements related to this component in case of
  69292. * context lost for instance.
  69293. */
  69294. rebuild(): void;
  69295. /**
  69296. * Disposes the component and the associated ressources
  69297. */
  69298. dispose(): void;
  69299. }
  69300. }
  69301. declare module BABYLON {
  69302. /**
  69303. * A helper for physics simulations
  69304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69305. */
  69306. export class PhysicsHelper {
  69307. private _scene;
  69308. private _physicsEngine;
  69309. /**
  69310. * Initializes the Physics helper
  69311. * @param scene Babylon.js scene
  69312. */
  69313. constructor(scene: Scene);
  69314. /**
  69315. * Applies a radial explosion impulse
  69316. * @param origin the origin of the explosion
  69317. * @param radiusOrEventOptions the radius or the options of radial explosion
  69318. * @param strength the explosion strength
  69319. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69320. * @returns A physics radial explosion event, or null
  69321. */
  69322. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69323. /**
  69324. * Applies a radial explosion force
  69325. * @param origin the origin of the explosion
  69326. * @param radiusOrEventOptions the radius or the options of radial explosion
  69327. * @param strength the explosion strength
  69328. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69329. * @returns A physics radial explosion event, or null
  69330. */
  69331. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69332. /**
  69333. * Creates a gravitational field
  69334. * @param origin the origin of the explosion
  69335. * @param radiusOrEventOptions the radius or the options of radial explosion
  69336. * @param strength the explosion strength
  69337. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69338. * @returns A physics gravitational field event, or null
  69339. */
  69340. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69341. /**
  69342. * Creates a physics updraft event
  69343. * @param origin the origin of the updraft
  69344. * @param radiusOrEventOptions the radius or the options of the updraft
  69345. * @param strength the strength of the updraft
  69346. * @param height the height of the updraft
  69347. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69348. * @returns A physics updraft event, or null
  69349. */
  69350. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69351. /**
  69352. * Creates a physics vortex event
  69353. * @param origin the of the vortex
  69354. * @param radiusOrEventOptions the radius or the options of the vortex
  69355. * @param strength the strength of the vortex
  69356. * @param height the height of the vortex
  69357. * @returns a Physics vortex event, or null
  69358. * A physics vortex event or null
  69359. */
  69360. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69361. }
  69362. /**
  69363. * Represents a physics radial explosion event
  69364. */
  69365. class PhysicsRadialExplosionEvent {
  69366. private _scene;
  69367. private _options;
  69368. private _sphere;
  69369. private _dataFetched;
  69370. /**
  69371. * Initializes a radial explosioin event
  69372. * @param _scene BabylonJS scene
  69373. * @param _options The options for the vortex event
  69374. */
  69375. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69376. /**
  69377. * Returns the data related to the radial explosion event (sphere).
  69378. * @returns The radial explosion event data
  69379. */
  69380. getData(): PhysicsRadialExplosionEventData;
  69381. /**
  69382. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69383. * @param impostor A physics imposter
  69384. * @param origin the origin of the explosion
  69385. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69386. */
  69387. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69388. /**
  69389. * Triggers affecterd impostors callbacks
  69390. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69391. */
  69392. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69393. /**
  69394. * Disposes the sphere.
  69395. * @param force Specifies if the sphere should be disposed by force
  69396. */
  69397. dispose(force?: boolean): void;
  69398. /*** Helpers ***/
  69399. private _prepareSphere;
  69400. private _intersectsWithSphere;
  69401. }
  69402. /**
  69403. * Represents a gravitational field event
  69404. */
  69405. class PhysicsGravitationalFieldEvent {
  69406. private _physicsHelper;
  69407. private _scene;
  69408. private _origin;
  69409. private _options;
  69410. private _tickCallback;
  69411. private _sphere;
  69412. private _dataFetched;
  69413. /**
  69414. * Initializes the physics gravitational field event
  69415. * @param _physicsHelper A physics helper
  69416. * @param _scene BabylonJS scene
  69417. * @param _origin The origin position of the gravitational field event
  69418. * @param _options The options for the vortex event
  69419. */
  69420. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69421. /**
  69422. * Returns the data related to the gravitational field event (sphere).
  69423. * @returns A gravitational field event
  69424. */
  69425. getData(): PhysicsGravitationalFieldEventData;
  69426. /**
  69427. * Enables the gravitational field.
  69428. */
  69429. enable(): void;
  69430. /**
  69431. * Disables the gravitational field.
  69432. */
  69433. disable(): void;
  69434. /**
  69435. * Disposes the sphere.
  69436. * @param force The force to dispose from the gravitational field event
  69437. */
  69438. dispose(force?: boolean): void;
  69439. private _tick;
  69440. }
  69441. /**
  69442. * Represents a physics updraft event
  69443. */
  69444. class PhysicsUpdraftEvent {
  69445. private _scene;
  69446. private _origin;
  69447. private _options;
  69448. private _physicsEngine;
  69449. private _originTop;
  69450. private _originDirection;
  69451. private _tickCallback;
  69452. private _cylinder;
  69453. private _cylinderPosition;
  69454. private _dataFetched;
  69455. /**
  69456. * Initializes the physics updraft event
  69457. * @param _scene BabylonJS scene
  69458. * @param _origin The origin position of the updraft
  69459. * @param _options The options for the updraft event
  69460. */
  69461. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69462. /**
  69463. * Returns the data related to the updraft event (cylinder).
  69464. * @returns A physics updraft event
  69465. */
  69466. getData(): PhysicsUpdraftEventData;
  69467. /**
  69468. * Enables the updraft.
  69469. */
  69470. enable(): void;
  69471. /**
  69472. * Disables the updraft.
  69473. */
  69474. disable(): void;
  69475. /**
  69476. * Disposes the cylinder.
  69477. * @param force Specifies if the updraft should be disposed by force
  69478. */
  69479. dispose(force?: boolean): void;
  69480. private getImpostorHitData;
  69481. private _tick;
  69482. /*** Helpers ***/
  69483. private _prepareCylinder;
  69484. private _intersectsWithCylinder;
  69485. }
  69486. /**
  69487. * Represents a physics vortex event
  69488. */
  69489. class PhysicsVortexEvent {
  69490. private _scene;
  69491. private _origin;
  69492. private _options;
  69493. private _physicsEngine;
  69494. private _originTop;
  69495. private _tickCallback;
  69496. private _cylinder;
  69497. private _cylinderPosition;
  69498. private _dataFetched;
  69499. /**
  69500. * Initializes the physics vortex event
  69501. * @param _scene The BabylonJS scene
  69502. * @param _origin The origin position of the vortex
  69503. * @param _options The options for the vortex event
  69504. */
  69505. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69506. /**
  69507. * Returns the data related to the vortex event (cylinder).
  69508. * @returns The physics vortex event data
  69509. */
  69510. getData(): PhysicsVortexEventData;
  69511. /**
  69512. * Enables the vortex.
  69513. */
  69514. enable(): void;
  69515. /**
  69516. * Disables the cortex.
  69517. */
  69518. disable(): void;
  69519. /**
  69520. * Disposes the sphere.
  69521. * @param force
  69522. */
  69523. dispose(force?: boolean): void;
  69524. private getImpostorHitData;
  69525. private _tick;
  69526. /*** Helpers ***/
  69527. private _prepareCylinder;
  69528. private _intersectsWithCylinder;
  69529. }
  69530. /**
  69531. * Options fot the radial explosion event
  69532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69533. */
  69534. export class PhysicsRadialExplosionEventOptions {
  69535. /**
  69536. * The radius of the sphere for the radial explosion.
  69537. */
  69538. radius: number;
  69539. /**
  69540. * The strenth of the explosion.
  69541. */
  69542. strength: number;
  69543. /**
  69544. * The strenght of the force in correspondence to the distance of the affected object
  69545. */
  69546. falloff: PhysicsRadialImpulseFalloff;
  69547. /**
  69548. * Sphere options for the radial explosion.
  69549. */
  69550. sphere: {
  69551. segments: number;
  69552. diameter: number;
  69553. };
  69554. /**
  69555. * Sphere options for the radial explosion.
  69556. */
  69557. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69558. }
  69559. /**
  69560. * Options fot the updraft event
  69561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69562. */
  69563. export class PhysicsUpdraftEventOptions {
  69564. /**
  69565. * The radius of the cylinder for the vortex
  69566. */
  69567. radius: number;
  69568. /**
  69569. * The strenth of the updraft.
  69570. */
  69571. strength: number;
  69572. /**
  69573. * The height of the cylinder for the updraft.
  69574. */
  69575. height: number;
  69576. /**
  69577. * The mode for the the updraft.
  69578. */
  69579. updraftMode: PhysicsUpdraftMode;
  69580. }
  69581. /**
  69582. * Options fot the vortex event
  69583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69584. */
  69585. export class PhysicsVortexEventOptions {
  69586. /**
  69587. * The radius of the cylinder for the vortex
  69588. */
  69589. radius: number;
  69590. /**
  69591. * The strenth of the vortex.
  69592. */
  69593. strength: number;
  69594. /**
  69595. * The height of the cylinder for the vortex.
  69596. */
  69597. height: number;
  69598. /**
  69599. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69600. */
  69601. centripetalForceThreshold: number;
  69602. /**
  69603. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69604. */
  69605. centripetalForceMultiplier: number;
  69606. /**
  69607. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69608. */
  69609. centrifugalForceMultiplier: number;
  69610. /**
  69611. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69612. */
  69613. updraftForceMultiplier: number;
  69614. }
  69615. /**
  69616. * The strenght of the force in correspondence to the distance of the affected object
  69617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69618. */
  69619. export enum PhysicsRadialImpulseFalloff {
  69620. /** Defines that impulse is constant in strength across it's whole radius */
  69621. Constant = 0,
  69622. /** Defines that impulse gets weaker if it's further from the origin */
  69623. Linear = 1
  69624. }
  69625. /**
  69626. * The strength of the force in correspondence to the distance of the affected object
  69627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69628. */
  69629. export enum PhysicsUpdraftMode {
  69630. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69631. Center = 0,
  69632. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69633. Perpendicular = 1
  69634. }
  69635. /**
  69636. * Interface for a physics hit data
  69637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69638. */
  69639. export interface PhysicsHitData {
  69640. /**
  69641. * The force applied at the contact point
  69642. */
  69643. force: Vector3;
  69644. /**
  69645. * The contact point
  69646. */
  69647. contactPoint: Vector3;
  69648. /**
  69649. * The distance from the origin to the contact point
  69650. */
  69651. distanceFromOrigin: number;
  69652. }
  69653. /**
  69654. * Interface for radial explosion event data
  69655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69656. */
  69657. export interface PhysicsRadialExplosionEventData {
  69658. /**
  69659. * A sphere used for the radial explosion event
  69660. */
  69661. sphere: Mesh;
  69662. }
  69663. /**
  69664. * Interface for gravitational field event data
  69665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69666. */
  69667. export interface PhysicsGravitationalFieldEventData {
  69668. /**
  69669. * A sphere mesh used for the gravitational field event
  69670. */
  69671. sphere: Mesh;
  69672. }
  69673. /**
  69674. * Interface for updraft event data
  69675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69676. */
  69677. export interface PhysicsUpdraftEventData {
  69678. /**
  69679. * A cylinder used for the updraft event
  69680. */
  69681. cylinder: Mesh;
  69682. }
  69683. /**
  69684. * Interface for vortex event data
  69685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69686. */
  69687. export interface PhysicsVortexEventData {
  69688. /**
  69689. * A cylinder used for the vortex event
  69690. */
  69691. cylinder: Mesh;
  69692. }
  69693. /**
  69694. * Interface for an affected physics impostor
  69695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69696. */
  69697. export interface PhysicsAffectedImpostorWithData {
  69698. /**
  69699. * The impostor affected by the effect
  69700. */
  69701. impostor: PhysicsImpostor;
  69702. /**
  69703. * The data about the hit/horce from the explosion
  69704. */
  69705. hitData: PhysicsHitData;
  69706. }
  69707. }
  69708. declare module BABYLON {
  69709. /** @hidden */
  69710. export var blackAndWhitePixelShader: {
  69711. name: string;
  69712. shader: string;
  69713. };
  69714. }
  69715. declare module BABYLON {
  69716. /**
  69717. * Post process used to render in black and white
  69718. */
  69719. export class BlackAndWhitePostProcess extends PostProcess {
  69720. /**
  69721. * Linear about to convert he result to black and white (default: 1)
  69722. */
  69723. degree: number;
  69724. /**
  69725. * Gets a string identifying the name of the class
  69726. * @returns "BlackAndWhitePostProcess" string
  69727. */
  69728. getClassName(): string;
  69729. /**
  69730. * Creates a black and white post process
  69731. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69732. * @param name The name of the effect.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69736. * @param engine The engine which the post process will be applied. (default: current engine)
  69737. * @param reusable If the post process can be reused on the same frame. (default: false)
  69738. */
  69739. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69740. /** @hidden */
  69741. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69742. }
  69743. }
  69744. declare module BABYLON {
  69745. /**
  69746. * This represents a set of one or more post processes in Babylon.
  69747. * A post process can be used to apply a shader to a texture after it is rendered.
  69748. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69749. */
  69750. export class PostProcessRenderEffect {
  69751. private _postProcesses;
  69752. private _getPostProcesses;
  69753. private _singleInstance;
  69754. private _cameras;
  69755. private _indicesForCamera;
  69756. /**
  69757. * Name of the effect
  69758. * @hidden
  69759. */
  69760. _name: string;
  69761. /**
  69762. * Instantiates a post process render effect.
  69763. * A post process can be used to apply a shader to a texture after it is rendered.
  69764. * @param engine The engine the effect is tied to
  69765. * @param name The name of the effect
  69766. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69767. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69768. */
  69769. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69770. /**
  69771. * Checks if all the post processes in the effect are supported.
  69772. */
  69773. get isSupported(): boolean;
  69774. /**
  69775. * Updates the current state of the effect
  69776. * @hidden
  69777. */
  69778. _update(): void;
  69779. /**
  69780. * Attaches the effect on cameras
  69781. * @param cameras The camera to attach to.
  69782. * @hidden
  69783. */
  69784. _attachCameras(cameras: Camera): void;
  69785. /**
  69786. * Attaches the effect on cameras
  69787. * @param cameras The camera to attach to.
  69788. * @hidden
  69789. */
  69790. _attachCameras(cameras: Camera[]): void;
  69791. /**
  69792. * Detaches the effect on cameras
  69793. * @param cameras The camera to detatch from.
  69794. * @hidden
  69795. */
  69796. _detachCameras(cameras: Camera): void;
  69797. /**
  69798. * Detatches the effect on cameras
  69799. * @param cameras The camera to detatch from.
  69800. * @hidden
  69801. */
  69802. _detachCameras(cameras: Camera[]): void;
  69803. /**
  69804. * Enables the effect on given cameras
  69805. * @param cameras The camera to enable.
  69806. * @hidden
  69807. */
  69808. _enable(cameras: Camera): void;
  69809. /**
  69810. * Enables the effect on given cameras
  69811. * @param cameras The camera to enable.
  69812. * @hidden
  69813. */
  69814. _enable(cameras: Nullable<Camera[]>): void;
  69815. /**
  69816. * Disables the effect on the given cameras
  69817. * @param cameras The camera to disable.
  69818. * @hidden
  69819. */
  69820. _disable(cameras: Camera): void;
  69821. /**
  69822. * Disables the effect on the given cameras
  69823. * @param cameras The camera to disable.
  69824. * @hidden
  69825. */
  69826. _disable(cameras: Nullable<Camera[]>): void;
  69827. /**
  69828. * Gets a list of the post processes contained in the effect.
  69829. * @param camera The camera to get the post processes on.
  69830. * @returns The list of the post processes in the effect.
  69831. */
  69832. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69833. }
  69834. }
  69835. declare module BABYLON {
  69836. /** @hidden */
  69837. export var extractHighlightsPixelShader: {
  69838. name: string;
  69839. shader: string;
  69840. };
  69841. }
  69842. declare module BABYLON {
  69843. /**
  69844. * 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.
  69845. */
  69846. export class ExtractHighlightsPostProcess extends PostProcess {
  69847. /**
  69848. * The luminance threshold, pixels below this value will be set to black.
  69849. */
  69850. threshold: number;
  69851. /** @hidden */
  69852. _exposure: number;
  69853. /**
  69854. * Post process which has the input texture to be used when performing highlight extraction
  69855. * @hidden
  69856. */
  69857. _inputPostProcess: Nullable<PostProcess>;
  69858. /**
  69859. * Gets a string identifying the name of the class
  69860. * @returns "ExtractHighlightsPostProcess" string
  69861. */
  69862. getClassName(): string;
  69863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69864. }
  69865. }
  69866. declare module BABYLON {
  69867. /** @hidden */
  69868. export var bloomMergePixelShader: {
  69869. name: string;
  69870. shader: string;
  69871. };
  69872. }
  69873. declare module BABYLON {
  69874. /**
  69875. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69876. */
  69877. export class BloomMergePostProcess extends PostProcess {
  69878. /** Weight of the bloom to be added to the original input. */
  69879. weight: number;
  69880. /**
  69881. * Gets a string identifying the name of the class
  69882. * @returns "BloomMergePostProcess" string
  69883. */
  69884. getClassName(): string;
  69885. /**
  69886. * Creates a new instance of @see BloomMergePostProcess
  69887. * @param name The name of the effect.
  69888. * @param originalFromInput Post process which's input will be used for the merge.
  69889. * @param blurred Blurred highlights post process which's output will be used.
  69890. * @param weight Weight of the bloom to be added to the original input.
  69891. * @param options The required width/height ratio to downsize to before computing the render pass.
  69892. * @param camera The camera to apply the render pass to.
  69893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69894. * @param engine The engine which the post process will be applied. (default: current engine)
  69895. * @param reusable If the post process can be reused on the same frame. (default: false)
  69896. * @param textureType Type of textures used when performing the post process. (default: 0)
  69897. * @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)
  69898. */
  69899. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69900. /** Weight of the bloom to be added to the original input. */
  69901. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /**
  69906. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69907. */
  69908. export class BloomEffect extends PostProcessRenderEffect {
  69909. private bloomScale;
  69910. /**
  69911. * @hidden Internal
  69912. */
  69913. _effects: Array<PostProcess>;
  69914. /**
  69915. * @hidden Internal
  69916. */
  69917. _downscale: ExtractHighlightsPostProcess;
  69918. private _blurX;
  69919. private _blurY;
  69920. private _merge;
  69921. /**
  69922. * The luminance threshold to find bright areas of the image to bloom.
  69923. */
  69924. get threshold(): number;
  69925. set threshold(value: number);
  69926. /**
  69927. * The strength of the bloom.
  69928. */
  69929. get weight(): number;
  69930. set weight(value: number);
  69931. /**
  69932. * Specifies the size of the bloom blur kernel, relative to the final output size
  69933. */
  69934. get kernel(): number;
  69935. set kernel(value: number);
  69936. /**
  69937. * Creates a new instance of @see BloomEffect
  69938. * @param scene The scene the effect belongs to.
  69939. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69940. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69941. * @param bloomWeight The the strength of bloom.
  69942. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69943. * @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)
  69944. */
  69945. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69946. /**
  69947. * Disposes each of the internal effects for a given camera.
  69948. * @param camera The camera to dispose the effect on.
  69949. */
  69950. disposeEffects(camera: Camera): void;
  69951. /**
  69952. * @hidden Internal
  69953. */
  69954. _updateEffects(): void;
  69955. /**
  69956. * Internal
  69957. * @returns if all the contained post processes are ready.
  69958. * @hidden
  69959. */
  69960. _isReady(): boolean;
  69961. }
  69962. }
  69963. declare module BABYLON {
  69964. /** @hidden */
  69965. export var chromaticAberrationPixelShader: {
  69966. name: string;
  69967. shader: string;
  69968. };
  69969. }
  69970. declare module BABYLON {
  69971. /**
  69972. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69973. */
  69974. export class ChromaticAberrationPostProcess extends PostProcess {
  69975. /**
  69976. * The amount of seperation of rgb channels (default: 30)
  69977. */
  69978. aberrationAmount: number;
  69979. /**
  69980. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69981. */
  69982. radialIntensity: number;
  69983. /**
  69984. * 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))
  69985. */
  69986. direction: Vector2;
  69987. /**
  69988. * 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))
  69989. */
  69990. centerPosition: Vector2;
  69991. /** The width of the screen to apply the effect on */
  69992. screenWidth: number;
  69993. /** The height of the screen to apply the effect on */
  69994. screenHeight: number;
  69995. /**
  69996. * Gets a string identifying the name of the class
  69997. * @returns "ChromaticAberrationPostProcess" string
  69998. */
  69999. getClassName(): string;
  70000. /**
  70001. * Creates a new instance ChromaticAberrationPostProcess
  70002. * @param name The name of the effect.
  70003. * @param screenWidth The width of the screen to apply the effect on.
  70004. * @param screenHeight The height of the screen to apply the effect on.
  70005. * @param options The required width/height ratio to downsize to before computing the render pass.
  70006. * @param camera The camera to apply the render pass to.
  70007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70008. * @param engine The engine which the post process will be applied. (default: current engine)
  70009. * @param reusable If the post process can be reused on the same frame. (default: false)
  70010. * @param textureType Type of textures used when performing the post process. (default: 0)
  70011. * @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)
  70012. */
  70013. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70014. /** @hidden */
  70015. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70016. }
  70017. }
  70018. declare module BABYLON {
  70019. /** @hidden */
  70020. export var circleOfConfusionPixelShader: {
  70021. name: string;
  70022. shader: string;
  70023. };
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70028. */
  70029. export class CircleOfConfusionPostProcess extends PostProcess {
  70030. /**
  70031. * 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.
  70032. */
  70033. lensSize: number;
  70034. /**
  70035. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70036. */
  70037. fStop: number;
  70038. /**
  70039. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70040. */
  70041. focusDistance: number;
  70042. /**
  70043. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70044. */
  70045. focalLength: number;
  70046. /**
  70047. * Gets a string identifying the name of the class
  70048. * @returns "CircleOfConfusionPostProcess" string
  70049. */
  70050. getClassName(): string;
  70051. private _depthTexture;
  70052. /**
  70053. * Creates a new instance CircleOfConfusionPostProcess
  70054. * @param name The name of the effect.
  70055. * @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.
  70056. * @param options The required width/height ratio to downsize to before computing the render pass.
  70057. * @param camera The camera to apply the render pass to.
  70058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70059. * @param engine The engine which the post process will be applied. (default: current engine)
  70060. * @param reusable If the post process can be reused on the same frame. (default: false)
  70061. * @param textureType Type of textures used when performing the post process. (default: 0)
  70062. * @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)
  70063. */
  70064. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70065. /**
  70066. * 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.
  70067. */
  70068. set depthTexture(value: RenderTargetTexture);
  70069. }
  70070. }
  70071. declare module BABYLON {
  70072. /** @hidden */
  70073. export var colorCorrectionPixelShader: {
  70074. name: string;
  70075. shader: string;
  70076. };
  70077. }
  70078. declare module BABYLON {
  70079. /**
  70080. *
  70081. * This post-process allows the modification of rendered colors by using
  70082. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70083. *
  70084. * The object needs to be provided an url to a texture containing the color
  70085. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70086. * Use an image editing software to tweak the LUT to match your needs.
  70087. *
  70088. * For an example of a color LUT, see here:
  70089. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70090. * For explanations on color grading, see here:
  70091. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70092. *
  70093. */
  70094. export class ColorCorrectionPostProcess extends PostProcess {
  70095. private _colorTableTexture;
  70096. /**
  70097. * Gets the color table url used to create the LUT texture
  70098. */
  70099. colorTableUrl: string;
  70100. /**
  70101. * Gets a string identifying the name of the class
  70102. * @returns "ColorCorrectionPostProcess" string
  70103. */
  70104. getClassName(): string;
  70105. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70106. /** @hidden */
  70107. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70108. }
  70109. }
  70110. declare module BABYLON {
  70111. /** @hidden */
  70112. export var convolutionPixelShader: {
  70113. name: string;
  70114. shader: string;
  70115. };
  70116. }
  70117. declare module BABYLON {
  70118. /**
  70119. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70120. * input texture to perform effects such as edge detection or sharpening
  70121. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70122. */
  70123. export class ConvolutionPostProcess extends PostProcess {
  70124. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70125. kernel: number[];
  70126. /**
  70127. * Gets a string identifying the name of the class
  70128. * @returns "ConvolutionPostProcess" string
  70129. */
  70130. getClassName(): string;
  70131. /**
  70132. * Creates a new instance ConvolutionPostProcess
  70133. * @param name The name of the effect.
  70134. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70135. * @param options The required width/height ratio to downsize to before computing the render pass.
  70136. * @param camera The camera to apply the render pass to.
  70137. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70138. * @param engine The engine which the post process will be applied. (default: current engine)
  70139. * @param reusable If the post process can be reused on the same frame. (default: false)
  70140. * @param textureType Type of textures used when performing the post process. (default: 0)
  70141. */
  70142. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70143. /** @hidden */
  70144. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70145. /**
  70146. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70147. */
  70148. static EdgeDetect0Kernel: number[];
  70149. /**
  70150. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70151. */
  70152. static EdgeDetect1Kernel: number[];
  70153. /**
  70154. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70155. */
  70156. static EdgeDetect2Kernel: number[];
  70157. /**
  70158. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70159. */
  70160. static SharpenKernel: number[];
  70161. /**
  70162. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70163. */
  70164. static EmbossKernel: number[];
  70165. /**
  70166. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70167. */
  70168. static GaussianKernel: number[];
  70169. }
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70174. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70175. * based on samples that have a large difference in distance than the center pixel.
  70176. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70177. */
  70178. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70179. /**
  70180. * The direction the blur should be applied
  70181. */
  70182. direction: Vector2;
  70183. /**
  70184. * Gets a string identifying the name of the class
  70185. * @returns "DepthOfFieldBlurPostProcess" string
  70186. */
  70187. getClassName(): string;
  70188. /**
  70189. * Creates a new instance CircleOfConfusionPostProcess
  70190. * @param name The name of the effect.
  70191. * @param scene The scene the effect belongs to.
  70192. * @param direction The direction the blur should be applied.
  70193. * @param kernel The size of the kernel used to blur.
  70194. * @param options The required width/height ratio to downsize to before computing the render pass.
  70195. * @param camera The camera to apply the render pass to.
  70196. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70197. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70199. * @param engine The engine which the post process will be applied. (default: current engine)
  70200. * @param reusable If the post process can be reused on the same frame. (default: false)
  70201. * @param textureType Type of textures used when performing the post process. (default: 0)
  70202. * @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)
  70203. */
  70204. 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);
  70205. }
  70206. }
  70207. declare module BABYLON {
  70208. /** @hidden */
  70209. export var depthOfFieldMergePixelShader: {
  70210. name: string;
  70211. shader: string;
  70212. };
  70213. }
  70214. declare module BABYLON {
  70215. /**
  70216. * Options to be set when merging outputs from the default pipeline.
  70217. */
  70218. export class DepthOfFieldMergePostProcessOptions {
  70219. /**
  70220. * The original image to merge on top of
  70221. */
  70222. originalFromInput: PostProcess;
  70223. /**
  70224. * Parameters to perform the merge of the depth of field effect
  70225. */
  70226. depthOfField?: {
  70227. circleOfConfusion: PostProcess;
  70228. blurSteps: Array<PostProcess>;
  70229. };
  70230. /**
  70231. * Parameters to perform the merge of bloom effect
  70232. */
  70233. bloom?: {
  70234. blurred: PostProcess;
  70235. weight: number;
  70236. };
  70237. }
  70238. /**
  70239. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70240. */
  70241. export class DepthOfFieldMergePostProcess extends PostProcess {
  70242. private blurSteps;
  70243. /**
  70244. * Gets a string identifying the name of the class
  70245. * @returns "DepthOfFieldMergePostProcess" string
  70246. */
  70247. getClassName(): string;
  70248. /**
  70249. * Creates a new instance of DepthOfFieldMergePostProcess
  70250. * @param name The name of the effect.
  70251. * @param originalFromInput Post process which's input will be used for the merge.
  70252. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70253. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70254. * @param options The required width/height ratio to downsize to before computing the render pass.
  70255. * @param camera The camera to apply the render pass to.
  70256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70257. * @param engine The engine which the post process will be applied. (default: current engine)
  70258. * @param reusable If the post process can be reused on the same frame. (default: false)
  70259. * @param textureType Type of textures used when performing the post process. (default: 0)
  70260. * @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)
  70261. */
  70262. 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);
  70263. /**
  70264. * Updates the effect with the current post process compile time values and recompiles the shader.
  70265. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70266. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70267. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70268. * @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
  70269. * @param onCompiled Called when the shader has been compiled.
  70270. * @param onError Called if there is an error when compiling a shader.
  70271. */
  70272. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70273. }
  70274. }
  70275. declare module BABYLON {
  70276. /**
  70277. * Specifies the level of max blur that should be applied when using the depth of field effect
  70278. */
  70279. export enum DepthOfFieldEffectBlurLevel {
  70280. /**
  70281. * Subtle blur
  70282. */
  70283. Low = 0,
  70284. /**
  70285. * Medium blur
  70286. */
  70287. Medium = 1,
  70288. /**
  70289. * Large blur
  70290. */
  70291. High = 2
  70292. }
  70293. /**
  70294. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70295. */
  70296. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70297. private _circleOfConfusion;
  70298. /**
  70299. * @hidden Internal, blurs from high to low
  70300. */
  70301. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70302. private _depthOfFieldBlurY;
  70303. private _dofMerge;
  70304. /**
  70305. * @hidden Internal post processes in depth of field effect
  70306. */
  70307. _effects: Array<PostProcess>;
  70308. /**
  70309. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70310. */
  70311. set focalLength(value: number);
  70312. get focalLength(): number;
  70313. /**
  70314. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70315. */
  70316. set fStop(value: number);
  70317. get fStop(): number;
  70318. /**
  70319. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70320. */
  70321. set focusDistance(value: number);
  70322. get focusDistance(): number;
  70323. /**
  70324. * 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.
  70325. */
  70326. set lensSize(value: number);
  70327. get lensSize(): number;
  70328. /**
  70329. * Creates a new instance DepthOfFieldEffect
  70330. * @param scene The scene the effect belongs to.
  70331. * @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.
  70332. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70333. * @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)
  70334. */
  70335. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70336. /**
  70337. * Get the current class name of the current effet
  70338. * @returns "DepthOfFieldEffect"
  70339. */
  70340. getClassName(): string;
  70341. /**
  70342. * 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.
  70343. */
  70344. set depthTexture(value: RenderTargetTexture);
  70345. /**
  70346. * Disposes each of the internal effects for a given camera.
  70347. * @param camera The camera to dispose the effect on.
  70348. */
  70349. disposeEffects(camera: Camera): void;
  70350. /**
  70351. * @hidden Internal
  70352. */
  70353. _updateEffects(): void;
  70354. /**
  70355. * Internal
  70356. * @returns if all the contained post processes are ready.
  70357. * @hidden
  70358. */
  70359. _isReady(): boolean;
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /** @hidden */
  70364. export var displayPassPixelShader: {
  70365. name: string;
  70366. shader: string;
  70367. };
  70368. }
  70369. declare module BABYLON {
  70370. /**
  70371. * DisplayPassPostProcess which produces an output the same as it's input
  70372. */
  70373. export class DisplayPassPostProcess extends PostProcess {
  70374. /**
  70375. * Gets a string identifying the name of the class
  70376. * @returns "DisplayPassPostProcess" string
  70377. */
  70378. getClassName(): string;
  70379. /**
  70380. * Creates the DisplayPassPostProcess
  70381. * @param name The name of the effect.
  70382. * @param options The required width/height ratio to downsize to before computing the render pass.
  70383. * @param camera The camera to apply the render pass to.
  70384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70385. * @param engine The engine which the post process will be applied. (default: current engine)
  70386. * @param reusable If the post process can be reused on the same frame. (default: false)
  70387. */
  70388. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70389. /** @hidden */
  70390. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70391. }
  70392. }
  70393. declare module BABYLON {
  70394. /** @hidden */
  70395. export var filterPixelShader: {
  70396. name: string;
  70397. shader: string;
  70398. };
  70399. }
  70400. declare module BABYLON {
  70401. /**
  70402. * Applies a kernel filter to the image
  70403. */
  70404. export class FilterPostProcess extends PostProcess {
  70405. /** The matrix to be applied to the image */
  70406. kernelMatrix: Matrix;
  70407. /**
  70408. * Gets a string identifying the name of the class
  70409. * @returns "FilterPostProcess" string
  70410. */
  70411. getClassName(): string;
  70412. /**
  70413. *
  70414. * @param name The name of the effect.
  70415. * @param kernelMatrix The matrix to be applied to the image
  70416. * @param options The required width/height ratio to downsize to before computing the render pass.
  70417. * @param camera The camera to apply the render pass to.
  70418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70419. * @param engine The engine which the post process will be applied. (default: current engine)
  70420. * @param reusable If the post process can be reused on the same frame. (default: false)
  70421. */
  70422. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70423. /** @hidden */
  70424. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70425. }
  70426. }
  70427. declare module BABYLON {
  70428. /** @hidden */
  70429. export var fxaaPixelShader: {
  70430. name: string;
  70431. shader: string;
  70432. };
  70433. }
  70434. declare module BABYLON {
  70435. /** @hidden */
  70436. export var fxaaVertexShader: {
  70437. name: string;
  70438. shader: string;
  70439. };
  70440. }
  70441. declare module BABYLON {
  70442. /**
  70443. * Fxaa post process
  70444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70445. */
  70446. export class FxaaPostProcess extends PostProcess {
  70447. /**
  70448. * Gets a string identifying the name of the class
  70449. * @returns "FxaaPostProcess" string
  70450. */
  70451. getClassName(): string;
  70452. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70453. private _getDefines;
  70454. /** @hidden */
  70455. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70456. }
  70457. }
  70458. declare module BABYLON {
  70459. /** @hidden */
  70460. export var grainPixelShader: {
  70461. name: string;
  70462. shader: string;
  70463. };
  70464. }
  70465. declare module BABYLON {
  70466. /**
  70467. * The GrainPostProcess adds noise to the image at mid luminance levels
  70468. */
  70469. export class GrainPostProcess extends PostProcess {
  70470. /**
  70471. * The intensity of the grain added (default: 30)
  70472. */
  70473. intensity: number;
  70474. /**
  70475. * If the grain should be randomized on every frame
  70476. */
  70477. animated: boolean;
  70478. /**
  70479. * Gets a string identifying the name of the class
  70480. * @returns "GrainPostProcess" string
  70481. */
  70482. getClassName(): string;
  70483. /**
  70484. * Creates a new instance of @see GrainPostProcess
  70485. * @param name The name of the effect.
  70486. * @param options The required width/height ratio to downsize to before computing the render pass.
  70487. * @param camera The camera to apply the render pass to.
  70488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70489. * @param engine The engine which the post process will be applied. (default: current engine)
  70490. * @param reusable If the post process can be reused on the same frame. (default: false)
  70491. * @param textureType Type of textures used when performing the post process. (default: 0)
  70492. * @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)
  70493. */
  70494. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70495. /** @hidden */
  70496. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70497. }
  70498. }
  70499. declare module BABYLON {
  70500. /** @hidden */
  70501. export var highlightsPixelShader: {
  70502. name: string;
  70503. shader: string;
  70504. };
  70505. }
  70506. declare module BABYLON {
  70507. /**
  70508. * Extracts highlights from the image
  70509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70510. */
  70511. export class HighlightsPostProcess extends PostProcess {
  70512. /**
  70513. * Gets a string identifying the name of the class
  70514. * @returns "HighlightsPostProcess" string
  70515. */
  70516. getClassName(): string;
  70517. /**
  70518. * Extracts highlights from the image
  70519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70520. * @param name The name of the effect.
  70521. * @param options The required width/height ratio to downsize to before computing the render pass.
  70522. * @param camera The camera to apply the render pass to.
  70523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70524. * @param engine The engine which the post process will be applied. (default: current engine)
  70525. * @param reusable If the post process can be reused on the same frame. (default: false)
  70526. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70527. */
  70528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70529. }
  70530. }
  70531. declare module BABYLON {
  70532. /**
  70533. * Contains all parameters needed for the prepass to perform
  70534. * motion blur
  70535. */
  70536. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70537. /**
  70538. * Is motion blur enabled
  70539. */
  70540. enabled: boolean;
  70541. /**
  70542. * Name of the configuration
  70543. */
  70544. name: string;
  70545. /**
  70546. * Textures that should be present in the MRT for this effect to work
  70547. */
  70548. readonly texturesRequired: number[];
  70549. }
  70550. }
  70551. declare module BABYLON {
  70552. interface Scene {
  70553. /** @hidden (Backing field) */
  70554. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70555. /**
  70556. * Gets or Sets the current geometry buffer associated to the scene.
  70557. */
  70558. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70559. /**
  70560. * Enables a GeometryBufferRender and associates it with the scene
  70561. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70562. * @returns the GeometryBufferRenderer
  70563. */
  70564. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70565. /**
  70566. * Disables the GeometryBufferRender associated with the scene
  70567. */
  70568. disableGeometryBufferRenderer(): void;
  70569. }
  70570. /**
  70571. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70572. * in several rendering techniques.
  70573. */
  70574. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70575. /**
  70576. * The component name helpful to identify the component in the list of scene components.
  70577. */
  70578. readonly name: string;
  70579. /**
  70580. * The scene the component belongs to.
  70581. */
  70582. scene: Scene;
  70583. /**
  70584. * Creates a new instance of the component for the given scene
  70585. * @param scene Defines the scene to register the component in
  70586. */
  70587. constructor(scene: Scene);
  70588. /**
  70589. * Registers the component in a given scene
  70590. */
  70591. register(): void;
  70592. /**
  70593. * Rebuilds the elements related to this component in case of
  70594. * context lost for instance.
  70595. */
  70596. rebuild(): void;
  70597. /**
  70598. * Disposes the component and the associated ressources
  70599. */
  70600. dispose(): void;
  70601. private _gatherRenderTargets;
  70602. }
  70603. }
  70604. declare module BABYLON {
  70605. /** @hidden */
  70606. export var motionBlurPixelShader: {
  70607. name: string;
  70608. shader: string;
  70609. };
  70610. }
  70611. declare module BABYLON {
  70612. /**
  70613. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70614. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70615. * As an example, all you have to do is to create the post-process:
  70616. * var mb = new BABYLON.MotionBlurPostProcess(
  70617. * 'mb', // The name of the effect.
  70618. * scene, // The scene containing the objects to blur according to their velocity.
  70619. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70620. * camera // The camera to apply the render pass to.
  70621. * );
  70622. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70623. */
  70624. export class MotionBlurPostProcess extends PostProcess {
  70625. /**
  70626. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70627. */
  70628. motionStrength: number;
  70629. /**
  70630. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70631. */
  70632. get motionBlurSamples(): number;
  70633. /**
  70634. * Sets the number of iterations to be used for motion blur quality
  70635. */
  70636. set motionBlurSamples(samples: number);
  70637. private _motionBlurSamples;
  70638. private _forceGeometryBuffer;
  70639. private _geometryBufferRenderer;
  70640. private _prePassRenderer;
  70641. /**
  70642. * Gets a string identifying the name of the class
  70643. * @returns "MotionBlurPostProcess" string
  70644. */
  70645. getClassName(): string;
  70646. /**
  70647. * Creates a new instance MotionBlurPostProcess
  70648. * @param name The name of the effect.
  70649. * @param scene The scene containing the objects to blur according to their velocity.
  70650. * @param options The required width/height ratio to downsize to before computing the render pass.
  70651. * @param camera The camera to apply the render pass to.
  70652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70653. * @param engine The engine which the post process will be applied. (default: current engine)
  70654. * @param reusable If the post process can be reused on the same frame. (default: false)
  70655. * @param textureType Type of textures used when performing the post process. (default: 0)
  70656. * @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)
  70657. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70658. */
  70659. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70660. /**
  70661. * Excludes the given skinned mesh from computing bones velocities.
  70662. * 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.
  70663. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70664. */
  70665. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70666. /**
  70667. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70668. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70669. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70670. */
  70671. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70672. /**
  70673. * Disposes the post process.
  70674. * @param camera The camera to dispose the post process on.
  70675. */
  70676. dispose(camera?: Camera): void;
  70677. /** @hidden */
  70678. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70679. }
  70680. }
  70681. declare module BABYLON {
  70682. /** @hidden */
  70683. export var refractionPixelShader: {
  70684. name: string;
  70685. shader: string;
  70686. };
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * Post process which applies a refractin texture
  70691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70692. */
  70693. export class RefractionPostProcess extends PostProcess {
  70694. private _refTexture;
  70695. private _ownRefractionTexture;
  70696. /** the base color of the refraction (used to taint the rendering) */
  70697. color: Color3;
  70698. /** simulated refraction depth */
  70699. depth: number;
  70700. /** the coefficient of the base color (0 to remove base color tainting) */
  70701. colorLevel: number;
  70702. /** Gets the url used to load the refraction texture */
  70703. refractionTextureUrl: string;
  70704. /**
  70705. * Gets or sets the refraction texture
  70706. * Please note that you are responsible for disposing the texture if you set it manually
  70707. */
  70708. get refractionTexture(): Texture;
  70709. set refractionTexture(value: Texture);
  70710. /**
  70711. * Gets a string identifying the name of the class
  70712. * @returns "RefractionPostProcess" string
  70713. */
  70714. getClassName(): string;
  70715. /**
  70716. * Initializes the RefractionPostProcess
  70717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70718. * @param name The name of the effect.
  70719. * @param refractionTextureUrl Url of the refraction texture to use
  70720. * @param color the base color of the refraction (used to taint the rendering)
  70721. * @param depth simulated refraction depth
  70722. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70723. * @param camera The camera to apply the render pass to.
  70724. * @param options The required width/height ratio to downsize to before computing the render pass.
  70725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70726. * @param engine The engine which the post process will be applied. (default: current engine)
  70727. * @param reusable If the post process can be reused on the same frame. (default: false)
  70728. */
  70729. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70730. /**
  70731. * Disposes of the post process
  70732. * @param camera Camera to dispose post process on
  70733. */
  70734. dispose(camera: Camera): void;
  70735. /** @hidden */
  70736. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70737. }
  70738. }
  70739. declare module BABYLON {
  70740. /** @hidden */
  70741. export var sharpenPixelShader: {
  70742. name: string;
  70743. shader: string;
  70744. };
  70745. }
  70746. declare module BABYLON {
  70747. /**
  70748. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70749. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70750. */
  70751. export class SharpenPostProcess extends PostProcess {
  70752. /**
  70753. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70754. */
  70755. colorAmount: number;
  70756. /**
  70757. * How much sharpness should be applied (default: 0.3)
  70758. */
  70759. edgeAmount: number;
  70760. /**
  70761. * Gets a string identifying the name of the class
  70762. * @returns "SharpenPostProcess" string
  70763. */
  70764. getClassName(): string;
  70765. /**
  70766. * Creates a new instance ConvolutionPostProcess
  70767. * @param name The name of the effect.
  70768. * @param options The required width/height ratio to downsize to before computing the render pass.
  70769. * @param camera The camera to apply the render pass to.
  70770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70771. * @param engine The engine which the post process will be applied. (default: current engine)
  70772. * @param reusable If the post process can be reused on the same frame. (default: false)
  70773. * @param textureType Type of textures used when performing the post process. (default: 0)
  70774. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  70775. */
  70776. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70777. /** @hidden */
  70778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. /**
  70783. * PostProcessRenderPipeline
  70784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70785. */
  70786. export class PostProcessRenderPipeline {
  70787. private engine;
  70788. private _renderEffects;
  70789. private _renderEffectsForIsolatedPass;
  70790. /**
  70791. * List of inspectable custom properties (used by the Inspector)
  70792. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70793. */
  70794. inspectableCustomProperties: IInspectable[];
  70795. /**
  70796. * @hidden
  70797. */
  70798. protected _cameras: Camera[];
  70799. /** @hidden */
  70800. _name: string;
  70801. /**
  70802. * Gets pipeline name
  70803. */
  70804. get name(): string;
  70805. /** Gets the list of attached cameras */
  70806. get cameras(): Camera[];
  70807. /**
  70808. * Initializes a PostProcessRenderPipeline
  70809. * @param engine engine to add the pipeline to
  70810. * @param name name of the pipeline
  70811. */
  70812. constructor(engine: Engine, name: string);
  70813. /**
  70814. * Gets the class name
  70815. * @returns "PostProcessRenderPipeline"
  70816. */
  70817. getClassName(): string;
  70818. /**
  70819. * If all the render effects in the pipeline are supported
  70820. */
  70821. get isSupported(): boolean;
  70822. /**
  70823. * Adds an effect to the pipeline
  70824. * @param renderEffect the effect to add
  70825. */
  70826. addEffect(renderEffect: PostProcessRenderEffect): void;
  70827. /** @hidden */
  70828. _rebuild(): void;
  70829. /** @hidden */
  70830. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70831. /** @hidden */
  70832. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70833. /** @hidden */
  70834. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70835. /** @hidden */
  70836. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70837. /** @hidden */
  70838. _attachCameras(cameras: Camera, unique: boolean): void;
  70839. /** @hidden */
  70840. _attachCameras(cameras: Camera[], unique: boolean): void;
  70841. /** @hidden */
  70842. _detachCameras(cameras: Camera): void;
  70843. /** @hidden */
  70844. _detachCameras(cameras: Nullable<Camera[]>): void;
  70845. /** @hidden */
  70846. _update(): void;
  70847. /** @hidden */
  70848. _reset(): void;
  70849. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70850. /**
  70851. * Sets the required values to the prepass renderer.
  70852. * @param prePassRenderer defines the prepass renderer to setup.
  70853. * @returns true if the pre pass is needed.
  70854. */
  70855. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70856. /**
  70857. * Disposes of the pipeline
  70858. */
  70859. dispose(): void;
  70860. }
  70861. }
  70862. declare module BABYLON {
  70863. /**
  70864. * PostProcessRenderPipelineManager class
  70865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70866. */
  70867. export class PostProcessRenderPipelineManager {
  70868. private _renderPipelines;
  70869. /**
  70870. * Initializes a PostProcessRenderPipelineManager
  70871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70872. */
  70873. constructor();
  70874. /**
  70875. * Gets the list of supported render pipelines
  70876. */
  70877. get supportedPipelines(): PostProcessRenderPipeline[];
  70878. /**
  70879. * Adds a pipeline to the manager
  70880. * @param renderPipeline The pipeline to add
  70881. */
  70882. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70883. /**
  70884. * Attaches a camera to the pipeline
  70885. * @param renderPipelineName The name of the pipeline to attach to
  70886. * @param cameras the camera to attach
  70887. * @param unique if the camera can be attached multiple times to the pipeline
  70888. */
  70889. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70890. /**
  70891. * Detaches a camera from the pipeline
  70892. * @param renderPipelineName The name of the pipeline to detach from
  70893. * @param cameras the camera to detach
  70894. */
  70895. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70896. /**
  70897. * Enables an effect by name on a pipeline
  70898. * @param renderPipelineName the name of the pipeline to enable the effect in
  70899. * @param renderEffectName the name of the effect to enable
  70900. * @param cameras the cameras that the effect should be enabled on
  70901. */
  70902. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70903. /**
  70904. * Disables an effect by name on a pipeline
  70905. * @param renderPipelineName the name of the pipeline to disable the effect in
  70906. * @param renderEffectName the name of the effect to disable
  70907. * @param cameras the cameras that the effect should be disabled on
  70908. */
  70909. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70910. /**
  70911. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70912. */
  70913. update(): void;
  70914. /** @hidden */
  70915. _rebuild(): void;
  70916. /**
  70917. * Disposes of the manager and pipelines
  70918. */
  70919. dispose(): void;
  70920. }
  70921. }
  70922. declare module BABYLON {
  70923. interface Scene {
  70924. /** @hidden (Backing field) */
  70925. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70926. /**
  70927. * Gets the postprocess render pipeline manager
  70928. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70929. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70930. */
  70931. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70932. }
  70933. /**
  70934. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70935. */
  70936. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70937. /**
  70938. * The component name helpfull to identify the component in the list of scene components.
  70939. */
  70940. readonly name: string;
  70941. /**
  70942. * The scene the component belongs to.
  70943. */
  70944. scene: Scene;
  70945. /**
  70946. * Creates a new instance of the component for the given scene
  70947. * @param scene Defines the scene to register the component in
  70948. */
  70949. constructor(scene: Scene);
  70950. /**
  70951. * Registers the component in a given scene
  70952. */
  70953. register(): void;
  70954. /**
  70955. * Rebuilds the elements related to this component in case of
  70956. * context lost for instance.
  70957. */
  70958. rebuild(): void;
  70959. /**
  70960. * Disposes the component and the associated ressources
  70961. */
  70962. dispose(): void;
  70963. private _gatherRenderTargets;
  70964. }
  70965. }
  70966. declare module BABYLON {
  70967. /**
  70968. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70969. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70970. */
  70971. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70972. private _scene;
  70973. private _camerasToBeAttached;
  70974. /**
  70975. * ID of the sharpen post process,
  70976. */
  70977. private readonly SharpenPostProcessId;
  70978. /**
  70979. * @ignore
  70980. * ID of the image processing post process;
  70981. */
  70982. readonly ImageProcessingPostProcessId: string;
  70983. /**
  70984. * @ignore
  70985. * ID of the Fast Approximate Anti-Aliasing post process;
  70986. */
  70987. readonly FxaaPostProcessId: string;
  70988. /**
  70989. * ID of the chromatic aberration post process,
  70990. */
  70991. private readonly ChromaticAberrationPostProcessId;
  70992. /**
  70993. * ID of the grain post process
  70994. */
  70995. private readonly GrainPostProcessId;
  70996. /**
  70997. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70998. */
  70999. sharpen: SharpenPostProcess;
  71000. private _sharpenEffect;
  71001. private bloom;
  71002. /**
  71003. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71004. */
  71005. depthOfField: DepthOfFieldEffect;
  71006. /**
  71007. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71008. */
  71009. fxaa: FxaaPostProcess;
  71010. /**
  71011. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71012. */
  71013. imageProcessing: ImageProcessingPostProcess;
  71014. /**
  71015. * Chromatic aberration post process which will shift rgb colors in the image
  71016. */
  71017. chromaticAberration: ChromaticAberrationPostProcess;
  71018. private _chromaticAberrationEffect;
  71019. /**
  71020. * Grain post process which add noise to the image
  71021. */
  71022. grain: GrainPostProcess;
  71023. private _grainEffect;
  71024. /**
  71025. * Glow post process which adds a glow to emissive areas of the image
  71026. */
  71027. private _glowLayer;
  71028. /**
  71029. * Animations which can be used to tweak settings over a period of time
  71030. */
  71031. animations: Animation[];
  71032. private _imageProcessingConfigurationObserver;
  71033. private _sharpenEnabled;
  71034. private _bloomEnabled;
  71035. private _depthOfFieldEnabled;
  71036. private _depthOfFieldBlurLevel;
  71037. private _fxaaEnabled;
  71038. private _imageProcessingEnabled;
  71039. private _defaultPipelineTextureType;
  71040. private _bloomScale;
  71041. private _chromaticAberrationEnabled;
  71042. private _grainEnabled;
  71043. private _buildAllowed;
  71044. /**
  71045. * Gets active scene
  71046. */
  71047. get scene(): Scene;
  71048. /**
  71049. * Enable or disable the sharpen process from the pipeline
  71050. */
  71051. set sharpenEnabled(enabled: boolean);
  71052. get sharpenEnabled(): boolean;
  71053. private _resizeObserver;
  71054. private _hardwareScaleLevel;
  71055. private _bloomKernel;
  71056. /**
  71057. * Specifies the size of the bloom blur kernel, relative to the final output size
  71058. */
  71059. get bloomKernel(): number;
  71060. set bloomKernel(value: number);
  71061. /**
  71062. * Specifies the weight of the bloom in the final rendering
  71063. */
  71064. private _bloomWeight;
  71065. /**
  71066. * Specifies the luma threshold for the area that will be blurred by the bloom
  71067. */
  71068. private _bloomThreshold;
  71069. private _hdr;
  71070. /**
  71071. * The strength of the bloom.
  71072. */
  71073. set bloomWeight(value: number);
  71074. get bloomWeight(): number;
  71075. /**
  71076. * The strength of the bloom.
  71077. */
  71078. set bloomThreshold(value: number);
  71079. get bloomThreshold(): number;
  71080. /**
  71081. * The scale of the bloom, lower value will provide better performance.
  71082. */
  71083. set bloomScale(value: number);
  71084. get bloomScale(): number;
  71085. /**
  71086. * Enable or disable the bloom from the pipeline
  71087. */
  71088. set bloomEnabled(enabled: boolean);
  71089. get bloomEnabled(): boolean;
  71090. private _rebuildBloom;
  71091. /**
  71092. * If the depth of field is enabled.
  71093. */
  71094. get depthOfFieldEnabled(): boolean;
  71095. set depthOfFieldEnabled(enabled: boolean);
  71096. /**
  71097. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71098. */
  71099. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71100. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71101. /**
  71102. * If the anti aliasing is enabled.
  71103. */
  71104. set fxaaEnabled(enabled: boolean);
  71105. get fxaaEnabled(): boolean;
  71106. private _samples;
  71107. /**
  71108. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71109. */
  71110. set samples(sampleCount: number);
  71111. get samples(): number;
  71112. /**
  71113. * If image processing is enabled.
  71114. */
  71115. set imageProcessingEnabled(enabled: boolean);
  71116. get imageProcessingEnabled(): boolean;
  71117. /**
  71118. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71119. */
  71120. set glowLayerEnabled(enabled: boolean);
  71121. get glowLayerEnabled(): boolean;
  71122. /**
  71123. * Gets the glow layer (or null if not defined)
  71124. */
  71125. get glowLayer(): Nullable<GlowLayer>;
  71126. /**
  71127. * Enable or disable the chromaticAberration process from the pipeline
  71128. */
  71129. set chromaticAberrationEnabled(enabled: boolean);
  71130. get chromaticAberrationEnabled(): boolean;
  71131. /**
  71132. * Enable or disable the grain process from the pipeline
  71133. */
  71134. set grainEnabled(enabled: boolean);
  71135. get grainEnabled(): boolean;
  71136. /**
  71137. * @constructor
  71138. * @param name - The rendering pipeline name (default: "")
  71139. * @param hdr - If high dynamic range textures should be used (default: true)
  71140. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71141. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71142. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71143. */
  71144. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71145. /**
  71146. * Get the class name
  71147. * @returns "DefaultRenderingPipeline"
  71148. */
  71149. getClassName(): string;
  71150. /**
  71151. * Force the compilation of the entire pipeline.
  71152. */
  71153. prepare(): void;
  71154. private _hasCleared;
  71155. private _prevPostProcess;
  71156. private _prevPrevPostProcess;
  71157. private _setAutoClearAndTextureSharing;
  71158. private _depthOfFieldSceneObserver;
  71159. private _buildPipeline;
  71160. private _disposePostProcesses;
  71161. /**
  71162. * Adds a camera to the pipeline
  71163. * @param camera the camera to be added
  71164. */
  71165. addCamera(camera: Camera): void;
  71166. /**
  71167. * Removes a camera from the pipeline
  71168. * @param camera the camera to remove
  71169. */
  71170. removeCamera(camera: Camera): void;
  71171. /**
  71172. * Dispose of the pipeline and stop all post processes
  71173. */
  71174. dispose(): void;
  71175. /**
  71176. * Serialize the rendering pipeline (Used when exporting)
  71177. * @returns the serialized object
  71178. */
  71179. serialize(): any;
  71180. /**
  71181. * Parse the serialized pipeline
  71182. * @param source Source pipeline.
  71183. * @param scene The scene to load the pipeline to.
  71184. * @param rootUrl The URL of the serialized pipeline.
  71185. * @returns An instantiated pipeline from the serialized object.
  71186. */
  71187. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. /** @hidden */
  71192. export var lensHighlightsPixelShader: {
  71193. name: string;
  71194. shader: string;
  71195. };
  71196. }
  71197. declare module BABYLON {
  71198. /** @hidden */
  71199. export var depthOfFieldPixelShader: {
  71200. name: string;
  71201. shader: string;
  71202. };
  71203. }
  71204. declare module BABYLON {
  71205. /**
  71206. * BABYLON.JS Chromatic Aberration GLSL Shader
  71207. * Author: Olivier Guyot
  71208. * Separates very slightly R, G and B colors on the edges of the screen
  71209. * Inspired by Francois Tarlier & Martins Upitis
  71210. */
  71211. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71212. /**
  71213. * @ignore
  71214. * The chromatic aberration PostProcess id in the pipeline
  71215. */
  71216. LensChromaticAberrationEffect: string;
  71217. /**
  71218. * @ignore
  71219. * The highlights enhancing PostProcess id in the pipeline
  71220. */
  71221. HighlightsEnhancingEffect: string;
  71222. /**
  71223. * @ignore
  71224. * The depth-of-field PostProcess id in the pipeline
  71225. */
  71226. LensDepthOfFieldEffect: string;
  71227. private _scene;
  71228. private _depthTexture;
  71229. private _grainTexture;
  71230. private _chromaticAberrationPostProcess;
  71231. private _highlightsPostProcess;
  71232. private _depthOfFieldPostProcess;
  71233. private _edgeBlur;
  71234. private _grainAmount;
  71235. private _chromaticAberration;
  71236. private _distortion;
  71237. private _highlightsGain;
  71238. private _highlightsThreshold;
  71239. private _dofDistance;
  71240. private _dofAperture;
  71241. private _dofDarken;
  71242. private _dofPentagon;
  71243. private _blurNoise;
  71244. /**
  71245. * @constructor
  71246. *
  71247. * Effect parameters are as follow:
  71248. * {
  71249. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71250. * edge_blur: number; // from 0 to x (1 for realism)
  71251. * distortion: number; // from 0 to x (1 for realism)
  71252. * grain_amount: number; // from 0 to 1
  71253. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71254. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71255. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71256. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71257. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71258. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71259. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71260. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71261. * }
  71262. * Note: if an effect parameter is unset, effect is disabled
  71263. *
  71264. * @param name The rendering pipeline name
  71265. * @param parameters - An object containing all parameters (see above)
  71266. * @param scene The scene linked to this pipeline
  71267. * @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)
  71268. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71269. */
  71270. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71271. /**
  71272. * Get the class name
  71273. * @returns "LensRenderingPipeline"
  71274. */
  71275. getClassName(): string;
  71276. /**
  71277. * Gets associated scene
  71278. */
  71279. get scene(): Scene;
  71280. /**
  71281. * Gets or sets the edge blur
  71282. */
  71283. get edgeBlur(): number;
  71284. set edgeBlur(value: number);
  71285. /**
  71286. * Gets or sets the grain amount
  71287. */
  71288. get grainAmount(): number;
  71289. set grainAmount(value: number);
  71290. /**
  71291. * Gets or sets the chromatic aberration amount
  71292. */
  71293. get chromaticAberration(): number;
  71294. set chromaticAberration(value: number);
  71295. /**
  71296. * Gets or sets the depth of field aperture
  71297. */
  71298. get dofAperture(): number;
  71299. set dofAperture(value: number);
  71300. /**
  71301. * Gets or sets the edge distortion
  71302. */
  71303. get edgeDistortion(): number;
  71304. set edgeDistortion(value: number);
  71305. /**
  71306. * Gets or sets the depth of field distortion
  71307. */
  71308. get dofDistortion(): number;
  71309. set dofDistortion(value: number);
  71310. /**
  71311. * Gets or sets the darken out of focus amount
  71312. */
  71313. get darkenOutOfFocus(): number;
  71314. set darkenOutOfFocus(value: number);
  71315. /**
  71316. * Gets or sets a boolean indicating if blur noise is enabled
  71317. */
  71318. get blurNoise(): boolean;
  71319. set blurNoise(value: boolean);
  71320. /**
  71321. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71322. */
  71323. get pentagonBokeh(): boolean;
  71324. set pentagonBokeh(value: boolean);
  71325. /**
  71326. * Gets or sets the highlight grain amount
  71327. */
  71328. get highlightsGain(): number;
  71329. set highlightsGain(value: number);
  71330. /**
  71331. * Gets or sets the highlight threshold
  71332. */
  71333. get highlightsThreshold(): number;
  71334. set highlightsThreshold(value: number);
  71335. /**
  71336. * Sets the amount of blur at the edges
  71337. * @param amount blur amount
  71338. */
  71339. setEdgeBlur(amount: number): void;
  71340. /**
  71341. * Sets edge blur to 0
  71342. */
  71343. disableEdgeBlur(): void;
  71344. /**
  71345. * Sets the amout of grain
  71346. * @param amount Amount of grain
  71347. */
  71348. setGrainAmount(amount: number): void;
  71349. /**
  71350. * Set grain amount to 0
  71351. */
  71352. disableGrain(): void;
  71353. /**
  71354. * Sets the chromatic aberration amount
  71355. * @param amount amount of chromatic aberration
  71356. */
  71357. setChromaticAberration(amount: number): void;
  71358. /**
  71359. * Sets chromatic aberration amount to 0
  71360. */
  71361. disableChromaticAberration(): void;
  71362. /**
  71363. * Sets the EdgeDistortion amount
  71364. * @param amount amount of EdgeDistortion
  71365. */
  71366. setEdgeDistortion(amount: number): void;
  71367. /**
  71368. * Sets edge distortion to 0
  71369. */
  71370. disableEdgeDistortion(): void;
  71371. /**
  71372. * Sets the FocusDistance amount
  71373. * @param amount amount of FocusDistance
  71374. */
  71375. setFocusDistance(amount: number): void;
  71376. /**
  71377. * Disables depth of field
  71378. */
  71379. disableDepthOfField(): void;
  71380. /**
  71381. * Sets the Aperture amount
  71382. * @param amount amount of Aperture
  71383. */
  71384. setAperture(amount: number): void;
  71385. /**
  71386. * Sets the DarkenOutOfFocus amount
  71387. * @param amount amount of DarkenOutOfFocus
  71388. */
  71389. setDarkenOutOfFocus(amount: number): void;
  71390. private _pentagonBokehIsEnabled;
  71391. /**
  71392. * Creates a pentagon bokeh effect
  71393. */
  71394. enablePentagonBokeh(): void;
  71395. /**
  71396. * Disables the pentagon bokeh effect
  71397. */
  71398. disablePentagonBokeh(): void;
  71399. /**
  71400. * Enables noise blur
  71401. */
  71402. enableNoiseBlur(): void;
  71403. /**
  71404. * Disables noise blur
  71405. */
  71406. disableNoiseBlur(): void;
  71407. /**
  71408. * Sets the HighlightsGain amount
  71409. * @param amount amount of HighlightsGain
  71410. */
  71411. setHighlightsGain(amount: number): void;
  71412. /**
  71413. * Sets the HighlightsThreshold amount
  71414. * @param amount amount of HighlightsThreshold
  71415. */
  71416. setHighlightsThreshold(amount: number): void;
  71417. /**
  71418. * Disables highlights
  71419. */
  71420. disableHighlights(): void;
  71421. /**
  71422. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71423. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71424. */
  71425. dispose(disableDepthRender?: boolean): void;
  71426. private _createChromaticAberrationPostProcess;
  71427. private _createHighlightsPostProcess;
  71428. private _createDepthOfFieldPostProcess;
  71429. private _createGrainTexture;
  71430. }
  71431. }
  71432. declare module BABYLON {
  71433. /**
  71434. * Contains all parameters needed for the prepass to perform
  71435. * screen space subsurface scattering
  71436. */
  71437. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71438. /**
  71439. * Is subsurface enabled
  71440. */
  71441. enabled: boolean;
  71442. /**
  71443. * Name of the configuration
  71444. */
  71445. name: string;
  71446. /**
  71447. * Textures that should be present in the MRT for this effect to work
  71448. */
  71449. readonly texturesRequired: number[];
  71450. }
  71451. }
  71452. declare module BABYLON {
  71453. /** @hidden */
  71454. export var ssao2PixelShader: {
  71455. name: string;
  71456. shader: string;
  71457. };
  71458. }
  71459. declare module BABYLON {
  71460. /** @hidden */
  71461. export var ssaoCombinePixelShader: {
  71462. name: string;
  71463. shader: string;
  71464. };
  71465. }
  71466. declare module BABYLON {
  71467. /**
  71468. * Render pipeline to produce ssao effect
  71469. */
  71470. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71471. /**
  71472. * @ignore
  71473. * The PassPostProcess id in the pipeline that contains the original scene color
  71474. */
  71475. SSAOOriginalSceneColorEffect: string;
  71476. /**
  71477. * @ignore
  71478. * The SSAO PostProcess id in the pipeline
  71479. */
  71480. SSAORenderEffect: string;
  71481. /**
  71482. * @ignore
  71483. * The horizontal blur PostProcess id in the pipeline
  71484. */
  71485. SSAOBlurHRenderEffect: string;
  71486. /**
  71487. * @ignore
  71488. * The vertical blur PostProcess id in the pipeline
  71489. */
  71490. SSAOBlurVRenderEffect: string;
  71491. /**
  71492. * @ignore
  71493. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71494. */
  71495. SSAOCombineRenderEffect: string;
  71496. /**
  71497. * The output strength of the SSAO post-process. Default value is 1.0.
  71498. */
  71499. totalStrength: number;
  71500. /**
  71501. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71502. */
  71503. maxZ: number;
  71504. /**
  71505. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71506. */
  71507. minZAspect: number;
  71508. private _samples;
  71509. /**
  71510. * Number of samples used for the SSAO calculations. Default value is 8
  71511. */
  71512. set samples(n: number);
  71513. get samples(): number;
  71514. private _textureSamples;
  71515. /**
  71516. * Number of samples to use for antialiasing
  71517. */
  71518. set textureSamples(n: number);
  71519. get textureSamples(): number;
  71520. /**
  71521. * Force rendering the geometry through geometry buffer
  71522. */
  71523. private _forceGeometryBuffer;
  71524. /**
  71525. * Ratio object used for SSAO ratio and blur ratio
  71526. */
  71527. private _ratio;
  71528. /**
  71529. * Dynamically generated sphere sampler.
  71530. */
  71531. private _sampleSphere;
  71532. /**
  71533. * Blur filter offsets
  71534. */
  71535. private _samplerOffsets;
  71536. private _expensiveBlur;
  71537. /**
  71538. * If bilateral blur should be used
  71539. */
  71540. set expensiveBlur(b: boolean);
  71541. get expensiveBlur(): boolean;
  71542. /**
  71543. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71544. */
  71545. radius: number;
  71546. /**
  71547. * The base color of the SSAO post-process
  71548. * The final result is "base + ssao" between [0, 1]
  71549. */
  71550. base: number;
  71551. /**
  71552. * Support test.
  71553. */
  71554. static get IsSupported(): boolean;
  71555. private _scene;
  71556. private _randomTexture;
  71557. private _originalColorPostProcess;
  71558. private _ssaoPostProcess;
  71559. private _blurHPostProcess;
  71560. private _blurVPostProcess;
  71561. private _ssaoCombinePostProcess;
  71562. private _prePassRenderer;
  71563. /**
  71564. * Gets active scene
  71565. */
  71566. get scene(): Scene;
  71567. /**
  71568. * @constructor
  71569. * @param name The rendering pipeline name
  71570. * @param scene The scene linked to this pipeline
  71571. * @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 }
  71572. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71573. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71574. */
  71575. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71576. /**
  71577. * Get the class name
  71578. * @returns "SSAO2RenderingPipeline"
  71579. */
  71580. getClassName(): string;
  71581. /**
  71582. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71583. */
  71584. dispose(disableGeometryBufferRenderer?: boolean): void;
  71585. private _createBlurPostProcess;
  71586. /** @hidden */
  71587. _rebuild(): void;
  71588. private _bits;
  71589. private _radicalInverse_VdC;
  71590. private _hammersley;
  71591. private _hemisphereSample_uniform;
  71592. private _generateHemisphere;
  71593. private _getDefinesForSSAO;
  71594. private _createSSAOPostProcess;
  71595. private _createSSAOCombinePostProcess;
  71596. private _createRandomTexture;
  71597. /**
  71598. * Serialize the rendering pipeline (Used when exporting)
  71599. * @returns the serialized object
  71600. */
  71601. serialize(): any;
  71602. /**
  71603. * Parse the serialized pipeline
  71604. * @param source Source pipeline.
  71605. * @param scene The scene to load the pipeline to.
  71606. * @param rootUrl The URL of the serialized pipeline.
  71607. * @returns An instantiated pipeline from the serialized object.
  71608. */
  71609. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71610. }
  71611. }
  71612. declare module BABYLON {
  71613. /** @hidden */
  71614. export var ssaoPixelShader: {
  71615. name: string;
  71616. shader: string;
  71617. };
  71618. }
  71619. declare module BABYLON {
  71620. /**
  71621. * Render pipeline to produce ssao effect
  71622. */
  71623. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71624. /**
  71625. * @ignore
  71626. * The PassPostProcess id in the pipeline that contains the original scene color
  71627. */
  71628. SSAOOriginalSceneColorEffect: string;
  71629. /**
  71630. * @ignore
  71631. * The SSAO PostProcess id in the pipeline
  71632. */
  71633. SSAORenderEffect: string;
  71634. /**
  71635. * @ignore
  71636. * The horizontal blur PostProcess id in the pipeline
  71637. */
  71638. SSAOBlurHRenderEffect: string;
  71639. /**
  71640. * @ignore
  71641. * The vertical blur PostProcess id in the pipeline
  71642. */
  71643. SSAOBlurVRenderEffect: string;
  71644. /**
  71645. * @ignore
  71646. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71647. */
  71648. SSAOCombineRenderEffect: string;
  71649. /**
  71650. * The output strength of the SSAO post-process. Default value is 1.0.
  71651. */
  71652. totalStrength: number;
  71653. /**
  71654. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71655. */
  71656. radius: number;
  71657. /**
  71658. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71659. * Must not be equal to fallOff and superior to fallOff.
  71660. * Default value is 0.0075
  71661. */
  71662. area: number;
  71663. /**
  71664. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71665. * Must not be equal to area and inferior to area.
  71666. * Default value is 0.000001
  71667. */
  71668. fallOff: number;
  71669. /**
  71670. * The base color of the SSAO post-process
  71671. * The final result is "base + ssao" between [0, 1]
  71672. */
  71673. base: number;
  71674. private _scene;
  71675. private _depthTexture;
  71676. private _randomTexture;
  71677. private _originalColorPostProcess;
  71678. private _ssaoPostProcess;
  71679. private _blurHPostProcess;
  71680. private _blurVPostProcess;
  71681. private _ssaoCombinePostProcess;
  71682. private _firstUpdate;
  71683. /**
  71684. * Gets active scene
  71685. */
  71686. get scene(): Scene;
  71687. /**
  71688. * @constructor
  71689. * @param name - The rendering pipeline name
  71690. * @param scene - The scene linked to this pipeline
  71691. * @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 }
  71692. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71693. */
  71694. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71695. /**
  71696. * Get the class name
  71697. * @returns "SSAORenderingPipeline"
  71698. */
  71699. getClassName(): string;
  71700. /**
  71701. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71702. */
  71703. dispose(disableDepthRender?: boolean): void;
  71704. private _createBlurPostProcess;
  71705. /** @hidden */
  71706. _rebuild(): void;
  71707. private _createSSAOPostProcess;
  71708. private _createSSAOCombinePostProcess;
  71709. private _createRandomTexture;
  71710. }
  71711. }
  71712. declare module BABYLON {
  71713. /**
  71714. * Contains all parameters needed for the prepass to perform
  71715. * screen space reflections
  71716. */
  71717. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71718. /**
  71719. * Is ssr enabled
  71720. */
  71721. enabled: boolean;
  71722. /**
  71723. * Name of the configuration
  71724. */
  71725. name: string;
  71726. /**
  71727. * Textures that should be present in the MRT for this effect to work
  71728. */
  71729. readonly texturesRequired: number[];
  71730. }
  71731. }
  71732. declare module BABYLON {
  71733. /** @hidden */
  71734. export var screenSpaceReflectionPixelShader: {
  71735. name: string;
  71736. shader: string;
  71737. };
  71738. }
  71739. declare module BABYLON {
  71740. /**
  71741. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71742. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71743. */
  71744. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71745. /**
  71746. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71747. */
  71748. threshold: number;
  71749. /**
  71750. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71751. */
  71752. strength: number;
  71753. /**
  71754. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71755. */
  71756. reflectionSpecularFalloffExponent: number;
  71757. /**
  71758. * 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]
  71759. */
  71760. step: number;
  71761. /**
  71762. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71763. */
  71764. roughnessFactor: number;
  71765. private _forceGeometryBuffer;
  71766. private _geometryBufferRenderer;
  71767. private _prePassRenderer;
  71768. private _enableSmoothReflections;
  71769. private _reflectionSamples;
  71770. private _smoothSteps;
  71771. /**
  71772. * Gets a string identifying the name of the class
  71773. * @returns "ScreenSpaceReflectionPostProcess" string
  71774. */
  71775. getClassName(): string;
  71776. /**
  71777. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71778. * @param name The name of the effect.
  71779. * @param scene The scene containing the objects to calculate reflections.
  71780. * @param options The required width/height ratio to downsize to before computing the render pass.
  71781. * @param camera The camera to apply the render pass to.
  71782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71783. * @param engine The engine which the post process will be applied. (default: current engine)
  71784. * @param reusable If the post process can be reused on the same frame. (default: false)
  71785. * @param textureType Type of textures used when performing the post process. (default: 0)
  71786. * @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)
  71787. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71788. */
  71789. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71790. /**
  71791. * Gets wether or not smoothing reflections is enabled.
  71792. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71793. */
  71794. get enableSmoothReflections(): boolean;
  71795. /**
  71796. * Sets wether or not smoothing reflections is enabled.
  71797. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71798. */
  71799. set enableSmoothReflections(enabled: boolean);
  71800. /**
  71801. * Gets the number of samples taken while computing reflections. More samples count is high,
  71802. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71803. */
  71804. get reflectionSamples(): number;
  71805. /**
  71806. * Sets the number of samples taken while computing reflections. More samples count is high,
  71807. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71808. */
  71809. set reflectionSamples(samples: number);
  71810. /**
  71811. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71812. * more the post-process will require GPU power and can generate a drop in FPS.
  71813. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71814. */
  71815. get smoothSteps(): number;
  71816. set smoothSteps(steps: number);
  71817. private _updateEffectDefines;
  71818. /** @hidden */
  71819. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71820. }
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export var standardPixelShader: {
  71825. name: string;
  71826. shader: string;
  71827. };
  71828. }
  71829. declare module BABYLON {
  71830. /**
  71831. * Standard rendering pipeline
  71832. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71833. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71834. */
  71835. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71836. /**
  71837. * Public members
  71838. */
  71839. /**
  71840. * Post-process which contains the original scene color before the pipeline applies all the effects
  71841. */
  71842. originalPostProcess: Nullable<PostProcess>;
  71843. /**
  71844. * Post-process used to down scale an image x4
  71845. */
  71846. downSampleX4PostProcess: Nullable<PostProcess>;
  71847. /**
  71848. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71849. */
  71850. brightPassPostProcess: Nullable<PostProcess>;
  71851. /**
  71852. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71853. */
  71854. blurHPostProcesses: PostProcess[];
  71855. /**
  71856. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71857. */
  71858. blurVPostProcesses: PostProcess[];
  71859. /**
  71860. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71861. */
  71862. textureAdderPostProcess: Nullable<PostProcess>;
  71863. /**
  71864. * Post-process used to create volumetric lighting effect
  71865. */
  71866. volumetricLightPostProcess: Nullable<PostProcess>;
  71867. /**
  71868. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71869. */
  71870. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71871. /**
  71872. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71873. */
  71874. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71875. /**
  71876. * Post-process used to merge the volumetric light effect and the real scene color
  71877. */
  71878. volumetricLightMergePostProces: Nullable<PostProcess>;
  71879. /**
  71880. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71881. */
  71882. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71883. /**
  71884. * Base post-process used to calculate the average luminance of the final image for HDR
  71885. */
  71886. luminancePostProcess: Nullable<PostProcess>;
  71887. /**
  71888. * Post-processes used to create down sample post-processes in order to get
  71889. * the average luminance of the final image for HDR
  71890. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71891. */
  71892. luminanceDownSamplePostProcesses: PostProcess[];
  71893. /**
  71894. * Post-process used to create a HDR effect (light adaptation)
  71895. */
  71896. hdrPostProcess: Nullable<PostProcess>;
  71897. /**
  71898. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71899. */
  71900. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71901. /**
  71902. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71903. */
  71904. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71905. /**
  71906. * Post-process used to merge the final HDR post-process and the real scene color
  71907. */
  71908. hdrFinalPostProcess: Nullable<PostProcess>;
  71909. /**
  71910. * Post-process used to create a lens flare effect
  71911. */
  71912. lensFlarePostProcess: Nullable<PostProcess>;
  71913. /**
  71914. * Post-process that merges the result of the lens flare post-process and the real scene color
  71915. */
  71916. lensFlareComposePostProcess: Nullable<PostProcess>;
  71917. /**
  71918. * Post-process used to create a motion blur effect
  71919. */
  71920. motionBlurPostProcess: Nullable<PostProcess>;
  71921. /**
  71922. * Post-process used to create a depth of field effect
  71923. */
  71924. depthOfFieldPostProcess: Nullable<PostProcess>;
  71925. /**
  71926. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71927. */
  71928. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71929. /**
  71930. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71931. */
  71932. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71933. /**
  71934. * Represents the brightness threshold in order to configure the illuminated surfaces
  71935. */
  71936. brightThreshold: number;
  71937. /**
  71938. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71939. */
  71940. blurWidth: number;
  71941. /**
  71942. * Sets if the blur for highlighted surfaces must be only horizontal
  71943. */
  71944. horizontalBlur: boolean;
  71945. /**
  71946. * Gets the overall exposure used by the pipeline
  71947. */
  71948. get exposure(): number;
  71949. /**
  71950. * Sets the overall exposure used by the pipeline
  71951. */
  71952. set exposure(value: number);
  71953. /**
  71954. * Texture used typically to simulate "dirty" on camera lens
  71955. */
  71956. lensTexture: Nullable<Texture>;
  71957. /**
  71958. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71959. */
  71960. volumetricLightCoefficient: number;
  71961. /**
  71962. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71963. */
  71964. volumetricLightPower: number;
  71965. /**
  71966. * Used the set the blur intensity to smooth the volumetric lights
  71967. */
  71968. volumetricLightBlurScale: number;
  71969. /**
  71970. * Light (spot or directional) used to generate the volumetric lights rays
  71971. * The source light must have a shadow generate so the pipeline can get its
  71972. * depth map
  71973. */
  71974. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71975. /**
  71976. * For eye adaptation, represents the minimum luminance the eye can see
  71977. */
  71978. hdrMinimumLuminance: number;
  71979. /**
  71980. * For eye adaptation, represents the decrease luminance speed
  71981. */
  71982. hdrDecreaseRate: number;
  71983. /**
  71984. * For eye adaptation, represents the increase luminance speed
  71985. */
  71986. hdrIncreaseRate: number;
  71987. /**
  71988. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71989. */
  71990. get hdrAutoExposure(): boolean;
  71991. /**
  71992. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71993. */
  71994. set hdrAutoExposure(value: boolean);
  71995. /**
  71996. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71997. */
  71998. lensColorTexture: Nullable<Texture>;
  71999. /**
  72000. * The overall strengh for the lens flare effect
  72001. */
  72002. lensFlareStrength: number;
  72003. /**
  72004. * Dispersion coefficient for lens flare ghosts
  72005. */
  72006. lensFlareGhostDispersal: number;
  72007. /**
  72008. * Main lens flare halo width
  72009. */
  72010. lensFlareHaloWidth: number;
  72011. /**
  72012. * Based on the lens distortion effect, defines how much the lens flare result
  72013. * is distorted
  72014. */
  72015. lensFlareDistortionStrength: number;
  72016. /**
  72017. * Configures the blur intensity used for for lens flare (halo)
  72018. */
  72019. lensFlareBlurWidth: number;
  72020. /**
  72021. * Lens star texture must be used to simulate rays on the flares and is available
  72022. * in the documentation
  72023. */
  72024. lensStarTexture: Nullable<Texture>;
  72025. /**
  72026. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72027. * flare effect by taking account of the dirt texture
  72028. */
  72029. lensFlareDirtTexture: Nullable<Texture>;
  72030. /**
  72031. * Represents the focal length for the depth of field effect
  72032. */
  72033. depthOfFieldDistance: number;
  72034. /**
  72035. * Represents the blur intensity for the blurred part of the depth of field effect
  72036. */
  72037. depthOfFieldBlurWidth: number;
  72038. /**
  72039. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72040. */
  72041. get motionStrength(): number;
  72042. /**
  72043. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72044. */
  72045. set motionStrength(strength: number);
  72046. /**
  72047. * Gets wether or not the motion blur post-process is object based or screen based.
  72048. */
  72049. get objectBasedMotionBlur(): boolean;
  72050. /**
  72051. * Sets wether or not the motion blur post-process should be object based or screen based
  72052. */
  72053. set objectBasedMotionBlur(value: boolean);
  72054. /**
  72055. * List of animations for the pipeline (IAnimatable implementation)
  72056. */
  72057. animations: Animation[];
  72058. /**
  72059. * Private members
  72060. */
  72061. private _scene;
  72062. private _currentDepthOfFieldSource;
  72063. private _basePostProcess;
  72064. private _fixedExposure;
  72065. private _currentExposure;
  72066. private _hdrAutoExposure;
  72067. private _hdrCurrentLuminance;
  72068. private _motionStrength;
  72069. private _isObjectBasedMotionBlur;
  72070. private _floatTextureType;
  72071. private _camerasToBeAttached;
  72072. private _ratio;
  72073. private _bloomEnabled;
  72074. private _depthOfFieldEnabled;
  72075. private _vlsEnabled;
  72076. private _lensFlareEnabled;
  72077. private _hdrEnabled;
  72078. private _motionBlurEnabled;
  72079. private _fxaaEnabled;
  72080. private _screenSpaceReflectionsEnabled;
  72081. private _motionBlurSamples;
  72082. private _volumetricLightStepsCount;
  72083. private _samples;
  72084. /**
  72085. * @ignore
  72086. * Specifies if the bloom pipeline is enabled
  72087. */
  72088. get BloomEnabled(): boolean;
  72089. set BloomEnabled(enabled: boolean);
  72090. /**
  72091. * @ignore
  72092. * Specifies if the depth of field pipeline is enabed
  72093. */
  72094. get DepthOfFieldEnabled(): boolean;
  72095. set DepthOfFieldEnabled(enabled: boolean);
  72096. /**
  72097. * @ignore
  72098. * Specifies if the lens flare pipeline is enabed
  72099. */
  72100. get LensFlareEnabled(): boolean;
  72101. set LensFlareEnabled(enabled: boolean);
  72102. /**
  72103. * @ignore
  72104. * Specifies if the HDR pipeline is enabled
  72105. */
  72106. get HDREnabled(): boolean;
  72107. set HDREnabled(enabled: boolean);
  72108. /**
  72109. * @ignore
  72110. * Specifies if the volumetric lights scattering effect is enabled
  72111. */
  72112. get VLSEnabled(): boolean;
  72113. set VLSEnabled(enabled: boolean);
  72114. /**
  72115. * @ignore
  72116. * Specifies if the motion blur effect is enabled
  72117. */
  72118. get MotionBlurEnabled(): boolean;
  72119. set MotionBlurEnabled(enabled: boolean);
  72120. /**
  72121. * Specifies if anti-aliasing is enabled
  72122. */
  72123. get fxaaEnabled(): boolean;
  72124. set fxaaEnabled(enabled: boolean);
  72125. /**
  72126. * Specifies if screen space reflections are enabled.
  72127. */
  72128. get screenSpaceReflectionsEnabled(): boolean;
  72129. set screenSpaceReflectionsEnabled(enabled: boolean);
  72130. /**
  72131. * Specifies the number of steps used to calculate the volumetric lights
  72132. * Typically in interval [50, 200]
  72133. */
  72134. get volumetricLightStepsCount(): number;
  72135. set volumetricLightStepsCount(count: number);
  72136. /**
  72137. * Specifies the number of samples used for the motion blur effect
  72138. * Typically in interval [16, 64]
  72139. */
  72140. get motionBlurSamples(): number;
  72141. set motionBlurSamples(samples: number);
  72142. /**
  72143. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72144. */
  72145. get samples(): number;
  72146. set samples(sampleCount: number);
  72147. /**
  72148. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72149. * @constructor
  72150. * @param name The rendering pipeline name
  72151. * @param scene The scene linked to this pipeline
  72152. * @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)
  72153. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72154. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72155. */
  72156. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72157. private _buildPipeline;
  72158. private _createDownSampleX4PostProcess;
  72159. private _createBrightPassPostProcess;
  72160. private _createBlurPostProcesses;
  72161. private _createTextureAdderPostProcess;
  72162. private _createVolumetricLightPostProcess;
  72163. private _createLuminancePostProcesses;
  72164. private _createHdrPostProcess;
  72165. private _createLensFlarePostProcess;
  72166. private _createDepthOfFieldPostProcess;
  72167. private _createMotionBlurPostProcess;
  72168. private _getDepthTexture;
  72169. private _disposePostProcesses;
  72170. /**
  72171. * Dispose of the pipeline and stop all post processes
  72172. */
  72173. dispose(): void;
  72174. /**
  72175. * Serialize the rendering pipeline (Used when exporting)
  72176. * @returns the serialized object
  72177. */
  72178. serialize(): any;
  72179. /**
  72180. * Parse the serialized pipeline
  72181. * @param source Source pipeline.
  72182. * @param scene The scene to load the pipeline to.
  72183. * @param rootUrl The URL of the serialized pipeline.
  72184. * @returns An instantiated pipeline from the serialized object.
  72185. */
  72186. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72187. /**
  72188. * Luminance steps
  72189. */
  72190. static LuminanceSteps: number;
  72191. }
  72192. }
  72193. declare module BABYLON {
  72194. /** @hidden */
  72195. export var stereoscopicInterlacePixelShader: {
  72196. name: string;
  72197. shader: string;
  72198. };
  72199. }
  72200. declare module BABYLON {
  72201. /**
  72202. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72203. */
  72204. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72205. private _stepSize;
  72206. private _passedProcess;
  72207. /**
  72208. * Gets a string identifying the name of the class
  72209. * @returns "StereoscopicInterlacePostProcessI" string
  72210. */
  72211. getClassName(): string;
  72212. /**
  72213. * Initializes a StereoscopicInterlacePostProcessI
  72214. * @param name The name of the effect.
  72215. * @param rigCameras The rig cameras to be appled to the post process
  72216. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72217. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72219. * @param engine The engine which the post process will be applied. (default: current engine)
  72220. * @param reusable If the post process can be reused on the same frame. (default: false)
  72221. */
  72222. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72223. }
  72224. /**
  72225. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72226. */
  72227. export class StereoscopicInterlacePostProcess extends PostProcess {
  72228. private _stepSize;
  72229. private _passedProcess;
  72230. /**
  72231. * Gets a string identifying the name of the class
  72232. * @returns "StereoscopicInterlacePostProcess" string
  72233. */
  72234. getClassName(): string;
  72235. /**
  72236. * Initializes a StereoscopicInterlacePostProcess
  72237. * @param name The name of the effect.
  72238. * @param rigCameras The rig cameras to be appled to the post process
  72239. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72241. * @param engine The engine which the post process will be applied. (default: current engine)
  72242. * @param reusable If the post process can be reused on the same frame. (default: false)
  72243. */
  72244. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72245. }
  72246. }
  72247. declare module BABYLON {
  72248. /** @hidden */
  72249. export var tonemapPixelShader: {
  72250. name: string;
  72251. shader: string;
  72252. };
  72253. }
  72254. declare module BABYLON {
  72255. /** Defines operator used for tonemapping */
  72256. export enum TonemappingOperator {
  72257. /** Hable */
  72258. Hable = 0,
  72259. /** Reinhard */
  72260. Reinhard = 1,
  72261. /** HejiDawson */
  72262. HejiDawson = 2,
  72263. /** Photographic */
  72264. Photographic = 3
  72265. }
  72266. /**
  72267. * Defines a post process to apply tone mapping
  72268. */
  72269. export class TonemapPostProcess extends PostProcess {
  72270. private _operator;
  72271. /** Defines the required exposure adjustement */
  72272. exposureAdjustment: number;
  72273. /**
  72274. * Gets a string identifying the name of the class
  72275. * @returns "TonemapPostProcess" string
  72276. */
  72277. getClassName(): string;
  72278. /**
  72279. * Creates a new TonemapPostProcess
  72280. * @param name defines the name of the postprocess
  72281. * @param _operator defines the operator to use
  72282. * @param exposureAdjustment defines the required exposure adjustement
  72283. * @param camera defines the camera to use (can be null)
  72284. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72285. * @param engine defines the hosting engine (can be ignore if camera is set)
  72286. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72287. */
  72288. constructor(name: string, _operator: TonemappingOperator,
  72289. /** Defines the required exposure adjustement */
  72290. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72291. }
  72292. }
  72293. declare module BABYLON {
  72294. /** @hidden */
  72295. export var volumetricLightScatteringPixelShader: {
  72296. name: string;
  72297. shader: string;
  72298. };
  72299. }
  72300. declare module BABYLON {
  72301. /** @hidden */
  72302. export var volumetricLightScatteringPassVertexShader: {
  72303. name: string;
  72304. shader: string;
  72305. };
  72306. }
  72307. declare module BABYLON {
  72308. /** @hidden */
  72309. export var volumetricLightScatteringPassPixelShader: {
  72310. name: string;
  72311. shader: string;
  72312. };
  72313. }
  72314. declare module BABYLON {
  72315. /**
  72316. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72317. */
  72318. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72319. private _volumetricLightScatteringPass;
  72320. private _volumetricLightScatteringRTT;
  72321. private _viewPort;
  72322. private _screenCoordinates;
  72323. private _cachedDefines;
  72324. /**
  72325. * If not undefined, the mesh position is computed from the attached node position
  72326. */
  72327. attachedNode: {
  72328. position: Vector3;
  72329. };
  72330. /**
  72331. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72332. */
  72333. customMeshPosition: Vector3;
  72334. /**
  72335. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72336. */
  72337. useCustomMeshPosition: boolean;
  72338. /**
  72339. * If the post-process should inverse the light scattering direction
  72340. */
  72341. invert: boolean;
  72342. /**
  72343. * The internal mesh used by the post-process
  72344. */
  72345. mesh: Mesh;
  72346. /**
  72347. * @hidden
  72348. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72349. */
  72350. get useDiffuseColor(): boolean;
  72351. set useDiffuseColor(useDiffuseColor: boolean);
  72352. /**
  72353. * Array containing the excluded meshes not rendered in the internal pass
  72354. */
  72355. excludedMeshes: AbstractMesh[];
  72356. /**
  72357. * Controls the overall intensity of the post-process
  72358. */
  72359. exposure: number;
  72360. /**
  72361. * Dissipates each sample's contribution in range [0, 1]
  72362. */
  72363. decay: number;
  72364. /**
  72365. * Controls the overall intensity of each sample
  72366. */
  72367. weight: number;
  72368. /**
  72369. * Controls the density of each sample
  72370. */
  72371. density: number;
  72372. /**
  72373. * @constructor
  72374. * @param name The post-process name
  72375. * @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)
  72376. * @param camera The camera that the post-process will be attached to
  72377. * @param mesh The mesh used to create the light scattering
  72378. * @param samples The post-process quality, default 100
  72379. * @param samplingModeThe post-process filtering mode
  72380. * @param engine The babylon engine
  72381. * @param reusable If the post-process is reusable
  72382. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72383. */
  72384. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72385. /**
  72386. * Returns the string "VolumetricLightScatteringPostProcess"
  72387. * @returns "VolumetricLightScatteringPostProcess"
  72388. */
  72389. getClassName(): string;
  72390. private _isReady;
  72391. /**
  72392. * Sets the new light position for light scattering effect
  72393. * @param position The new custom light position
  72394. */
  72395. setCustomMeshPosition(position: Vector3): void;
  72396. /**
  72397. * Returns the light position for light scattering effect
  72398. * @return Vector3 The custom light position
  72399. */
  72400. getCustomMeshPosition(): Vector3;
  72401. /**
  72402. * Disposes the internal assets and detaches the post-process from the camera
  72403. */
  72404. dispose(camera: Camera): void;
  72405. /**
  72406. * Returns the render target texture used by the post-process
  72407. * @return the render target texture used by the post-process
  72408. */
  72409. getPass(): RenderTargetTexture;
  72410. private _meshExcluded;
  72411. private _createPass;
  72412. private _updateMeshScreenCoordinates;
  72413. /**
  72414. * Creates a default mesh for the Volumeric Light Scattering post-process
  72415. * @param name The mesh name
  72416. * @param scene The scene where to create the mesh
  72417. * @return the default mesh
  72418. */
  72419. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72420. }
  72421. }
  72422. declare module BABYLON {
  72423. /** @hidden */
  72424. export var screenSpaceCurvaturePixelShader: {
  72425. name: string;
  72426. shader: string;
  72427. };
  72428. }
  72429. declare module BABYLON {
  72430. /**
  72431. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72432. */
  72433. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72434. /**
  72435. * Defines how much ridge the curvature effect displays.
  72436. */
  72437. ridge: number;
  72438. /**
  72439. * Defines how much valley the curvature effect displays.
  72440. */
  72441. valley: number;
  72442. private _geometryBufferRenderer;
  72443. /**
  72444. * Gets a string identifying the name of the class
  72445. * @returns "ScreenSpaceCurvaturePostProcess" string
  72446. */
  72447. getClassName(): string;
  72448. /**
  72449. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72450. * @param name The name of the effect.
  72451. * @param scene The scene containing the objects to blur according to their velocity.
  72452. * @param options The required width/height ratio to downsize to before computing the render pass.
  72453. * @param camera The camera to apply the render pass to.
  72454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72455. * @param engine The engine which the post process will be applied. (default: current engine)
  72456. * @param reusable If the post process can be reused on the same frame. (default: false)
  72457. * @param textureType Type of textures used when performing the post process. (default: 0)
  72458. * @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)
  72459. */
  72460. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72461. /**
  72462. * Support test.
  72463. */
  72464. static get IsSupported(): boolean;
  72465. /** @hidden */
  72466. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72467. }
  72468. }
  72469. declare module BABYLON {
  72470. interface Scene {
  72471. /** @hidden (Backing field) */
  72472. _boundingBoxRenderer: BoundingBoxRenderer;
  72473. /** @hidden (Backing field) */
  72474. _forceShowBoundingBoxes: boolean;
  72475. /**
  72476. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72477. */
  72478. forceShowBoundingBoxes: boolean;
  72479. /**
  72480. * Gets the bounding box renderer associated with the scene
  72481. * @returns a BoundingBoxRenderer
  72482. */
  72483. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72484. }
  72485. interface AbstractMesh {
  72486. /** @hidden (Backing field) */
  72487. _showBoundingBox: boolean;
  72488. /**
  72489. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72490. */
  72491. showBoundingBox: boolean;
  72492. }
  72493. /**
  72494. * Component responsible of rendering the bounding box of the meshes in a scene.
  72495. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72496. */
  72497. export class BoundingBoxRenderer implements ISceneComponent {
  72498. /**
  72499. * The component name helpfull to identify the component in the list of scene components.
  72500. */
  72501. readonly name: string;
  72502. /**
  72503. * The scene the component belongs to.
  72504. */
  72505. scene: Scene;
  72506. /**
  72507. * Color of the bounding box lines placed in front of an object
  72508. */
  72509. frontColor: Color3;
  72510. /**
  72511. * Color of the bounding box lines placed behind an object
  72512. */
  72513. backColor: Color3;
  72514. /**
  72515. * Defines if the renderer should show the back lines or not
  72516. */
  72517. showBackLines: boolean;
  72518. /**
  72519. * Observable raised before rendering a bounding box
  72520. */
  72521. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72522. /**
  72523. * Observable raised after rendering a bounding box
  72524. */
  72525. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72526. /**
  72527. * When false, no bounding boxes will be rendered
  72528. */
  72529. enabled: boolean;
  72530. /**
  72531. * @hidden
  72532. */
  72533. renderList: SmartArray<BoundingBox>;
  72534. private _colorShader;
  72535. private _vertexBuffers;
  72536. private _indexBuffer;
  72537. private _fillIndexBuffer;
  72538. private _fillIndexData;
  72539. /**
  72540. * Instantiates a new bounding box renderer in a scene.
  72541. * @param scene the scene the renderer renders in
  72542. */
  72543. constructor(scene: Scene);
  72544. /**
  72545. * Registers the component in a given scene
  72546. */
  72547. register(): void;
  72548. private _evaluateSubMesh;
  72549. private _preActiveMesh;
  72550. private _prepareRessources;
  72551. private _createIndexBuffer;
  72552. /**
  72553. * Rebuilds the elements related to this component in case of
  72554. * context lost for instance.
  72555. */
  72556. rebuild(): void;
  72557. /**
  72558. * @hidden
  72559. */
  72560. reset(): void;
  72561. /**
  72562. * Render the bounding boxes of a specific rendering group
  72563. * @param renderingGroupId defines the rendering group to render
  72564. */
  72565. render(renderingGroupId: number): void;
  72566. /**
  72567. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72568. * @param mesh Define the mesh to render the occlusion bounding box for
  72569. */
  72570. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72571. /**
  72572. * Dispose and release the resources attached to this renderer.
  72573. */
  72574. dispose(): void;
  72575. }
  72576. }
  72577. declare module BABYLON {
  72578. interface Scene {
  72579. /** @hidden (Backing field) */
  72580. _depthRenderer: {
  72581. [id: string]: DepthRenderer;
  72582. };
  72583. /**
  72584. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72585. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72586. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72587. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72588. * @returns the created depth renderer
  72589. */
  72590. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72591. /**
  72592. * Disables a depth renderer for a given camera
  72593. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72594. */
  72595. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72596. }
  72597. /**
  72598. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72599. * in several rendering techniques.
  72600. */
  72601. export class DepthRendererSceneComponent implements ISceneComponent {
  72602. /**
  72603. * The component name helpfull to identify the component in the list of scene components.
  72604. */
  72605. readonly name: string;
  72606. /**
  72607. * The scene the component belongs to.
  72608. */
  72609. scene: Scene;
  72610. /**
  72611. * Creates a new instance of the component for the given scene
  72612. * @param scene Defines the scene to register the component in
  72613. */
  72614. constructor(scene: Scene);
  72615. /**
  72616. * Registers the component in a given scene
  72617. */
  72618. register(): void;
  72619. /**
  72620. * Rebuilds the elements related to this component in case of
  72621. * context lost for instance.
  72622. */
  72623. rebuild(): void;
  72624. /**
  72625. * Disposes the component and the associated ressources
  72626. */
  72627. dispose(): void;
  72628. private _gatherRenderTargets;
  72629. private _gatherActiveCameraRenderTargets;
  72630. }
  72631. }
  72632. declare module BABYLON {
  72633. interface AbstractScene {
  72634. /** @hidden (Backing field) */
  72635. _prePassRenderer: Nullable<PrePassRenderer>;
  72636. /**
  72637. * Gets or Sets the current prepass renderer associated to the scene.
  72638. */
  72639. prePassRenderer: Nullable<PrePassRenderer>;
  72640. /**
  72641. * Enables the prepass and associates it with the scene
  72642. * @returns the PrePassRenderer
  72643. */
  72644. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72645. /**
  72646. * Disables the prepass associated with the scene
  72647. */
  72648. disablePrePassRenderer(): void;
  72649. }
  72650. /**
  72651. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72652. * in several rendering techniques.
  72653. */
  72654. export class PrePassRendererSceneComponent implements ISceneComponent {
  72655. /**
  72656. * The component name helpful to identify the component in the list of scene components.
  72657. */
  72658. readonly name: string;
  72659. /**
  72660. * The scene the component belongs to.
  72661. */
  72662. scene: Scene;
  72663. /**
  72664. * Creates a new instance of the component for the given scene
  72665. * @param scene Defines the scene to register the component in
  72666. */
  72667. constructor(scene: Scene);
  72668. /**
  72669. * Registers the component in a given scene
  72670. */
  72671. register(): void;
  72672. private _beforeCameraDraw;
  72673. private _afterCameraDraw;
  72674. private _beforeClearStage;
  72675. /**
  72676. * Rebuilds the elements related to this component in case of
  72677. * context lost for instance.
  72678. */
  72679. rebuild(): void;
  72680. /**
  72681. * Disposes the component and the associated ressources
  72682. */
  72683. dispose(): void;
  72684. }
  72685. }
  72686. declare module BABYLON {
  72687. /** @hidden */
  72688. export var fibonacci: {
  72689. name: string;
  72690. shader: string;
  72691. };
  72692. }
  72693. declare module BABYLON {
  72694. /** @hidden */
  72695. export var diffusionProfile: {
  72696. name: string;
  72697. shader: string;
  72698. };
  72699. }
  72700. declare module BABYLON {
  72701. /** @hidden */
  72702. export var subSurfaceScatteringPixelShader: {
  72703. name: string;
  72704. shader: string;
  72705. };
  72706. }
  72707. declare module BABYLON {
  72708. /**
  72709. * Sub surface scattering post process
  72710. */
  72711. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72712. /**
  72713. * Gets a string identifying the name of the class
  72714. * @returns "SubSurfaceScatteringPostProcess" string
  72715. */
  72716. getClassName(): string;
  72717. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72718. }
  72719. }
  72720. declare module BABYLON {
  72721. /**
  72722. * Contains all parameters needed for the prepass to perform
  72723. * screen space subsurface scattering
  72724. */
  72725. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72726. /** @hidden */
  72727. static _SceneComponentInitialization: (scene: Scene) => void;
  72728. private _ssDiffusionS;
  72729. private _ssFilterRadii;
  72730. private _ssDiffusionD;
  72731. /**
  72732. * Post process to attach for screen space subsurface scattering
  72733. */
  72734. postProcess: SubSurfaceScatteringPostProcess;
  72735. /**
  72736. * Diffusion profile color for subsurface scattering
  72737. */
  72738. get ssDiffusionS(): number[];
  72739. /**
  72740. * Diffusion profile max color channel value for subsurface scattering
  72741. */
  72742. get ssDiffusionD(): number[];
  72743. /**
  72744. * Diffusion profile filter radius for subsurface scattering
  72745. */
  72746. get ssFilterRadii(): number[];
  72747. /**
  72748. * Is subsurface enabled
  72749. */
  72750. enabled: boolean;
  72751. /**
  72752. * Name of the configuration
  72753. */
  72754. name: string;
  72755. /**
  72756. * Diffusion profile colors for subsurface scattering
  72757. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72758. * See ...
  72759. * Note that you can only store up to 5 of them
  72760. */
  72761. ssDiffusionProfileColors: Color3[];
  72762. /**
  72763. * Defines the ratio real world => scene units.
  72764. * Used for subsurface scattering
  72765. */
  72766. metersPerUnit: number;
  72767. /**
  72768. * Textures that should be present in the MRT for this effect to work
  72769. */
  72770. readonly texturesRequired: number[];
  72771. private _scene;
  72772. /**
  72773. * Builds a subsurface configuration object
  72774. * @param scene The scene
  72775. */
  72776. constructor(scene: Scene);
  72777. /**
  72778. * Adds a new diffusion profile.
  72779. * Useful for more realistic subsurface scattering on diverse materials.
  72780. * @param color The color of the diffusion profile. Should be the average color of the material.
  72781. * @return The index of the diffusion profile for the material subsurface configuration
  72782. */
  72783. addDiffusionProfile(color: Color3): number;
  72784. /**
  72785. * Creates the sss post process
  72786. * @return The created post process
  72787. */
  72788. createPostProcess(): SubSurfaceScatteringPostProcess;
  72789. /**
  72790. * Deletes all diffusion profiles.
  72791. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72792. */
  72793. clearAllDiffusionProfiles(): void;
  72794. /**
  72795. * Disposes this object
  72796. */
  72797. dispose(): void;
  72798. /**
  72799. * @hidden
  72800. * https://zero-radiance.github.io/post/sampling-diffusion/
  72801. *
  72802. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72803. * ------------------------------------------------------------------------------------
  72804. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72805. * PDF[r, phi, s] = r * R[r, phi, s]
  72806. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72807. * ------------------------------------------------------------------------------------
  72808. * We importance sample the color channel with the widest scattering distance.
  72809. */
  72810. getDiffusionProfileParameters(color: Color3): number;
  72811. /**
  72812. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72813. * 'u' is the random number (the value of the CDF): [0, 1).
  72814. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72815. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72816. */
  72817. private _sampleBurleyDiffusionProfile;
  72818. }
  72819. }
  72820. declare module BABYLON {
  72821. interface AbstractScene {
  72822. /** @hidden (Backing field) */
  72823. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72824. /**
  72825. * Gets or Sets the current prepass renderer associated to the scene.
  72826. */
  72827. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72828. /**
  72829. * Enables the subsurface effect for prepass
  72830. * @returns the SubSurfaceConfiguration
  72831. */
  72832. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72833. /**
  72834. * Disables the subsurface effect for prepass
  72835. */
  72836. disableSubSurfaceForPrePass(): void;
  72837. }
  72838. /**
  72839. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72840. * in several rendering techniques.
  72841. */
  72842. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72843. /**
  72844. * The component name helpful to identify the component in the list of scene components.
  72845. */
  72846. readonly name: string;
  72847. /**
  72848. * The scene the component belongs to.
  72849. */
  72850. scene: Scene;
  72851. /**
  72852. * Creates a new instance of the component for the given scene
  72853. * @param scene Defines the scene to register the component in
  72854. */
  72855. constructor(scene: Scene);
  72856. /**
  72857. * Registers the component in a given scene
  72858. */
  72859. register(): void;
  72860. /**
  72861. * Serializes the component data to the specified json object
  72862. * @param serializationObject The object to serialize to
  72863. */
  72864. serialize(serializationObject: any): void;
  72865. /**
  72866. * Adds all the elements from the container to the scene
  72867. * @param container the container holding the elements
  72868. */
  72869. addFromContainer(container: AbstractScene): void;
  72870. /**
  72871. * Removes all the elements in the container from the scene
  72872. * @param container contains the elements to remove
  72873. * @param dispose if the removed element should be disposed (default: false)
  72874. */
  72875. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72876. /**
  72877. * Rebuilds the elements related to this component in case of
  72878. * context lost for instance.
  72879. */
  72880. rebuild(): void;
  72881. /**
  72882. * Disposes the component and the associated ressources
  72883. */
  72884. dispose(): void;
  72885. }
  72886. }
  72887. declare module BABYLON {
  72888. /** @hidden */
  72889. export var outlinePixelShader: {
  72890. name: string;
  72891. shader: string;
  72892. };
  72893. }
  72894. declare module BABYLON {
  72895. /** @hidden */
  72896. export var outlineVertexShader: {
  72897. name: string;
  72898. shader: string;
  72899. };
  72900. }
  72901. declare module BABYLON {
  72902. interface Scene {
  72903. /** @hidden */
  72904. _outlineRenderer: OutlineRenderer;
  72905. /**
  72906. * Gets the outline renderer associated with the scene
  72907. * @returns a OutlineRenderer
  72908. */
  72909. getOutlineRenderer(): OutlineRenderer;
  72910. }
  72911. interface AbstractMesh {
  72912. /** @hidden (Backing field) */
  72913. _renderOutline: boolean;
  72914. /**
  72915. * Gets or sets a boolean indicating if the outline must be rendered as well
  72916. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72917. */
  72918. renderOutline: boolean;
  72919. /** @hidden (Backing field) */
  72920. _renderOverlay: boolean;
  72921. /**
  72922. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72923. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72924. */
  72925. renderOverlay: boolean;
  72926. }
  72927. /**
  72928. * This class is responsible to draw bothe outline/overlay of meshes.
  72929. * It should not be used directly but through the available method on mesh.
  72930. */
  72931. export class OutlineRenderer implements ISceneComponent {
  72932. /**
  72933. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72934. */
  72935. private static _StencilReference;
  72936. /**
  72937. * The name of the component. Each component must have a unique name.
  72938. */
  72939. name: string;
  72940. /**
  72941. * The scene the component belongs to.
  72942. */
  72943. scene: Scene;
  72944. /**
  72945. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72946. */
  72947. zOffset: number;
  72948. private _engine;
  72949. private _effect;
  72950. private _cachedDefines;
  72951. private _savedDepthWrite;
  72952. /**
  72953. * Instantiates a new outline renderer. (There could be only one per scene).
  72954. * @param scene Defines the scene it belongs to
  72955. */
  72956. constructor(scene: Scene);
  72957. /**
  72958. * Register the component to one instance of a scene.
  72959. */
  72960. register(): void;
  72961. /**
  72962. * Rebuilds the elements related to this component in case of
  72963. * context lost for instance.
  72964. */
  72965. rebuild(): void;
  72966. /**
  72967. * Disposes the component and the associated ressources.
  72968. */
  72969. dispose(): void;
  72970. /**
  72971. * Renders the outline in the canvas.
  72972. * @param subMesh Defines the sumesh to render
  72973. * @param batch Defines the batch of meshes in case of instances
  72974. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72975. */
  72976. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72977. /**
  72978. * Returns whether or not the outline renderer is ready for a given submesh.
  72979. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72980. * @param subMesh Defines the submesh to check readyness for
  72981. * @param useInstances Defines wheter wee are trying to render instances or not
  72982. * @returns true if ready otherwise false
  72983. */
  72984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72985. private _beforeRenderingMesh;
  72986. private _afterRenderingMesh;
  72987. }
  72988. }
  72989. declare module BABYLON {
  72990. /**
  72991. * Defines the basic options interface of a Sprite Frame Source Size.
  72992. */
  72993. export interface ISpriteJSONSpriteSourceSize {
  72994. /**
  72995. * number of the original width of the Frame
  72996. */
  72997. w: number;
  72998. /**
  72999. * number of the original height of the Frame
  73000. */
  73001. h: number;
  73002. }
  73003. /**
  73004. * Defines the basic options interface of a Sprite Frame Data.
  73005. */
  73006. export interface ISpriteJSONSpriteFrameData {
  73007. /**
  73008. * number of the x offset of the Frame
  73009. */
  73010. x: number;
  73011. /**
  73012. * number of the y offset of the Frame
  73013. */
  73014. y: number;
  73015. /**
  73016. * number of the width of the Frame
  73017. */
  73018. w: number;
  73019. /**
  73020. * number of the height of the Frame
  73021. */
  73022. h: number;
  73023. }
  73024. /**
  73025. * Defines the basic options interface of a JSON Sprite.
  73026. */
  73027. export interface ISpriteJSONSprite {
  73028. /**
  73029. * string name of the Frame
  73030. */
  73031. filename: string;
  73032. /**
  73033. * ISpriteJSONSpriteFrame basic object of the frame data
  73034. */
  73035. frame: ISpriteJSONSpriteFrameData;
  73036. /**
  73037. * boolean to flag is the frame was rotated.
  73038. */
  73039. rotated: boolean;
  73040. /**
  73041. * boolean to flag is the frame was trimmed.
  73042. */
  73043. trimmed: boolean;
  73044. /**
  73045. * ISpriteJSONSpriteFrame basic object of the source data
  73046. */
  73047. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73048. /**
  73049. * ISpriteJSONSpriteFrame basic object of the source data
  73050. */
  73051. sourceSize: ISpriteJSONSpriteSourceSize;
  73052. }
  73053. /**
  73054. * Defines the basic options interface of a JSON atlas.
  73055. */
  73056. export interface ISpriteJSONAtlas {
  73057. /**
  73058. * Array of objects that contain the frame data.
  73059. */
  73060. frames: Array<ISpriteJSONSprite>;
  73061. /**
  73062. * object basic object containing the sprite meta data.
  73063. */
  73064. meta?: object;
  73065. }
  73066. }
  73067. declare module BABYLON {
  73068. /** @hidden */
  73069. export var spriteMapPixelShader: {
  73070. name: string;
  73071. shader: string;
  73072. };
  73073. }
  73074. declare module BABYLON {
  73075. /** @hidden */
  73076. export var spriteMapVertexShader: {
  73077. name: string;
  73078. shader: string;
  73079. };
  73080. }
  73081. declare module BABYLON {
  73082. /**
  73083. * Defines the basic options interface of a SpriteMap
  73084. */
  73085. export interface ISpriteMapOptions {
  73086. /**
  73087. * Vector2 of the number of cells in the grid.
  73088. */
  73089. stageSize?: Vector2;
  73090. /**
  73091. * Vector2 of the size of the output plane in World Units.
  73092. */
  73093. outputSize?: Vector2;
  73094. /**
  73095. * Vector3 of the position of the output plane in World Units.
  73096. */
  73097. outputPosition?: Vector3;
  73098. /**
  73099. * Vector3 of the rotation of the output plane.
  73100. */
  73101. outputRotation?: Vector3;
  73102. /**
  73103. * number of layers that the system will reserve in resources.
  73104. */
  73105. layerCount?: number;
  73106. /**
  73107. * number of max animation frames a single cell will reserve in resources.
  73108. */
  73109. maxAnimationFrames?: number;
  73110. /**
  73111. * number cell index of the base tile when the system compiles.
  73112. */
  73113. baseTile?: number;
  73114. /**
  73115. * boolean flip the sprite after its been repositioned by the framing data.
  73116. */
  73117. flipU?: boolean;
  73118. /**
  73119. * Vector3 scalar of the global RGB values of the SpriteMap.
  73120. */
  73121. colorMultiply?: Vector3;
  73122. }
  73123. /**
  73124. * Defines the IDisposable interface in order to be cleanable from resources.
  73125. */
  73126. export interface ISpriteMap extends IDisposable {
  73127. /**
  73128. * String name of the SpriteMap.
  73129. */
  73130. name: string;
  73131. /**
  73132. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73133. */
  73134. atlasJSON: ISpriteJSONAtlas;
  73135. /**
  73136. * Texture of the SpriteMap.
  73137. */
  73138. spriteSheet: Texture;
  73139. /**
  73140. * The parameters to initialize the SpriteMap with.
  73141. */
  73142. options: ISpriteMapOptions;
  73143. }
  73144. /**
  73145. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73146. */
  73147. export class SpriteMap implements ISpriteMap {
  73148. /** The Name of the spriteMap */
  73149. name: string;
  73150. /** The JSON file with the frame and meta data */
  73151. atlasJSON: ISpriteJSONAtlas;
  73152. /** The systems Sprite Sheet Texture */
  73153. spriteSheet: Texture;
  73154. /** Arguments passed with the Constructor */
  73155. options: ISpriteMapOptions;
  73156. /** Public Sprite Storage array, parsed from atlasJSON */
  73157. sprites: Array<ISpriteJSONSprite>;
  73158. /** Returns the Number of Sprites in the System */
  73159. get spriteCount(): number;
  73160. /** Returns the Position of Output Plane*/
  73161. get position(): Vector3;
  73162. /** Returns the Position of Output Plane*/
  73163. set position(v: Vector3);
  73164. /** Returns the Rotation of Output Plane*/
  73165. get rotation(): Vector3;
  73166. /** Returns the Rotation of Output Plane*/
  73167. set rotation(v: Vector3);
  73168. /** Sets the AnimationMap*/
  73169. get animationMap(): RawTexture;
  73170. /** Sets the AnimationMap*/
  73171. set animationMap(v: RawTexture);
  73172. /** Scene that the SpriteMap was created in */
  73173. private _scene;
  73174. /** Texture Buffer of Float32 that holds tile frame data*/
  73175. private _frameMap;
  73176. /** Texture Buffers of Float32 that holds tileMap data*/
  73177. private _tileMaps;
  73178. /** Texture Buffer of Float32 that holds Animation Data*/
  73179. private _animationMap;
  73180. /** Custom ShaderMaterial Central to the System*/
  73181. private _material;
  73182. /** Custom ShaderMaterial Central to the System*/
  73183. private _output;
  73184. /** Systems Time Ticker*/
  73185. private _time;
  73186. /**
  73187. * Creates a new SpriteMap
  73188. * @param name defines the SpriteMaps Name
  73189. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73190. * @param spriteSheet is the Texture that the Sprites are on.
  73191. * @param options a basic deployment configuration
  73192. * @param scene The Scene that the map is deployed on
  73193. */
  73194. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73195. /**
  73196. * Returns tileID location
  73197. * @returns Vector2 the cell position ID
  73198. */
  73199. getTileID(): Vector2;
  73200. /**
  73201. * Gets the UV location of the mouse over the SpriteMap.
  73202. * @returns Vector2 the UV position of the mouse interaction
  73203. */
  73204. getMousePosition(): Vector2;
  73205. /**
  73206. * Creates the "frame" texture Buffer
  73207. * -------------------------------------
  73208. * Structure of frames
  73209. * "filename": "Falling-Water-2.png",
  73210. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73211. * "rotated": true,
  73212. * "trimmed": true,
  73213. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73214. * "sourceSize": {"w":32,"h":32}
  73215. * @returns RawTexture of the frameMap
  73216. */
  73217. private _createFrameBuffer;
  73218. /**
  73219. * Creates the tileMap texture Buffer
  73220. * @param buffer normally and array of numbers, or a false to generate from scratch
  73221. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73222. * @returns RawTexture of the tileMap
  73223. */
  73224. private _createTileBuffer;
  73225. /**
  73226. * Modifies the data of the tileMaps
  73227. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73228. * @param pos is the iVector2 Coordinates of the Tile
  73229. * @param tile The SpriteIndex of the new Tile
  73230. */
  73231. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73232. /**
  73233. * Creates the animationMap texture Buffer
  73234. * @param buffer normally and array of numbers, or a false to generate from scratch
  73235. * @returns RawTexture of the animationMap
  73236. */
  73237. private _createTileAnimationBuffer;
  73238. /**
  73239. * Modifies the data of the animationMap
  73240. * @param cellID is the Index of the Sprite
  73241. * @param _frame is the target Animation frame
  73242. * @param toCell is the Target Index of the next frame of the animation
  73243. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73244. * @param speed is a global scalar of the time variable on the map.
  73245. */
  73246. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73247. /**
  73248. * Exports the .tilemaps file
  73249. */
  73250. saveTileMaps(): void;
  73251. /**
  73252. * Imports the .tilemaps file
  73253. * @param url of the .tilemaps file
  73254. */
  73255. loadTileMaps(url: string): void;
  73256. /**
  73257. * Release associated resources
  73258. */
  73259. dispose(): void;
  73260. }
  73261. }
  73262. declare module BABYLON {
  73263. /**
  73264. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73265. * @see https://doc.babylonjs.com/babylon101/sprites
  73266. */
  73267. export class SpritePackedManager extends SpriteManager {
  73268. /** defines the packed manager's name */
  73269. name: string;
  73270. /**
  73271. * Creates a new sprite manager from a packed sprite sheet
  73272. * @param name defines the manager's name
  73273. * @param imgUrl defines the sprite sheet url
  73274. * @param capacity defines the maximum allowed number of sprites
  73275. * @param scene defines the hosting scene
  73276. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73277. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73278. * @param samplingMode defines the smapling mode to use with spritesheet
  73279. * @param fromPacked set to true; do not alter
  73280. */
  73281. constructor(
  73282. /** defines the packed manager's name */
  73283. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73284. }
  73285. }
  73286. declare module BABYLON {
  73287. /**
  73288. * Defines the list of states available for a task inside a AssetsManager
  73289. */
  73290. export enum AssetTaskState {
  73291. /**
  73292. * Initialization
  73293. */
  73294. INIT = 0,
  73295. /**
  73296. * Running
  73297. */
  73298. RUNNING = 1,
  73299. /**
  73300. * Done
  73301. */
  73302. DONE = 2,
  73303. /**
  73304. * Error
  73305. */
  73306. ERROR = 3
  73307. }
  73308. /**
  73309. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73310. */
  73311. export abstract class AbstractAssetTask {
  73312. /**
  73313. * Task name
  73314. */ name: string;
  73315. /**
  73316. * Callback called when the task is successful
  73317. */
  73318. onSuccess: (task: any) => void;
  73319. /**
  73320. * Callback called when the task is not successful
  73321. */
  73322. onError: (task: any, message?: string, exception?: any) => void;
  73323. /**
  73324. * Creates a new AssetsManager
  73325. * @param name defines the name of the task
  73326. */
  73327. constructor(
  73328. /**
  73329. * Task name
  73330. */ name: string);
  73331. private _isCompleted;
  73332. private _taskState;
  73333. private _errorObject;
  73334. /**
  73335. * Get if the task is completed
  73336. */
  73337. get isCompleted(): boolean;
  73338. /**
  73339. * Gets the current state of the task
  73340. */
  73341. get taskState(): AssetTaskState;
  73342. /**
  73343. * Gets the current error object (if task is in error)
  73344. */
  73345. get errorObject(): {
  73346. message?: string;
  73347. exception?: any;
  73348. };
  73349. /**
  73350. * Internal only
  73351. * @hidden
  73352. */
  73353. _setErrorObject(message?: string, exception?: any): void;
  73354. /**
  73355. * Execute the current task
  73356. * @param scene defines the scene where you want your assets to be loaded
  73357. * @param onSuccess is a callback called when the task is successfully executed
  73358. * @param onError is a callback called if an error occurs
  73359. */
  73360. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73361. /**
  73362. * Execute the current task
  73363. * @param scene defines the scene where you want your assets to be loaded
  73364. * @param onSuccess is a callback called when the task is successfully executed
  73365. * @param onError is a callback called if an error occurs
  73366. */
  73367. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73368. /**
  73369. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73370. * This can be used with failed tasks that have the reason for failure fixed.
  73371. */
  73372. reset(): void;
  73373. private onErrorCallback;
  73374. private onDoneCallback;
  73375. }
  73376. /**
  73377. * Define the interface used by progress events raised during assets loading
  73378. */
  73379. export interface IAssetsProgressEvent {
  73380. /**
  73381. * Defines the number of remaining tasks to process
  73382. */
  73383. remainingCount: number;
  73384. /**
  73385. * Defines the total number of tasks
  73386. */
  73387. totalCount: number;
  73388. /**
  73389. * Defines the task that was just processed
  73390. */
  73391. task: AbstractAssetTask;
  73392. }
  73393. /**
  73394. * Class used to share progress information about assets loading
  73395. */
  73396. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73397. /**
  73398. * Defines the number of remaining tasks to process
  73399. */
  73400. remainingCount: number;
  73401. /**
  73402. * Defines the total number of tasks
  73403. */
  73404. totalCount: number;
  73405. /**
  73406. * Defines the task that was just processed
  73407. */
  73408. task: AbstractAssetTask;
  73409. /**
  73410. * Creates a AssetsProgressEvent
  73411. * @param remainingCount defines the number of remaining tasks to process
  73412. * @param totalCount defines the total number of tasks
  73413. * @param task defines the task that was just processed
  73414. */
  73415. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73416. }
  73417. /**
  73418. * Define a task used by AssetsManager to load assets into a container
  73419. */
  73420. export class ContainerAssetTask extends AbstractAssetTask {
  73421. /**
  73422. * Defines the name of the task
  73423. */
  73424. name: string;
  73425. /**
  73426. * Defines the list of mesh's names you want to load
  73427. */
  73428. meshesNames: any;
  73429. /**
  73430. * Defines the root url to use as a base to load your meshes and associated resources
  73431. */
  73432. rootUrl: string;
  73433. /**
  73434. * Defines the filename or File of the scene to load from
  73435. */
  73436. sceneFilename: string | File;
  73437. /**
  73438. * Get the loaded asset container
  73439. */
  73440. loadedContainer: AssetContainer;
  73441. /**
  73442. * Gets the list of loaded meshes
  73443. */
  73444. loadedMeshes: Array<AbstractMesh>;
  73445. /**
  73446. * Gets the list of loaded particle systems
  73447. */
  73448. loadedParticleSystems: Array<IParticleSystem>;
  73449. /**
  73450. * Gets the list of loaded skeletons
  73451. */
  73452. loadedSkeletons: Array<Skeleton>;
  73453. /**
  73454. * Gets the list of loaded animation groups
  73455. */
  73456. loadedAnimationGroups: Array<AnimationGroup>;
  73457. /**
  73458. * Callback called when the task is successful
  73459. */
  73460. onSuccess: (task: ContainerAssetTask) => void;
  73461. /**
  73462. * Callback called when the task is successful
  73463. */
  73464. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73465. /**
  73466. * Creates a new ContainerAssetTask
  73467. * @param name defines the name of the task
  73468. * @param meshesNames defines the list of mesh's names you want to load
  73469. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73470. * @param sceneFilename defines the filename or File of the scene to load from
  73471. */
  73472. constructor(
  73473. /**
  73474. * Defines the name of the task
  73475. */
  73476. name: string,
  73477. /**
  73478. * Defines the list of mesh's names you want to load
  73479. */
  73480. meshesNames: any,
  73481. /**
  73482. * Defines the root url to use as a base to load your meshes and associated resources
  73483. */
  73484. rootUrl: string,
  73485. /**
  73486. * Defines the filename or File of the scene to load from
  73487. */
  73488. sceneFilename: string | File);
  73489. /**
  73490. * Execute the current task
  73491. * @param scene defines the scene where you want your assets to be loaded
  73492. * @param onSuccess is a callback called when the task is successfully executed
  73493. * @param onError is a callback called if an error occurs
  73494. */
  73495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73496. }
  73497. /**
  73498. * Define a task used by AssetsManager to load meshes
  73499. */
  73500. export class MeshAssetTask extends AbstractAssetTask {
  73501. /**
  73502. * Defines the name of the task
  73503. */
  73504. name: string;
  73505. /**
  73506. * Defines the list of mesh's names you want to load
  73507. */
  73508. meshesNames: any;
  73509. /**
  73510. * Defines the root url to use as a base to load your meshes and associated resources
  73511. */
  73512. rootUrl: string;
  73513. /**
  73514. * Defines the filename or File of the scene to load from
  73515. */
  73516. sceneFilename: string | File;
  73517. /**
  73518. * Gets the list of loaded meshes
  73519. */
  73520. loadedMeshes: Array<AbstractMesh>;
  73521. /**
  73522. * Gets the list of loaded particle systems
  73523. */
  73524. loadedParticleSystems: Array<IParticleSystem>;
  73525. /**
  73526. * Gets the list of loaded skeletons
  73527. */
  73528. loadedSkeletons: Array<Skeleton>;
  73529. /**
  73530. * Gets the list of loaded animation groups
  73531. */
  73532. loadedAnimationGroups: Array<AnimationGroup>;
  73533. /**
  73534. * Callback called when the task is successful
  73535. */
  73536. onSuccess: (task: MeshAssetTask) => void;
  73537. /**
  73538. * Callback called when the task is successful
  73539. */
  73540. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73541. /**
  73542. * Creates a new MeshAssetTask
  73543. * @param name defines the name of the task
  73544. * @param meshesNames defines the list of mesh's names you want to load
  73545. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73546. * @param sceneFilename defines the filename or File of the scene to load from
  73547. */
  73548. constructor(
  73549. /**
  73550. * Defines the name of the task
  73551. */
  73552. name: string,
  73553. /**
  73554. * Defines the list of mesh's names you want to load
  73555. */
  73556. meshesNames: any,
  73557. /**
  73558. * Defines the root url to use as a base to load your meshes and associated resources
  73559. */
  73560. rootUrl: string,
  73561. /**
  73562. * Defines the filename or File of the scene to load from
  73563. */
  73564. sceneFilename: string | File);
  73565. /**
  73566. * Execute the current task
  73567. * @param scene defines the scene where you want your assets to be loaded
  73568. * @param onSuccess is a callback called when the task is successfully executed
  73569. * @param onError is a callback called if an error occurs
  73570. */
  73571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73572. }
  73573. /**
  73574. * Define a task used by AssetsManager to load text content
  73575. */
  73576. export class TextFileAssetTask extends AbstractAssetTask {
  73577. /**
  73578. * Defines the name of the task
  73579. */
  73580. name: string;
  73581. /**
  73582. * Defines the location of the file to load
  73583. */
  73584. url: string;
  73585. /**
  73586. * Gets the loaded text string
  73587. */
  73588. text: string;
  73589. /**
  73590. * Callback called when the task is successful
  73591. */
  73592. onSuccess: (task: TextFileAssetTask) => void;
  73593. /**
  73594. * Callback called when the task is successful
  73595. */
  73596. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73597. /**
  73598. * Creates a new TextFileAssetTask object
  73599. * @param name defines the name of the task
  73600. * @param url defines the location of the file to load
  73601. */
  73602. constructor(
  73603. /**
  73604. * Defines the name of the task
  73605. */
  73606. name: string,
  73607. /**
  73608. * Defines the location of the file to load
  73609. */
  73610. url: string);
  73611. /**
  73612. * Execute the current task
  73613. * @param scene defines the scene where you want your assets to be loaded
  73614. * @param onSuccess is a callback called when the task is successfully executed
  73615. * @param onError is a callback called if an error occurs
  73616. */
  73617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73618. }
  73619. /**
  73620. * Define a task used by AssetsManager to load binary data
  73621. */
  73622. export class BinaryFileAssetTask extends AbstractAssetTask {
  73623. /**
  73624. * Defines the name of the task
  73625. */
  73626. name: string;
  73627. /**
  73628. * Defines the location of the file to load
  73629. */
  73630. url: string;
  73631. /**
  73632. * Gets the lodaded data (as an array buffer)
  73633. */
  73634. data: ArrayBuffer;
  73635. /**
  73636. * Callback called when the task is successful
  73637. */
  73638. onSuccess: (task: BinaryFileAssetTask) => void;
  73639. /**
  73640. * Callback called when the task is successful
  73641. */
  73642. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73643. /**
  73644. * Creates a new BinaryFileAssetTask object
  73645. * @param name defines the name of the new task
  73646. * @param url defines the location of the file to load
  73647. */
  73648. constructor(
  73649. /**
  73650. * Defines the name of the task
  73651. */
  73652. name: string,
  73653. /**
  73654. * Defines the location of the file to load
  73655. */
  73656. url: string);
  73657. /**
  73658. * Execute the current task
  73659. * @param scene defines the scene where you want your assets to be loaded
  73660. * @param onSuccess is a callback called when the task is successfully executed
  73661. * @param onError is a callback called if an error occurs
  73662. */
  73663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73664. }
  73665. /**
  73666. * Define a task used by AssetsManager to load images
  73667. */
  73668. export class ImageAssetTask extends AbstractAssetTask {
  73669. /**
  73670. * Defines the name of the task
  73671. */
  73672. name: string;
  73673. /**
  73674. * Defines the location of the image to load
  73675. */
  73676. url: string;
  73677. /**
  73678. * Gets the loaded images
  73679. */
  73680. image: HTMLImageElement;
  73681. /**
  73682. * Callback called when the task is successful
  73683. */
  73684. onSuccess: (task: ImageAssetTask) => void;
  73685. /**
  73686. * Callback called when the task is successful
  73687. */
  73688. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73689. /**
  73690. * Creates a new ImageAssetTask
  73691. * @param name defines the name of the task
  73692. * @param url defines the location of the image to load
  73693. */
  73694. constructor(
  73695. /**
  73696. * Defines the name of the task
  73697. */
  73698. name: string,
  73699. /**
  73700. * Defines the location of the image to load
  73701. */
  73702. url: string);
  73703. /**
  73704. * Execute the current task
  73705. * @param scene defines the scene where you want your assets to be loaded
  73706. * @param onSuccess is a callback called when the task is successfully executed
  73707. * @param onError is a callback called if an error occurs
  73708. */
  73709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73710. }
  73711. /**
  73712. * Defines the interface used by texture loading tasks
  73713. */
  73714. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73715. /**
  73716. * Gets the loaded texture
  73717. */
  73718. texture: TEX;
  73719. }
  73720. /**
  73721. * Define a task used by AssetsManager to load 2D textures
  73722. */
  73723. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73724. /**
  73725. * Defines the name of the task
  73726. */
  73727. name: string;
  73728. /**
  73729. * Defines the location of the file to load
  73730. */
  73731. url: string;
  73732. /**
  73733. * Defines if mipmap should not be generated (default is false)
  73734. */
  73735. noMipmap?: boolean | undefined;
  73736. /**
  73737. * Defines if texture must be inverted on Y axis (default is true)
  73738. */
  73739. invertY: boolean;
  73740. /**
  73741. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73742. */
  73743. samplingMode: number;
  73744. /**
  73745. * Gets the loaded texture
  73746. */
  73747. texture: Texture;
  73748. /**
  73749. * Callback called when the task is successful
  73750. */
  73751. onSuccess: (task: TextureAssetTask) => void;
  73752. /**
  73753. * Callback called when the task is successful
  73754. */
  73755. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73756. /**
  73757. * Creates a new TextureAssetTask object
  73758. * @param name defines the name of the task
  73759. * @param url defines the location of the file to load
  73760. * @param noMipmap defines if mipmap should not be generated (default is false)
  73761. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73762. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73763. */
  73764. constructor(
  73765. /**
  73766. * Defines the name of the task
  73767. */
  73768. name: string,
  73769. /**
  73770. * Defines the location of the file to load
  73771. */
  73772. url: string,
  73773. /**
  73774. * Defines if mipmap should not be generated (default is false)
  73775. */
  73776. noMipmap?: boolean | undefined,
  73777. /**
  73778. * Defines if texture must be inverted on Y axis (default is true)
  73779. */
  73780. invertY?: boolean,
  73781. /**
  73782. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73783. */
  73784. samplingMode?: number);
  73785. /**
  73786. * Execute the current task
  73787. * @param scene defines the scene where you want your assets to be loaded
  73788. * @param onSuccess is a callback called when the task is successfully executed
  73789. * @param onError is a callback called if an error occurs
  73790. */
  73791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73792. }
  73793. /**
  73794. * Define a task used by AssetsManager to load cube textures
  73795. */
  73796. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73797. /**
  73798. * Defines the name of the task
  73799. */
  73800. name: string;
  73801. /**
  73802. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73803. */
  73804. url: string;
  73805. /**
  73806. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73807. */
  73808. extensions?: string[] | undefined;
  73809. /**
  73810. * Defines if mipmaps should not be generated (default is false)
  73811. */
  73812. noMipmap?: boolean | undefined;
  73813. /**
  73814. * Defines the explicit list of files (undefined by default)
  73815. */
  73816. files?: string[] | undefined;
  73817. /**
  73818. * Gets the loaded texture
  73819. */
  73820. texture: CubeTexture;
  73821. /**
  73822. * Callback called when the task is successful
  73823. */
  73824. onSuccess: (task: CubeTextureAssetTask) => void;
  73825. /**
  73826. * Callback called when the task is successful
  73827. */
  73828. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73829. /**
  73830. * Creates a new CubeTextureAssetTask
  73831. * @param name defines the name of the task
  73832. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73833. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73834. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73835. * @param files defines the explicit list of files (undefined by default)
  73836. */
  73837. constructor(
  73838. /**
  73839. * Defines the name of the task
  73840. */
  73841. name: string,
  73842. /**
  73843. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73844. */
  73845. url: string,
  73846. /**
  73847. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73848. */
  73849. extensions?: string[] | undefined,
  73850. /**
  73851. * Defines if mipmaps should not be generated (default is false)
  73852. */
  73853. noMipmap?: boolean | undefined,
  73854. /**
  73855. * Defines the explicit list of files (undefined by default)
  73856. */
  73857. files?: string[] | undefined);
  73858. /**
  73859. * Execute the current task
  73860. * @param scene defines the scene where you want your assets to be loaded
  73861. * @param onSuccess is a callback called when the task is successfully executed
  73862. * @param onError is a callback called if an error occurs
  73863. */
  73864. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73865. }
  73866. /**
  73867. * Define a task used by AssetsManager to load HDR cube textures
  73868. */
  73869. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73870. /**
  73871. * Defines the name of the task
  73872. */
  73873. name: string;
  73874. /**
  73875. * Defines the location of the file to load
  73876. */
  73877. url: string;
  73878. /**
  73879. * Defines the desired size (the more it increases the longer the generation will be)
  73880. */
  73881. size: number;
  73882. /**
  73883. * Defines if mipmaps should not be generated (default is false)
  73884. */
  73885. noMipmap: boolean;
  73886. /**
  73887. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73888. */
  73889. generateHarmonics: boolean;
  73890. /**
  73891. * 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)
  73892. */
  73893. gammaSpace: boolean;
  73894. /**
  73895. * Internal Use Only
  73896. */
  73897. reserved: boolean;
  73898. /**
  73899. * Gets the loaded texture
  73900. */
  73901. texture: HDRCubeTexture;
  73902. /**
  73903. * Callback called when the task is successful
  73904. */
  73905. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73906. /**
  73907. * Callback called when the task is successful
  73908. */
  73909. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73910. /**
  73911. * Creates a new HDRCubeTextureAssetTask object
  73912. * @param name defines the name of the task
  73913. * @param url defines the location of the file to load
  73914. * @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.
  73915. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73916. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73917. * @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)
  73918. * @param reserved Internal use only
  73919. */
  73920. constructor(
  73921. /**
  73922. * Defines the name of the task
  73923. */
  73924. name: string,
  73925. /**
  73926. * Defines the location of the file to load
  73927. */
  73928. url: string,
  73929. /**
  73930. * Defines the desired size (the more it increases the longer the generation will be)
  73931. */
  73932. size: number,
  73933. /**
  73934. * Defines if mipmaps should not be generated (default is false)
  73935. */
  73936. noMipmap?: boolean,
  73937. /**
  73938. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73939. */
  73940. generateHarmonics?: boolean,
  73941. /**
  73942. * 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)
  73943. */
  73944. gammaSpace?: boolean,
  73945. /**
  73946. * Internal Use Only
  73947. */
  73948. reserved?: boolean);
  73949. /**
  73950. * Execute the current task
  73951. * @param scene defines the scene where you want your assets to be loaded
  73952. * @param onSuccess is a callback called when the task is successfully executed
  73953. * @param onError is a callback called if an error occurs
  73954. */
  73955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73956. }
  73957. /**
  73958. * Define a task used by AssetsManager to load Equirectangular cube textures
  73959. */
  73960. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73961. /**
  73962. * Defines the name of the task
  73963. */
  73964. name: string;
  73965. /**
  73966. * Defines the location of the file to load
  73967. */
  73968. url: string;
  73969. /**
  73970. * Defines the desired size (the more it increases the longer the generation will be)
  73971. */
  73972. size: number;
  73973. /**
  73974. * Defines if mipmaps should not be generated (default is false)
  73975. */
  73976. noMipmap: boolean;
  73977. /**
  73978. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73979. * but the standard material would require them in Gamma space) (default is true)
  73980. */
  73981. gammaSpace: boolean;
  73982. /**
  73983. * Gets the loaded texture
  73984. */
  73985. texture: EquiRectangularCubeTexture;
  73986. /**
  73987. * Callback called when the task is successful
  73988. */
  73989. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73990. /**
  73991. * Callback called when the task is successful
  73992. */
  73993. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73994. /**
  73995. * Creates a new EquiRectangularCubeTextureAssetTask object
  73996. * @param name defines the name of the task
  73997. * @param url defines the location of the file to load
  73998. * @param size defines the desired size (the more it increases the longer the generation will be)
  73999. * If the size is omitted this implies you are using a preprocessed cubemap.
  74000. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74001. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74002. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74003. * (default is true)
  74004. */
  74005. constructor(
  74006. /**
  74007. * Defines the name of the task
  74008. */
  74009. name: string,
  74010. /**
  74011. * Defines the location of the file to load
  74012. */
  74013. url: string,
  74014. /**
  74015. * Defines the desired size (the more it increases the longer the generation will be)
  74016. */
  74017. size: number,
  74018. /**
  74019. * Defines if mipmaps should not be generated (default is false)
  74020. */
  74021. noMipmap?: boolean,
  74022. /**
  74023. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74024. * but the standard material would require them in Gamma space) (default is true)
  74025. */
  74026. gammaSpace?: boolean);
  74027. /**
  74028. * Execute the current task
  74029. * @param scene defines the scene where you want your assets to be loaded
  74030. * @param onSuccess is a callback called when the task is successfully executed
  74031. * @param onError is a callback called if an error occurs
  74032. */
  74033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74034. }
  74035. /**
  74036. * This class can be used to easily import assets into a scene
  74037. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74038. */
  74039. export class AssetsManager {
  74040. private _scene;
  74041. private _isLoading;
  74042. protected _tasks: AbstractAssetTask[];
  74043. protected _waitingTasksCount: number;
  74044. protected _totalTasksCount: number;
  74045. /**
  74046. * Callback called when all tasks are processed
  74047. */
  74048. onFinish: (tasks: AbstractAssetTask[]) => void;
  74049. /**
  74050. * Callback called when a task is successful
  74051. */
  74052. onTaskSuccess: (task: AbstractAssetTask) => void;
  74053. /**
  74054. * Callback called when a task had an error
  74055. */
  74056. onTaskError: (task: AbstractAssetTask) => void;
  74057. /**
  74058. * Callback called when a task is done (whatever the result is)
  74059. */
  74060. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74061. /**
  74062. * Observable called when all tasks are processed
  74063. */
  74064. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74065. /**
  74066. * Observable called when a task had an error
  74067. */
  74068. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74069. /**
  74070. * Observable called when all tasks were executed
  74071. */
  74072. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74073. /**
  74074. * Observable called when a task is done (whatever the result is)
  74075. */
  74076. onProgressObservable: Observable<IAssetsProgressEvent>;
  74077. /**
  74078. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74079. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74080. */
  74081. useDefaultLoadingScreen: boolean;
  74082. /**
  74083. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74084. * when all assets have been downloaded.
  74085. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74086. */
  74087. autoHideLoadingUI: boolean;
  74088. /**
  74089. * Creates a new AssetsManager
  74090. * @param scene defines the scene to work on
  74091. */
  74092. constructor(scene: Scene);
  74093. /**
  74094. * Add a ContainerAssetTask to the list of active tasks
  74095. * @param taskName defines the name of the new task
  74096. * @param meshesNames defines the name of meshes to load
  74097. * @param rootUrl defines the root url to use to locate files
  74098. * @param sceneFilename defines the filename of the scene file
  74099. * @returns a new ContainerAssetTask object
  74100. */
  74101. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74102. /**
  74103. * Add a MeshAssetTask to the list of active tasks
  74104. * @param taskName defines the name of the new task
  74105. * @param meshesNames defines the name of meshes to load
  74106. * @param rootUrl defines the root url to use to locate files
  74107. * @param sceneFilename defines the filename of the scene file
  74108. * @returns a new MeshAssetTask object
  74109. */
  74110. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74111. /**
  74112. * Add a TextFileAssetTask to the list of active tasks
  74113. * @param taskName defines the name of the new task
  74114. * @param url defines the url of the file to load
  74115. * @returns a new TextFileAssetTask object
  74116. */
  74117. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74118. /**
  74119. * Add a BinaryFileAssetTask to the list of active tasks
  74120. * @param taskName defines the name of the new task
  74121. * @param url defines the url of the file to load
  74122. * @returns a new BinaryFileAssetTask object
  74123. */
  74124. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74125. /**
  74126. * Add a ImageAssetTask to the list of active tasks
  74127. * @param taskName defines the name of the new task
  74128. * @param url defines the url of the file to load
  74129. * @returns a new ImageAssetTask object
  74130. */
  74131. addImageTask(taskName: string, url: string): ImageAssetTask;
  74132. /**
  74133. * Add a TextureAssetTask to the list of active tasks
  74134. * @param taskName defines the name of the new task
  74135. * @param url defines the url of the file to load
  74136. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74137. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74138. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74139. * @returns a new TextureAssetTask object
  74140. */
  74141. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74142. /**
  74143. * Add a CubeTextureAssetTask to the list of active tasks
  74144. * @param taskName defines the name of the new task
  74145. * @param url defines the url of the file to load
  74146. * @param extensions defines the extension to use to load the cube map (can be null)
  74147. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74148. * @param files defines the list of files to load (can be null)
  74149. * @returns a new CubeTextureAssetTask object
  74150. */
  74151. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74152. /**
  74153. *
  74154. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74155. * @param taskName defines the name of the new task
  74156. * @param url defines the url of the file to load
  74157. * @param size defines the size you want for the cubemap (can be null)
  74158. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74159. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74160. * @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)
  74161. * @param reserved Internal use only
  74162. * @returns a new HDRCubeTextureAssetTask object
  74163. */
  74164. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74165. /**
  74166. *
  74167. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74168. * @param taskName defines the name of the new task
  74169. * @param url defines the url of the file to load
  74170. * @param size defines the size you want for the cubemap (can be null)
  74171. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74172. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74173. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74174. * @returns a new EquiRectangularCubeTextureAssetTask object
  74175. */
  74176. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74177. /**
  74178. * Remove a task from the assets manager.
  74179. * @param task the task to remove
  74180. */
  74181. removeTask(task: AbstractAssetTask): void;
  74182. private _decreaseWaitingTasksCount;
  74183. private _runTask;
  74184. /**
  74185. * Reset the AssetsManager and remove all tasks
  74186. * @return the current instance of the AssetsManager
  74187. */
  74188. reset(): AssetsManager;
  74189. /**
  74190. * Start the loading process
  74191. * @return the current instance of the AssetsManager
  74192. */
  74193. load(): AssetsManager;
  74194. /**
  74195. * Start the loading process as an async operation
  74196. * @return a promise returning the list of failed tasks
  74197. */
  74198. loadAsync(): Promise<void>;
  74199. }
  74200. }
  74201. declare module BABYLON {
  74202. /**
  74203. * Wrapper class for promise with external resolve and reject.
  74204. */
  74205. export class Deferred<T> {
  74206. /**
  74207. * The promise associated with this deferred object.
  74208. */
  74209. readonly promise: Promise<T>;
  74210. private _resolve;
  74211. private _reject;
  74212. /**
  74213. * The resolve method of the promise associated with this deferred object.
  74214. */
  74215. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74216. /**
  74217. * The reject method of the promise associated with this deferred object.
  74218. */
  74219. get reject(): (reason?: any) => void;
  74220. /**
  74221. * Constructor for this deferred object.
  74222. */
  74223. constructor();
  74224. }
  74225. }
  74226. declare module BABYLON {
  74227. /**
  74228. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74229. */
  74230. export class MeshExploder {
  74231. private _centerMesh;
  74232. private _meshes;
  74233. private _meshesOrigins;
  74234. private _toCenterVectors;
  74235. private _scaledDirection;
  74236. private _newPosition;
  74237. private _centerPosition;
  74238. /**
  74239. * Explodes meshes from a center mesh.
  74240. * @param meshes The meshes to explode.
  74241. * @param centerMesh The mesh to be center of explosion.
  74242. */
  74243. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74244. private _setCenterMesh;
  74245. /**
  74246. * Get class name
  74247. * @returns "MeshExploder"
  74248. */
  74249. getClassName(): string;
  74250. /**
  74251. * "Exploded meshes"
  74252. * @returns Array of meshes with the centerMesh at index 0.
  74253. */
  74254. getMeshes(): Array<Mesh>;
  74255. /**
  74256. * Explodes meshes giving a specific direction
  74257. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74258. */
  74259. explode(direction?: number): void;
  74260. }
  74261. }
  74262. declare module BABYLON {
  74263. /**
  74264. * Class used to help managing file picking and drag'n'drop
  74265. */
  74266. export class FilesInput {
  74267. /**
  74268. * List of files ready to be loaded
  74269. */
  74270. static get FilesToLoad(): {
  74271. [key: string]: File;
  74272. };
  74273. /**
  74274. * Callback called when a file is processed
  74275. */
  74276. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74277. private _engine;
  74278. private _currentScene;
  74279. private _sceneLoadedCallback;
  74280. private _progressCallback;
  74281. private _additionalRenderLoopLogicCallback;
  74282. private _textureLoadingCallback;
  74283. private _startingProcessingFilesCallback;
  74284. private _onReloadCallback;
  74285. private _errorCallback;
  74286. private _elementToMonitor;
  74287. private _sceneFileToLoad;
  74288. private _filesToLoad;
  74289. /**
  74290. * Creates a new FilesInput
  74291. * @param engine defines the rendering engine
  74292. * @param scene defines the hosting scene
  74293. * @param sceneLoadedCallback callback called when scene is loaded
  74294. * @param progressCallback callback called to track progress
  74295. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74296. * @param textureLoadingCallback callback called when a texture is loading
  74297. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74298. * @param onReloadCallback callback called when a reload is requested
  74299. * @param errorCallback callback call if an error occurs
  74300. */
  74301. 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>);
  74302. private _dragEnterHandler;
  74303. private _dragOverHandler;
  74304. private _dropHandler;
  74305. /**
  74306. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74307. * @param elementToMonitor defines the DOM element to track
  74308. */
  74309. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74310. /** Gets the current list of files to load */
  74311. get filesToLoad(): File[];
  74312. /**
  74313. * Release all associated resources
  74314. */
  74315. dispose(): void;
  74316. private renderFunction;
  74317. private drag;
  74318. private drop;
  74319. private _traverseFolder;
  74320. private _processFiles;
  74321. /**
  74322. * Load files from a drop event
  74323. * @param event defines the drop event to use as source
  74324. */
  74325. loadFiles(event: any): void;
  74326. private _processReload;
  74327. /**
  74328. * Reload the current scene from the loaded files
  74329. */
  74330. reload(): void;
  74331. }
  74332. }
  74333. declare module BABYLON {
  74334. /**
  74335. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74336. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74337. */
  74338. export class SceneOptimization {
  74339. /**
  74340. * Defines the priority of this optimization (0 by default which means first in the list)
  74341. */
  74342. priority: number;
  74343. /**
  74344. * Gets a string describing the action executed by the current optimization
  74345. * @returns description string
  74346. */
  74347. getDescription(): string;
  74348. /**
  74349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74350. * @param scene defines the current scene where to apply this optimization
  74351. * @param optimizer defines the current optimizer
  74352. * @returns true if everything that can be done was applied
  74353. */
  74354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74355. /**
  74356. * Creates the SceneOptimization object
  74357. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74358. * @param desc defines the description associated with the optimization
  74359. */
  74360. constructor(
  74361. /**
  74362. * Defines the priority of this optimization (0 by default which means first in the list)
  74363. */
  74364. priority?: number);
  74365. }
  74366. /**
  74367. * Defines an optimization used to reduce the size of render target textures
  74368. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74369. */
  74370. export class TextureOptimization extends SceneOptimization {
  74371. /**
  74372. * Defines the priority of this optimization (0 by default which means first in the list)
  74373. */
  74374. priority: number;
  74375. /**
  74376. * 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
  74377. */
  74378. maximumSize: number;
  74379. /**
  74380. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74381. */
  74382. step: number;
  74383. /**
  74384. * Gets a string describing the action executed by the current optimization
  74385. * @returns description string
  74386. */
  74387. getDescription(): string;
  74388. /**
  74389. * Creates the TextureOptimization object
  74390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74391. * @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
  74392. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74393. */
  74394. constructor(
  74395. /**
  74396. * Defines the priority of this optimization (0 by default which means first in the list)
  74397. */
  74398. priority?: number,
  74399. /**
  74400. * 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
  74401. */
  74402. maximumSize?: number,
  74403. /**
  74404. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74405. */
  74406. step?: number);
  74407. /**
  74408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74409. * @param scene defines the current scene where to apply this optimization
  74410. * @param optimizer defines the current optimizer
  74411. * @returns true if everything that can be done was applied
  74412. */
  74413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74414. }
  74415. /**
  74416. * Defines an optimization used to increase or decrease the rendering resolution
  74417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74418. */
  74419. export class HardwareScalingOptimization extends SceneOptimization {
  74420. /**
  74421. * Defines the priority of this optimization (0 by default which means first in the list)
  74422. */
  74423. priority: number;
  74424. /**
  74425. * Defines the maximum scale to use (2 by default)
  74426. */
  74427. maximumScale: number;
  74428. /**
  74429. * Defines the step to use between two passes (0.5 by default)
  74430. */
  74431. step: number;
  74432. private _currentScale;
  74433. private _directionOffset;
  74434. /**
  74435. * Gets a string describing the action executed by the current optimization
  74436. * @return description string
  74437. */
  74438. getDescription(): string;
  74439. /**
  74440. * Creates the HardwareScalingOptimization object
  74441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74442. * @param maximumScale defines the maximum scale to use (2 by default)
  74443. * @param step defines the step to use between two passes (0.5 by default)
  74444. */
  74445. constructor(
  74446. /**
  74447. * Defines the priority of this optimization (0 by default which means first in the list)
  74448. */
  74449. priority?: number,
  74450. /**
  74451. * Defines the maximum scale to use (2 by default)
  74452. */
  74453. maximumScale?: number,
  74454. /**
  74455. * Defines the step to use between two passes (0.5 by default)
  74456. */
  74457. step?: number);
  74458. /**
  74459. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74460. * @param scene defines the current scene where to apply this optimization
  74461. * @param optimizer defines the current optimizer
  74462. * @returns true if everything that can be done was applied
  74463. */
  74464. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74465. }
  74466. /**
  74467. * Defines an optimization used to remove shadows
  74468. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74469. */
  74470. export class ShadowsOptimization extends SceneOptimization {
  74471. /**
  74472. * Gets a string describing the action executed by the current optimization
  74473. * @return description string
  74474. */
  74475. getDescription(): string;
  74476. /**
  74477. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74478. * @param scene defines the current scene where to apply this optimization
  74479. * @param optimizer defines the current optimizer
  74480. * @returns true if everything that can be done was applied
  74481. */
  74482. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74483. }
  74484. /**
  74485. * Defines an optimization used to turn post-processes off
  74486. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74487. */
  74488. export class PostProcessesOptimization extends SceneOptimization {
  74489. /**
  74490. * Gets a string describing the action executed by the current optimization
  74491. * @return description string
  74492. */
  74493. getDescription(): string;
  74494. /**
  74495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74496. * @param scene defines the current scene where to apply this optimization
  74497. * @param optimizer defines the current optimizer
  74498. * @returns true if everything that can be done was applied
  74499. */
  74500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74501. }
  74502. /**
  74503. * Defines an optimization used to turn lens flares off
  74504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74505. */
  74506. export class LensFlaresOptimization extends SceneOptimization {
  74507. /**
  74508. * Gets a string describing the action executed by the current optimization
  74509. * @return description string
  74510. */
  74511. getDescription(): string;
  74512. /**
  74513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74514. * @param scene defines the current scene where to apply this optimization
  74515. * @param optimizer defines the current optimizer
  74516. * @returns true if everything that can be done was applied
  74517. */
  74518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74519. }
  74520. /**
  74521. * Defines an optimization based on user defined callback.
  74522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74523. */
  74524. export class CustomOptimization extends SceneOptimization {
  74525. /**
  74526. * Callback called to apply the custom optimization.
  74527. */
  74528. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74529. /**
  74530. * Callback called to get custom description
  74531. */
  74532. onGetDescription: () => string;
  74533. /**
  74534. * Gets a string describing the action executed by the current optimization
  74535. * @returns description string
  74536. */
  74537. getDescription(): string;
  74538. /**
  74539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74540. * @param scene defines the current scene where to apply this optimization
  74541. * @param optimizer defines the current optimizer
  74542. * @returns true if everything that can be done was applied
  74543. */
  74544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74545. }
  74546. /**
  74547. * Defines an optimization used to turn particles off
  74548. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74549. */
  74550. export class ParticlesOptimization extends SceneOptimization {
  74551. /**
  74552. * Gets a string describing the action executed by the current optimization
  74553. * @return description string
  74554. */
  74555. getDescription(): string;
  74556. /**
  74557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74558. * @param scene defines the current scene where to apply this optimization
  74559. * @param optimizer defines the current optimizer
  74560. * @returns true if everything that can be done was applied
  74561. */
  74562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74563. }
  74564. /**
  74565. * Defines an optimization used to turn render targets off
  74566. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74567. */
  74568. export class RenderTargetsOptimization extends SceneOptimization {
  74569. /**
  74570. * Gets a string describing the action executed by the current optimization
  74571. * @return description string
  74572. */
  74573. getDescription(): string;
  74574. /**
  74575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74576. * @param scene defines the current scene where to apply this optimization
  74577. * @param optimizer defines the current optimizer
  74578. * @returns true if everything that can be done was applied
  74579. */
  74580. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74581. }
  74582. /**
  74583. * Defines an optimization used to merge meshes with compatible materials
  74584. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74585. */
  74586. export class MergeMeshesOptimization extends SceneOptimization {
  74587. private static _UpdateSelectionTree;
  74588. /**
  74589. * Gets or sets a boolean which defines if optimization octree has to be updated
  74590. */
  74591. static get UpdateSelectionTree(): boolean;
  74592. /**
  74593. * Gets or sets a boolean which defines if optimization octree has to be updated
  74594. */
  74595. static set UpdateSelectionTree(value: boolean);
  74596. /**
  74597. * Gets a string describing the action executed by the current optimization
  74598. * @return description string
  74599. */
  74600. getDescription(): string;
  74601. private _canBeMerged;
  74602. /**
  74603. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74604. * @param scene defines the current scene where to apply this optimization
  74605. * @param optimizer defines the current optimizer
  74606. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74607. * @returns true if everything that can be done was applied
  74608. */
  74609. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74610. }
  74611. /**
  74612. * Defines a list of options used by SceneOptimizer
  74613. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74614. */
  74615. export class SceneOptimizerOptions {
  74616. /**
  74617. * Defines the target frame rate to reach (60 by default)
  74618. */
  74619. targetFrameRate: number;
  74620. /**
  74621. * Defines the interval between two checkes (2000ms by default)
  74622. */
  74623. trackerDuration: number;
  74624. /**
  74625. * Gets the list of optimizations to apply
  74626. */
  74627. optimizations: SceneOptimization[];
  74628. /**
  74629. * Creates a new list of options used by SceneOptimizer
  74630. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74631. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74632. */
  74633. constructor(
  74634. /**
  74635. * Defines the target frame rate to reach (60 by default)
  74636. */
  74637. targetFrameRate?: number,
  74638. /**
  74639. * Defines the interval between two checkes (2000ms by default)
  74640. */
  74641. trackerDuration?: number);
  74642. /**
  74643. * Add a new optimization
  74644. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74645. * @returns the current SceneOptimizerOptions
  74646. */
  74647. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74648. /**
  74649. * Add a new custom optimization
  74650. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74651. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74652. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74653. * @returns the current SceneOptimizerOptions
  74654. */
  74655. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74656. /**
  74657. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74658. * @param targetFrameRate defines the target frame rate (60 by default)
  74659. * @returns a SceneOptimizerOptions object
  74660. */
  74661. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74662. /**
  74663. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74664. * @param targetFrameRate defines the target frame rate (60 by default)
  74665. * @returns a SceneOptimizerOptions object
  74666. */
  74667. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74668. /**
  74669. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74670. * @param targetFrameRate defines the target frame rate (60 by default)
  74671. * @returns a SceneOptimizerOptions object
  74672. */
  74673. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74674. }
  74675. /**
  74676. * Class used to run optimizations in order to reach a target frame rate
  74677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74678. */
  74679. export class SceneOptimizer implements IDisposable {
  74680. private _isRunning;
  74681. private _options;
  74682. private _scene;
  74683. private _currentPriorityLevel;
  74684. private _targetFrameRate;
  74685. private _trackerDuration;
  74686. private _currentFrameRate;
  74687. private _sceneDisposeObserver;
  74688. private _improvementMode;
  74689. /**
  74690. * Defines an observable called when the optimizer reaches the target frame rate
  74691. */
  74692. onSuccessObservable: Observable<SceneOptimizer>;
  74693. /**
  74694. * Defines an observable called when the optimizer enables an optimization
  74695. */
  74696. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74697. /**
  74698. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74699. */
  74700. onFailureObservable: Observable<SceneOptimizer>;
  74701. /**
  74702. * Gets a boolean indicating if the optimizer is in improvement mode
  74703. */
  74704. get isInImprovementMode(): boolean;
  74705. /**
  74706. * Gets the current priority level (0 at start)
  74707. */
  74708. get currentPriorityLevel(): number;
  74709. /**
  74710. * Gets the current frame rate checked by the SceneOptimizer
  74711. */
  74712. get currentFrameRate(): number;
  74713. /**
  74714. * Gets or sets the current target frame rate (60 by default)
  74715. */
  74716. get targetFrameRate(): number;
  74717. /**
  74718. * Gets or sets the current target frame rate (60 by default)
  74719. */
  74720. set targetFrameRate(value: number);
  74721. /**
  74722. * Gets or sets the current interval between two checks (every 2000ms by default)
  74723. */
  74724. get trackerDuration(): number;
  74725. /**
  74726. * Gets or sets the current interval between two checks (every 2000ms by default)
  74727. */
  74728. set trackerDuration(value: number);
  74729. /**
  74730. * Gets the list of active optimizations
  74731. */
  74732. get optimizations(): SceneOptimization[];
  74733. /**
  74734. * Creates a new SceneOptimizer
  74735. * @param scene defines the scene to work on
  74736. * @param options defines the options to use with the SceneOptimizer
  74737. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74738. * @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)
  74739. */
  74740. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74741. /**
  74742. * Stops the current optimizer
  74743. */
  74744. stop(): void;
  74745. /**
  74746. * Reset the optimizer to initial step (current priority level = 0)
  74747. */
  74748. reset(): void;
  74749. /**
  74750. * Start the optimizer. By default it will try to reach a specific framerate
  74751. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74752. */
  74753. start(): void;
  74754. private _checkCurrentState;
  74755. /**
  74756. * Release all resources
  74757. */
  74758. dispose(): void;
  74759. /**
  74760. * Helper function to create a SceneOptimizer with one single line of code
  74761. * @param scene defines the scene to work on
  74762. * @param options defines the options to use with the SceneOptimizer
  74763. * @param onSuccess defines a callback to call on success
  74764. * @param onFailure defines a callback to call on failure
  74765. * @returns the new SceneOptimizer object
  74766. */
  74767. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74768. }
  74769. }
  74770. declare module BABYLON {
  74771. /**
  74772. * Class used to serialize a scene into a string
  74773. */
  74774. export class SceneSerializer {
  74775. /**
  74776. * Clear cache used by a previous serialization
  74777. */
  74778. static ClearCache(): void;
  74779. /**
  74780. * Serialize a scene into a JSON compatible object
  74781. * @param scene defines the scene to serialize
  74782. * @returns a JSON compatible object
  74783. */
  74784. static Serialize(scene: Scene): any;
  74785. /**
  74786. * Serialize a mesh into a JSON compatible object
  74787. * @param toSerialize defines the mesh to serialize
  74788. * @param withParents defines if parents must be serialized as well
  74789. * @param withChildren defines if children must be serialized as well
  74790. * @returns a JSON compatible object
  74791. */
  74792. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74793. }
  74794. }
  74795. declare module BABYLON {
  74796. /**
  74797. * Class used to host texture specific utilities
  74798. */
  74799. export class TextureTools {
  74800. /**
  74801. * Uses the GPU to create a copy texture rescaled at a given size
  74802. * @param texture Texture to copy from
  74803. * @param width defines the desired width
  74804. * @param height defines the desired height
  74805. * @param useBilinearMode defines if bilinear mode has to be used
  74806. * @return the generated texture
  74807. */
  74808. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /**
  74813. * This represents the different options available for the video capture.
  74814. */
  74815. export interface VideoRecorderOptions {
  74816. /** Defines the mime type of the video. */
  74817. mimeType: string;
  74818. /** Defines the FPS the video should be recorded at. */
  74819. fps: number;
  74820. /** Defines the chunk size for the recording data. */
  74821. recordChunckSize: number;
  74822. /** The audio tracks to attach to the recording. */
  74823. audioTracks?: MediaStreamTrack[];
  74824. }
  74825. /**
  74826. * This can help with recording videos from BabylonJS.
  74827. * This is based on the available WebRTC functionalities of the browser.
  74828. *
  74829. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74830. */
  74831. export class VideoRecorder {
  74832. private static readonly _defaultOptions;
  74833. /**
  74834. * Returns whether or not the VideoRecorder is available in your browser.
  74835. * @param engine Defines the Babylon Engine.
  74836. * @returns true if supported otherwise false.
  74837. */
  74838. static IsSupported(engine: Engine): boolean;
  74839. private readonly _options;
  74840. private _canvas;
  74841. private _mediaRecorder;
  74842. private _recordedChunks;
  74843. private _fileName;
  74844. private _resolve;
  74845. private _reject;
  74846. /**
  74847. * True when a recording is already in progress.
  74848. */
  74849. get isRecording(): boolean;
  74850. /**
  74851. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74852. * @param engine Defines the BabylonJS Engine you wish to record.
  74853. * @param options Defines options that can be used to customize the capture.
  74854. */
  74855. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74856. /**
  74857. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74858. */
  74859. stopRecording(): void;
  74860. /**
  74861. * Starts recording the canvas for a max duration specified in parameters.
  74862. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74863. * If null no automatic download will start and you can rely on the promise to get the data back.
  74864. * @param maxDuration Defines the maximum recording time in seconds.
  74865. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74866. * @return A promise callback at the end of the recording with the video data in Blob.
  74867. */
  74868. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74869. /**
  74870. * Releases internal resources used during the recording.
  74871. */
  74872. dispose(): void;
  74873. private _handleDataAvailable;
  74874. private _handleError;
  74875. private _handleStop;
  74876. }
  74877. }
  74878. declare module BABYLON {
  74879. /**
  74880. * Class containing a set of static utilities functions for screenshots
  74881. */
  74882. export class ScreenshotTools {
  74883. /**
  74884. * Captures a screenshot of the current rendering
  74885. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74886. * @param engine defines the rendering engine
  74887. * @param camera defines the source camera
  74888. * @param size This parameter can be set to a single number or to an object with the
  74889. * following (optional) properties: precision, width, height. If a single number is passed,
  74890. * it will be used for both width and height. If an object is passed, the screenshot size
  74891. * will be derived from the parameters. The precision property is a multiplier allowing
  74892. * rendering at a higher or lower resolution
  74893. * @param successCallback defines the callback receives a single parameter which contains the
  74894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74895. * src parameter of an <img> to display it
  74896. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74897. * Check your browser for supported MIME types
  74898. */
  74899. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74900. /**
  74901. * Captures a screenshot of the current rendering
  74902. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74903. * @param engine defines the rendering engine
  74904. * @param camera defines the source camera
  74905. * @param size This parameter can be set to a single number or to an object with the
  74906. * following (optional) properties: precision, width, height. If a single number is passed,
  74907. * it will be used for both width and height. If an object is passed, the screenshot size
  74908. * will be derived from the parameters. The precision property is a multiplier allowing
  74909. * rendering at a higher or lower resolution
  74910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74911. * Check your browser for supported MIME types
  74912. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74913. * to the src parameter of an <img> to display it
  74914. */
  74915. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74916. /**
  74917. * Generates an image screenshot from the specified camera.
  74918. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74919. * @param engine The engine to use for rendering
  74920. * @param camera The camera to use for rendering
  74921. * @param size This parameter can be set to a single number or to an object with the
  74922. * following (optional) properties: precision, width, height. If a single number is passed,
  74923. * it will be used for both width and height. If an object is passed, the screenshot size
  74924. * will be derived from the parameters. The precision property is a multiplier allowing
  74925. * rendering at a higher or lower resolution
  74926. * @param successCallback The callback receives a single parameter which contains the
  74927. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74928. * src parameter of an <img> to display it
  74929. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74930. * Check your browser for supported MIME types
  74931. * @param samples Texture samples (default: 1)
  74932. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74933. * @param fileName A name for for the downloaded file.
  74934. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74935. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74936. */
  74937. 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;
  74938. /**
  74939. * Generates an image screenshot from the specified camera.
  74940. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74941. * @param engine The engine to use for rendering
  74942. * @param camera The camera to use for rendering
  74943. * @param size This parameter can be set to a single number or to an object with the
  74944. * following (optional) properties: precision, width, height. If a single number is passed,
  74945. * it will be used for both width and height. If an object is passed, the screenshot size
  74946. * will be derived from the parameters. The precision property is a multiplier allowing
  74947. * rendering at a higher or lower resolution
  74948. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74949. * Check your browser for supported MIME types
  74950. * @param samples Texture samples (default: 1)
  74951. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74952. * @param fileName A name for for the downloaded file.
  74953. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74954. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74955. * to the src parameter of an <img> to display it
  74956. */
  74957. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74958. /**
  74959. * Gets height and width for screenshot size
  74960. * @private
  74961. */
  74962. private static _getScreenshotSize;
  74963. }
  74964. }
  74965. declare module BABYLON {
  74966. /**
  74967. * Interface for a data buffer
  74968. */
  74969. export interface IDataBuffer {
  74970. /**
  74971. * Reads bytes from the data buffer.
  74972. * @param byteOffset The byte offset to read
  74973. * @param byteLength The byte length to read
  74974. * @returns A promise that resolves when the bytes are read
  74975. */
  74976. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74977. /**
  74978. * The byte length of the buffer.
  74979. */
  74980. readonly byteLength: number;
  74981. }
  74982. /**
  74983. * Utility class for reading from a data buffer
  74984. */
  74985. export class DataReader {
  74986. /**
  74987. * The data buffer associated with this data reader.
  74988. */
  74989. readonly buffer: IDataBuffer;
  74990. /**
  74991. * The current byte offset from the beginning of the data buffer.
  74992. */
  74993. byteOffset: number;
  74994. private _dataView;
  74995. private _dataByteOffset;
  74996. /**
  74997. * Constructor
  74998. * @param buffer The buffer to read
  74999. */
  75000. constructor(buffer: IDataBuffer);
  75001. /**
  75002. * Loads the given byte length.
  75003. * @param byteLength The byte length to load
  75004. * @returns A promise that resolves when the load is complete
  75005. */
  75006. loadAsync(byteLength: number): Promise<void>;
  75007. /**
  75008. * Read a unsigned 32-bit integer from the currently loaded data range.
  75009. * @returns The 32-bit integer read
  75010. */
  75011. readUint32(): number;
  75012. /**
  75013. * Read a byte array from the currently loaded data range.
  75014. * @param byteLength The byte length to read
  75015. * @returns The byte array read
  75016. */
  75017. readUint8Array(byteLength: number): Uint8Array;
  75018. /**
  75019. * Read a string from the currently loaded data range.
  75020. * @param byteLength The byte length to read
  75021. * @returns The string read
  75022. */
  75023. readString(byteLength: number): string;
  75024. /**
  75025. * Skips the given byte length the currently loaded data range.
  75026. * @param byteLength The byte length to skip
  75027. */
  75028. skipBytes(byteLength: number): void;
  75029. }
  75030. }
  75031. declare module BABYLON {
  75032. /**
  75033. * Class for storing data to local storage if available or in-memory storage otherwise
  75034. */
  75035. export class DataStorage {
  75036. private static _Storage;
  75037. private static _GetStorage;
  75038. /**
  75039. * Reads a string from the data storage
  75040. * @param key The key to read
  75041. * @param defaultValue The value if the key doesn't exist
  75042. * @returns The string value
  75043. */
  75044. static ReadString(key: string, defaultValue: string): string;
  75045. /**
  75046. * Writes a string to the data storage
  75047. * @param key The key to write
  75048. * @param value The value to write
  75049. */
  75050. static WriteString(key: string, value: string): void;
  75051. /**
  75052. * Reads a boolean from the data storage
  75053. * @param key The key to read
  75054. * @param defaultValue The value if the key doesn't exist
  75055. * @returns The boolean value
  75056. */
  75057. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75058. /**
  75059. * Writes a boolean to the data storage
  75060. * @param key The key to write
  75061. * @param value The value to write
  75062. */
  75063. static WriteBoolean(key: string, value: boolean): void;
  75064. /**
  75065. * Reads a number from the data storage
  75066. * @param key The key to read
  75067. * @param defaultValue The value if the key doesn't exist
  75068. * @returns The number value
  75069. */
  75070. static ReadNumber(key: string, defaultValue: number): number;
  75071. /**
  75072. * Writes a number to the data storage
  75073. * @param key The key to write
  75074. * @param value The value to write
  75075. */
  75076. static WriteNumber(key: string, value: number): void;
  75077. }
  75078. }
  75079. declare module BABYLON {
  75080. /**
  75081. * Class used to record delta files between 2 scene states
  75082. */
  75083. export class SceneRecorder {
  75084. private _trackedScene;
  75085. private _savedJSON;
  75086. /**
  75087. * Track a given scene. This means the current scene state will be considered the original state
  75088. * @param scene defines the scene to track
  75089. */
  75090. track(scene: Scene): void;
  75091. /**
  75092. * Get the delta between current state and original state
  75093. * @returns a string containing the delta
  75094. */
  75095. getDelta(): any;
  75096. private _compareArray;
  75097. private _compareObjects;
  75098. private _compareCollections;
  75099. private static GetShadowGeneratorById;
  75100. /**
  75101. * Apply a given delta to a given scene
  75102. * @param deltaJSON defines the JSON containing the delta
  75103. * @param scene defines the scene to apply the delta to
  75104. */
  75105. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75106. private static _ApplyPropertiesToEntity;
  75107. private static _ApplyDeltaForEntity;
  75108. }
  75109. }
  75110. declare module BABYLON {
  75111. /**
  75112. * A 3D trajectory consisting of an order list of vectors describing a
  75113. * path of motion through 3D space.
  75114. */
  75115. export class Trajectory {
  75116. private _points;
  75117. private readonly _segmentLength;
  75118. /**
  75119. * Serialize to JSON.
  75120. * @returns serialized JSON string
  75121. */
  75122. serialize(): string;
  75123. /**
  75124. * Deserialize from JSON.
  75125. * @param json serialized JSON string
  75126. * @returns deserialized Trajectory
  75127. */
  75128. static Deserialize(json: string): Trajectory;
  75129. /**
  75130. * Create a new empty Trajectory.
  75131. * @param segmentLength radius of discretization for Trajectory points
  75132. */
  75133. constructor(segmentLength?: number);
  75134. /**
  75135. * Get the length of the Trajectory.
  75136. * @returns length of the Trajectory
  75137. */
  75138. getLength(): number;
  75139. /**
  75140. * Append a new point to the Trajectory.
  75141. * NOTE: This implementation has many allocations.
  75142. * @param point point to append to the Trajectory
  75143. */
  75144. add(point: DeepImmutable<Vector3>): void;
  75145. /**
  75146. * Create a new Trajectory with a segment length chosen to make it
  75147. * probable that the new Trajectory will have a specified number of
  75148. * segments. This operation is imprecise.
  75149. * @param targetResolution number of segments desired
  75150. * @returns new Trajectory with approximately the requested number of segments
  75151. */
  75152. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75153. /**
  75154. * Convert Trajectory segments into tokenized representation. This
  75155. * representation is an array of numbers where each nth number is the
  75156. * index of the token which is most similar to the nth segment of the
  75157. * Trajectory.
  75158. * @param tokens list of vectors which serve as discrete tokens
  75159. * @returns list of indices of most similar token per segment
  75160. */
  75161. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75162. private static _forwardDir;
  75163. private static _inverseFromVec;
  75164. private static _upDir;
  75165. private static _fromToVec;
  75166. private static _lookMatrix;
  75167. /**
  75168. * Transform the rotation (i.e., direction) of a segment to isolate
  75169. * the relative transformation represented by the segment. This operation
  75170. * may or may not succeed due to singularities in the equations that define
  75171. * motion relativity in this context.
  75172. * @param priorVec the origin of the prior segment
  75173. * @param fromVec the origin of the current segment
  75174. * @param toVec the destination of the current segment
  75175. * @param result reference to output variable
  75176. * @returns whether or not transformation was successful
  75177. */
  75178. private static _transformSegmentDirToRef;
  75179. private static _bestMatch;
  75180. private static _score;
  75181. private static _bestScore;
  75182. /**
  75183. * Determine which token vector is most similar to the
  75184. * segment vector.
  75185. * @param segment segment vector
  75186. * @param tokens token vector list
  75187. * @returns index of the most similar token to the segment
  75188. */
  75189. private static _tokenizeSegment;
  75190. }
  75191. /**
  75192. * Class representing a set of known, named trajectories to which Trajectories can be
  75193. * added and using which Trajectories can be recognized.
  75194. */
  75195. export class TrajectoryClassifier {
  75196. private _maximumAllowableMatchCost;
  75197. private _vector3Alphabet;
  75198. private _levenshteinAlphabet;
  75199. private _nameToDescribedTrajectory;
  75200. /**
  75201. * Serialize to JSON.
  75202. * @returns JSON serialization
  75203. */
  75204. serialize(): string;
  75205. /**
  75206. * Deserialize from JSON.
  75207. * @param json JSON serialization
  75208. * @returns deserialized TrajectorySet
  75209. */
  75210. static Deserialize(json: string): TrajectoryClassifier;
  75211. /**
  75212. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75213. * VERY naive, need to be generating these things from known
  75214. * sets. Better version later, probably eliminating this one.
  75215. * @returns auto-generated TrajectorySet
  75216. */
  75217. static Generate(): TrajectoryClassifier;
  75218. private constructor();
  75219. /**
  75220. * Add a new Trajectory to the set with a given name.
  75221. * @param trajectory new Trajectory to be added
  75222. * @param classification name to which to add the Trajectory
  75223. */
  75224. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75225. /**
  75226. * Remove a known named trajectory and all Trajectories associated with it.
  75227. * @param classification name to remove
  75228. * @returns whether anything was removed
  75229. */
  75230. deleteClassification(classification: string): boolean;
  75231. /**
  75232. * Attempt to recognize a Trajectory from among all the classifications
  75233. * already known to the classifier.
  75234. * @param trajectory Trajectory to be recognized
  75235. * @returns classification of Trajectory if recognized, null otherwise
  75236. */
  75237. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75238. }
  75239. }
  75240. declare module BABYLON {
  75241. /**
  75242. * An interface for all Hit test features
  75243. */
  75244. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75245. /**
  75246. * Triggered when new babylon (transformed) hit test results are available
  75247. */
  75248. onHitTestResultObservable: Observable<T[]>;
  75249. }
  75250. /**
  75251. * Options used for hit testing
  75252. */
  75253. export interface IWebXRLegacyHitTestOptions {
  75254. /**
  75255. * Only test when user interacted with the scene. Default - hit test every frame
  75256. */
  75257. testOnPointerDownOnly?: boolean;
  75258. /**
  75259. * The node to use to transform the local results to world coordinates
  75260. */
  75261. worldParentNode?: TransformNode;
  75262. }
  75263. /**
  75264. * Interface defining the babylon result of raycasting/hit-test
  75265. */
  75266. export interface IWebXRLegacyHitResult {
  75267. /**
  75268. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75269. */
  75270. transformationMatrix: Matrix;
  75271. /**
  75272. * The native hit test result
  75273. */
  75274. xrHitResult: XRHitResult | XRHitTestResult;
  75275. }
  75276. /**
  75277. * The currently-working hit-test module.
  75278. * Hit test (or Ray-casting) is used to interact with the real world.
  75279. * For further information read here - https://github.com/immersive-web/hit-test
  75280. */
  75281. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75282. /**
  75283. * options to use when constructing this feature
  75284. */
  75285. readonly options: IWebXRLegacyHitTestOptions;
  75286. private _direction;
  75287. private _mat;
  75288. private _onSelectEnabled;
  75289. private _origin;
  75290. /**
  75291. * The module's name
  75292. */
  75293. static readonly Name: string;
  75294. /**
  75295. * The (Babylon) version of this module.
  75296. * This is an integer representing the implementation version.
  75297. * This number does not correspond to the WebXR specs version
  75298. */
  75299. static readonly Version: number;
  75300. /**
  75301. * Populated with the last native XR Hit Results
  75302. */
  75303. lastNativeXRHitResults: XRHitResult[];
  75304. /**
  75305. * Triggered when new babylon (transformed) hit test results are available
  75306. */
  75307. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75308. /**
  75309. * Creates a new instance of the (legacy version) hit test feature
  75310. * @param _xrSessionManager an instance of WebXRSessionManager
  75311. * @param options options to use when constructing this feature
  75312. */
  75313. constructor(_xrSessionManager: WebXRSessionManager,
  75314. /**
  75315. * options to use when constructing this feature
  75316. */
  75317. options?: IWebXRLegacyHitTestOptions);
  75318. /**
  75319. * execute a hit test with an XR Ray
  75320. *
  75321. * @param xrSession a native xrSession that will execute this hit test
  75322. * @param xrRay the ray (position and direction) to use for ray-casting
  75323. * @param referenceSpace native XR reference space to use for the hit-test
  75324. * @param filter filter function that will filter the results
  75325. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75326. */
  75327. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75328. /**
  75329. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75330. * @param event the (select) event to use to select with
  75331. * @param referenceSpace the reference space to use for this hit test
  75332. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75333. */
  75334. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75335. /**
  75336. * attach this feature
  75337. * Will usually be called by the features manager
  75338. *
  75339. * @returns true if successful.
  75340. */
  75341. attach(): boolean;
  75342. /**
  75343. * detach this feature.
  75344. * Will usually be called by the features manager
  75345. *
  75346. * @returns true if successful.
  75347. */
  75348. detach(): boolean;
  75349. /**
  75350. * Dispose this feature and all of the resources attached
  75351. */
  75352. dispose(): void;
  75353. protected _onXRFrame(frame: XRFrame): void;
  75354. private _onHitTestResults;
  75355. private _onSelect;
  75356. }
  75357. }
  75358. declare module BABYLON {
  75359. /**
  75360. * Options used for hit testing (version 2)
  75361. */
  75362. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75363. /**
  75364. * Do not create a permanent hit test. Will usually be used when only
  75365. * transient inputs are needed.
  75366. */
  75367. disablePermanentHitTest?: boolean;
  75368. /**
  75369. * Enable transient (for example touch-based) hit test inspections
  75370. */
  75371. enableTransientHitTest?: boolean;
  75372. /**
  75373. * Offset ray for the permanent hit test
  75374. */
  75375. offsetRay?: Vector3;
  75376. /**
  75377. * Offset ray for the transient hit test
  75378. */
  75379. transientOffsetRay?: Vector3;
  75380. /**
  75381. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75382. */
  75383. useReferenceSpace?: boolean;
  75384. /**
  75385. * Override the default entity type(s) of the hit-test result
  75386. */
  75387. entityTypes?: XRHitTestTrackableType[];
  75388. }
  75389. /**
  75390. * Interface defining the babylon result of hit-test
  75391. */
  75392. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75393. /**
  75394. * The input source that generated this hit test (if transient)
  75395. */
  75396. inputSource?: XRInputSource;
  75397. /**
  75398. * Is this a transient hit test
  75399. */
  75400. isTransient?: boolean;
  75401. /**
  75402. * Position of the hit test result
  75403. */
  75404. position: Vector3;
  75405. /**
  75406. * Rotation of the hit test result
  75407. */
  75408. rotationQuaternion: Quaternion;
  75409. /**
  75410. * The native hit test result
  75411. */
  75412. xrHitResult: XRHitTestResult;
  75413. }
  75414. /**
  75415. * The currently-working hit-test module.
  75416. * Hit test (or Ray-casting) is used to interact with the real world.
  75417. * For further information read here - https://github.com/immersive-web/hit-test
  75418. *
  75419. * Tested on chrome (mobile) 80.
  75420. */
  75421. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75422. /**
  75423. * options to use when constructing this feature
  75424. */
  75425. readonly options: IWebXRHitTestOptions;
  75426. private _tmpMat;
  75427. private _tmpPos;
  75428. private _tmpQuat;
  75429. private _transientXrHitTestSource;
  75430. private _xrHitTestSource;
  75431. private initHitTestSource;
  75432. /**
  75433. * The module's name
  75434. */
  75435. static readonly Name: string;
  75436. /**
  75437. * The (Babylon) version of this module.
  75438. * This is an integer representing the implementation version.
  75439. * This number does not correspond to the WebXR specs version
  75440. */
  75441. static readonly Version: number;
  75442. /**
  75443. * When set to true, each hit test will have its own position/rotation objects
  75444. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75445. * the developers will clone them or copy them as they see fit.
  75446. */
  75447. autoCloneTransformation: boolean;
  75448. /**
  75449. * Triggered when new babylon (transformed) hit test results are available
  75450. * Note - this will be called when results come back from the device. It can be an empty array!!
  75451. */
  75452. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75453. /**
  75454. * Use this to temporarily pause hit test checks.
  75455. */
  75456. paused: boolean;
  75457. /**
  75458. * Creates a new instance of the hit test feature
  75459. * @param _xrSessionManager an instance of WebXRSessionManager
  75460. * @param options options to use when constructing this feature
  75461. */
  75462. constructor(_xrSessionManager: WebXRSessionManager,
  75463. /**
  75464. * options to use when constructing this feature
  75465. */
  75466. options?: IWebXRHitTestOptions);
  75467. /**
  75468. * attach this feature
  75469. * Will usually be called by the features manager
  75470. *
  75471. * @returns true if successful.
  75472. */
  75473. attach(): boolean;
  75474. /**
  75475. * detach this feature.
  75476. * Will usually be called by the features manager
  75477. *
  75478. * @returns true if successful.
  75479. */
  75480. detach(): boolean;
  75481. /**
  75482. * Dispose this feature and all of the resources attached
  75483. */
  75484. dispose(): void;
  75485. protected _onXRFrame(frame: XRFrame): void;
  75486. private _processWebXRHitTestResult;
  75487. }
  75488. }
  75489. declare module BABYLON {
  75490. /**
  75491. * Configuration options of the anchor system
  75492. */
  75493. export interface IWebXRAnchorSystemOptions {
  75494. /**
  75495. * a node that will be used to convert local to world coordinates
  75496. */
  75497. worldParentNode?: TransformNode;
  75498. /**
  75499. * If set to true a reference of the created anchors will be kept until the next session starts
  75500. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75501. */
  75502. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75503. }
  75504. /**
  75505. * A babylon container for an XR Anchor
  75506. */
  75507. export interface IWebXRAnchor {
  75508. /**
  75509. * A babylon-assigned ID for this anchor
  75510. */
  75511. id: number;
  75512. /**
  75513. * Transformation matrix to apply to an object attached to this anchor
  75514. */
  75515. transformationMatrix: Matrix;
  75516. /**
  75517. * The native anchor object
  75518. */
  75519. xrAnchor: XRAnchor;
  75520. /**
  75521. * if defined, this object will be constantly updated by the anchor's position and rotation
  75522. */
  75523. attachedNode?: TransformNode;
  75524. }
  75525. /**
  75526. * An implementation of the anchor system for WebXR.
  75527. * For further information see https://github.com/immersive-web/anchors/
  75528. */
  75529. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75530. private _options;
  75531. private _lastFrameDetected;
  75532. private _trackedAnchors;
  75533. private _referenceSpaceForFrameAnchors;
  75534. private _futureAnchors;
  75535. /**
  75536. * The module's name
  75537. */
  75538. static readonly Name: string;
  75539. /**
  75540. * The (Babylon) version of this module.
  75541. * This is an integer representing the implementation version.
  75542. * This number does not correspond to the WebXR specs version
  75543. */
  75544. static readonly Version: number;
  75545. /**
  75546. * Observers registered here will be executed when a new anchor was added to the session
  75547. */
  75548. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75549. /**
  75550. * Observers registered here will be executed when an anchor was removed from the session
  75551. */
  75552. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75553. /**
  75554. * Observers registered here will be executed when an existing anchor updates
  75555. * This can execute N times every frame
  75556. */
  75557. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75558. /**
  75559. * Set the reference space to use for anchor creation, when not using a hit test.
  75560. * Will default to the session's reference space if not defined
  75561. */
  75562. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75563. /**
  75564. * constructs a new anchor system
  75565. * @param _xrSessionManager an instance of WebXRSessionManager
  75566. * @param _options configuration object for this feature
  75567. */
  75568. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75569. private _tmpVector;
  75570. private _tmpQuaternion;
  75571. private _populateTmpTransformation;
  75572. /**
  75573. * Create a new anchor point using a hit test result at a specific point in the scene
  75574. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75575. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75576. *
  75577. * @param hitTestResult The hit test result to use for this anchor creation
  75578. * @param position an optional position offset for this anchor
  75579. * @param rotationQuaternion an optional rotation offset for this anchor
  75580. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75581. */
  75582. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75583. /**
  75584. * Add a new anchor at a specific position and rotation
  75585. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75586. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75587. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75588. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75589. *
  75590. * @param position the position in which to add an anchor
  75591. * @param rotationQuaternion an optional rotation for the anchor transformation
  75592. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75593. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75594. */
  75595. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75596. /**
  75597. * detach this feature.
  75598. * Will usually be called by the features manager
  75599. *
  75600. * @returns true if successful.
  75601. */
  75602. detach(): boolean;
  75603. /**
  75604. * Dispose this feature and all of the resources attached
  75605. */
  75606. dispose(): void;
  75607. protected _onXRFrame(frame: XRFrame): void;
  75608. /**
  75609. * avoiding using Array.find for global support.
  75610. * @param xrAnchor the plane to find in the array
  75611. */
  75612. private _findIndexInAnchorArray;
  75613. private _updateAnchorWithXRFrame;
  75614. private _createAnchorAtTransformation;
  75615. }
  75616. }
  75617. declare module BABYLON {
  75618. /**
  75619. * Options used in the plane detector module
  75620. */
  75621. export interface IWebXRPlaneDetectorOptions {
  75622. /**
  75623. * The node to use to transform the local results to world coordinates
  75624. */
  75625. worldParentNode?: TransformNode;
  75626. /**
  75627. * If set to true a reference of the created planes will be kept until the next session starts
  75628. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75629. */
  75630. doNotRemovePlanesOnSessionEnded?: boolean;
  75631. }
  75632. /**
  75633. * A babylon interface for a WebXR plane.
  75634. * A Plane is actually a polygon, built from N points in space
  75635. *
  75636. * Supported in chrome 79, not supported in canary 81 ATM
  75637. */
  75638. export interface IWebXRPlane {
  75639. /**
  75640. * a babylon-assigned ID for this polygon
  75641. */
  75642. id: number;
  75643. /**
  75644. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75645. */
  75646. polygonDefinition: Array<Vector3>;
  75647. /**
  75648. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75649. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75650. */
  75651. transformationMatrix: Matrix;
  75652. /**
  75653. * the native xr-plane object
  75654. */
  75655. xrPlane: XRPlane;
  75656. }
  75657. /**
  75658. * The plane detector is used to detect planes in the real world when in AR
  75659. * For more information see https://github.com/immersive-web/real-world-geometry/
  75660. */
  75661. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75662. private _options;
  75663. private _detectedPlanes;
  75664. private _enabled;
  75665. private _lastFrameDetected;
  75666. /**
  75667. * The module's name
  75668. */
  75669. static readonly Name: string;
  75670. /**
  75671. * The (Babylon) version of this module.
  75672. * This is an integer representing the implementation version.
  75673. * This number does not correspond to the WebXR specs version
  75674. */
  75675. static readonly Version: number;
  75676. /**
  75677. * Observers registered here will be executed when a new plane was added to the session
  75678. */
  75679. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75680. /**
  75681. * Observers registered here will be executed when a plane is no longer detected in the session
  75682. */
  75683. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75684. /**
  75685. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75686. * This can execute N times every frame
  75687. */
  75688. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75689. /**
  75690. * construct a new Plane Detector
  75691. * @param _xrSessionManager an instance of xr Session manager
  75692. * @param _options configuration to use when constructing this feature
  75693. */
  75694. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75695. /**
  75696. * detach this feature.
  75697. * Will usually be called by the features manager
  75698. *
  75699. * @returns true if successful.
  75700. */
  75701. detach(): boolean;
  75702. /**
  75703. * Dispose this feature and all of the resources attached
  75704. */
  75705. dispose(): void;
  75706. protected _onXRFrame(frame: XRFrame): void;
  75707. private _init;
  75708. private _updatePlaneWithXRPlane;
  75709. /**
  75710. * avoiding using Array.find for global support.
  75711. * @param xrPlane the plane to find in the array
  75712. */
  75713. private findIndexInPlaneArray;
  75714. }
  75715. }
  75716. declare module BABYLON {
  75717. /**
  75718. * Options interface for the background remover plugin
  75719. */
  75720. export interface IWebXRBackgroundRemoverOptions {
  75721. /**
  75722. * Further background meshes to disable when entering AR
  75723. */
  75724. backgroundMeshes?: AbstractMesh[];
  75725. /**
  75726. * flags to configure the removal of the environment helper.
  75727. * If not set, the entire background will be removed. If set, flags should be set as well.
  75728. */
  75729. environmentHelperRemovalFlags?: {
  75730. /**
  75731. * Should the skybox be removed (default false)
  75732. */
  75733. skyBox?: boolean;
  75734. /**
  75735. * Should the ground be removed (default false)
  75736. */
  75737. ground?: boolean;
  75738. };
  75739. /**
  75740. * don't disable the environment helper
  75741. */
  75742. ignoreEnvironmentHelper?: boolean;
  75743. }
  75744. /**
  75745. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75746. */
  75747. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75748. /**
  75749. * read-only options to be used in this module
  75750. */
  75751. readonly options: IWebXRBackgroundRemoverOptions;
  75752. /**
  75753. * The module's name
  75754. */
  75755. static readonly Name: string;
  75756. /**
  75757. * The (Babylon) version of this module.
  75758. * This is an integer representing the implementation version.
  75759. * This number does not correspond to the WebXR specs version
  75760. */
  75761. static readonly Version: number;
  75762. /**
  75763. * registered observers will be triggered when the background state changes
  75764. */
  75765. onBackgroundStateChangedObservable: Observable<boolean>;
  75766. /**
  75767. * constructs a new background remover module
  75768. * @param _xrSessionManager the session manager for this module
  75769. * @param options read-only options to be used in this module
  75770. */
  75771. constructor(_xrSessionManager: WebXRSessionManager,
  75772. /**
  75773. * read-only options to be used in this module
  75774. */
  75775. options?: IWebXRBackgroundRemoverOptions);
  75776. /**
  75777. * attach this feature
  75778. * Will usually be called by the features manager
  75779. *
  75780. * @returns true if successful.
  75781. */
  75782. attach(): boolean;
  75783. /**
  75784. * detach this feature.
  75785. * Will usually be called by the features manager
  75786. *
  75787. * @returns true if successful.
  75788. */
  75789. detach(): boolean;
  75790. /**
  75791. * Dispose this feature and all of the resources attached
  75792. */
  75793. dispose(): void;
  75794. protected _onXRFrame(_xrFrame: XRFrame): void;
  75795. private _setBackgroundState;
  75796. }
  75797. }
  75798. declare module BABYLON {
  75799. /**
  75800. * Options for the controller physics feature
  75801. */
  75802. export class IWebXRControllerPhysicsOptions {
  75803. /**
  75804. * Should the headset get its own impostor
  75805. */
  75806. enableHeadsetImpostor?: boolean;
  75807. /**
  75808. * Optional parameters for the headset impostor
  75809. */
  75810. headsetImpostorParams?: {
  75811. /**
  75812. * The type of impostor to create. Default is sphere
  75813. */
  75814. impostorType: number;
  75815. /**
  75816. * the size of the impostor. Defaults to 10cm
  75817. */
  75818. impostorSize?: number | {
  75819. width: number;
  75820. height: number;
  75821. depth: number;
  75822. };
  75823. /**
  75824. * Friction definitions
  75825. */
  75826. friction?: number;
  75827. /**
  75828. * Restitution
  75829. */
  75830. restitution?: number;
  75831. };
  75832. /**
  75833. * The physics properties of the future impostors
  75834. */
  75835. physicsProperties?: {
  75836. /**
  75837. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75838. * Note that this requires a physics engine that supports mesh impostors!
  75839. */
  75840. useControllerMesh?: boolean;
  75841. /**
  75842. * The type of impostor to create. Default is sphere
  75843. */
  75844. impostorType?: number;
  75845. /**
  75846. * the size of the impostor. Defaults to 10cm
  75847. */
  75848. impostorSize?: number | {
  75849. width: number;
  75850. height: number;
  75851. depth: number;
  75852. };
  75853. /**
  75854. * Friction definitions
  75855. */
  75856. friction?: number;
  75857. /**
  75858. * Restitution
  75859. */
  75860. restitution?: number;
  75861. };
  75862. /**
  75863. * the xr input to use with this pointer selection
  75864. */
  75865. xrInput: WebXRInput;
  75866. }
  75867. /**
  75868. * Add physics impostor to your webxr controllers,
  75869. * including naive calculation of their linear and angular velocity
  75870. */
  75871. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75872. private readonly _options;
  75873. private _attachController;
  75874. private _controllers;
  75875. private _debugMode;
  75876. private _delta;
  75877. private _headsetImpostor?;
  75878. private _headsetMesh?;
  75879. private _lastTimestamp;
  75880. private _tmpQuaternion;
  75881. private _tmpVector;
  75882. /**
  75883. * The module's name
  75884. */
  75885. static readonly Name: string;
  75886. /**
  75887. * The (Babylon) version of this module.
  75888. * This is an integer representing the implementation version.
  75889. * This number does not correspond to the webxr specs version
  75890. */
  75891. static readonly Version: number;
  75892. /**
  75893. * Construct a new Controller Physics Feature
  75894. * @param _xrSessionManager the corresponding xr session manager
  75895. * @param _options options to create this feature with
  75896. */
  75897. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75898. /**
  75899. * @hidden
  75900. * enable debugging - will show console outputs and the impostor mesh
  75901. */
  75902. _enablePhysicsDebug(): void;
  75903. /**
  75904. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75905. * @param xrController the controller to add
  75906. */
  75907. addController(xrController: WebXRInputSource): void;
  75908. /**
  75909. * attach this feature
  75910. * Will usually be called by the features manager
  75911. *
  75912. * @returns true if successful.
  75913. */
  75914. attach(): boolean;
  75915. /**
  75916. * detach this feature.
  75917. * Will usually be called by the features manager
  75918. *
  75919. * @returns true if successful.
  75920. */
  75921. detach(): boolean;
  75922. /**
  75923. * Get the headset impostor, if enabled
  75924. * @returns the impostor
  75925. */
  75926. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75927. /**
  75928. * Get the physics impostor of a specific controller.
  75929. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75930. * @param controller the controller or the controller id of which to get the impostor
  75931. * @returns the impostor or null
  75932. */
  75933. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75934. /**
  75935. * Update the physics properties provided in the constructor
  75936. * @param newProperties the new properties object
  75937. */
  75938. setPhysicsProperties(newProperties: {
  75939. impostorType?: number;
  75940. impostorSize?: number | {
  75941. width: number;
  75942. height: number;
  75943. depth: number;
  75944. };
  75945. friction?: number;
  75946. restitution?: number;
  75947. }): void;
  75948. protected _onXRFrame(_xrFrame: any): void;
  75949. private _detachController;
  75950. }
  75951. }
  75952. declare module BABYLON {
  75953. /**
  75954. * A babylon interface for a "WebXR" feature point.
  75955. * Represents the position and confidence value of a given feature point.
  75956. */
  75957. export interface IWebXRFeaturePoint {
  75958. /**
  75959. * Represents the position of the feature point in world space.
  75960. */
  75961. position: Vector3;
  75962. /**
  75963. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75964. */
  75965. confidenceValue: number;
  75966. }
  75967. /**
  75968. * The feature point system is used to detect feature points from real world geometry.
  75969. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75970. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75971. */
  75972. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75973. private _enabled;
  75974. private _featurePointCloud;
  75975. /**
  75976. * The module's name
  75977. */
  75978. static readonly Name: string;
  75979. /**
  75980. * The (Babylon) version of this module.
  75981. * This is an integer representing the implementation version.
  75982. * This number does not correspond to the WebXR specs version
  75983. */
  75984. static readonly Version: number;
  75985. /**
  75986. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75987. * Will notify the observers about which feature points have been added.
  75988. */
  75989. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75990. /**
  75991. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75992. * Will notify the observers about which feature points have been updated.
  75993. */
  75994. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75995. /**
  75996. * The current feature point cloud maintained across frames.
  75997. */
  75998. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75999. /**
  76000. * construct the feature point system
  76001. * @param _xrSessionManager an instance of xr Session manager
  76002. */
  76003. constructor(_xrSessionManager: WebXRSessionManager);
  76004. /**
  76005. * Detach this feature.
  76006. * Will usually be called by the features manager
  76007. *
  76008. * @returns true if successful.
  76009. */
  76010. detach(): boolean;
  76011. /**
  76012. * Dispose this feature and all of the resources attached
  76013. */
  76014. dispose(): void;
  76015. /**
  76016. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76017. */
  76018. protected _onXRFrame(frame: XRFrame): void;
  76019. /**
  76020. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76021. */
  76022. private _init;
  76023. }
  76024. }
  76025. declare module BABYLON {
  76026. /**
  76027. * Configuration interface for the hand tracking feature
  76028. */
  76029. export interface IWebXRHandTrackingOptions {
  76030. /**
  76031. * The xrInput that will be used as source for new hands
  76032. */
  76033. xrInput: WebXRInput;
  76034. /**
  76035. * Configuration object for the joint meshes
  76036. */
  76037. jointMeshes?: {
  76038. /**
  76039. * Should the meshes created be invisible (defaults to false)
  76040. */
  76041. invisible?: boolean;
  76042. /**
  76043. * A source mesh to be used to create instances. Defaults to a sphere.
  76044. * This mesh will be the source for all other (25) meshes.
  76045. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76046. */
  76047. sourceMesh?: Mesh;
  76048. /**
  76049. * This function will be called after a mesh was created for a specific joint.
  76050. * Using this function you can either manipulate the instance or return a new mesh.
  76051. * When returning a new mesh the instance created before will be disposed
  76052. */
  76053. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76054. /**
  76055. * Should the source mesh stay visible. Defaults to false
  76056. */
  76057. keepOriginalVisible?: boolean;
  76058. /**
  76059. * Scale factor for all instances (defaults to 2)
  76060. */
  76061. scaleFactor?: number;
  76062. /**
  76063. * Should each instance have its own physics impostor
  76064. */
  76065. enablePhysics?: boolean;
  76066. /**
  76067. * If enabled, override default physics properties
  76068. */
  76069. physicsProps?: {
  76070. friction?: number;
  76071. restitution?: number;
  76072. impostorType?: number;
  76073. };
  76074. /**
  76075. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76076. */
  76077. handMesh?: AbstractMesh;
  76078. };
  76079. }
  76080. /**
  76081. * Parts of the hands divided to writs and finger names
  76082. */
  76083. export const enum HandPart {
  76084. /**
  76085. * HandPart - Wrist
  76086. */
  76087. WRIST = "wrist",
  76088. /**
  76089. * HandPart - The THumb
  76090. */
  76091. THUMB = "thumb",
  76092. /**
  76093. * HandPart - Index finger
  76094. */
  76095. INDEX = "index",
  76096. /**
  76097. * HandPart - Middle finger
  76098. */
  76099. MIDDLE = "middle",
  76100. /**
  76101. * HandPart - Ring finger
  76102. */
  76103. RING = "ring",
  76104. /**
  76105. * HandPart - Little finger
  76106. */
  76107. LITTLE = "little"
  76108. }
  76109. /**
  76110. * Representing a single hand (with its corresponding native XRHand object)
  76111. */
  76112. export class WebXRHand implements IDisposable {
  76113. /** the controller to which the hand correlates */
  76114. readonly xrController: WebXRInputSource;
  76115. /** the meshes to be used to track the hand joints */
  76116. readonly trackedMeshes: AbstractMesh[];
  76117. /**
  76118. * Hand-parts definition (key is HandPart)
  76119. */
  76120. handPartsDefinition: {
  76121. [key: string]: number[];
  76122. };
  76123. /**
  76124. * Populate the HandPartsDefinition object.
  76125. * This is called as a side effect since certain browsers don't have XRHand defined.
  76126. */
  76127. private generateHandPartsDefinition;
  76128. /**
  76129. * Construct a new hand object
  76130. * @param xrController the controller to which the hand correlates
  76131. * @param trackedMeshes the meshes to be used to track the hand joints
  76132. */
  76133. constructor(
  76134. /** the controller to which the hand correlates */
  76135. xrController: WebXRInputSource,
  76136. /** the meshes to be used to track the hand joints */
  76137. trackedMeshes: AbstractMesh[]);
  76138. /**
  76139. * Update this hand from the latest xr frame
  76140. * @param xrFrame xrFrame to update from
  76141. * @param referenceSpace The current viewer reference space
  76142. * @param scaleFactor optional scale factor for the meshes
  76143. */
  76144. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76145. /**
  76146. * Get meshes of part of the hand
  76147. * @param part the part of hand to get
  76148. * @returns An array of meshes that correlate to the hand part requested
  76149. */
  76150. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76151. /**
  76152. * Dispose this Hand object
  76153. */
  76154. dispose(): void;
  76155. }
  76156. /**
  76157. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76158. */
  76159. export class WebXRHandTracking extends WebXRAbstractFeature {
  76160. /**
  76161. * options to use when constructing this feature
  76162. */
  76163. readonly options: IWebXRHandTrackingOptions;
  76164. private static _idCounter;
  76165. /**
  76166. * The module's name
  76167. */
  76168. static readonly Name: string;
  76169. /**
  76170. * The (Babylon) version of this module.
  76171. * This is an integer representing the implementation version.
  76172. * This number does not correspond to the WebXR specs version
  76173. */
  76174. static readonly Version: number;
  76175. /**
  76176. * This observable will notify registered observers when a new hand object was added and initialized
  76177. */
  76178. onHandAddedObservable: Observable<WebXRHand>;
  76179. /**
  76180. * This observable will notify its observers right before the hand object is disposed
  76181. */
  76182. onHandRemovedObservable: Observable<WebXRHand>;
  76183. private _hands;
  76184. /**
  76185. * Creates a new instance of the hit test feature
  76186. * @param _xrSessionManager an instance of WebXRSessionManager
  76187. * @param options options to use when constructing this feature
  76188. */
  76189. constructor(_xrSessionManager: WebXRSessionManager,
  76190. /**
  76191. * options to use when constructing this feature
  76192. */
  76193. options: IWebXRHandTrackingOptions);
  76194. /**
  76195. * Check if the needed objects are defined.
  76196. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76197. */
  76198. isCompatible(): boolean;
  76199. /**
  76200. * attach this feature
  76201. * Will usually be called by the features manager
  76202. *
  76203. * @returns true if successful.
  76204. */
  76205. attach(): boolean;
  76206. /**
  76207. * detach this feature.
  76208. * Will usually be called by the features manager
  76209. *
  76210. * @returns true if successful.
  76211. */
  76212. detach(): boolean;
  76213. /**
  76214. * Dispose this feature and all of the resources attached
  76215. */
  76216. dispose(): void;
  76217. /**
  76218. * Get the hand object according to the controller id
  76219. * @param controllerId the controller id to which we want to get the hand
  76220. * @returns null if not found or the WebXRHand object if found
  76221. */
  76222. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76223. /**
  76224. * Get a hand object according to the requested handedness
  76225. * @param handedness the handedness to request
  76226. * @returns null if not found or the WebXRHand object if found
  76227. */
  76228. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76229. protected _onXRFrame(_xrFrame: XRFrame): void;
  76230. private _attachHand;
  76231. private _detachHand;
  76232. }
  76233. }
  76234. declare module BABYLON {
  76235. /**
  76236. * The motion controller class for all microsoft mixed reality controllers
  76237. */
  76238. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76239. protected readonly _mapping: {
  76240. defaultButton: {
  76241. valueNodeName: string;
  76242. unpressedNodeName: string;
  76243. pressedNodeName: string;
  76244. };
  76245. defaultAxis: {
  76246. valueNodeName: string;
  76247. minNodeName: string;
  76248. maxNodeName: string;
  76249. };
  76250. buttons: {
  76251. "xr-standard-trigger": {
  76252. rootNodeName: string;
  76253. componentProperty: string;
  76254. states: string[];
  76255. };
  76256. "xr-standard-squeeze": {
  76257. rootNodeName: string;
  76258. componentProperty: string;
  76259. states: string[];
  76260. };
  76261. "xr-standard-touchpad": {
  76262. rootNodeName: string;
  76263. labelAnchorNodeName: string;
  76264. touchPointNodeName: string;
  76265. };
  76266. "xr-standard-thumbstick": {
  76267. rootNodeName: string;
  76268. componentProperty: string;
  76269. states: string[];
  76270. };
  76271. };
  76272. axes: {
  76273. "xr-standard-touchpad": {
  76274. "x-axis": {
  76275. rootNodeName: string;
  76276. };
  76277. "y-axis": {
  76278. rootNodeName: string;
  76279. };
  76280. };
  76281. "xr-standard-thumbstick": {
  76282. "x-axis": {
  76283. rootNodeName: string;
  76284. };
  76285. "y-axis": {
  76286. rootNodeName: string;
  76287. };
  76288. };
  76289. };
  76290. };
  76291. /**
  76292. * The base url used to load the left and right controller models
  76293. */
  76294. static MODEL_BASE_URL: string;
  76295. /**
  76296. * The name of the left controller model file
  76297. */
  76298. static MODEL_LEFT_FILENAME: string;
  76299. /**
  76300. * The name of the right controller model file
  76301. */
  76302. static MODEL_RIGHT_FILENAME: string;
  76303. profileId: string;
  76304. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76305. protected _getFilenameAndPath(): {
  76306. filename: string;
  76307. path: string;
  76308. };
  76309. protected _getModelLoadingConstraints(): boolean;
  76310. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76311. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76312. protected _updateModel(): void;
  76313. }
  76314. }
  76315. declare module BABYLON {
  76316. /**
  76317. * The motion controller class for oculus touch (quest, rift).
  76318. * This class supports legacy mapping as well the standard xr mapping
  76319. */
  76320. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76321. private _forceLegacyControllers;
  76322. private _modelRootNode;
  76323. /**
  76324. * The base url used to load the left and right controller models
  76325. */
  76326. static MODEL_BASE_URL: string;
  76327. /**
  76328. * The name of the left controller model file
  76329. */
  76330. static MODEL_LEFT_FILENAME: string;
  76331. /**
  76332. * The name of the right controller model file
  76333. */
  76334. static MODEL_RIGHT_FILENAME: string;
  76335. /**
  76336. * Base Url for the Quest controller model.
  76337. */
  76338. static QUEST_MODEL_BASE_URL: string;
  76339. profileId: string;
  76340. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76341. protected _getFilenameAndPath(): {
  76342. filename: string;
  76343. path: string;
  76344. };
  76345. protected _getModelLoadingConstraints(): boolean;
  76346. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76347. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76348. protected _updateModel(): void;
  76349. /**
  76350. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76351. * between the touch and touch 2.
  76352. */
  76353. private _isQuest;
  76354. }
  76355. }
  76356. declare module BABYLON {
  76357. /**
  76358. * The motion controller class for the standard HTC-Vive controllers
  76359. */
  76360. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76361. private _modelRootNode;
  76362. /**
  76363. * The base url used to load the left and right controller models
  76364. */
  76365. static MODEL_BASE_URL: string;
  76366. /**
  76367. * File name for the controller model.
  76368. */
  76369. static MODEL_FILENAME: string;
  76370. profileId: string;
  76371. /**
  76372. * Create a new Vive motion controller object
  76373. * @param scene the scene to use to create this controller
  76374. * @param gamepadObject the corresponding gamepad object
  76375. * @param handedness the handedness of the controller
  76376. */
  76377. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76378. protected _getFilenameAndPath(): {
  76379. filename: string;
  76380. path: string;
  76381. };
  76382. protected _getModelLoadingConstraints(): boolean;
  76383. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76384. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76385. protected _updateModel(): void;
  76386. }
  76387. }
  76388. declare module BABYLON {
  76389. /**
  76390. * A cursor which tracks a point on a path
  76391. */
  76392. export class PathCursor {
  76393. private path;
  76394. /**
  76395. * Stores path cursor callbacks for when an onchange event is triggered
  76396. */
  76397. private _onchange;
  76398. /**
  76399. * The value of the path cursor
  76400. */
  76401. value: number;
  76402. /**
  76403. * The animation array of the path cursor
  76404. */
  76405. animations: Animation[];
  76406. /**
  76407. * Initializes the path cursor
  76408. * @param path The path to track
  76409. */
  76410. constructor(path: Path2);
  76411. /**
  76412. * Gets the cursor point on the path
  76413. * @returns A point on the path cursor at the cursor location
  76414. */
  76415. getPoint(): Vector3;
  76416. /**
  76417. * Moves the cursor ahead by the step amount
  76418. * @param step The amount to move the cursor forward
  76419. * @returns This path cursor
  76420. */
  76421. moveAhead(step?: number): PathCursor;
  76422. /**
  76423. * Moves the cursor behind by the step amount
  76424. * @param step The amount to move the cursor back
  76425. * @returns This path cursor
  76426. */
  76427. moveBack(step?: number): PathCursor;
  76428. /**
  76429. * Moves the cursor by the step amount
  76430. * If the step amount is greater than one, an exception is thrown
  76431. * @param step The amount to move the cursor
  76432. * @returns This path cursor
  76433. */
  76434. move(step: number): PathCursor;
  76435. /**
  76436. * Ensures that the value is limited between zero and one
  76437. * @returns This path cursor
  76438. */
  76439. private ensureLimits;
  76440. /**
  76441. * Runs onchange callbacks on change (used by the animation engine)
  76442. * @returns This path cursor
  76443. */
  76444. private raiseOnChange;
  76445. /**
  76446. * Executes a function on change
  76447. * @param f A path cursor onchange callback
  76448. * @returns This path cursor
  76449. */
  76450. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76451. }
  76452. }
  76453. declare module BABYLON {
  76454. /** @hidden */
  76455. export var blurPixelShader: {
  76456. name: string;
  76457. shader: string;
  76458. };
  76459. }
  76460. declare module BABYLON {
  76461. /** @hidden */
  76462. export var pointCloudVertexDeclaration: {
  76463. name: string;
  76464. shader: string;
  76465. };
  76466. }
  76467. // Mixins
  76468. interface Window {
  76469. mozIndexedDB: IDBFactory;
  76470. webkitIndexedDB: IDBFactory;
  76471. msIndexedDB: IDBFactory;
  76472. webkitURL: typeof URL;
  76473. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76474. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76475. WebGLRenderingContext: WebGLRenderingContext;
  76476. MSGesture: MSGesture;
  76477. CANNON: any;
  76478. AudioContext: AudioContext;
  76479. webkitAudioContext: AudioContext;
  76480. PointerEvent: any;
  76481. Math: Math;
  76482. Uint8Array: Uint8ArrayConstructor;
  76483. Float32Array: Float32ArrayConstructor;
  76484. mozURL: typeof URL;
  76485. msURL: typeof URL;
  76486. VRFrameData: any; // WebVR, from specs 1.1
  76487. DracoDecoderModule: any;
  76488. setImmediate(handler: (...args: any[]) => void): number;
  76489. }
  76490. interface HTMLCanvasElement {
  76491. requestPointerLock(): void;
  76492. msRequestPointerLock?(): void;
  76493. mozRequestPointerLock?(): void;
  76494. webkitRequestPointerLock?(): void;
  76495. /** Track wether a record is in progress */
  76496. isRecording: boolean;
  76497. /** Capture Stream method defined by some browsers */
  76498. captureStream(fps?: number): MediaStream;
  76499. }
  76500. interface CanvasRenderingContext2D {
  76501. msImageSmoothingEnabled: boolean;
  76502. }
  76503. interface MouseEvent {
  76504. mozMovementX: number;
  76505. mozMovementY: number;
  76506. webkitMovementX: number;
  76507. webkitMovementY: number;
  76508. msMovementX: number;
  76509. msMovementY: number;
  76510. }
  76511. interface Navigator {
  76512. mozGetVRDevices: (any: any) => any;
  76513. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76514. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76515. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76516. webkitGetGamepads(): Gamepad[];
  76517. msGetGamepads(): Gamepad[];
  76518. webkitGamepads(): Gamepad[];
  76519. }
  76520. interface HTMLVideoElement {
  76521. mozSrcObject: any;
  76522. }
  76523. interface Math {
  76524. fround(x: number): number;
  76525. imul(a: number, b: number): number;
  76526. }
  76527. interface WebGLRenderingContext {
  76528. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76529. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76530. vertexAttribDivisor(index: number, divisor: number): void;
  76531. createVertexArray(): any;
  76532. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76533. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76534. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76535. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76536. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76537. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76538. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76539. // Queries
  76540. createQuery(): WebGLQuery;
  76541. deleteQuery(query: WebGLQuery): void;
  76542. beginQuery(target: number, query: WebGLQuery): void;
  76543. endQuery(target: number): void;
  76544. getQueryParameter(query: WebGLQuery, pname: number): any;
  76545. getQuery(target: number, pname: number): any;
  76546. MAX_SAMPLES: number;
  76547. RGBA8: number;
  76548. READ_FRAMEBUFFER: number;
  76549. DRAW_FRAMEBUFFER: number;
  76550. UNIFORM_BUFFER: number;
  76551. HALF_FLOAT_OES: number;
  76552. RGBA16F: number;
  76553. RGBA32F: number;
  76554. R32F: number;
  76555. RG32F: number;
  76556. RGB32F: number;
  76557. R16F: number;
  76558. RG16F: number;
  76559. RGB16F: number;
  76560. RED: number;
  76561. RG: number;
  76562. R8: number;
  76563. RG8: number;
  76564. UNSIGNED_INT_24_8: number;
  76565. DEPTH24_STENCIL8: number;
  76566. MIN: number;
  76567. MAX: number;
  76568. /* Multiple Render Targets */
  76569. drawBuffers(buffers: number[]): void;
  76570. readBuffer(src: number): void;
  76571. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76572. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76573. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76574. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76575. // Occlusion Query
  76576. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76577. ANY_SAMPLES_PASSED: number;
  76578. QUERY_RESULT_AVAILABLE: number;
  76579. QUERY_RESULT: number;
  76580. }
  76581. interface WebGLProgram {
  76582. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76583. }
  76584. interface EXT_disjoint_timer_query {
  76585. QUERY_COUNTER_BITS_EXT: number;
  76586. TIME_ELAPSED_EXT: number;
  76587. TIMESTAMP_EXT: number;
  76588. GPU_DISJOINT_EXT: number;
  76589. QUERY_RESULT_EXT: number;
  76590. QUERY_RESULT_AVAILABLE_EXT: number;
  76591. queryCounterEXT(query: WebGLQuery, target: number): void;
  76592. createQueryEXT(): WebGLQuery;
  76593. beginQueryEXT(target: number, query: WebGLQuery): void;
  76594. endQueryEXT(target: number): void;
  76595. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76596. deleteQueryEXT(query: WebGLQuery): void;
  76597. }
  76598. interface WebGLUniformLocation {
  76599. _currentState: any;
  76600. }
  76601. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76602. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76603. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76604. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76605. interface WebGLRenderingContext {
  76606. readonly RASTERIZER_DISCARD: number;
  76607. readonly DEPTH_COMPONENT24: number;
  76608. readonly TEXTURE_3D: number;
  76609. readonly TEXTURE_2D_ARRAY: number;
  76610. readonly TEXTURE_COMPARE_FUNC: number;
  76611. readonly TEXTURE_COMPARE_MODE: number;
  76612. readonly COMPARE_REF_TO_TEXTURE: number;
  76613. readonly TEXTURE_WRAP_R: number;
  76614. readonly HALF_FLOAT: number;
  76615. readonly RGB8: number;
  76616. readonly RED_INTEGER: number;
  76617. readonly RG_INTEGER: number;
  76618. readonly RGB_INTEGER: number;
  76619. readonly RGBA_INTEGER: number;
  76620. readonly R8_SNORM: number;
  76621. readonly RG8_SNORM: number;
  76622. readonly RGB8_SNORM: number;
  76623. readonly RGBA8_SNORM: number;
  76624. readonly R8I: number;
  76625. readonly RG8I: number;
  76626. readonly RGB8I: number;
  76627. readonly RGBA8I: number;
  76628. readonly R8UI: number;
  76629. readonly RG8UI: number;
  76630. readonly RGB8UI: number;
  76631. readonly RGBA8UI: number;
  76632. readonly R16I: number;
  76633. readonly RG16I: number;
  76634. readonly RGB16I: number;
  76635. readonly RGBA16I: number;
  76636. readonly R16UI: number;
  76637. readonly RG16UI: number;
  76638. readonly RGB16UI: number;
  76639. readonly RGBA16UI: number;
  76640. readonly R32I: number;
  76641. readonly RG32I: number;
  76642. readonly RGB32I: number;
  76643. readonly RGBA32I: number;
  76644. readonly R32UI: number;
  76645. readonly RG32UI: number;
  76646. readonly RGB32UI: number;
  76647. readonly RGBA32UI: number;
  76648. readonly RGB10_A2UI: number;
  76649. readonly R11F_G11F_B10F: number;
  76650. readonly RGB9_E5: number;
  76651. readonly RGB10_A2: number;
  76652. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76653. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76654. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76655. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76656. readonly DEPTH_COMPONENT32F: number;
  76657. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76658. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76659. 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;
  76660. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76661. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76662. readonly TRANSFORM_FEEDBACK: number;
  76663. readonly INTERLEAVED_ATTRIBS: number;
  76664. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76665. createTransformFeedback(): WebGLTransformFeedback;
  76666. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76667. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76668. beginTransformFeedback(primitiveMode: number): void;
  76669. endTransformFeedback(): void;
  76670. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76671. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76672. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76673. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76674. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76675. }
  76676. interface ImageBitmap {
  76677. readonly width: number;
  76678. readonly height: number;
  76679. close(): void;
  76680. }
  76681. interface WebGLQuery extends WebGLObject {
  76682. }
  76683. declare var WebGLQuery: {
  76684. prototype: WebGLQuery;
  76685. new(): WebGLQuery;
  76686. };
  76687. interface WebGLSampler extends WebGLObject {
  76688. }
  76689. declare var WebGLSampler: {
  76690. prototype: WebGLSampler;
  76691. new(): WebGLSampler;
  76692. };
  76693. interface WebGLSync extends WebGLObject {
  76694. }
  76695. declare var WebGLSync: {
  76696. prototype: WebGLSync;
  76697. new(): WebGLSync;
  76698. };
  76699. interface WebGLTransformFeedback extends WebGLObject {
  76700. }
  76701. declare var WebGLTransformFeedback: {
  76702. prototype: WebGLTransformFeedback;
  76703. new(): WebGLTransformFeedback;
  76704. };
  76705. interface WebGLVertexArrayObject extends WebGLObject {
  76706. }
  76707. declare var WebGLVertexArrayObject: {
  76708. prototype: WebGLVertexArrayObject;
  76709. new(): WebGLVertexArrayObject;
  76710. };
  76711. // Type definitions for WebVR API
  76712. // Project: https://w3c.github.io/webvr/
  76713. // Definitions by: six a <https://github.com/lostfictions>
  76714. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76715. interface VRDisplay extends EventTarget {
  76716. /**
  76717. * Dictionary of capabilities describing the VRDisplay.
  76718. */
  76719. readonly capabilities: VRDisplayCapabilities;
  76720. /**
  76721. * z-depth defining the far plane of the eye view frustum
  76722. * enables mapping of values in the render target depth
  76723. * attachment to scene coordinates. Initially set to 10000.0.
  76724. */
  76725. depthFar: number;
  76726. /**
  76727. * z-depth defining the near plane of the eye view frustum
  76728. * enables mapping of values in the render target depth
  76729. * attachment to scene coordinates. Initially set to 0.01.
  76730. */
  76731. depthNear: number;
  76732. /**
  76733. * An identifier for this distinct VRDisplay. Used as an
  76734. * association point in the Gamepad API.
  76735. */
  76736. readonly displayId: number;
  76737. /**
  76738. * A display name, a user-readable name identifying it.
  76739. */
  76740. readonly displayName: string;
  76741. readonly isConnected: boolean;
  76742. readonly isPresenting: boolean;
  76743. /**
  76744. * If this VRDisplay supports room-scale experiences, the optional
  76745. * stage attribute contains details on the room-scale parameters.
  76746. */
  76747. readonly stageParameters: VRStageParameters | null;
  76748. /**
  76749. * Passing the value returned by `requestAnimationFrame` to
  76750. * `cancelAnimationFrame` will unregister the callback.
  76751. * @param handle Define the hanle of the request to cancel
  76752. */
  76753. cancelAnimationFrame(handle: number): void;
  76754. /**
  76755. * Stops presenting to the VRDisplay.
  76756. * @returns a promise to know when it stopped
  76757. */
  76758. exitPresent(): Promise<void>;
  76759. /**
  76760. * Return the current VREyeParameters for the given eye.
  76761. * @param whichEye Define the eye we want the parameter for
  76762. * @returns the eye parameters
  76763. */
  76764. getEyeParameters(whichEye: string): VREyeParameters;
  76765. /**
  76766. * Populates the passed VRFrameData with the information required to render
  76767. * the current frame.
  76768. * @param frameData Define the data structure to populate
  76769. * @returns true if ok otherwise false
  76770. */
  76771. getFrameData(frameData: VRFrameData): boolean;
  76772. /**
  76773. * Get the layers currently being presented.
  76774. * @returns the list of VR layers
  76775. */
  76776. getLayers(): VRLayer[];
  76777. /**
  76778. * Return a VRPose containing the future predicted pose of the VRDisplay
  76779. * when the current frame will be presented. The value returned will not
  76780. * change until JavaScript has returned control to the browser.
  76781. *
  76782. * The VRPose will contain the position, orientation, velocity,
  76783. * and acceleration of each of these properties.
  76784. * @returns the pose object
  76785. */
  76786. getPose(): VRPose;
  76787. /**
  76788. * Return the current instantaneous pose of the VRDisplay, with no
  76789. * prediction applied.
  76790. * @returns the current instantaneous pose
  76791. */
  76792. getImmediatePose(): VRPose;
  76793. /**
  76794. * The callback passed to `requestAnimationFrame` will be called
  76795. * any time a new frame should be rendered. When the VRDisplay is
  76796. * presenting the callback will be called at the native refresh
  76797. * rate of the HMD. When not presenting this function acts
  76798. * identically to how window.requestAnimationFrame acts. Content should
  76799. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76800. * asynchronously from other displays and at differing refresh rates.
  76801. * @param callback Define the eaction to run next frame
  76802. * @returns the request handle it
  76803. */
  76804. requestAnimationFrame(callback: FrameRequestCallback): number;
  76805. /**
  76806. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76807. * Repeat calls while already presenting will update the VRLayers being displayed.
  76808. * @param layers Define the list of layer to present
  76809. * @returns a promise to know when the request has been fulfilled
  76810. */
  76811. requestPresent(layers: VRLayer[]): Promise<void>;
  76812. /**
  76813. * Reset the pose for this display, treating its current position and
  76814. * orientation as the "origin/zero" values. VRPose.position,
  76815. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76816. * updated when calling resetPose(). This should be called in only
  76817. * sitting-space experiences.
  76818. */
  76819. resetPose(): void;
  76820. /**
  76821. * The VRLayer provided to the VRDisplay will be captured and presented
  76822. * in the HMD. Calling this function has the same effect on the source
  76823. * canvas as any other operation that uses its source image, and canvases
  76824. * created without preserveDrawingBuffer set to true will be cleared.
  76825. * @param pose Define the pose to submit
  76826. */
  76827. submitFrame(pose?: VRPose): void;
  76828. }
  76829. declare var VRDisplay: {
  76830. prototype: VRDisplay;
  76831. new(): VRDisplay;
  76832. };
  76833. interface VRLayer {
  76834. leftBounds?: number[] | Float32Array | null;
  76835. rightBounds?: number[] | Float32Array | null;
  76836. source?: HTMLCanvasElement | null;
  76837. }
  76838. interface VRDisplayCapabilities {
  76839. readonly canPresent: boolean;
  76840. readonly hasExternalDisplay: boolean;
  76841. readonly hasOrientation: boolean;
  76842. readonly hasPosition: boolean;
  76843. readonly maxLayers: number;
  76844. }
  76845. interface VREyeParameters {
  76846. /** @deprecated */
  76847. readonly fieldOfView: VRFieldOfView;
  76848. readonly offset: Float32Array;
  76849. readonly renderHeight: number;
  76850. readonly renderWidth: number;
  76851. }
  76852. interface VRFieldOfView {
  76853. readonly downDegrees: number;
  76854. readonly leftDegrees: number;
  76855. readonly rightDegrees: number;
  76856. readonly upDegrees: number;
  76857. }
  76858. interface VRFrameData {
  76859. readonly leftProjectionMatrix: Float32Array;
  76860. readonly leftViewMatrix: Float32Array;
  76861. readonly pose: VRPose;
  76862. readonly rightProjectionMatrix: Float32Array;
  76863. readonly rightViewMatrix: Float32Array;
  76864. readonly timestamp: number;
  76865. }
  76866. interface VRPose {
  76867. readonly angularAcceleration: Float32Array | null;
  76868. readonly angularVelocity: Float32Array | null;
  76869. readonly linearAcceleration: Float32Array | null;
  76870. readonly linearVelocity: Float32Array | null;
  76871. readonly orientation: Float32Array | null;
  76872. readonly position: Float32Array | null;
  76873. readonly timestamp: number;
  76874. }
  76875. interface VRStageParameters {
  76876. sittingToStandingTransform?: Float32Array;
  76877. sizeX?: number;
  76878. sizeY?: number;
  76879. }
  76880. interface Navigator {
  76881. getVRDisplays(): Promise<VRDisplay[]>;
  76882. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76883. }
  76884. interface Window {
  76885. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76886. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76887. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76888. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76889. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76890. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76891. }
  76892. interface Gamepad {
  76893. readonly displayId: number;
  76894. }
  76895. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76896. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76897. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76898. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76899. type XRHandedness = "none" | "left" | "right";
  76900. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76901. type XREye = "none" | "left" | "right";
  76902. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76903. interface XRSpace extends EventTarget {}
  76904. interface XRRenderState {
  76905. depthNear?: number;
  76906. depthFar?: number;
  76907. inlineVerticalFieldOfView?: number;
  76908. baseLayer?: XRWebGLLayer;
  76909. }
  76910. interface XRInputSource {
  76911. handedness: XRHandedness;
  76912. targetRayMode: XRTargetRayMode;
  76913. targetRaySpace: XRSpace;
  76914. gripSpace: XRSpace | undefined;
  76915. gamepad: Gamepad | undefined;
  76916. profiles: Array<string>;
  76917. hand: XRHand | undefined;
  76918. }
  76919. interface XRSessionInit {
  76920. optionalFeatures?: string[];
  76921. requiredFeatures?: string[];
  76922. }
  76923. interface XRSession {
  76924. addEventListener: Function;
  76925. removeEventListener: Function;
  76926. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76927. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76928. requestAnimationFrame: Function;
  76929. end(): Promise<void>;
  76930. renderState: XRRenderState;
  76931. inputSources: Array<XRInputSource>;
  76932. // hit test
  76933. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76934. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76935. // legacy AR hit test
  76936. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76937. // legacy plane detection
  76938. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76939. }
  76940. interface XRReferenceSpace extends XRSpace {
  76941. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76942. onreset: any;
  76943. }
  76944. type XRPlaneSet = Set<XRPlane>;
  76945. type XRAnchorSet = Set<XRAnchor>;
  76946. interface XRFrame {
  76947. session: XRSession;
  76948. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76949. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76950. // AR
  76951. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76952. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76953. // Anchors
  76954. trackedAnchors?: XRAnchorSet;
  76955. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76956. // Planes
  76957. worldInformation: {
  76958. detectedPlanes?: XRPlaneSet;
  76959. };
  76960. // Hand tracking
  76961. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76962. }
  76963. interface XRViewerPose extends XRPose {
  76964. views: Array<XRView>;
  76965. }
  76966. interface XRPose {
  76967. transform: XRRigidTransform;
  76968. emulatedPosition: boolean;
  76969. }
  76970. interface XRWebGLLayerOptions {
  76971. antialias?: boolean;
  76972. depth?: boolean;
  76973. stencil?: boolean;
  76974. alpha?: boolean;
  76975. multiview?: boolean;
  76976. framebufferScaleFactor?: number;
  76977. }
  76978. declare var XRWebGLLayer: {
  76979. prototype: XRWebGLLayer;
  76980. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76981. };
  76982. interface XRWebGLLayer {
  76983. framebuffer: WebGLFramebuffer;
  76984. framebufferWidth: number;
  76985. framebufferHeight: number;
  76986. getViewport: Function;
  76987. }
  76988. declare class XRRigidTransform {
  76989. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76990. position: DOMPointReadOnly;
  76991. orientation: DOMPointReadOnly;
  76992. matrix: Float32Array;
  76993. inverse: XRRigidTransform;
  76994. }
  76995. interface XRView {
  76996. eye: XREye;
  76997. projectionMatrix: Float32Array;
  76998. transform: XRRigidTransform;
  76999. }
  77000. interface XRInputSourceChangeEvent {
  77001. session: XRSession;
  77002. removed: Array<XRInputSource>;
  77003. added: Array<XRInputSource>;
  77004. }
  77005. interface XRInputSourceEvent extends Event {
  77006. readonly frame: XRFrame;
  77007. readonly inputSource: XRInputSource;
  77008. }
  77009. // Experimental(er) features
  77010. declare class XRRay {
  77011. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77012. origin: DOMPointReadOnly;
  77013. direction: DOMPointReadOnly;
  77014. matrix: Float32Array;
  77015. }
  77016. declare enum XRHitTestTrackableType {
  77017. "point",
  77018. "plane",
  77019. "mesh",
  77020. }
  77021. interface XRHitResult {
  77022. hitMatrix: Float32Array;
  77023. }
  77024. interface XRTransientInputHitTestResult {
  77025. readonly inputSource: XRInputSource;
  77026. readonly results: Array<XRHitTestResult>;
  77027. }
  77028. interface XRHitTestResult {
  77029. getPose(baseSpace: XRSpace): XRPose | undefined;
  77030. // When anchor system is enabled
  77031. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77032. }
  77033. interface XRHitTestSource {
  77034. cancel(): void;
  77035. }
  77036. interface XRTransientInputHitTestSource {
  77037. cancel(): void;
  77038. }
  77039. interface XRHitTestOptionsInit {
  77040. space: XRSpace;
  77041. entityTypes?: Array<XRHitTestTrackableType>;
  77042. offsetRay?: XRRay;
  77043. }
  77044. interface XRTransientInputHitTestOptionsInit {
  77045. profile: string;
  77046. entityTypes?: Array<XRHitTestTrackableType>;
  77047. offsetRay?: XRRay;
  77048. }
  77049. interface XRAnchor {
  77050. anchorSpace: XRSpace;
  77051. delete(): void;
  77052. }
  77053. interface XRPlane {
  77054. orientation: "Horizontal" | "Vertical";
  77055. planeSpace: XRSpace;
  77056. polygon: Array<DOMPointReadOnly>;
  77057. lastChangedTime: number;
  77058. }
  77059. interface XRJointSpace extends XRSpace {}
  77060. interface XRJointPose extends XRPose {
  77061. radius: number | undefined;
  77062. }
  77063. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  77064. readonly length: number;
  77065. [index: number]: XRJointSpace;
  77066. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  77067. readonly WRIST: number;
  77068. readonly THUMB_METACARPAL: number;
  77069. readonly THUMB_PHALANX_PROXIMAL: number;
  77070. readonly THUMB_PHALANX_DISTAL: number;
  77071. readonly THUMB_PHALANX_TIP: number;
  77072. readonly INDEX_METACARPAL: number;
  77073. readonly INDEX_PHALANX_PROXIMAL: number;
  77074. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77075. readonly INDEX_PHALANX_DISTAL: number;
  77076. readonly INDEX_PHALANX_TIP: number;
  77077. readonly MIDDLE_METACARPAL: number;
  77078. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77079. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77080. readonly MIDDLE_PHALANX_DISTAL: number;
  77081. readonly MIDDLE_PHALANX_TIP: number;
  77082. readonly RING_METACARPAL: number;
  77083. readonly RING_PHALANX_PROXIMAL: number;
  77084. readonly RING_PHALANX_INTERMEDIATE: number;
  77085. readonly RING_PHALANX_DISTAL: number;
  77086. readonly RING_PHALANX_TIP: number;
  77087. readonly LITTLE_METACARPAL: number;
  77088. readonly LITTLE_PHALANX_PROXIMAL: number;
  77089. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77090. readonly LITTLE_PHALANX_DISTAL: number;
  77091. readonly LITTLE_PHALANX_TIP: number;
  77092. }
  77093. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77094. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77095. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77096. interface XRSession {
  77097. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77098. }
  77099. interface XRFrame {
  77100. featurePointCloud? : Array<number>;
  77101. }
  77102. /**
  77103. * @ignore
  77104. */
  77105. declare module BABYLON.GLTF2.Exporter {
  77106. }
  77107. /**
  77108. * @ignore
  77109. */
  77110. declare module BABYLON.GLTF1 {
  77111. }
  77112. declare module BABYLON.GUI {
  77113. /**
  77114. * Class used to specific a value and its associated unit
  77115. */
  77116. export class ValueAndUnit {
  77117. /** defines the unit to store */
  77118. unit: number;
  77119. /** defines a boolean indicating if the value can be negative */
  77120. negativeValueAllowed: boolean;
  77121. private _value;
  77122. private _originalUnit;
  77123. /**
  77124. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77125. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77126. */
  77127. ignoreAdaptiveScaling: boolean;
  77128. /**
  77129. * Creates a new ValueAndUnit
  77130. * @param value defines the value to store
  77131. * @param unit defines the unit to store
  77132. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77133. */
  77134. constructor(value: number,
  77135. /** defines the unit to store */
  77136. unit?: number,
  77137. /** defines a boolean indicating if the value can be negative */
  77138. negativeValueAllowed?: boolean);
  77139. /** Gets a boolean indicating if the value is a percentage */
  77140. get isPercentage(): boolean;
  77141. /** Gets a boolean indicating if the value is store as pixel */
  77142. get isPixel(): boolean;
  77143. /** Gets direct internal value */
  77144. get internalValue(): number;
  77145. /**
  77146. * Gets value as pixel
  77147. * @param host defines the root host
  77148. * @param refValue defines the reference value for percentages
  77149. * @returns the value as pixel
  77150. */
  77151. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77152. /**
  77153. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77154. * @param value defines the value to store
  77155. * @param unit defines the unit to store
  77156. * @returns the current ValueAndUnit
  77157. */
  77158. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77159. /**
  77160. * Gets the value accordingly to its unit
  77161. * @param host defines the root host
  77162. * @returns the value
  77163. */
  77164. getValue(host: AdvancedDynamicTexture): number;
  77165. /**
  77166. * Gets a string representation of the value
  77167. * @param host defines the root host
  77168. * @param decimals defines an optional number of decimals to display
  77169. * @returns a string
  77170. */
  77171. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77172. /**
  77173. * Store a value parsed from a string
  77174. * @param source defines the source string
  77175. * @returns true if the value was successfully parsed
  77176. */
  77177. fromString(source: string | number): boolean;
  77178. private static _Regex;
  77179. private static _UNITMODE_PERCENTAGE;
  77180. private static _UNITMODE_PIXEL;
  77181. /** UNITMODE_PERCENTAGE */
  77182. static get UNITMODE_PERCENTAGE(): number;
  77183. /** UNITMODE_PIXEL */
  77184. static get UNITMODE_PIXEL(): number;
  77185. }
  77186. }
  77187. declare module BABYLON.GUI {
  77188. /**
  77189. * Define a style used by control to automatically setup properties based on a template.
  77190. * Only support font related properties so far
  77191. */
  77192. export class Style implements BABYLON.IDisposable {
  77193. private _fontFamily;
  77194. private _fontStyle;
  77195. private _fontWeight;
  77196. /** @hidden */
  77197. _host: AdvancedDynamicTexture;
  77198. /** @hidden */
  77199. _fontSize: ValueAndUnit;
  77200. /**
  77201. * BABYLON.Observable raised when the style values are changed
  77202. */
  77203. onChangedObservable: BABYLON.Observable<Style>;
  77204. /**
  77205. * Creates a new style object
  77206. * @param host defines the AdvancedDynamicTexture which hosts this style
  77207. */
  77208. constructor(host: AdvancedDynamicTexture);
  77209. /**
  77210. * Gets or sets the font size
  77211. */
  77212. get fontSize(): string | number;
  77213. set fontSize(value: string | number);
  77214. /**
  77215. * Gets or sets the font family
  77216. */
  77217. get fontFamily(): string;
  77218. set fontFamily(value: string);
  77219. /**
  77220. * Gets or sets the font style
  77221. */
  77222. get fontStyle(): string;
  77223. set fontStyle(value: string);
  77224. /** Gets or sets font weight */
  77225. get fontWeight(): string;
  77226. set fontWeight(value: string);
  77227. /** Dispose all associated resources */
  77228. dispose(): void;
  77229. }
  77230. }
  77231. declare module BABYLON.GUI {
  77232. /**
  77233. * Class used to transport BABYLON.Vector2 information for pointer events
  77234. */
  77235. export class Vector2WithInfo extends BABYLON.Vector2 {
  77236. /** defines the current mouse button index */
  77237. buttonIndex: number;
  77238. /**
  77239. * Creates a new Vector2WithInfo
  77240. * @param source defines the vector2 data to transport
  77241. * @param buttonIndex defines the current mouse button index
  77242. */
  77243. constructor(source: BABYLON.Vector2,
  77244. /** defines the current mouse button index */
  77245. buttonIndex?: number);
  77246. }
  77247. /** Class used to provide 2D matrix features */
  77248. export class Matrix2D {
  77249. /** Gets the internal array of 6 floats used to store matrix data */
  77250. m: Float32Array;
  77251. /**
  77252. * Creates a new matrix
  77253. * @param m00 defines value for (0, 0)
  77254. * @param m01 defines value for (0, 1)
  77255. * @param m10 defines value for (1, 0)
  77256. * @param m11 defines value for (1, 1)
  77257. * @param m20 defines value for (2, 0)
  77258. * @param m21 defines value for (2, 1)
  77259. */
  77260. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77261. /**
  77262. * Fills the matrix from direct values
  77263. * @param m00 defines value for (0, 0)
  77264. * @param m01 defines value for (0, 1)
  77265. * @param m10 defines value for (1, 0)
  77266. * @param m11 defines value for (1, 1)
  77267. * @param m20 defines value for (2, 0)
  77268. * @param m21 defines value for (2, 1)
  77269. * @returns the current modified matrix
  77270. */
  77271. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77272. /**
  77273. * Gets matrix determinant
  77274. * @returns the determinant
  77275. */
  77276. determinant(): number;
  77277. /**
  77278. * Inverses the matrix and stores it in a target matrix
  77279. * @param result defines the target matrix
  77280. * @returns the current matrix
  77281. */
  77282. invertToRef(result: Matrix2D): Matrix2D;
  77283. /**
  77284. * Multiplies the current matrix with another one
  77285. * @param other defines the second operand
  77286. * @param result defines the target matrix
  77287. * @returns the current matrix
  77288. */
  77289. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77290. /**
  77291. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77292. * @param x defines the x coordinate to transform
  77293. * @param y defines the x coordinate to transform
  77294. * @param result defines the target vector2
  77295. * @returns the current matrix
  77296. */
  77297. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77298. /**
  77299. * Creates an identity matrix
  77300. * @returns a new matrix
  77301. */
  77302. static Identity(): Matrix2D;
  77303. /**
  77304. * Creates a translation matrix and stores it in a target matrix
  77305. * @param x defines the x coordinate of the translation
  77306. * @param y defines the y coordinate of the translation
  77307. * @param result defines the target matrix
  77308. */
  77309. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77310. /**
  77311. * Creates a scaling matrix and stores it in a target matrix
  77312. * @param x defines the x coordinate of the scaling
  77313. * @param y defines the y coordinate of the scaling
  77314. * @param result defines the target matrix
  77315. */
  77316. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77317. /**
  77318. * Creates a rotation matrix and stores it in a target matrix
  77319. * @param angle defines the rotation angle
  77320. * @param result defines the target matrix
  77321. */
  77322. static RotationToRef(angle: number, result: Matrix2D): void;
  77323. private static _TempPreTranslationMatrix;
  77324. private static _TempPostTranslationMatrix;
  77325. private static _TempRotationMatrix;
  77326. private static _TempScalingMatrix;
  77327. private static _TempCompose0;
  77328. private static _TempCompose1;
  77329. private static _TempCompose2;
  77330. /**
  77331. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77332. * @param tx defines the x coordinate of the translation
  77333. * @param ty defines the y coordinate of the translation
  77334. * @param angle defines the rotation angle
  77335. * @param scaleX defines the x coordinate of the scaling
  77336. * @param scaleY defines the y coordinate of the scaling
  77337. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77338. * @param result defines the target matrix
  77339. */
  77340. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77341. }
  77342. }
  77343. declare module BABYLON.GUI {
  77344. /**
  77345. * Class used to store 2D control sizes
  77346. */
  77347. export class Measure {
  77348. /** defines left coordinate */
  77349. left: number;
  77350. /** defines top coordinate */
  77351. top: number;
  77352. /** defines width dimension */
  77353. width: number;
  77354. /** defines height dimension */
  77355. height: number;
  77356. /**
  77357. * Creates a new measure
  77358. * @param left defines left coordinate
  77359. * @param top defines top coordinate
  77360. * @param width defines width dimension
  77361. * @param height defines height dimension
  77362. */
  77363. constructor(
  77364. /** defines left coordinate */
  77365. left: number,
  77366. /** defines top coordinate */
  77367. top: number,
  77368. /** defines width dimension */
  77369. width: number,
  77370. /** defines height dimension */
  77371. height: number);
  77372. /**
  77373. * Copy from another measure
  77374. * @param other defines the other measure to copy from
  77375. */
  77376. copyFrom(other: Measure): void;
  77377. /**
  77378. * Copy from a group of 4 floats
  77379. * @param left defines left coordinate
  77380. * @param top defines top coordinate
  77381. * @param width defines width dimension
  77382. * @param height defines height dimension
  77383. */
  77384. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77385. /**
  77386. * Computes the axis aligned bounding box measure for two given measures
  77387. * @param a Input measure
  77388. * @param b Input measure
  77389. * @param result the resulting bounding measure
  77390. */
  77391. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77392. /**
  77393. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77394. * @param transform the matrix to transform the measure before computing the AABB
  77395. * @param addX number to add to left
  77396. * @param addY number to add to top
  77397. * @param addWidth number to add to width
  77398. * @param addHeight number to add to height
  77399. * @param result the resulting AABB
  77400. */
  77401. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77402. /**
  77403. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77404. * @param transform the matrix to transform the measure before computing the AABB
  77405. * @param result the resulting AABB
  77406. */
  77407. transformToRef(transform: Matrix2D, result: Measure): void;
  77408. /**
  77409. * Check equality between this measure and another one
  77410. * @param other defines the other measures
  77411. * @returns true if both measures are equals
  77412. */
  77413. isEqualsTo(other: Measure): boolean;
  77414. /**
  77415. * Creates an empty measure
  77416. * @returns a new measure
  77417. */
  77418. static Empty(): Measure;
  77419. }
  77420. }
  77421. declare module BABYLON.GUI {
  77422. /**
  77423. * Interface used to define a control that can receive focus
  77424. */
  77425. export interface IFocusableControl {
  77426. /**
  77427. * Function called when the control receives the focus
  77428. */
  77429. onFocus(): void;
  77430. /**
  77431. * Function called when the control loses the focus
  77432. */
  77433. onBlur(): void;
  77434. /**
  77435. * Function called to let the control handle keyboard events
  77436. * @param evt defines the current keyboard event
  77437. */
  77438. processKeyboard(evt: KeyboardEvent): void;
  77439. /**
  77440. * Function called to get the list of controls that should not steal the focus from this control
  77441. * @returns an array of controls
  77442. */
  77443. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77444. }
  77445. /**
  77446. * Class used to create texture to support 2D GUI elements
  77447. * @see https://doc.babylonjs.com/how_to/gui
  77448. */
  77449. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77450. private _isDirty;
  77451. private _renderObserver;
  77452. private _resizeObserver;
  77453. private _preKeyboardObserver;
  77454. private _pointerMoveObserver;
  77455. private _pointerObserver;
  77456. private _canvasPointerOutObserver;
  77457. private _canvasBlurObserver;
  77458. private _background;
  77459. /** @hidden */
  77460. _rootContainer: Container;
  77461. /** @hidden */
  77462. _lastPickedControl: Control;
  77463. /** @hidden */
  77464. _lastControlOver: {
  77465. [pointerId: number]: Control;
  77466. };
  77467. /** @hidden */
  77468. _lastControlDown: {
  77469. [pointerId: number]: Control;
  77470. };
  77471. /** @hidden */
  77472. _capturingControl: {
  77473. [pointerId: number]: Control;
  77474. };
  77475. /** @hidden */
  77476. _shouldBlockPointer: boolean;
  77477. /** @hidden */
  77478. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77479. /** @hidden */
  77480. _linkedControls: Control[];
  77481. private _isFullscreen;
  77482. private _fullscreenViewport;
  77483. private _idealWidth;
  77484. private _idealHeight;
  77485. private _useSmallestIdeal;
  77486. private _renderAtIdealSize;
  77487. private _focusedControl;
  77488. private _blockNextFocusCheck;
  77489. private _renderScale;
  77490. private _rootElement;
  77491. private _cursorChanged;
  77492. private _defaultMousePointerId;
  77493. /** @hidden */
  77494. _numLayoutCalls: number;
  77495. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77496. get numLayoutCalls(): number;
  77497. /** @hidden */
  77498. _numRenderCalls: number;
  77499. /** Gets the number of render calls made the last time the ADT has been rendered */
  77500. get numRenderCalls(): number;
  77501. /**
  77502. * Define type to string to ensure compatibility across browsers
  77503. * Safari doesn't support DataTransfer constructor
  77504. */
  77505. private _clipboardData;
  77506. /**
  77507. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77508. */
  77509. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77510. /**
  77511. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77512. */
  77513. onControlPickedObservable: BABYLON.Observable<Control>;
  77514. /**
  77515. * BABYLON.Observable event triggered before layout is evaluated
  77516. */
  77517. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77518. /**
  77519. * BABYLON.Observable event triggered after the layout was evaluated
  77520. */
  77521. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77522. /**
  77523. * BABYLON.Observable event triggered before the texture is rendered
  77524. */
  77525. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77526. /**
  77527. * BABYLON.Observable event triggered after the texture was rendered
  77528. */
  77529. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77530. /**
  77531. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77532. */
  77533. premulAlpha: boolean;
  77534. /**
  77535. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77536. * Useful when you want more antialiasing
  77537. */
  77538. get renderScale(): number;
  77539. set renderScale(value: number);
  77540. /** Gets or sets the background color */
  77541. get background(): string;
  77542. set background(value: string);
  77543. /**
  77544. * Gets or sets the ideal width used to design controls.
  77545. * The GUI will then rescale everything accordingly
  77546. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77547. */
  77548. get idealWidth(): number;
  77549. set idealWidth(value: number);
  77550. /**
  77551. * Gets or sets the ideal height used to design controls.
  77552. * The GUI will then rescale everything accordingly
  77553. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77554. */
  77555. get idealHeight(): number;
  77556. set idealHeight(value: number);
  77557. /**
  77558. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77559. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77560. */
  77561. get useSmallestIdeal(): boolean;
  77562. set useSmallestIdeal(value: boolean);
  77563. /**
  77564. * Gets or sets a boolean indicating if adaptive scaling must be used
  77565. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77566. */
  77567. get renderAtIdealSize(): boolean;
  77568. set renderAtIdealSize(value: boolean);
  77569. /**
  77570. * Gets the ratio used when in "ideal mode"
  77571. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77572. * */
  77573. get idealRatio(): number;
  77574. /**
  77575. * Gets the underlying layer used to render the texture when in fullscreen mode
  77576. */
  77577. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77578. /**
  77579. * Gets the root container control
  77580. */
  77581. get rootContainer(): Container;
  77582. /**
  77583. * Returns an array containing the root container.
  77584. * This is mostly used to let the Inspector introspects the ADT
  77585. * @returns an array containing the rootContainer
  77586. */
  77587. getChildren(): Array<Container>;
  77588. /**
  77589. * Will return all controls that are inside this texture
  77590. * @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
  77591. * @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
  77592. * @return all child controls
  77593. */
  77594. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77595. /**
  77596. * Gets or sets the current focused control
  77597. */
  77598. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77599. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77600. /**
  77601. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77602. */
  77603. get isForeground(): boolean;
  77604. set isForeground(value: boolean);
  77605. /**
  77606. * Gets or set information about clipboardData
  77607. */
  77608. get clipboardData(): string;
  77609. set clipboardData(value: string);
  77610. /**
  77611. * Creates a new AdvancedDynamicTexture
  77612. * @param name defines the name of the texture
  77613. * @param width defines the width of the texture
  77614. * @param height defines the height of the texture
  77615. * @param scene defines the hosting scene
  77616. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77617. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77618. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77619. */
  77620. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77621. /**
  77622. * Get the current class name of the texture useful for serialization or dynamic coding.
  77623. * @returns "AdvancedDynamicTexture"
  77624. */
  77625. getClassName(): string;
  77626. /**
  77627. * Function used to execute a function on all controls
  77628. * @param func defines the function to execute
  77629. * @param container defines the container where controls belong. If null the root container will be used
  77630. */
  77631. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77632. private _useInvalidateRectOptimization;
  77633. /**
  77634. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77635. */
  77636. get useInvalidateRectOptimization(): boolean;
  77637. set useInvalidateRectOptimization(value: boolean);
  77638. private _invalidatedRectangle;
  77639. /**
  77640. * Invalidates a rectangle area on the gui texture
  77641. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77642. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77643. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77644. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77645. */
  77646. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77647. /**
  77648. * Marks the texture as dirty forcing a complete update
  77649. */
  77650. markAsDirty(): void;
  77651. /**
  77652. * Helper function used to create a new style
  77653. * @returns a new style
  77654. * @see https://doc.babylonjs.com/how_to/gui#styles
  77655. */
  77656. createStyle(): Style;
  77657. /**
  77658. * Adds a new control to the root container
  77659. * @param control defines the control to add
  77660. * @returns the current texture
  77661. */
  77662. addControl(control: Control): AdvancedDynamicTexture;
  77663. /**
  77664. * Removes a control from the root container
  77665. * @param control defines the control to remove
  77666. * @returns the current texture
  77667. */
  77668. removeControl(control: Control): AdvancedDynamicTexture;
  77669. /**
  77670. * Release all resources
  77671. */
  77672. dispose(): void;
  77673. private _onResize;
  77674. /** @hidden */
  77675. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77676. /**
  77677. * Get screen coordinates for a vector3
  77678. * @param position defines the position to project
  77679. * @param worldMatrix defines the world matrix to use
  77680. * @returns the projected position
  77681. */
  77682. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77683. private _checkUpdate;
  77684. private _clearMeasure;
  77685. private _render;
  77686. /** @hidden */
  77687. _changeCursor(cursor: string): void;
  77688. /** @hidden */
  77689. _registerLastControlDown(control: Control, pointerId: number): void;
  77690. private _doPicking;
  77691. /** @hidden */
  77692. _cleanControlAfterRemovalFromList(list: {
  77693. [pointerId: number]: Control;
  77694. }, control: Control): void;
  77695. /** @hidden */
  77696. _cleanControlAfterRemoval(control: Control): void;
  77697. /** Attach to all scene events required to support pointer events */
  77698. attach(): void;
  77699. /** @hidden */
  77700. private onClipboardCopy;
  77701. /** @hidden */
  77702. private onClipboardCut;
  77703. /** @hidden */
  77704. private onClipboardPaste;
  77705. /**
  77706. * Register the clipboard Events onto the canvas
  77707. */
  77708. registerClipboardEvents(): void;
  77709. /**
  77710. * Unregister the clipboard Events from the canvas
  77711. */
  77712. unRegisterClipboardEvents(): void;
  77713. /**
  77714. * Connect the texture to a hosting mesh to enable interactions
  77715. * @param mesh defines the mesh to attach to
  77716. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77717. */
  77718. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77719. /**
  77720. * Move the focus to a specific control
  77721. * @param control defines the control which will receive the focus
  77722. */
  77723. moveFocusToControl(control: IFocusableControl): void;
  77724. private _manageFocus;
  77725. private _attachToOnPointerOut;
  77726. private _attachToOnBlur;
  77727. /**
  77728. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77729. * @param mesh defines the mesh which will receive the texture
  77730. * @param width defines the texture width (1024 by default)
  77731. * @param height defines the texture height (1024 by default)
  77732. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77733. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77734. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77735. * @returns a new AdvancedDynamicTexture
  77736. */
  77737. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77738. /**
  77739. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77740. * In this mode the texture will rely on a layer for its rendering.
  77741. * This allows it to be treated like any other layer.
  77742. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77743. * LayerMask is set through advancedTexture.layer.layerMask
  77744. * @param name defines name for the texture
  77745. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77746. * @param scene defines the hsoting scene
  77747. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77748. * @returns a new AdvancedDynamicTexture
  77749. */
  77750. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77751. }
  77752. }
  77753. declare module BABYLON.GUI {
  77754. /**
  77755. * Root class used for all 2D controls
  77756. * @see https://doc.babylonjs.com/how_to/gui#controls
  77757. */
  77758. export class Control {
  77759. /** defines the name of the control */
  77760. name?: string | undefined;
  77761. /**
  77762. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77763. */
  77764. static AllowAlphaInheritance: boolean;
  77765. private _alpha;
  77766. private _alphaSet;
  77767. private _zIndex;
  77768. /** @hidden */
  77769. _host: AdvancedDynamicTexture;
  77770. /** Gets or sets the control parent */
  77771. parent: BABYLON.Nullable<Container>;
  77772. /** @hidden */
  77773. _currentMeasure: Measure;
  77774. private _fontFamily;
  77775. private _fontStyle;
  77776. private _fontWeight;
  77777. private _fontSize;
  77778. private _font;
  77779. /** @hidden */
  77780. _width: ValueAndUnit;
  77781. /** @hidden */
  77782. _height: ValueAndUnit;
  77783. /** @hidden */
  77784. protected _fontOffset: {
  77785. ascent: number;
  77786. height: number;
  77787. descent: number;
  77788. };
  77789. private _color;
  77790. private _style;
  77791. private _styleObserver;
  77792. /** @hidden */
  77793. protected _horizontalAlignment: number;
  77794. /** @hidden */
  77795. protected _verticalAlignment: number;
  77796. /** @hidden */
  77797. protected _isDirty: boolean;
  77798. /** @hidden */
  77799. protected _wasDirty: boolean;
  77800. /** @hidden */
  77801. _tempParentMeasure: Measure;
  77802. /** @hidden */
  77803. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77804. /** @hidden */
  77805. protected _cachedParentMeasure: Measure;
  77806. private _paddingLeft;
  77807. private _paddingRight;
  77808. private _paddingTop;
  77809. private _paddingBottom;
  77810. /** @hidden */
  77811. _left: ValueAndUnit;
  77812. /** @hidden */
  77813. _top: ValueAndUnit;
  77814. private _scaleX;
  77815. private _scaleY;
  77816. private _rotation;
  77817. private _transformCenterX;
  77818. private _transformCenterY;
  77819. /** @hidden */
  77820. _transformMatrix: Matrix2D;
  77821. /** @hidden */
  77822. protected _invertTransformMatrix: Matrix2D;
  77823. /** @hidden */
  77824. protected _transformedPosition: BABYLON.Vector2;
  77825. private _isMatrixDirty;
  77826. private _cachedOffsetX;
  77827. private _cachedOffsetY;
  77828. private _isVisible;
  77829. private _isHighlighted;
  77830. /** @hidden */
  77831. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  77832. private _fontSet;
  77833. private _dummyVector2;
  77834. private _downCount;
  77835. private _enterCount;
  77836. private _doNotRender;
  77837. private _downPointerIds;
  77838. protected _isEnabled: boolean;
  77839. protected _disabledColor: string;
  77840. protected _disabledColorItem: string;
  77841. /** @hidden */
  77842. protected _rebuildLayout: boolean;
  77843. /** @hidden */
  77844. _customData: any;
  77845. /** @hidden */
  77846. _isClipped: boolean;
  77847. /** @hidden */
  77848. _automaticSize: boolean;
  77849. /** @hidden */
  77850. _tag: any;
  77851. /**
  77852. * 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
  77853. */
  77854. uniqueId: number;
  77855. /**
  77856. * Gets or sets an object used to store user defined information for the node
  77857. */
  77858. metadata: any;
  77859. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77860. isHitTestVisible: boolean;
  77861. /** Gets or sets a boolean indicating if the control can block pointer events */
  77862. isPointerBlocker: boolean;
  77863. /** Gets or sets a boolean indicating if the control can be focusable */
  77864. isFocusInvisible: boolean;
  77865. /**
  77866. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77867. * 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
  77868. */
  77869. clipChildren: boolean;
  77870. /**
  77871. * Gets or sets a boolean indicating that control content must be clipped
  77872. * 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
  77873. */
  77874. clipContent: boolean;
  77875. /**
  77876. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77877. */
  77878. useBitmapCache: boolean;
  77879. private _cacheData;
  77880. private _shadowOffsetX;
  77881. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77882. get shadowOffsetX(): number;
  77883. set shadowOffsetX(value: number);
  77884. private _shadowOffsetY;
  77885. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77886. get shadowOffsetY(): number;
  77887. set shadowOffsetY(value: number);
  77888. private _shadowBlur;
  77889. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77890. get shadowBlur(): number;
  77891. set shadowBlur(value: number);
  77892. private _shadowColor;
  77893. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77894. get shadowColor(): string;
  77895. set shadowColor(value: string);
  77896. /** Gets or sets the cursor to use when the control is hovered */
  77897. hoverCursor: string;
  77898. /** @hidden */
  77899. protected _linkOffsetX: ValueAndUnit;
  77900. /** @hidden */
  77901. protected _linkOffsetY: ValueAndUnit;
  77902. /** Gets the control type name */
  77903. get typeName(): string;
  77904. /**
  77905. * Get the current class name of the control.
  77906. * @returns current class name
  77907. */
  77908. getClassName(): string;
  77909. /**
  77910. * An event triggered when pointer wheel is scrolled
  77911. */
  77912. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77913. /**
  77914. * An event triggered when the pointer move over the control.
  77915. */
  77916. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77917. /**
  77918. * An event triggered when the pointer move out of the control.
  77919. */
  77920. onPointerOutObservable: BABYLON.Observable<Control>;
  77921. /**
  77922. * An event triggered when the pointer taps the control
  77923. */
  77924. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77925. /**
  77926. * An event triggered when pointer up
  77927. */
  77928. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77929. /**
  77930. * An event triggered when a control is clicked on
  77931. */
  77932. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77933. /**
  77934. * An event triggered when pointer enters the control
  77935. */
  77936. onPointerEnterObservable: BABYLON.Observable<Control>;
  77937. /**
  77938. * An event triggered when the control is marked as dirty
  77939. */
  77940. onDirtyObservable: BABYLON.Observable<Control>;
  77941. /**
  77942. * An event triggered before drawing the control
  77943. */
  77944. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77945. /**
  77946. * An event triggered after the control was drawn
  77947. */
  77948. onAfterDrawObservable: BABYLON.Observable<Control>;
  77949. /**
  77950. * An event triggered when the control has been disposed
  77951. */
  77952. onDisposeObservable: BABYLON.Observable<Control>;
  77953. /**
  77954. * Get the hosting AdvancedDynamicTexture
  77955. */
  77956. get host(): AdvancedDynamicTexture;
  77957. /** Gets or set information about font offsets (used to render and align text) */
  77958. get fontOffset(): {
  77959. ascent: number;
  77960. height: number;
  77961. descent: number;
  77962. };
  77963. set fontOffset(offset: {
  77964. ascent: number;
  77965. height: number;
  77966. descent: number;
  77967. });
  77968. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77969. get alpha(): number;
  77970. set alpha(value: number);
  77971. /**
  77972. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77973. */
  77974. get isHighlighted(): boolean;
  77975. set isHighlighted(value: boolean);
  77976. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77977. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77978. */
  77979. get scaleX(): number;
  77980. set scaleX(value: number);
  77981. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77982. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77983. */
  77984. get scaleY(): number;
  77985. set scaleY(value: number);
  77986. /** Gets or sets the rotation angle (0 by default)
  77987. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77988. */
  77989. get rotation(): number;
  77990. set rotation(value: number);
  77991. /** Gets or sets the transformation center on Y axis (0 by default)
  77992. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77993. */
  77994. get transformCenterY(): number;
  77995. set transformCenterY(value: number);
  77996. /** Gets or sets the transformation center on X axis (0 by default)
  77997. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77998. */
  77999. get transformCenterX(): number;
  78000. set transformCenterX(value: number);
  78001. /**
  78002. * Gets or sets the horizontal alignment
  78003. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78004. */
  78005. get horizontalAlignment(): number;
  78006. set horizontalAlignment(value: number);
  78007. /**
  78008. * Gets or sets the vertical alignment
  78009. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78010. */
  78011. get verticalAlignment(): number;
  78012. set verticalAlignment(value: number);
  78013. /**
  78014. * Gets or sets a fixed ratio for this control.
  78015. * When different from 0, the ratio is used to compute the "second" dimension.
  78016. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78017. * second dimension is computed as first dimension * fixedRatio
  78018. */
  78019. fixedRatio: number;
  78020. private _fixedRatioMasterIsWidth;
  78021. /**
  78022. * Gets or sets control width
  78023. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78024. */
  78025. get width(): string | number;
  78026. set width(value: string | number);
  78027. /**
  78028. * Gets or sets the control width in pixel
  78029. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78030. */
  78031. get widthInPixels(): number;
  78032. set widthInPixels(value: number);
  78033. /**
  78034. * Gets or sets control height
  78035. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78036. */
  78037. get height(): string | number;
  78038. set height(value: string | number);
  78039. /**
  78040. * Gets or sets control height in pixel
  78041. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78042. */
  78043. get heightInPixels(): number;
  78044. set heightInPixels(value: number);
  78045. /** Gets or set font family */
  78046. get fontFamily(): string;
  78047. set fontFamily(value: string);
  78048. /** Gets or sets font style */
  78049. get fontStyle(): string;
  78050. set fontStyle(value: string);
  78051. /** Gets or sets font weight */
  78052. get fontWeight(): string;
  78053. set fontWeight(value: string);
  78054. /**
  78055. * Gets or sets style
  78056. * @see https://doc.babylonjs.com/how_to/gui#styles
  78057. */
  78058. get style(): BABYLON.Nullable<Style>;
  78059. set style(value: BABYLON.Nullable<Style>);
  78060. /** @hidden */
  78061. get _isFontSizeInPercentage(): boolean;
  78062. /** Gets or sets font size in pixels */
  78063. get fontSizeInPixels(): number;
  78064. set fontSizeInPixels(value: number);
  78065. /** Gets or sets font size */
  78066. get fontSize(): string | number;
  78067. set fontSize(value: string | number);
  78068. /** Gets or sets foreground color */
  78069. get color(): string;
  78070. set color(value: string);
  78071. /** Gets or sets z index which is used to reorder controls on the z axis */
  78072. get zIndex(): number;
  78073. set zIndex(value: number);
  78074. /** Gets or sets a boolean indicating if the control can be rendered */
  78075. get notRenderable(): boolean;
  78076. set notRenderable(value: boolean);
  78077. /** Gets or sets a boolean indicating if the control is visible */
  78078. get isVisible(): boolean;
  78079. set isVisible(value: boolean);
  78080. /** Gets a boolean indicating that the control needs to update its rendering */
  78081. get isDirty(): boolean;
  78082. /**
  78083. * Gets the current linked mesh (or null if none)
  78084. */
  78085. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78086. /**
  78087. * Gets or sets a value indicating the padding to use on the left of the control
  78088. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78089. */
  78090. get paddingLeft(): string | number;
  78091. set paddingLeft(value: string | number);
  78092. /**
  78093. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78095. */
  78096. get paddingLeftInPixels(): number;
  78097. set paddingLeftInPixels(value: number);
  78098. /**
  78099. * Gets or sets a value indicating the padding to use on the right of the control
  78100. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78101. */
  78102. get paddingRight(): string | number;
  78103. set paddingRight(value: string | number);
  78104. /**
  78105. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78106. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78107. */
  78108. get paddingRightInPixels(): number;
  78109. set paddingRightInPixels(value: number);
  78110. /**
  78111. * Gets or sets a value indicating the padding to use on the top of the control
  78112. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78113. */
  78114. get paddingTop(): string | number;
  78115. set paddingTop(value: string | number);
  78116. /**
  78117. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78118. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78119. */
  78120. get paddingTopInPixels(): number;
  78121. set paddingTopInPixels(value: number);
  78122. /**
  78123. * Gets or sets a value indicating the padding to use on the bottom of the control
  78124. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78125. */
  78126. get paddingBottom(): string | number;
  78127. set paddingBottom(value: string | number);
  78128. /**
  78129. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78130. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78131. */
  78132. get paddingBottomInPixels(): number;
  78133. set paddingBottomInPixels(value: number);
  78134. /**
  78135. * Gets or sets a value indicating the left coordinate of the control
  78136. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78137. */
  78138. get left(): string | number;
  78139. set left(value: string | number);
  78140. /**
  78141. * Gets or sets a value indicating the left coordinate in pixels of the control
  78142. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78143. */
  78144. get leftInPixels(): number;
  78145. set leftInPixels(value: number);
  78146. /**
  78147. * Gets or sets a value indicating the top coordinate of the control
  78148. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78149. */
  78150. get top(): string | number;
  78151. set top(value: string | number);
  78152. /**
  78153. * Gets or sets a value indicating the top coordinate in pixels of the control
  78154. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78155. */
  78156. get topInPixels(): number;
  78157. set topInPixels(value: number);
  78158. /**
  78159. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78160. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78161. */
  78162. get linkOffsetX(): string | number;
  78163. set linkOffsetX(value: string | number);
  78164. /**
  78165. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78166. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78167. */
  78168. get linkOffsetXInPixels(): number;
  78169. set linkOffsetXInPixels(value: number);
  78170. /**
  78171. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78172. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78173. */
  78174. get linkOffsetY(): string | number;
  78175. set linkOffsetY(value: string | number);
  78176. /**
  78177. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78178. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78179. */
  78180. get linkOffsetYInPixels(): number;
  78181. set linkOffsetYInPixels(value: number);
  78182. /** Gets the center coordinate on X axis */
  78183. get centerX(): number;
  78184. /** Gets the center coordinate on Y axis */
  78185. get centerY(): number;
  78186. /** Gets or sets if control is Enabled*/
  78187. get isEnabled(): boolean;
  78188. set isEnabled(value: boolean);
  78189. /** Gets or sets background color of control if it's disabled*/
  78190. get disabledColor(): string;
  78191. set disabledColor(value: string);
  78192. /** Gets or sets front color of control if it's disabled*/
  78193. get disabledColorItem(): string;
  78194. set disabledColorItem(value: string);
  78195. /**
  78196. * Creates a new control
  78197. * @param name defines the name of the control
  78198. */
  78199. constructor(
  78200. /** defines the name of the control */
  78201. name?: string | undefined);
  78202. /** @hidden */
  78203. protected _getTypeName(): string;
  78204. /**
  78205. * Gets the first ascendant in the hierarchy of the given type
  78206. * @param className defines the required type
  78207. * @returns the ascendant or null if not found
  78208. */
  78209. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78210. /** @hidden */
  78211. _resetFontCache(): void;
  78212. /**
  78213. * Determines if a container is an ascendant of the current control
  78214. * @param container defines the container to look for
  78215. * @returns true if the container is one of the ascendant of the control
  78216. */
  78217. isAscendant(container: Control): boolean;
  78218. /**
  78219. * Gets coordinates in local control space
  78220. * @param globalCoordinates defines the coordinates to transform
  78221. * @returns the new coordinates in local space
  78222. */
  78223. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78224. /**
  78225. * Gets coordinates in local control space
  78226. * @param globalCoordinates defines the coordinates to transform
  78227. * @param result defines the target vector2 where to store the result
  78228. * @returns the current control
  78229. */
  78230. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78231. /**
  78232. * Gets coordinates in parent local control space
  78233. * @param globalCoordinates defines the coordinates to transform
  78234. * @returns the new coordinates in parent local space
  78235. */
  78236. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78237. /**
  78238. * Move the current control to a vector3 position projected onto the screen.
  78239. * @param position defines the target position
  78240. * @param scene defines the hosting scene
  78241. */
  78242. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78243. /**
  78244. * Will store all controls that have this control as ascendant in a given array
  78245. * @param results defines the array where to store the descendants
  78246. * @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
  78247. * @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
  78248. */
  78249. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78250. /**
  78251. * Will return all controls that have this control as ascendant
  78252. * @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
  78253. * @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
  78254. * @return all child controls
  78255. */
  78256. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78257. /**
  78258. * Link current control with a target mesh
  78259. * @param mesh defines the mesh to link with
  78260. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78261. */
  78262. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78263. /** @hidden */
  78264. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78265. /** @hidden */
  78266. _offsetLeft(offset: number): void;
  78267. /** @hidden */
  78268. _offsetTop(offset: number): void;
  78269. /** @hidden */
  78270. _markMatrixAsDirty(): void;
  78271. /** @hidden */
  78272. _flagDescendantsAsMatrixDirty(): void;
  78273. /** @hidden */
  78274. _intersectsRect(rect: Measure): boolean;
  78275. /** @hidden */
  78276. protected invalidateRect(): void;
  78277. /** @hidden */
  78278. _markAsDirty(force?: boolean): void;
  78279. /** @hidden */
  78280. _markAllAsDirty(): void;
  78281. /** @hidden */
  78282. _link(host: AdvancedDynamicTexture): void;
  78283. /** @hidden */
  78284. protected _transform(context?: CanvasRenderingContext2D): void;
  78285. /** @hidden */
  78286. _renderHighlight(context: CanvasRenderingContext2D): void;
  78287. /** @hidden */
  78288. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78289. /** @hidden */
  78290. protected _applyStates(context: CanvasRenderingContext2D): void;
  78291. /** @hidden */
  78292. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78293. /** @hidden */
  78294. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78295. protected _evaluateClippingState(parentMeasure: Measure): void;
  78296. /** @hidden */
  78297. _measure(): void;
  78298. /** @hidden */
  78299. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78300. /** @hidden */
  78301. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78302. /** @hidden */
  78303. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78304. /** @hidden */
  78305. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78306. private static _ClipMeasure;
  78307. private _tmpMeasureA;
  78308. private _clip;
  78309. /** @hidden */
  78310. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78311. /** @hidden */
  78312. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78313. /**
  78314. * Tests if a given coordinates belong to the current control
  78315. * @param x defines x coordinate to test
  78316. * @param y defines y coordinate to test
  78317. * @returns true if the coordinates are inside the control
  78318. */
  78319. contains(x: number, y: number): boolean;
  78320. /** @hidden */
  78321. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78322. /** @hidden */
  78323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78324. /** @hidden */
  78325. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78326. /** @hidden */
  78327. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78328. /** @hidden */
  78329. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78330. /** @hidden */
  78331. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78332. /** @hidden */
  78333. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78334. /** @hidden */
  78335. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78336. /** @hidden */
  78337. _onCanvasBlur(): void;
  78338. /** @hidden */
  78339. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78340. private _prepareFont;
  78341. /** Releases associated resources */
  78342. dispose(): void;
  78343. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78344. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78345. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78346. private static _VERTICAL_ALIGNMENT_TOP;
  78347. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78348. private static _VERTICAL_ALIGNMENT_CENTER;
  78349. /** HORIZONTAL_ALIGNMENT_LEFT */
  78350. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78351. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78352. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78353. /** HORIZONTAL_ALIGNMENT_CENTER */
  78354. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78355. /** VERTICAL_ALIGNMENT_TOP */
  78356. static get VERTICAL_ALIGNMENT_TOP(): number;
  78357. /** VERTICAL_ALIGNMENT_BOTTOM */
  78358. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78359. /** VERTICAL_ALIGNMENT_CENTER */
  78360. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78361. private static _FontHeightSizes;
  78362. /** @hidden */
  78363. static _GetFontOffset(font: string): {
  78364. ascent: number;
  78365. height: number;
  78366. descent: number;
  78367. };
  78368. /**
  78369. * Creates a stack panel that can be used to render headers
  78370. * @param control defines the control to associate with the header
  78371. * @param text defines the text of the header
  78372. * @param size defines the size of the header
  78373. * @param options defines options used to configure the header
  78374. * @returns a new StackPanel
  78375. * @ignore
  78376. * @hidden
  78377. */
  78378. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78379. isHorizontal: boolean;
  78380. controlFirst: boolean;
  78381. }) => any;
  78382. /** @hidden */
  78383. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78384. }
  78385. }
  78386. declare module BABYLON.GUI {
  78387. /**
  78388. * Root class for 2D containers
  78389. * @see https://doc.babylonjs.com/how_to/gui#containers
  78390. */
  78391. export class Container extends Control {
  78392. name?: string | undefined;
  78393. /** @hidden */
  78394. _children: Control[];
  78395. /** @hidden */
  78396. protected _measureForChildren: Measure;
  78397. /** @hidden */
  78398. protected _background: string;
  78399. /** @hidden */
  78400. protected _adaptWidthToChildren: boolean;
  78401. /** @hidden */
  78402. protected _adaptHeightToChildren: boolean;
  78403. /**
  78404. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78405. */
  78406. logLayoutCycleErrors: boolean;
  78407. /**
  78408. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78409. */
  78410. maxLayoutCycle: number;
  78411. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78412. get adaptHeightToChildren(): boolean;
  78413. set adaptHeightToChildren(value: boolean);
  78414. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78415. get adaptWidthToChildren(): boolean;
  78416. set adaptWidthToChildren(value: boolean);
  78417. /** Gets or sets background color */
  78418. get background(): string;
  78419. set background(value: string);
  78420. /** Gets the list of children */
  78421. get children(): Control[];
  78422. /**
  78423. * Creates a new Container
  78424. * @param name defines the name of the container
  78425. */
  78426. constructor(name?: string | undefined);
  78427. protected _getTypeName(): string;
  78428. _flagDescendantsAsMatrixDirty(): void;
  78429. /**
  78430. * Gets a child using its name
  78431. * @param name defines the child name to look for
  78432. * @returns the child control if found
  78433. */
  78434. getChildByName(name: string): BABYLON.Nullable<Control>;
  78435. /**
  78436. * Gets a child using its type and its name
  78437. * @param name defines the child name to look for
  78438. * @param type defines the child type to look for
  78439. * @returns the child control if found
  78440. */
  78441. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78442. /**
  78443. * Search for a specific control in children
  78444. * @param control defines the control to look for
  78445. * @returns true if the control is in child list
  78446. */
  78447. containsControl(control: Control): boolean;
  78448. /**
  78449. * Adds a new control to the current container
  78450. * @param control defines the control to add
  78451. * @returns the current container
  78452. */
  78453. addControl(control: BABYLON.Nullable<Control>): Container;
  78454. /**
  78455. * Removes all controls from the current container
  78456. * @returns the current container
  78457. */
  78458. clearControls(): Container;
  78459. /**
  78460. * Removes a control from the current container
  78461. * @param control defines the control to remove
  78462. * @returns the current container
  78463. */
  78464. removeControl(control: Control): Container;
  78465. /** @hidden */
  78466. _reOrderControl(control: Control): void;
  78467. /** @hidden */
  78468. _offsetLeft(offset: number): void;
  78469. /** @hidden */
  78470. _offsetTop(offset: number): void;
  78471. /** @hidden */
  78472. _markAllAsDirty(): void;
  78473. /** @hidden */
  78474. protected _localDraw(context: CanvasRenderingContext2D): void;
  78475. /** @hidden */
  78476. _link(host: AdvancedDynamicTexture): void;
  78477. /** @hidden */
  78478. protected _beforeLayout(): void;
  78479. /** @hidden */
  78480. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78481. /** @hidden */
  78482. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78483. protected _postMeasure(): void;
  78484. /** @hidden */
  78485. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78486. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78487. /** @hidden */
  78488. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78489. /** @hidden */
  78490. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78491. /** Releases associated resources */
  78492. dispose(): void;
  78493. }
  78494. }
  78495. declare module BABYLON.GUI {
  78496. /** Class used to create rectangle container */
  78497. export class Rectangle extends Container {
  78498. name?: string | undefined;
  78499. private _thickness;
  78500. private _cornerRadius;
  78501. /** Gets or sets border thickness */
  78502. get thickness(): number;
  78503. set thickness(value: number);
  78504. /** Gets or sets the corner radius angle */
  78505. get cornerRadius(): number;
  78506. set cornerRadius(value: number);
  78507. /**
  78508. * Creates a new Rectangle
  78509. * @param name defines the control name
  78510. */
  78511. constructor(name?: string | undefined);
  78512. protected _getTypeName(): string;
  78513. protected _localDraw(context: CanvasRenderingContext2D): void;
  78514. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78515. private _drawRoundedRect;
  78516. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78517. }
  78518. }
  78519. declare module BABYLON.GUI {
  78520. /**
  78521. * Enum that determines the text-wrapping mode to use.
  78522. */
  78523. export enum TextWrapping {
  78524. /**
  78525. * Clip the text when it's larger than Control.width; this is the default mode.
  78526. */
  78527. Clip = 0,
  78528. /**
  78529. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78530. */
  78531. WordWrap = 1,
  78532. /**
  78533. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78534. */
  78535. Ellipsis = 2
  78536. }
  78537. /**
  78538. * Class used to create text block control
  78539. */
  78540. export class TextBlock extends Control {
  78541. /**
  78542. * Defines the name of the control
  78543. */
  78544. name?: string | undefined;
  78545. private _text;
  78546. private _textWrapping;
  78547. private _textHorizontalAlignment;
  78548. private _textVerticalAlignment;
  78549. private _lines;
  78550. private _resizeToFit;
  78551. private _lineSpacing;
  78552. private _outlineWidth;
  78553. private _outlineColor;
  78554. private _underline;
  78555. private _lineThrough;
  78556. /**
  78557. * An event triggered after the text is changed
  78558. */
  78559. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78560. /**
  78561. * An event triggered after the text was broken up into lines
  78562. */
  78563. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78564. /**
  78565. * Function used to split a string into words. By default, a string is split at each space character found
  78566. */
  78567. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78568. /**
  78569. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78570. */
  78571. get lines(): any[];
  78572. /**
  78573. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78574. */
  78575. get resizeToFit(): boolean;
  78576. /**
  78577. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78578. */
  78579. set resizeToFit(value: boolean);
  78580. /**
  78581. * Gets or sets a boolean indicating if text must be wrapped
  78582. */
  78583. get textWrapping(): TextWrapping | boolean;
  78584. /**
  78585. * Gets or sets a boolean indicating if text must be wrapped
  78586. */
  78587. set textWrapping(value: TextWrapping | boolean);
  78588. /**
  78589. * Gets or sets text to display
  78590. */
  78591. get text(): string;
  78592. /**
  78593. * Gets or sets text to display
  78594. */
  78595. set text(value: string);
  78596. /**
  78597. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78598. */
  78599. get textHorizontalAlignment(): number;
  78600. /**
  78601. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78602. */
  78603. set textHorizontalAlignment(value: number);
  78604. /**
  78605. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78606. */
  78607. get textVerticalAlignment(): number;
  78608. /**
  78609. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78610. */
  78611. set textVerticalAlignment(value: number);
  78612. /**
  78613. * Gets or sets line spacing value
  78614. */
  78615. set lineSpacing(value: string | number);
  78616. /**
  78617. * Gets or sets line spacing value
  78618. */
  78619. get lineSpacing(): string | number;
  78620. /**
  78621. * Gets or sets outlineWidth of the text to display
  78622. */
  78623. get outlineWidth(): number;
  78624. /**
  78625. * Gets or sets outlineWidth of the text to display
  78626. */
  78627. set outlineWidth(value: number);
  78628. /**
  78629. * Gets or sets a boolean indicating that text must have underline
  78630. */
  78631. get underline(): boolean;
  78632. /**
  78633. * Gets or sets a boolean indicating that text must have underline
  78634. */
  78635. set underline(value: boolean);
  78636. /**
  78637. * Gets or sets an boolean indicating that text must be crossed out
  78638. */
  78639. get lineThrough(): boolean;
  78640. /**
  78641. * Gets or sets an boolean indicating that text must be crossed out
  78642. */
  78643. set lineThrough(value: boolean);
  78644. /**
  78645. * Gets or sets outlineColor of the text to display
  78646. */
  78647. get outlineColor(): string;
  78648. /**
  78649. * Gets or sets outlineColor of the text to display
  78650. */
  78651. set outlineColor(value: string);
  78652. /**
  78653. * Creates a new TextBlock object
  78654. * @param name defines the name of the control
  78655. * @param text defines the text to display (emptry string by default)
  78656. */
  78657. constructor(
  78658. /**
  78659. * Defines the name of the control
  78660. */
  78661. name?: string | undefined, text?: string);
  78662. protected _getTypeName(): string;
  78663. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78664. private _drawText;
  78665. /** @hidden */
  78666. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78667. protected _applyStates(context: CanvasRenderingContext2D): void;
  78668. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78669. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78670. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78671. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78672. protected _renderLines(context: CanvasRenderingContext2D): void;
  78673. /**
  78674. * Given a width constraint applied on the text block, find the expected height
  78675. * @returns expected height
  78676. */
  78677. computeExpectedHeight(): number;
  78678. dispose(): void;
  78679. }
  78680. }
  78681. declare module BABYLON.GUI {
  78682. /**
  78683. * Class used to create 2D images
  78684. */
  78685. export class Image extends Control {
  78686. name?: string | undefined;
  78687. private _workingCanvas;
  78688. private _domImage;
  78689. private _imageWidth;
  78690. private _imageHeight;
  78691. private _loaded;
  78692. private _stretch;
  78693. private _source;
  78694. private _autoScale;
  78695. private _sourceLeft;
  78696. private _sourceTop;
  78697. private _sourceWidth;
  78698. private _sourceHeight;
  78699. private _svgAttributesComputationCompleted;
  78700. private _isSVG;
  78701. private _cellWidth;
  78702. private _cellHeight;
  78703. private _cellId;
  78704. private _populateNinePatchSlicesFromImage;
  78705. private _sliceLeft;
  78706. private _sliceRight;
  78707. private _sliceTop;
  78708. private _sliceBottom;
  78709. private _detectPointerOnOpaqueOnly;
  78710. private _imageDataCache;
  78711. /**
  78712. * BABYLON.Observable notified when the content is loaded
  78713. */
  78714. onImageLoadedObservable: BABYLON.Observable<Image>;
  78715. /**
  78716. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78717. */
  78718. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78719. /**
  78720. * Gets a boolean indicating that the content is loaded
  78721. */
  78722. get isLoaded(): boolean;
  78723. /**
  78724. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78725. */
  78726. get populateNinePatchSlicesFromImage(): boolean;
  78727. set populateNinePatchSlicesFromImage(value: boolean);
  78728. /**
  78729. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78730. * Beware using this as this will comsume more memory as the image has to be stored twice
  78731. */
  78732. get detectPointerOnOpaqueOnly(): boolean;
  78733. set detectPointerOnOpaqueOnly(value: boolean);
  78734. /**
  78735. * Gets or sets the left value for slicing (9-patch)
  78736. */
  78737. get sliceLeft(): number;
  78738. set sliceLeft(value: number);
  78739. /**
  78740. * Gets or sets the right value for slicing (9-patch)
  78741. */
  78742. get sliceRight(): number;
  78743. set sliceRight(value: number);
  78744. /**
  78745. * Gets or sets the top value for slicing (9-patch)
  78746. */
  78747. get sliceTop(): number;
  78748. set sliceTop(value: number);
  78749. /**
  78750. * Gets or sets the bottom value for slicing (9-patch)
  78751. */
  78752. get sliceBottom(): number;
  78753. set sliceBottom(value: number);
  78754. /**
  78755. * Gets or sets the left coordinate in the source image
  78756. */
  78757. get sourceLeft(): number;
  78758. set sourceLeft(value: number);
  78759. /**
  78760. * Gets or sets the top coordinate in the source image
  78761. */
  78762. get sourceTop(): number;
  78763. set sourceTop(value: number);
  78764. /**
  78765. * Gets or sets the width to capture in the source image
  78766. */
  78767. get sourceWidth(): number;
  78768. set sourceWidth(value: number);
  78769. /**
  78770. * Gets or sets the height to capture in the source image
  78771. */
  78772. get sourceHeight(): number;
  78773. set sourceHeight(value: number);
  78774. /** Indicates if the format of the image is SVG */
  78775. get isSVG(): boolean;
  78776. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78777. get svgAttributesComputationCompleted(): boolean;
  78778. /**
  78779. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78780. * @see https://doc.babylonjs.com/how_to/gui#image
  78781. */
  78782. get autoScale(): boolean;
  78783. set autoScale(value: boolean);
  78784. /** Gets or sets the streching mode used by the image */
  78785. get stretch(): number;
  78786. set stretch(value: number);
  78787. /** @hidden */
  78788. _rotate90(n: number, preserveProperties?: boolean): Image;
  78789. private _handleRotationForSVGImage;
  78790. private _rotate90SourceProperties;
  78791. /**
  78792. * Gets or sets the internal DOM image used to render the control
  78793. */
  78794. set domImage(value: HTMLImageElement);
  78795. get domImage(): HTMLImageElement;
  78796. private _onImageLoaded;
  78797. private _extractNinePatchSliceDataFromImage;
  78798. /**
  78799. * Gets or sets image source url
  78800. */
  78801. set source(value: BABYLON.Nullable<string>);
  78802. /**
  78803. * Checks for svg document with icon id present
  78804. */
  78805. private _svgCheck;
  78806. /**
  78807. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78808. * given external svg file and icon id
  78809. */
  78810. private _getSVGAttribs;
  78811. /**
  78812. * Gets or sets the cell width to use when animation sheet is enabled
  78813. * @see https://doc.babylonjs.com/how_to/gui#image
  78814. */
  78815. get cellWidth(): number;
  78816. set cellWidth(value: number);
  78817. /**
  78818. * Gets or sets the cell height to use when animation sheet is enabled
  78819. * @see https://doc.babylonjs.com/how_to/gui#image
  78820. */
  78821. get cellHeight(): number;
  78822. set cellHeight(value: number);
  78823. /**
  78824. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78825. * @see https://doc.babylonjs.com/how_to/gui#image
  78826. */
  78827. get cellId(): number;
  78828. set cellId(value: number);
  78829. /**
  78830. * Creates a new Image
  78831. * @param name defines the control name
  78832. * @param url defines the image url
  78833. */
  78834. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78835. /**
  78836. * Tests if a given coordinates belong to the current control
  78837. * @param x defines x coordinate to test
  78838. * @param y defines y coordinate to test
  78839. * @returns true if the coordinates are inside the control
  78840. */
  78841. contains(x: number, y: number): boolean;
  78842. protected _getTypeName(): string;
  78843. /** Force the control to synchronize with its content */
  78844. synchronizeSizeWithContent(): void;
  78845. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78846. private _prepareWorkingCanvasForOpaqueDetection;
  78847. private _drawImage;
  78848. _draw(context: CanvasRenderingContext2D): void;
  78849. private _renderCornerPatch;
  78850. private _renderNinePatch;
  78851. dispose(): void;
  78852. /** STRETCH_NONE */
  78853. static readonly STRETCH_NONE: number;
  78854. /** STRETCH_FILL */
  78855. static readonly STRETCH_FILL: number;
  78856. /** STRETCH_UNIFORM */
  78857. static readonly STRETCH_UNIFORM: number;
  78858. /** STRETCH_EXTEND */
  78859. static readonly STRETCH_EXTEND: number;
  78860. /** NINE_PATCH */
  78861. static readonly STRETCH_NINE_PATCH: number;
  78862. }
  78863. }
  78864. declare module BABYLON.GUI {
  78865. /**
  78866. * Class used to create 2D buttons
  78867. */
  78868. export class Button extends Rectangle {
  78869. name?: string | undefined;
  78870. /**
  78871. * Function called to generate a pointer enter animation
  78872. */
  78873. pointerEnterAnimation: () => void;
  78874. /**
  78875. * Function called to generate a pointer out animation
  78876. */
  78877. pointerOutAnimation: () => void;
  78878. /**
  78879. * Function called to generate a pointer down animation
  78880. */
  78881. pointerDownAnimation: () => void;
  78882. /**
  78883. * Function called to generate a pointer up animation
  78884. */
  78885. pointerUpAnimation: () => void;
  78886. /**
  78887. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78888. */
  78889. delegatePickingToChildren: boolean;
  78890. private _image;
  78891. /**
  78892. * Returns the image part of the button (if any)
  78893. */
  78894. get image(): BABYLON.Nullable<Image>;
  78895. private _textBlock;
  78896. /**
  78897. * Returns the image part of the button (if any)
  78898. */
  78899. get textBlock(): BABYLON.Nullable<TextBlock>;
  78900. /**
  78901. * Creates a new Button
  78902. * @param name defines the name of the button
  78903. */
  78904. constructor(name?: string | undefined);
  78905. protected _getTypeName(): string;
  78906. /** @hidden */
  78907. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78908. /** @hidden */
  78909. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78910. /** @hidden */
  78911. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78912. /** @hidden */
  78913. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78914. /** @hidden */
  78915. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78916. /**
  78917. * Creates a new button made with an image and a text
  78918. * @param name defines the name of the button
  78919. * @param text defines the text of the button
  78920. * @param imageUrl defines the url of the image
  78921. * @returns a new Button
  78922. */
  78923. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78924. /**
  78925. * Creates a new button made with an image
  78926. * @param name defines the name of the button
  78927. * @param imageUrl defines the url of the image
  78928. * @returns a new Button
  78929. */
  78930. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78931. /**
  78932. * Creates a new button made with a text
  78933. * @param name defines the name of the button
  78934. * @param text defines the text of the button
  78935. * @returns a new Button
  78936. */
  78937. static CreateSimpleButton(name: string, text: string): Button;
  78938. /**
  78939. * Creates a new button made with an image and a centered text
  78940. * @param name defines the name of the button
  78941. * @param text defines the text of the button
  78942. * @param imageUrl defines the url of the image
  78943. * @returns a new Button
  78944. */
  78945. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78946. }
  78947. }
  78948. declare module BABYLON.GUI {
  78949. /**
  78950. * Class used to create a 2D stack panel container
  78951. */
  78952. export class StackPanel extends Container {
  78953. name?: string | undefined;
  78954. private _isVertical;
  78955. private _manualWidth;
  78956. private _manualHeight;
  78957. private _doNotTrackManualChanges;
  78958. /**
  78959. * Gets or sets a boolean indicating that layou warnings should be ignored
  78960. */
  78961. ignoreLayoutWarnings: boolean;
  78962. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78963. get isVertical(): boolean;
  78964. set isVertical(value: boolean);
  78965. /**
  78966. * Gets or sets panel width.
  78967. * This value should not be set when in horizontal mode as it will be computed automatically
  78968. */
  78969. set width(value: string | number);
  78970. get width(): string | number;
  78971. /**
  78972. * Gets or sets panel height.
  78973. * This value should not be set when in vertical mode as it will be computed automatically
  78974. */
  78975. set height(value: string | number);
  78976. get height(): string | number;
  78977. /**
  78978. * Creates a new StackPanel
  78979. * @param name defines control name
  78980. */
  78981. constructor(name?: string | undefined);
  78982. protected _getTypeName(): string;
  78983. /** @hidden */
  78984. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78985. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78986. protected _postMeasure(): void;
  78987. }
  78988. }
  78989. declare module BABYLON.GUI {
  78990. /**
  78991. * Class used to represent a 2D checkbox
  78992. */
  78993. export class Checkbox extends Control {
  78994. name?: string | undefined;
  78995. private _isChecked;
  78996. private _background;
  78997. private _checkSizeRatio;
  78998. private _thickness;
  78999. /** Gets or sets border thickness */
  79000. get thickness(): number;
  79001. set thickness(value: number);
  79002. /**
  79003. * BABYLON.Observable raised when isChecked property changes
  79004. */
  79005. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79006. /** Gets or sets a value indicating the ratio between overall size and check size */
  79007. get checkSizeRatio(): number;
  79008. set checkSizeRatio(value: number);
  79009. /** Gets or sets background color */
  79010. get background(): string;
  79011. set background(value: string);
  79012. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79013. get isChecked(): boolean;
  79014. set isChecked(value: boolean);
  79015. /**
  79016. * Creates a new CheckBox
  79017. * @param name defines the control name
  79018. */
  79019. constructor(name?: string | undefined);
  79020. protected _getTypeName(): string;
  79021. /** @hidden */
  79022. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79023. /** @hidden */
  79024. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79025. /**
  79026. * Utility function to easily create a checkbox with a header
  79027. * @param title defines the label to use for the header
  79028. * @param onValueChanged defines the callback to call when value changes
  79029. * @returns a StackPanel containing the checkbox and a textBlock
  79030. */
  79031. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79032. }
  79033. }
  79034. declare module BABYLON.GUI {
  79035. /**
  79036. * Class used to store key control properties
  79037. */
  79038. export class KeyPropertySet {
  79039. /** Width */
  79040. width?: string;
  79041. /** Height */
  79042. height?: string;
  79043. /** Left padding */
  79044. paddingLeft?: string;
  79045. /** Right padding */
  79046. paddingRight?: string;
  79047. /** Top padding */
  79048. paddingTop?: string;
  79049. /** Bottom padding */
  79050. paddingBottom?: string;
  79051. /** Foreground color */
  79052. color?: string;
  79053. /** Background color */
  79054. background?: string;
  79055. }
  79056. /**
  79057. * Class used to create virtual keyboard
  79058. */
  79059. export class VirtualKeyboard extends StackPanel {
  79060. /** BABYLON.Observable raised when a key is pressed */
  79061. onKeyPressObservable: BABYLON.Observable<string>;
  79062. /** Gets or sets default key button width */
  79063. defaultButtonWidth: string;
  79064. /** Gets or sets default key button height */
  79065. defaultButtonHeight: string;
  79066. /** Gets or sets default key button left padding */
  79067. defaultButtonPaddingLeft: string;
  79068. /** Gets or sets default key button right padding */
  79069. defaultButtonPaddingRight: string;
  79070. /** Gets or sets default key button top padding */
  79071. defaultButtonPaddingTop: string;
  79072. /** Gets or sets default key button bottom padding */
  79073. defaultButtonPaddingBottom: string;
  79074. /** Gets or sets default key button foreground color */
  79075. defaultButtonColor: string;
  79076. /** Gets or sets default key button background color */
  79077. defaultButtonBackground: string;
  79078. /** Gets or sets shift button foreground color */
  79079. shiftButtonColor: string;
  79080. /** Gets or sets shift button thickness*/
  79081. selectedShiftThickness: number;
  79082. /** Gets shift key state */
  79083. shiftState: number;
  79084. protected _getTypeName(): string;
  79085. private _createKey;
  79086. /**
  79087. * Adds a new row of keys
  79088. * @param keys defines the list of keys to add
  79089. * @param propertySets defines the associated property sets
  79090. */
  79091. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79092. /**
  79093. * Set the shift key to a specific state
  79094. * @param shiftState defines the new shift state
  79095. */
  79096. applyShiftState(shiftState: number): void;
  79097. private _currentlyConnectedInputText;
  79098. private _connectedInputTexts;
  79099. private _onKeyPressObserver;
  79100. /** Gets the input text control currently attached to the keyboard */
  79101. get connectedInputText(): BABYLON.Nullable<InputText>;
  79102. /**
  79103. * Connects the keyboard with an input text control
  79104. *
  79105. * @param input defines the target control
  79106. */
  79107. connect(input: InputText): void;
  79108. /**
  79109. * Disconnects the keyboard from connected InputText controls
  79110. *
  79111. * @param input optionally defines a target control, otherwise all are disconnected
  79112. */
  79113. disconnect(input?: InputText): void;
  79114. private _removeConnectedInputObservables;
  79115. /**
  79116. * Release all resources
  79117. */
  79118. dispose(): void;
  79119. /**
  79120. * Creates a new keyboard using a default layout
  79121. *
  79122. * @param name defines control name
  79123. * @returns a new VirtualKeyboard
  79124. */
  79125. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79126. }
  79127. }
  79128. declare module BABYLON.GUI {
  79129. /**
  79130. * Class used to create input text control
  79131. */
  79132. export class InputText extends Control implements IFocusableControl {
  79133. name?: string | undefined;
  79134. private _text;
  79135. private _placeholderText;
  79136. private _background;
  79137. private _focusedBackground;
  79138. private _focusedColor;
  79139. private _placeholderColor;
  79140. private _thickness;
  79141. private _margin;
  79142. private _autoStretchWidth;
  79143. private _maxWidth;
  79144. private _isFocused;
  79145. private _blinkTimeout;
  79146. private _blinkIsEven;
  79147. private _cursorOffset;
  79148. private _scrollLeft;
  79149. private _textWidth;
  79150. private _clickedCoordinate;
  79151. private _deadKey;
  79152. private _addKey;
  79153. private _currentKey;
  79154. private _isTextHighlightOn;
  79155. private _textHighlightColor;
  79156. private _highligherOpacity;
  79157. private _highlightedText;
  79158. private _startHighlightIndex;
  79159. private _endHighlightIndex;
  79160. private _cursorIndex;
  79161. private _onFocusSelectAll;
  79162. private _isPointerDown;
  79163. private _onClipboardObserver;
  79164. private _onPointerDblTapObserver;
  79165. /** @hidden */
  79166. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79167. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79168. promptMessage: string;
  79169. /** Force disable prompt on mobile device */
  79170. disableMobilePrompt: boolean;
  79171. /** BABYLON.Observable raised when the text changes */
  79172. onTextChangedObservable: BABYLON.Observable<InputText>;
  79173. /** BABYLON.Observable raised just before an entered character is to be added */
  79174. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79175. /** BABYLON.Observable raised when the control gets the focus */
  79176. onFocusObservable: BABYLON.Observable<InputText>;
  79177. /** BABYLON.Observable raised when the control loses the focus */
  79178. onBlurObservable: BABYLON.Observable<InputText>;
  79179. /**Observable raised when the text is highlighted */
  79180. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79181. /**Observable raised when copy event is triggered */
  79182. onTextCopyObservable: BABYLON.Observable<InputText>;
  79183. /** BABYLON.Observable raised when cut event is triggered */
  79184. onTextCutObservable: BABYLON.Observable<InputText>;
  79185. /** BABYLON.Observable raised when paste event is triggered */
  79186. onTextPasteObservable: BABYLON.Observable<InputText>;
  79187. /** BABYLON.Observable raised when a key event was processed */
  79188. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79189. /** Gets or sets the maximum width allowed by the control */
  79190. get maxWidth(): string | number;
  79191. /** Gets the maximum width allowed by the control in pixels */
  79192. get maxWidthInPixels(): number;
  79193. set maxWidth(value: string | number);
  79194. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79195. get highligherOpacity(): number;
  79196. set highligherOpacity(value: number);
  79197. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79198. get onFocusSelectAll(): boolean;
  79199. set onFocusSelectAll(value: boolean);
  79200. /** Gets or sets the text hightlight color */
  79201. get textHighlightColor(): string;
  79202. set textHighlightColor(value: string);
  79203. /** Gets or sets control margin */
  79204. get margin(): string;
  79205. /** Gets control margin in pixels */
  79206. get marginInPixels(): number;
  79207. set margin(value: string);
  79208. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79209. get autoStretchWidth(): boolean;
  79210. set autoStretchWidth(value: boolean);
  79211. /** Gets or sets border thickness */
  79212. get thickness(): number;
  79213. set thickness(value: number);
  79214. /** Gets or sets the background color when focused */
  79215. get focusedBackground(): string;
  79216. set focusedBackground(value: string);
  79217. /** Gets or sets the background color when focused */
  79218. get focusedColor(): string;
  79219. set focusedColor(value: string);
  79220. /** Gets or sets the background color */
  79221. get background(): string;
  79222. set background(value: string);
  79223. /** Gets or sets the placeholder color */
  79224. get placeholderColor(): string;
  79225. set placeholderColor(value: string);
  79226. /** Gets or sets the text displayed when the control is empty */
  79227. get placeholderText(): string;
  79228. set placeholderText(value: string);
  79229. /** Gets or sets the dead key flag */
  79230. get deadKey(): boolean;
  79231. set deadKey(flag: boolean);
  79232. /** Gets or sets the highlight text */
  79233. get highlightedText(): string;
  79234. set highlightedText(text: string);
  79235. /** Gets or sets if the current key should be added */
  79236. get addKey(): boolean;
  79237. set addKey(flag: boolean);
  79238. /** Gets or sets the value of the current key being entered */
  79239. get currentKey(): string;
  79240. set currentKey(key: string);
  79241. /** Gets or sets the text displayed in the control */
  79242. get text(): string;
  79243. set text(value: string);
  79244. /** Gets or sets control width */
  79245. get width(): string | number;
  79246. set width(value: string | number);
  79247. /**
  79248. * Creates a new InputText
  79249. * @param name defines the control name
  79250. * @param text defines the text of the control
  79251. */
  79252. constructor(name?: string | undefined, text?: string);
  79253. /** @hidden */
  79254. onBlur(): void;
  79255. /** @hidden */
  79256. onFocus(): void;
  79257. protected _getTypeName(): string;
  79258. /**
  79259. * Function called to get the list of controls that should not steal the focus from this control
  79260. * @returns an array of controls
  79261. */
  79262. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79263. /** @hidden */
  79264. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79265. /** @hidden */
  79266. private _updateValueFromCursorIndex;
  79267. /** @hidden */
  79268. private _processDblClick;
  79269. /** @hidden */
  79270. private _selectAllText;
  79271. /**
  79272. * Handles the keyboard event
  79273. * @param evt Defines the KeyboardEvent
  79274. */
  79275. processKeyboard(evt: KeyboardEvent): void;
  79276. /** @hidden */
  79277. private _onCopyText;
  79278. /** @hidden */
  79279. private _onCutText;
  79280. /** @hidden */
  79281. private _onPasteText;
  79282. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79283. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79284. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79285. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79286. protected _beforeRenderText(text: string): string;
  79287. dispose(): void;
  79288. }
  79289. }
  79290. declare module BABYLON.GUI {
  79291. /**
  79292. * Class used to create a 2D grid container
  79293. */
  79294. export class Grid extends Container {
  79295. name?: string | undefined;
  79296. private _rowDefinitions;
  79297. private _columnDefinitions;
  79298. private _cells;
  79299. private _childControls;
  79300. /**
  79301. * Gets the number of columns
  79302. */
  79303. get columnCount(): number;
  79304. /**
  79305. * Gets the number of rows
  79306. */
  79307. get rowCount(): number;
  79308. /** Gets the list of children */
  79309. get children(): Control[];
  79310. /** Gets the list of cells (e.g. the containers) */
  79311. get cells(): {
  79312. [key: string]: Container;
  79313. };
  79314. /**
  79315. * Gets the definition of a specific row
  79316. * @param index defines the index of the row
  79317. * @returns the row definition
  79318. */
  79319. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79320. /**
  79321. * Gets the definition of a specific column
  79322. * @param index defines the index of the column
  79323. * @returns the column definition
  79324. */
  79325. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79326. /**
  79327. * Adds a new row to the grid
  79328. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79329. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79330. * @returns the current grid
  79331. */
  79332. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79333. /**
  79334. * Adds a new column to the grid
  79335. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79336. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79337. * @returns the current grid
  79338. */
  79339. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79340. /**
  79341. * Update a row definition
  79342. * @param index defines the index of the row to update
  79343. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79344. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79345. * @returns the current grid
  79346. */
  79347. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79348. /**
  79349. * Update a column definition
  79350. * @param index defines the index of the column to update
  79351. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79352. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79353. * @returns the current grid
  79354. */
  79355. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79356. /**
  79357. * Gets the list of children stored in a specific cell
  79358. * @param row defines the row to check
  79359. * @param column defines the column to check
  79360. * @returns the list of controls
  79361. */
  79362. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79363. /**
  79364. * Gets a string representing the child cell info (row x column)
  79365. * @param child defines the control to get info from
  79366. * @returns a string containing the child cell info (row x column)
  79367. */
  79368. getChildCellInfo(child: Control): string;
  79369. private _removeCell;
  79370. private _offsetCell;
  79371. /**
  79372. * Remove a column definition at specified index
  79373. * @param index defines the index of the column to remove
  79374. * @returns the current grid
  79375. */
  79376. removeColumnDefinition(index: number): Grid;
  79377. /**
  79378. * Remove a row definition at specified index
  79379. * @param index defines the index of the row to remove
  79380. * @returns the current grid
  79381. */
  79382. removeRowDefinition(index: number): Grid;
  79383. /**
  79384. * Adds a new control to the current grid
  79385. * @param control defines the control to add
  79386. * @param row defines the row where to add the control (0 by default)
  79387. * @param column defines the column where to add the control (0 by default)
  79388. * @returns the current grid
  79389. */
  79390. addControl(control: Control, row?: number, column?: number): Grid;
  79391. /**
  79392. * Removes a control from the current container
  79393. * @param control defines the control to remove
  79394. * @returns the current container
  79395. */
  79396. removeControl(control: Control): Container;
  79397. /**
  79398. * Creates a new Grid
  79399. * @param name defines control name
  79400. */
  79401. constructor(name?: string | undefined);
  79402. protected _getTypeName(): string;
  79403. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79404. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79405. _flagDescendantsAsMatrixDirty(): void;
  79406. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79407. /** Releases associated resources */
  79408. dispose(): void;
  79409. }
  79410. }
  79411. declare module BABYLON.GUI {
  79412. /** Class used to create color pickers */
  79413. export class ColorPicker extends Control {
  79414. name?: string | undefined;
  79415. private static _Epsilon;
  79416. private _colorWheelCanvas;
  79417. private _value;
  79418. private _tmpColor;
  79419. private _pointerStartedOnSquare;
  79420. private _pointerStartedOnWheel;
  79421. private _squareLeft;
  79422. private _squareTop;
  79423. private _squareSize;
  79424. private _h;
  79425. private _s;
  79426. private _v;
  79427. private _lastPointerDownID;
  79428. /**
  79429. * BABYLON.Observable raised when the value changes
  79430. */
  79431. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79432. /** Gets or sets the color of the color picker */
  79433. get value(): BABYLON.Color3;
  79434. set value(value: BABYLON.Color3);
  79435. /**
  79436. * Gets or sets control width
  79437. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79438. */
  79439. get width(): string | number;
  79440. set width(value: string | number);
  79441. /**
  79442. * Gets or sets control height
  79443. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79444. */
  79445. get height(): string | number;
  79446. /** Gets or sets control height */
  79447. set height(value: string | number);
  79448. /** Gets or sets control size */
  79449. get size(): string | number;
  79450. set size(value: string | number);
  79451. /**
  79452. * Creates a new ColorPicker
  79453. * @param name defines the control name
  79454. */
  79455. constructor(name?: string | undefined);
  79456. protected _getTypeName(): string;
  79457. /** @hidden */
  79458. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79459. private _updateSquareProps;
  79460. private _drawGradientSquare;
  79461. private _drawCircle;
  79462. private _createColorWheelCanvas;
  79463. /** @hidden */
  79464. _draw(context: CanvasRenderingContext2D): void;
  79465. private _pointerIsDown;
  79466. private _updateValueFromPointer;
  79467. private _isPointOnSquare;
  79468. private _isPointOnWheel;
  79469. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79470. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79471. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79472. _onCanvasBlur(): void;
  79473. /**
  79474. * This function expands the color picker by creating a color picker dialog with manual
  79475. * color value input and the ability to save colors into an array to be used later in
  79476. * subsequent launches of the dialogue.
  79477. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79478. * @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.
  79479. * @returns picked color as a hex string and the saved colors array as hex strings.
  79480. */
  79481. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79482. pickerWidth?: string;
  79483. pickerHeight?: string;
  79484. headerHeight?: string;
  79485. lastColor?: string;
  79486. swatchLimit?: number;
  79487. numSwatchesPerLine?: number;
  79488. savedColors?: Array<string>;
  79489. }): Promise<{
  79490. savedColors?: string[];
  79491. pickedColor: string;
  79492. }>;
  79493. }
  79494. }
  79495. declare module BABYLON.GUI {
  79496. /** Class used to create 2D ellipse containers */
  79497. export class Ellipse extends Container {
  79498. name?: string | undefined;
  79499. private _thickness;
  79500. /** Gets or sets border thickness */
  79501. get thickness(): number;
  79502. set thickness(value: number);
  79503. /**
  79504. * Creates a new Ellipse
  79505. * @param name defines the control name
  79506. */
  79507. constructor(name?: string | undefined);
  79508. protected _getTypeName(): string;
  79509. protected _localDraw(context: CanvasRenderingContext2D): void;
  79510. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79511. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79512. }
  79513. }
  79514. declare module BABYLON.GUI {
  79515. /**
  79516. * Class used to create a password control
  79517. */
  79518. export class InputPassword extends InputText {
  79519. protected _beforeRenderText(text: string): string;
  79520. }
  79521. }
  79522. declare module BABYLON.GUI {
  79523. /** Class used to render 2D lines */
  79524. export class Line extends Control {
  79525. name?: string | undefined;
  79526. private _lineWidth;
  79527. private _x1;
  79528. private _y1;
  79529. private _x2;
  79530. private _y2;
  79531. private _dash;
  79532. private _connectedControl;
  79533. private _connectedControlDirtyObserver;
  79534. /** Gets or sets the dash pattern */
  79535. get dash(): Array<number>;
  79536. set dash(value: Array<number>);
  79537. /** Gets or sets the control connected with the line end */
  79538. get connectedControl(): Control;
  79539. set connectedControl(value: Control);
  79540. /** Gets or sets start coordinates on X axis */
  79541. get x1(): string | number;
  79542. set x1(value: string | number);
  79543. /** Gets or sets start coordinates on Y axis */
  79544. get y1(): string | number;
  79545. set y1(value: string | number);
  79546. /** Gets or sets end coordinates on X axis */
  79547. get x2(): string | number;
  79548. set x2(value: string | number);
  79549. /** Gets or sets end coordinates on Y axis */
  79550. get y2(): string | number;
  79551. set y2(value: string | number);
  79552. /** Gets or sets line width */
  79553. get lineWidth(): number;
  79554. set lineWidth(value: number);
  79555. /** Gets or sets horizontal alignment */
  79556. set horizontalAlignment(value: number);
  79557. /** Gets or sets vertical alignment */
  79558. set verticalAlignment(value: number);
  79559. private get _effectiveX2();
  79560. private get _effectiveY2();
  79561. /**
  79562. * Creates a new Line
  79563. * @param name defines the control name
  79564. */
  79565. constructor(name?: string | undefined);
  79566. protected _getTypeName(): string;
  79567. _draw(context: CanvasRenderingContext2D): void;
  79568. _measure(): void;
  79569. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79570. /**
  79571. * Move one end of the line given 3D cartesian coordinates.
  79572. * @param position Targeted world position
  79573. * @param scene BABYLON.Scene
  79574. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79575. */
  79576. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79577. /**
  79578. * Move one end of the line to a position in screen absolute space.
  79579. * @param projectedPosition Position in screen absolute space (X, Y)
  79580. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79581. */
  79582. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79583. }
  79584. }
  79585. declare module BABYLON.GUI {
  79586. /**
  79587. * Class used to store a point for a MultiLine object.
  79588. * The point can be pure 2D coordinates, a mesh or a control
  79589. */
  79590. export class MultiLinePoint {
  79591. private _multiLine;
  79592. private _x;
  79593. private _y;
  79594. private _control;
  79595. private _mesh;
  79596. private _controlObserver;
  79597. private _meshObserver;
  79598. /** @hidden */
  79599. _point: BABYLON.Vector2;
  79600. /**
  79601. * Creates a new MultiLinePoint
  79602. * @param multiLine defines the source MultiLine object
  79603. */
  79604. constructor(multiLine: MultiLine);
  79605. /** Gets or sets x coordinate */
  79606. get x(): string | number;
  79607. set x(value: string | number);
  79608. /** Gets or sets y coordinate */
  79609. get y(): string | number;
  79610. set y(value: string | number);
  79611. /** Gets or sets the control associated with this point */
  79612. get control(): BABYLON.Nullable<Control>;
  79613. set control(value: BABYLON.Nullable<Control>);
  79614. /** Gets or sets the mesh associated with this point */
  79615. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79616. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79617. /** Resets links */
  79618. resetLinks(): void;
  79619. /**
  79620. * Gets a translation vector
  79621. * @returns the translation vector
  79622. */
  79623. translate(): BABYLON.Vector2;
  79624. private _translatePoint;
  79625. /** Release associated resources */
  79626. dispose(): void;
  79627. }
  79628. }
  79629. declare module BABYLON.GUI {
  79630. /**
  79631. * Class used to create multi line control
  79632. */
  79633. export class MultiLine extends Control {
  79634. name?: string | undefined;
  79635. private _lineWidth;
  79636. private _dash;
  79637. private _points;
  79638. private _minX;
  79639. private _minY;
  79640. private _maxX;
  79641. private _maxY;
  79642. /**
  79643. * Creates a new MultiLine
  79644. * @param name defines the control name
  79645. */
  79646. constructor(name?: string | undefined);
  79647. /** Gets or sets dash pattern */
  79648. get dash(): Array<number>;
  79649. set dash(value: Array<number>);
  79650. /**
  79651. * Gets point stored at specified index
  79652. * @param index defines the index to look for
  79653. * @returns the requested point if found
  79654. */
  79655. getAt(index: number): MultiLinePoint;
  79656. /** Function called when a point is updated */
  79657. onPointUpdate: () => void;
  79658. /**
  79659. * Adds new points to the point collection
  79660. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79661. * @returns the list of created MultiLinePoint
  79662. */
  79663. add(...items: (AbstractMesh | Control | {
  79664. x: string | number;
  79665. y: string | number;
  79666. })[]): MultiLinePoint[];
  79667. /**
  79668. * Adds a new point to the point collection
  79669. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79670. * @returns the created MultiLinePoint
  79671. */
  79672. push(item?: (AbstractMesh | Control | {
  79673. x: string | number;
  79674. y: string | number;
  79675. })): MultiLinePoint;
  79676. /**
  79677. * Remove a specific value or point from the active point collection
  79678. * @param value defines the value or point to remove
  79679. */
  79680. remove(value: number | MultiLinePoint): void;
  79681. /**
  79682. * Resets this object to initial state (no point)
  79683. */
  79684. reset(): void;
  79685. /**
  79686. * Resets all links
  79687. */
  79688. resetLinks(): void;
  79689. /** Gets or sets line width */
  79690. get lineWidth(): number;
  79691. set lineWidth(value: number);
  79692. set horizontalAlignment(value: number);
  79693. set verticalAlignment(value: number);
  79694. protected _getTypeName(): string;
  79695. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79696. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79697. _measure(): void;
  79698. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79699. dispose(): void;
  79700. }
  79701. }
  79702. declare module BABYLON.GUI {
  79703. /**
  79704. * Class used to create radio button controls
  79705. */
  79706. export class RadioButton extends Control {
  79707. name?: string | undefined;
  79708. private _isChecked;
  79709. private _background;
  79710. private _checkSizeRatio;
  79711. private _thickness;
  79712. /** Gets or sets border thickness */
  79713. get thickness(): number;
  79714. set thickness(value: number);
  79715. /** Gets or sets group name */
  79716. group: string;
  79717. /** BABYLON.Observable raised when isChecked is changed */
  79718. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79719. /** Gets or sets a value indicating the ratio between overall size and check size */
  79720. get checkSizeRatio(): number;
  79721. set checkSizeRatio(value: number);
  79722. /** Gets or sets background color */
  79723. get background(): string;
  79724. set background(value: string);
  79725. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79726. get isChecked(): boolean;
  79727. set isChecked(value: boolean);
  79728. /**
  79729. * Creates a new RadioButton
  79730. * @param name defines the control name
  79731. */
  79732. constructor(name?: string | undefined);
  79733. protected _getTypeName(): string;
  79734. _draw(context: CanvasRenderingContext2D): void;
  79735. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79736. /**
  79737. * Utility function to easily create a radio button with a header
  79738. * @param title defines the label to use for the header
  79739. * @param group defines the group to use for the radio button
  79740. * @param isChecked defines the initial state of the radio button
  79741. * @param onValueChanged defines the callback to call when value changes
  79742. * @returns a StackPanel containing the radio button and a textBlock
  79743. */
  79744. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79745. }
  79746. }
  79747. declare module BABYLON.GUI {
  79748. /**
  79749. * Class used to create slider controls
  79750. */
  79751. export class BaseSlider extends Control {
  79752. name?: string | undefined;
  79753. protected _thumbWidth: ValueAndUnit;
  79754. private _minimum;
  79755. private _maximum;
  79756. private _value;
  79757. private _isVertical;
  79758. protected _barOffset: ValueAndUnit;
  79759. private _isThumbClamped;
  79760. protected _displayThumb: boolean;
  79761. private _step;
  79762. private _lastPointerDownID;
  79763. protected _effectiveBarOffset: number;
  79764. protected _renderLeft: number;
  79765. protected _renderTop: number;
  79766. protected _renderWidth: number;
  79767. protected _renderHeight: number;
  79768. protected _backgroundBoxLength: number;
  79769. protected _backgroundBoxThickness: number;
  79770. protected _effectiveThumbThickness: number;
  79771. /** BABYLON.Observable raised when the sldier value changes */
  79772. onValueChangedObservable: BABYLON.Observable<number>;
  79773. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79774. get displayThumb(): boolean;
  79775. set displayThumb(value: boolean);
  79776. /** Gets or sets a step to apply to values (0 by default) */
  79777. get step(): number;
  79778. set step(value: number);
  79779. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79780. get barOffset(): string | number;
  79781. /** Gets main bar offset in pixels*/
  79782. get barOffsetInPixels(): number;
  79783. set barOffset(value: string | number);
  79784. /** Gets or sets thumb width */
  79785. get thumbWidth(): string | number;
  79786. /** Gets thumb width in pixels */
  79787. get thumbWidthInPixels(): number;
  79788. set thumbWidth(value: string | number);
  79789. /** Gets or sets minimum value */
  79790. get minimum(): number;
  79791. set minimum(value: number);
  79792. /** Gets or sets maximum value */
  79793. get maximum(): number;
  79794. set maximum(value: number);
  79795. /** Gets or sets current value */
  79796. get value(): number;
  79797. set value(value: number);
  79798. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79799. get isVertical(): boolean;
  79800. set isVertical(value: boolean);
  79801. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79802. get isThumbClamped(): boolean;
  79803. set isThumbClamped(value: boolean);
  79804. /**
  79805. * Creates a new BaseSlider
  79806. * @param name defines the control name
  79807. */
  79808. constructor(name?: string | undefined);
  79809. protected _getTypeName(): string;
  79810. protected _getThumbPosition(): number;
  79811. protected _getThumbThickness(type: string): number;
  79812. protected _prepareRenderingData(type: string): void;
  79813. private _pointerIsDown;
  79814. /** @hidden */
  79815. protected _updateValueFromPointer(x: number, y: number): void;
  79816. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79817. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79818. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79819. _onCanvasBlur(): void;
  79820. }
  79821. }
  79822. declare module BABYLON.GUI {
  79823. /**
  79824. * Class used to create slider controls
  79825. */
  79826. export class Slider extends BaseSlider {
  79827. name?: string | undefined;
  79828. private _background;
  79829. private _borderColor;
  79830. private _thumbColor;
  79831. private _isThumbCircle;
  79832. protected _displayValueBar: boolean;
  79833. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79834. get displayValueBar(): boolean;
  79835. set displayValueBar(value: boolean);
  79836. /** Gets or sets border color */
  79837. get borderColor(): string;
  79838. set borderColor(value: string);
  79839. /** Gets or sets background color */
  79840. get background(): string;
  79841. set background(value: string);
  79842. /** Gets or sets thumb's color */
  79843. get thumbColor(): string;
  79844. set thumbColor(value: string);
  79845. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79846. get isThumbCircle(): boolean;
  79847. set isThumbCircle(value: boolean);
  79848. /**
  79849. * Creates a new Slider
  79850. * @param name defines the control name
  79851. */
  79852. constructor(name?: string | undefined);
  79853. protected _getTypeName(): string;
  79854. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79855. }
  79856. }
  79857. declare module BABYLON.GUI {
  79858. /** Class used to create a RadioGroup
  79859. * which contains groups of radio buttons
  79860. */
  79861. export class SelectorGroup {
  79862. /** name of SelectorGroup */
  79863. name: string;
  79864. private _groupPanel;
  79865. private _selectors;
  79866. private _groupHeader;
  79867. /**
  79868. * Creates a new SelectorGroup
  79869. * @param name of group, used as a group heading
  79870. */
  79871. constructor(
  79872. /** name of SelectorGroup */
  79873. name: string);
  79874. /** Gets the groupPanel of the SelectorGroup */
  79875. get groupPanel(): StackPanel;
  79876. /** Gets the selectors array */
  79877. get selectors(): StackPanel[];
  79878. /** Gets and sets the group header */
  79879. get header(): string;
  79880. set header(label: string);
  79881. /** @hidden */
  79882. private _addGroupHeader;
  79883. /** @hidden*/
  79884. _getSelector(selectorNb: number): StackPanel | undefined;
  79885. /** Removes the selector at the given position
  79886. * @param selectorNb the position of the selector within the group
  79887. */
  79888. removeSelector(selectorNb: number): void;
  79889. }
  79890. /** Class used to create a CheckboxGroup
  79891. * which contains groups of checkbox buttons
  79892. */
  79893. export class CheckboxGroup extends SelectorGroup {
  79894. /** Adds a checkbox as a control
  79895. * @param text is the label for the selector
  79896. * @param func is the function called when the Selector is checked
  79897. * @param checked is true when Selector is checked
  79898. */
  79899. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79900. /** @hidden */
  79901. _setSelectorLabel(selectorNb: number, label: string): void;
  79902. /** @hidden */
  79903. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79904. /** @hidden */
  79905. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79906. /** @hidden */
  79907. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79908. }
  79909. /** Class used to create a RadioGroup
  79910. * which contains groups of radio buttons
  79911. */
  79912. export class RadioGroup extends SelectorGroup {
  79913. private _selectNb;
  79914. /** Adds a radio button as a control
  79915. * @param label is the label for the selector
  79916. * @param func is the function called when the Selector is checked
  79917. * @param checked is true when Selector is checked
  79918. */
  79919. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79920. /** @hidden */
  79921. _setSelectorLabel(selectorNb: number, label: string): void;
  79922. /** @hidden */
  79923. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79924. /** @hidden */
  79925. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79926. /** @hidden */
  79927. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79928. }
  79929. /** Class used to create a SliderGroup
  79930. * which contains groups of slider buttons
  79931. */
  79932. export class SliderGroup extends SelectorGroup {
  79933. /**
  79934. * Adds a slider to the SelectorGroup
  79935. * @param label is the label for the SliderBar
  79936. * @param func is the function called when the Slider moves
  79937. * @param unit is a string describing the units used, eg degrees or metres
  79938. * @param min is the minimum value for the Slider
  79939. * @param max is the maximum value for the Slider
  79940. * @param value is the start value for the Slider between min and max
  79941. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79942. */
  79943. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79944. /** @hidden */
  79945. _setSelectorLabel(selectorNb: number, label: string): void;
  79946. /** @hidden */
  79947. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79948. /** @hidden */
  79949. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79950. /** @hidden */
  79951. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79952. }
  79953. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79954. * @see https://doc.babylonjs.com/how_to/selector
  79955. */
  79956. export class SelectionPanel extends Rectangle {
  79957. /** name of SelectionPanel */
  79958. name: string;
  79959. /** an array of SelectionGroups */
  79960. groups: SelectorGroup[];
  79961. private _panel;
  79962. private _buttonColor;
  79963. private _buttonBackground;
  79964. private _headerColor;
  79965. private _barColor;
  79966. private _barHeight;
  79967. private _spacerHeight;
  79968. private _labelColor;
  79969. private _groups;
  79970. private _bars;
  79971. /**
  79972. * Creates a new SelectionPanel
  79973. * @param name of SelectionPanel
  79974. * @param groups is an array of SelectionGroups
  79975. */
  79976. constructor(
  79977. /** name of SelectionPanel */
  79978. name: string,
  79979. /** an array of SelectionGroups */
  79980. groups?: SelectorGroup[]);
  79981. protected _getTypeName(): string;
  79982. /** Gets the (stack) panel of the SelectionPanel */
  79983. get panel(): StackPanel;
  79984. /** Gets or sets the headerColor */
  79985. get headerColor(): string;
  79986. set headerColor(color: string);
  79987. private _setHeaderColor;
  79988. /** Gets or sets the button color */
  79989. get buttonColor(): string;
  79990. set buttonColor(color: string);
  79991. private _setbuttonColor;
  79992. /** Gets or sets the label color */
  79993. get labelColor(): string;
  79994. set labelColor(color: string);
  79995. private _setLabelColor;
  79996. /** Gets or sets the button background */
  79997. get buttonBackground(): string;
  79998. set buttonBackground(color: string);
  79999. private _setButtonBackground;
  80000. /** Gets or sets the color of separator bar */
  80001. get barColor(): string;
  80002. set barColor(color: string);
  80003. private _setBarColor;
  80004. /** Gets or sets the height of separator bar */
  80005. get barHeight(): string;
  80006. set barHeight(value: string);
  80007. private _setBarHeight;
  80008. /** Gets or sets the height of spacers*/
  80009. get spacerHeight(): string;
  80010. set spacerHeight(value: string);
  80011. private _setSpacerHeight;
  80012. /** Adds a bar between groups */
  80013. private _addSpacer;
  80014. /** Add a group to the selection panel
  80015. * @param group is the selector group to add
  80016. */
  80017. addGroup(group: SelectorGroup): void;
  80018. /** Remove the group from the given position
  80019. * @param groupNb is the position of the group in the list
  80020. */
  80021. removeGroup(groupNb: number): void;
  80022. /** Change a group header label
  80023. * @param label is the new group header label
  80024. * @param groupNb is the number of the group to relabel
  80025. * */
  80026. setHeaderName(label: string, groupNb: number): void;
  80027. /** Change selector label to the one given
  80028. * @param label is the new selector label
  80029. * @param groupNb is the number of the groupcontaining the selector
  80030. * @param selectorNb is the number of the selector within a group to relabel
  80031. * */
  80032. relabel(label: string, groupNb: number, selectorNb: number): void;
  80033. /** For a given group position remove the selector at the given position
  80034. * @param groupNb is the number of the group to remove the selector from
  80035. * @param selectorNb is the number of the selector within the group
  80036. */
  80037. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80038. /** For a given group position of correct type add a checkbox button
  80039. * @param groupNb is the number of the group to remove the selector from
  80040. * @param label is the label for the selector
  80041. * @param func is the function called when the Selector is checked
  80042. * @param checked is true when Selector is checked
  80043. */
  80044. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80045. /** For a given group position of correct type add a radio button
  80046. * @param groupNb is the number of the group to remove the selector from
  80047. * @param label is the label for the selector
  80048. * @param func is the function called when the Selector is checked
  80049. * @param checked is true when Selector is checked
  80050. */
  80051. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80052. /**
  80053. * For a given slider group add a slider
  80054. * @param groupNb is the number of the group to add the slider to
  80055. * @param label is the label for the Slider
  80056. * @param func is the function called when the Slider moves
  80057. * @param unit is a string describing the units used, eg degrees or metres
  80058. * @param min is the minimum value for the Slider
  80059. * @param max is the maximum value for the Slider
  80060. * @param value is the start value for the Slider between min and max
  80061. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80062. */
  80063. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80064. }
  80065. }
  80066. declare module BABYLON.GUI {
  80067. /**
  80068. * Class used to hold a the container for ScrollViewer
  80069. * @hidden
  80070. */
  80071. export class _ScrollViewerWindow extends Container {
  80072. parentClientWidth: number;
  80073. parentClientHeight: number;
  80074. private _freezeControls;
  80075. private _parentMeasure;
  80076. private _oldLeft;
  80077. private _oldTop;
  80078. get freezeControls(): boolean;
  80079. set freezeControls(value: boolean);
  80080. private _bucketWidth;
  80081. private _bucketHeight;
  80082. private _buckets;
  80083. private _bucketLen;
  80084. get bucketWidth(): number;
  80085. get bucketHeight(): number;
  80086. setBucketSizes(width: number, height: number): void;
  80087. private _useBuckets;
  80088. private _makeBuckets;
  80089. private _dispatchInBuckets;
  80090. private _updateMeasures;
  80091. private _updateChildrenMeasures;
  80092. private _restoreMeasures;
  80093. /**
  80094. * Creates a new ScrollViewerWindow
  80095. * @param name of ScrollViewerWindow
  80096. */
  80097. constructor(name?: string);
  80098. protected _getTypeName(): string;
  80099. /** @hidden */
  80100. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80101. /** @hidden */
  80102. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80103. private _scrollChildren;
  80104. private _scrollChildrenWithBuckets;
  80105. /** @hidden */
  80106. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80107. protected _postMeasure(): void;
  80108. }
  80109. }
  80110. declare module BABYLON.GUI {
  80111. /**
  80112. * Class used to create slider controls
  80113. */
  80114. export class ScrollBar extends BaseSlider {
  80115. name?: string | undefined;
  80116. private _background;
  80117. private _borderColor;
  80118. private _tempMeasure;
  80119. /** Gets or sets border color */
  80120. get borderColor(): string;
  80121. set borderColor(value: string);
  80122. /** Gets or sets background color */
  80123. get background(): string;
  80124. set background(value: string);
  80125. /**
  80126. * Creates a new Slider
  80127. * @param name defines the control name
  80128. */
  80129. constructor(name?: string | undefined);
  80130. protected _getTypeName(): string;
  80131. protected _getThumbThickness(): number;
  80132. _draw(context: CanvasRenderingContext2D): void;
  80133. private _first;
  80134. private _originX;
  80135. private _originY;
  80136. /** @hidden */
  80137. protected _updateValueFromPointer(x: number, y: number): void;
  80138. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80139. }
  80140. }
  80141. declare module BABYLON.GUI {
  80142. /**
  80143. * Class used to create slider controls
  80144. */
  80145. export class ImageScrollBar extends BaseSlider {
  80146. name?: string | undefined;
  80147. private _backgroundBaseImage;
  80148. private _backgroundImage;
  80149. private _thumbImage;
  80150. private _thumbBaseImage;
  80151. private _thumbLength;
  80152. private _thumbHeight;
  80153. private _barImageHeight;
  80154. private _tempMeasure;
  80155. /** Number of 90° rotation to apply on the images when in vertical mode */
  80156. num90RotationInVerticalMode: number;
  80157. /**
  80158. * Gets or sets the image used to render the background for horizontal bar
  80159. */
  80160. get backgroundImage(): Image;
  80161. set backgroundImage(value: Image);
  80162. /**
  80163. * Gets or sets the image used to render the thumb
  80164. */
  80165. get thumbImage(): Image;
  80166. set thumbImage(value: Image);
  80167. /**
  80168. * Gets or sets the length of the thumb
  80169. */
  80170. get thumbLength(): number;
  80171. set thumbLength(value: number);
  80172. /**
  80173. * Gets or sets the height of the thumb
  80174. */
  80175. get thumbHeight(): number;
  80176. set thumbHeight(value: number);
  80177. /**
  80178. * Gets or sets the height of the bar image
  80179. */
  80180. get barImageHeight(): number;
  80181. set barImageHeight(value: number);
  80182. /**
  80183. * Creates a new ImageScrollBar
  80184. * @param name defines the control name
  80185. */
  80186. constructor(name?: string | undefined);
  80187. protected _getTypeName(): string;
  80188. protected _getThumbThickness(): number;
  80189. _draw(context: CanvasRenderingContext2D): void;
  80190. private _first;
  80191. private _originX;
  80192. private _originY;
  80193. /** @hidden */
  80194. protected _updateValueFromPointer(x: number, y: number): void;
  80195. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80196. }
  80197. }
  80198. declare module BABYLON.GUI {
  80199. /**
  80200. * Class used to hold a viewer window and sliders in a grid
  80201. */
  80202. export class ScrollViewer extends Rectangle {
  80203. private _grid;
  80204. private _horizontalBarSpace;
  80205. private _verticalBarSpace;
  80206. private _dragSpace;
  80207. private _horizontalBar;
  80208. private _verticalBar;
  80209. private _barColor;
  80210. private _barBackground;
  80211. private _barImage;
  80212. private _horizontalBarImage;
  80213. private _verticalBarImage;
  80214. private _barBackgroundImage;
  80215. private _horizontalBarBackgroundImage;
  80216. private _verticalBarBackgroundImage;
  80217. private _barSize;
  80218. private _window;
  80219. private _pointerIsOver;
  80220. private _wheelPrecision;
  80221. private _onWheelObserver;
  80222. private _clientWidth;
  80223. private _clientHeight;
  80224. private _useImageBar;
  80225. private _thumbLength;
  80226. private _thumbHeight;
  80227. private _barImageHeight;
  80228. private _horizontalBarImageHeight;
  80229. private _verticalBarImageHeight;
  80230. private _oldWindowContentsWidth;
  80231. private _oldWindowContentsHeight;
  80232. /**
  80233. * Gets the horizontal scrollbar
  80234. */
  80235. get horizontalBar(): ScrollBar | ImageScrollBar;
  80236. /**
  80237. * Gets the vertical scrollbar
  80238. */
  80239. get verticalBar(): ScrollBar | ImageScrollBar;
  80240. /**
  80241. * Adds a new control to the current container
  80242. * @param control defines the control to add
  80243. * @returns the current container
  80244. */
  80245. addControl(control: BABYLON.Nullable<Control>): Container;
  80246. /**
  80247. * Removes a control from the current container
  80248. * @param control defines the control to remove
  80249. * @returns the current container
  80250. */
  80251. removeControl(control: Control): Container;
  80252. /** Gets the list of children */
  80253. get children(): Control[];
  80254. _flagDescendantsAsMatrixDirty(): void;
  80255. /**
  80256. * Freezes or unfreezes the controls in the window.
  80257. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80258. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80259. */
  80260. get freezeControls(): boolean;
  80261. set freezeControls(value: boolean);
  80262. /** Gets the bucket width */
  80263. get bucketWidth(): number;
  80264. /** Gets the bucket height */
  80265. get bucketHeight(): number;
  80266. /**
  80267. * Sets the bucket sizes.
  80268. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80269. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80270. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80271. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80272. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80273. * used), that's why it is not enabled by default.
  80274. * @param width width of the bucket
  80275. * @param height height of the bucket
  80276. */
  80277. setBucketSizes(width: number, height: number): void;
  80278. private _forceHorizontalBar;
  80279. private _forceVerticalBar;
  80280. /**
  80281. * Forces the horizontal scroll bar to be displayed
  80282. */
  80283. get forceHorizontalBar(): boolean;
  80284. set forceHorizontalBar(value: boolean);
  80285. /**
  80286. * Forces the vertical scroll bar to be displayed
  80287. */
  80288. get forceVerticalBar(): boolean;
  80289. set forceVerticalBar(value: boolean);
  80290. /**
  80291. * Creates a new ScrollViewer
  80292. * @param name of ScrollViewer
  80293. */
  80294. constructor(name?: string, isImageBased?: boolean);
  80295. /** Reset the scroll viewer window to initial size */
  80296. resetWindow(): void;
  80297. protected _getTypeName(): string;
  80298. private _buildClientSizes;
  80299. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80300. protected _postMeasure(): void;
  80301. /**
  80302. * Gets or sets the mouse wheel precision
  80303. * from 0 to 1 with a default value of 0.05
  80304. * */
  80305. get wheelPrecision(): number;
  80306. set wheelPrecision(value: number);
  80307. /** Gets or sets the scroll bar container background color */
  80308. get scrollBackground(): string;
  80309. set scrollBackground(color: string);
  80310. /** Gets or sets the bar color */
  80311. get barColor(): string;
  80312. set barColor(color: string);
  80313. /** Gets or sets the bar image */
  80314. get thumbImage(): Image;
  80315. set thumbImage(value: Image);
  80316. /** Gets or sets the horizontal bar image */
  80317. get horizontalThumbImage(): Image;
  80318. set horizontalThumbImage(value: Image);
  80319. /** Gets or sets the vertical bar image */
  80320. get verticalThumbImage(): Image;
  80321. set verticalThumbImage(value: Image);
  80322. /** Gets or sets the size of the bar */
  80323. get barSize(): number;
  80324. set barSize(value: number);
  80325. /** Gets or sets the length of the thumb */
  80326. get thumbLength(): number;
  80327. set thumbLength(value: number);
  80328. /** Gets or sets the height of the thumb */
  80329. get thumbHeight(): number;
  80330. set thumbHeight(value: number);
  80331. /** Gets or sets the height of the bar image */
  80332. get barImageHeight(): number;
  80333. set barImageHeight(value: number);
  80334. /** Gets or sets the height of the horizontal bar image */
  80335. get horizontalBarImageHeight(): number;
  80336. set horizontalBarImageHeight(value: number);
  80337. /** Gets or sets the height of the vertical bar image */
  80338. get verticalBarImageHeight(): number;
  80339. set verticalBarImageHeight(value: number);
  80340. /** Gets or sets the bar background */
  80341. get barBackground(): string;
  80342. set barBackground(color: string);
  80343. /** Gets or sets the bar background image */
  80344. get barImage(): Image;
  80345. set barImage(value: Image);
  80346. /** Gets or sets the horizontal bar background image */
  80347. get horizontalBarImage(): Image;
  80348. set horizontalBarImage(value: Image);
  80349. /** Gets or sets the vertical bar background image */
  80350. get verticalBarImage(): Image;
  80351. set verticalBarImage(value: Image);
  80352. private _setWindowPosition;
  80353. /** @hidden */
  80354. private _updateScroller;
  80355. _link(host: AdvancedDynamicTexture): void;
  80356. /** @hidden */
  80357. private _addBar;
  80358. /** @hidden */
  80359. private _attachWheel;
  80360. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80361. /** Releases associated resources */
  80362. dispose(): void;
  80363. }
  80364. }
  80365. declare module BABYLON.GUI {
  80366. /** Class used to render a grid */
  80367. export class DisplayGrid extends Control {
  80368. name?: string | undefined;
  80369. private _cellWidth;
  80370. private _cellHeight;
  80371. private _minorLineTickness;
  80372. private _minorLineColor;
  80373. private _majorLineTickness;
  80374. private _majorLineColor;
  80375. private _majorLineFrequency;
  80376. private _background;
  80377. private _displayMajorLines;
  80378. private _displayMinorLines;
  80379. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80380. get displayMinorLines(): boolean;
  80381. set displayMinorLines(value: boolean);
  80382. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80383. get displayMajorLines(): boolean;
  80384. set displayMajorLines(value: boolean);
  80385. /** Gets or sets background color (Black by default) */
  80386. get background(): string;
  80387. set background(value: string);
  80388. /** Gets or sets the width of each cell (20 by default) */
  80389. get cellWidth(): number;
  80390. set cellWidth(value: number);
  80391. /** Gets or sets the height of each cell (20 by default) */
  80392. get cellHeight(): number;
  80393. set cellHeight(value: number);
  80394. /** Gets or sets the tickness of minor lines (1 by default) */
  80395. get minorLineTickness(): number;
  80396. set minorLineTickness(value: number);
  80397. /** Gets or sets the color of minor lines (DarkGray by default) */
  80398. get minorLineColor(): string;
  80399. set minorLineColor(value: string);
  80400. /** Gets or sets the tickness of major lines (2 by default) */
  80401. get majorLineTickness(): number;
  80402. set majorLineTickness(value: number);
  80403. /** Gets or sets the color of major lines (White by default) */
  80404. get majorLineColor(): string;
  80405. set majorLineColor(value: string);
  80406. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80407. get majorLineFrequency(): number;
  80408. set majorLineFrequency(value: number);
  80409. /**
  80410. * Creates a new GridDisplayRectangle
  80411. * @param name defines the control name
  80412. */
  80413. constructor(name?: string | undefined);
  80414. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80415. protected _getTypeName(): string;
  80416. }
  80417. }
  80418. declare module BABYLON.GUI {
  80419. /**
  80420. * Class used to create slider controls based on images
  80421. */
  80422. export class ImageBasedSlider extends BaseSlider {
  80423. name?: string | undefined;
  80424. private _backgroundImage;
  80425. private _thumbImage;
  80426. private _valueBarImage;
  80427. private _tempMeasure;
  80428. get displayThumb(): boolean;
  80429. set displayThumb(value: boolean);
  80430. /**
  80431. * Gets or sets the image used to render the background
  80432. */
  80433. get backgroundImage(): Image;
  80434. set backgroundImage(value: Image);
  80435. /**
  80436. * Gets or sets the image used to render the value bar
  80437. */
  80438. get valueBarImage(): Image;
  80439. set valueBarImage(value: Image);
  80440. /**
  80441. * Gets or sets the image used to render the thumb
  80442. */
  80443. get thumbImage(): Image;
  80444. set thumbImage(value: Image);
  80445. /**
  80446. * Creates a new ImageBasedSlider
  80447. * @param name defines the control name
  80448. */
  80449. constructor(name?: string | undefined);
  80450. protected _getTypeName(): string;
  80451. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80452. }
  80453. }
  80454. declare module BABYLON.GUI {
  80455. /**
  80456. * Forcing an export so that this code will execute
  80457. * @hidden
  80458. */
  80459. const name = "Statics";
  80460. }
  80461. declare module BABYLON.GUI {
  80462. /**
  80463. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80464. */
  80465. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80466. /**
  80467. * Define the instrumented AdvancedDynamicTexture.
  80468. */
  80469. texture: AdvancedDynamicTexture;
  80470. private _captureRenderTime;
  80471. private _renderTime;
  80472. private _captureLayoutTime;
  80473. private _layoutTime;
  80474. private _onBeginRenderObserver;
  80475. private _onEndRenderObserver;
  80476. private _onBeginLayoutObserver;
  80477. private _onEndLayoutObserver;
  80478. /**
  80479. * Gets the perf counter used to capture render time
  80480. */
  80481. get renderTimeCounter(): BABYLON.PerfCounter;
  80482. /**
  80483. * Gets the perf counter used to capture layout time
  80484. */
  80485. get layoutTimeCounter(): BABYLON.PerfCounter;
  80486. /**
  80487. * Enable or disable the render time capture
  80488. */
  80489. get captureRenderTime(): boolean;
  80490. set captureRenderTime(value: boolean);
  80491. /**
  80492. * Enable or disable the layout time capture
  80493. */
  80494. get captureLayoutTime(): boolean;
  80495. set captureLayoutTime(value: boolean);
  80496. /**
  80497. * Instantiates a new advanced dynamic texture instrumentation.
  80498. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80499. * @param texture Defines the AdvancedDynamicTexture to instrument
  80500. */
  80501. constructor(
  80502. /**
  80503. * Define the instrumented AdvancedDynamicTexture.
  80504. */
  80505. texture: AdvancedDynamicTexture);
  80506. /**
  80507. * Dispose and release associated resources.
  80508. */
  80509. dispose(): void;
  80510. }
  80511. }
  80512. declare module BABYLON.GUI {
  80513. /**
  80514. * Class used to load GUI via XML.
  80515. */
  80516. export class XmlLoader {
  80517. private _nodes;
  80518. private _nodeTypes;
  80519. private _isLoaded;
  80520. private _objectAttributes;
  80521. private _parentClass;
  80522. /**
  80523. * Create a new xml loader
  80524. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80525. */
  80526. constructor(parentClass?: null);
  80527. private _getChainElement;
  80528. private _getClassAttribute;
  80529. private _createGuiElement;
  80530. private _parseGrid;
  80531. private _parseElement;
  80532. private _prepareSourceElement;
  80533. private _parseElementsFromSource;
  80534. private _parseXml;
  80535. /**
  80536. * Gets if the loading has finished.
  80537. * @returns whether the loading has finished or not
  80538. */
  80539. isLoaded(): boolean;
  80540. /**
  80541. * Gets a loaded node / control by id.
  80542. * @param id the Controls id set in the xml
  80543. * @returns element of type Control
  80544. */
  80545. getNodeById(id: string): any;
  80546. /**
  80547. * Gets all loaded nodes / controls
  80548. * @returns Array of controls
  80549. */
  80550. getNodes(): any;
  80551. /**
  80552. * Initiates the xml layout loading
  80553. * @param xmlFile defines the xml layout to load
  80554. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80555. * @param callback defines the callback called on layout load.
  80556. */
  80557. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80558. }
  80559. }
  80560. declare module BABYLON.GUI {
  80561. /**
  80562. * Class used to create containers for controls
  80563. */
  80564. export class Container3D extends Control3D {
  80565. private _blockLayout;
  80566. /**
  80567. * Gets the list of child controls
  80568. */
  80569. protected _children: Control3D[];
  80570. /**
  80571. * Gets the list of child controls
  80572. */
  80573. get children(): Array<Control3D>;
  80574. /**
  80575. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80576. * This is helpful to optimize layout operation when adding multiple children in a row
  80577. */
  80578. get blockLayout(): boolean;
  80579. set blockLayout(value: boolean);
  80580. /**
  80581. * Creates a new container
  80582. * @param name defines the container name
  80583. */
  80584. constructor(name?: string);
  80585. /**
  80586. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80587. * @returns the current container
  80588. */
  80589. updateLayout(): Container3D;
  80590. /**
  80591. * Gets a boolean indicating if the given control is in the children of this control
  80592. * @param control defines the control to check
  80593. * @returns true if the control is in the child list
  80594. */
  80595. containsControl(control: Control3D): boolean;
  80596. /**
  80597. * Adds a control to the children of this control
  80598. * @param control defines the control to add
  80599. * @returns the current container
  80600. */
  80601. addControl(control: Control3D): Container3D;
  80602. /**
  80603. * This function will be called everytime a new control is added
  80604. */
  80605. protected _arrangeChildren(): void;
  80606. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80607. /**
  80608. * Removes a control from the children of this control
  80609. * @param control defines the control to remove
  80610. * @returns the current container
  80611. */
  80612. removeControl(control: Control3D): Container3D;
  80613. protected _getTypeName(): string;
  80614. /**
  80615. * Releases all associated resources
  80616. */
  80617. dispose(): void;
  80618. /** Control rotation will remain unchanged */
  80619. static readonly UNSET_ORIENTATION: number;
  80620. /** Control will rotate to make it look at sphere central axis */
  80621. static readonly FACEORIGIN_ORIENTATION: number;
  80622. /** Control will rotate to make it look back at sphere central axis */
  80623. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80624. /** Control will rotate to look at z axis (0, 0, 1) */
  80625. static readonly FACEFORWARD_ORIENTATION: number;
  80626. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80627. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80628. }
  80629. }
  80630. declare module BABYLON.GUI {
  80631. /**
  80632. * Class used to manage 3D user interface
  80633. * @see https://doc.babylonjs.com/how_to/gui3d
  80634. */
  80635. export class GUI3DManager implements BABYLON.IDisposable {
  80636. private _scene;
  80637. private _sceneDisposeObserver;
  80638. private _utilityLayer;
  80639. private _rootContainer;
  80640. private _pointerObserver;
  80641. private _pointerOutObserver;
  80642. /** @hidden */
  80643. _lastPickedControl: Control3D;
  80644. /** @hidden */
  80645. _lastControlOver: {
  80646. [pointerId: number]: Control3D;
  80647. };
  80648. /** @hidden */
  80649. _lastControlDown: {
  80650. [pointerId: number]: Control3D;
  80651. };
  80652. /**
  80653. * BABYLON.Observable raised when the point picked by the pointer events changed
  80654. */
  80655. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80656. /** @hidden */
  80657. _sharedMaterials: {
  80658. [key: string]: BABYLON.Material;
  80659. };
  80660. /** Gets the hosting scene */
  80661. get scene(): BABYLON.Scene;
  80662. /** Gets associated utility layer */
  80663. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80664. /**
  80665. * Creates a new GUI3DManager
  80666. * @param scene
  80667. */
  80668. constructor(scene?: BABYLON.Scene);
  80669. private _handlePointerOut;
  80670. private _doPicking;
  80671. /**
  80672. * Gets the root container
  80673. */
  80674. get rootContainer(): Container3D;
  80675. /**
  80676. * Gets a boolean indicating if the given control is in the root child list
  80677. * @param control defines the control to check
  80678. * @returns true if the control is in the root child list
  80679. */
  80680. containsControl(control: Control3D): boolean;
  80681. /**
  80682. * Adds a control to the root child list
  80683. * @param control defines the control to add
  80684. * @returns the current manager
  80685. */
  80686. addControl(control: Control3D): GUI3DManager;
  80687. /**
  80688. * Removes a control from the root child list
  80689. * @param control defines the control to remove
  80690. * @returns the current container
  80691. */
  80692. removeControl(control: Control3D): GUI3DManager;
  80693. /**
  80694. * Releases all associated resources
  80695. */
  80696. dispose(): void;
  80697. }
  80698. }
  80699. declare module BABYLON.GUI {
  80700. /**
  80701. * Class used to transport BABYLON.Vector3 information for pointer events
  80702. */
  80703. export class Vector3WithInfo extends BABYLON.Vector3 {
  80704. /** defines the current mouse button index */
  80705. buttonIndex: number;
  80706. /**
  80707. * Creates a new Vector3WithInfo
  80708. * @param source defines the vector3 data to transport
  80709. * @param buttonIndex defines the current mouse button index
  80710. */
  80711. constructor(source: BABYLON.Vector3,
  80712. /** defines the current mouse button index */
  80713. buttonIndex?: number);
  80714. }
  80715. }
  80716. declare module BABYLON.GUI {
  80717. /**
  80718. * Class used as base class for controls
  80719. */
  80720. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80721. /** Defines the control name */
  80722. name?: string | undefined;
  80723. /** @hidden */
  80724. _host: GUI3DManager;
  80725. private _node;
  80726. private _downCount;
  80727. private _enterCount;
  80728. private _downPointerIds;
  80729. private _isVisible;
  80730. /** Gets or sets the control position in world space */
  80731. get position(): BABYLON.Vector3;
  80732. set position(value: BABYLON.Vector3);
  80733. /** Gets or sets the control scaling in world space */
  80734. get scaling(): BABYLON.Vector3;
  80735. set scaling(value: BABYLON.Vector3);
  80736. /** Callback used to start pointer enter animation */
  80737. pointerEnterAnimation: () => void;
  80738. /** Callback used to start pointer out animation */
  80739. pointerOutAnimation: () => void;
  80740. /** Callback used to start pointer down animation */
  80741. pointerDownAnimation: () => void;
  80742. /** Callback used to start pointer up animation */
  80743. pointerUpAnimation: () => void;
  80744. /**
  80745. * An event triggered when the pointer move over the control
  80746. */
  80747. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80748. /**
  80749. * An event triggered when the pointer move out of the control
  80750. */
  80751. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80752. /**
  80753. * An event triggered when the pointer taps the control
  80754. */
  80755. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80756. /**
  80757. * An event triggered when pointer is up
  80758. */
  80759. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80760. /**
  80761. * An event triggered when a control is clicked on (with a mouse)
  80762. */
  80763. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80764. /**
  80765. * An event triggered when pointer enters the control
  80766. */
  80767. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80768. /**
  80769. * Gets or sets the parent container
  80770. */
  80771. parent: BABYLON.Nullable<Container3D>;
  80772. private _behaviors;
  80773. /**
  80774. * Gets the list of attached behaviors
  80775. * @see https://doc.babylonjs.com/features/behaviour
  80776. */
  80777. get behaviors(): BABYLON.Behavior<Control3D>[];
  80778. /**
  80779. * Attach a behavior to the control
  80780. * @see https://doc.babylonjs.com/features/behaviour
  80781. * @param behavior defines the behavior to attach
  80782. * @returns the current control
  80783. */
  80784. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80785. /**
  80786. * Remove an attached behavior
  80787. * @see https://doc.babylonjs.com/features/behaviour
  80788. * @param behavior defines the behavior to attach
  80789. * @returns the current control
  80790. */
  80791. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80792. /**
  80793. * Gets an attached behavior by name
  80794. * @param name defines the name of the behavior to look for
  80795. * @see https://doc.babylonjs.com/features/behaviour
  80796. * @returns null if behavior was not found else the requested behavior
  80797. */
  80798. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80799. /** Gets or sets a boolean indicating if the control is visible */
  80800. get isVisible(): boolean;
  80801. set isVisible(value: boolean);
  80802. /**
  80803. * Creates a new control
  80804. * @param name defines the control name
  80805. */
  80806. constructor(
  80807. /** Defines the control name */
  80808. name?: string | undefined);
  80809. /**
  80810. * Gets a string representing the class name
  80811. */
  80812. get typeName(): string;
  80813. /**
  80814. * Get the current class name of the control.
  80815. * @returns current class name
  80816. */
  80817. getClassName(): string;
  80818. protected _getTypeName(): string;
  80819. /**
  80820. * Gets the transform node used by this control
  80821. */
  80822. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80823. /**
  80824. * Gets the mesh used to render this control
  80825. */
  80826. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80827. /**
  80828. * Link the control as child of the given node
  80829. * @param node defines the node to link to. Use null to unlink the control
  80830. * @returns the current control
  80831. */
  80832. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80833. /** @hidden **/
  80834. _prepareNode(scene: BABYLON.Scene): void;
  80835. /**
  80836. * Node creation.
  80837. * Can be overriden by children
  80838. * @param scene defines the scene where the node must be attached
  80839. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80840. */
  80841. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80842. /**
  80843. * Affect a material to the given mesh
  80844. * @param mesh defines the mesh which will represent the control
  80845. */
  80846. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80847. /** @hidden */
  80848. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80849. /** @hidden */
  80850. _onPointerEnter(target: Control3D): boolean;
  80851. /** @hidden */
  80852. _onPointerOut(target: Control3D): void;
  80853. /** @hidden */
  80854. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80855. /** @hidden */
  80856. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80857. /** @hidden */
  80858. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80859. /** @hidden */
  80860. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80861. /** @hidden */
  80862. _disposeNode(): void;
  80863. /**
  80864. * Releases all associated resources
  80865. */
  80866. dispose(): void;
  80867. }
  80868. }
  80869. declare module BABYLON.GUI {
  80870. /**
  80871. * Class used as a root to all buttons
  80872. */
  80873. export class AbstractButton3D extends Control3D {
  80874. /**
  80875. * Creates a new button
  80876. * @param name defines the control name
  80877. */
  80878. constructor(name?: string);
  80879. protected _getTypeName(): string;
  80880. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80881. }
  80882. }
  80883. declare module BABYLON.GUI {
  80884. /**
  80885. * Class used to create a button in 3D
  80886. */
  80887. export class Button3D extends AbstractButton3D {
  80888. /** @hidden */
  80889. protected _currentMaterial: BABYLON.Material;
  80890. private _facadeTexture;
  80891. private _content;
  80892. private _contentResolution;
  80893. private _contentScaleRatio;
  80894. /**
  80895. * Gets or sets the texture resolution used to render content (512 by default)
  80896. */
  80897. get contentResolution(): BABYLON.int;
  80898. set contentResolution(value: BABYLON.int);
  80899. /**
  80900. * Gets or sets the texture scale ratio used to render content (2 by default)
  80901. */
  80902. get contentScaleRatio(): number;
  80903. set contentScaleRatio(value: number);
  80904. protected _disposeFacadeTexture(): void;
  80905. protected _resetContent(): void;
  80906. /**
  80907. * Creates a new button
  80908. * @param name defines the control name
  80909. */
  80910. constructor(name?: string);
  80911. /**
  80912. * Gets or sets the GUI 2D content used to display the button's facade
  80913. */
  80914. get content(): Control;
  80915. set content(value: Control);
  80916. /**
  80917. * Apply the facade texture (created from the content property).
  80918. * This function can be overloaded by child classes
  80919. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80920. */
  80921. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80922. protected _getTypeName(): string;
  80923. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80924. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80925. /**
  80926. * Releases all associated resources
  80927. */
  80928. dispose(): void;
  80929. }
  80930. }
  80931. declare module BABYLON.GUI {
  80932. /**
  80933. * Abstract class used to create a container panel deployed on the surface of a volume
  80934. */
  80935. export abstract class VolumeBasedPanel extends Container3D {
  80936. private _columns;
  80937. private _rows;
  80938. private _rowThenColum;
  80939. private _orientation;
  80940. protected _cellWidth: number;
  80941. protected _cellHeight: number;
  80942. /**
  80943. * Gets or sets the distance between elements
  80944. */
  80945. margin: number;
  80946. /**
  80947. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80948. * | Value | Type | Description |
  80949. * | ----- | ----------------------------------- | ----------- |
  80950. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80951. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80952. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80953. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80954. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80955. */
  80956. get orientation(): number;
  80957. set orientation(value: number);
  80958. /**
  80959. * Gets or sets the number of columns requested (10 by default).
  80960. * The panel will automatically compute the number of rows based on number of child controls.
  80961. */
  80962. get columns(): BABYLON.int;
  80963. set columns(value: BABYLON.int);
  80964. /**
  80965. * Gets or sets a the number of rows requested.
  80966. * The panel will automatically compute the number of columns based on number of child controls.
  80967. */
  80968. get rows(): BABYLON.int;
  80969. set rows(value: BABYLON.int);
  80970. /**
  80971. * Creates new VolumeBasedPanel
  80972. */
  80973. constructor();
  80974. protected _arrangeChildren(): void;
  80975. /** Child classes must implement this function to provide correct control positioning */
  80976. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80977. /** Child classes can implement this function to provide additional processing */
  80978. protected _finalProcessing(): void;
  80979. }
  80980. }
  80981. declare module BABYLON.GUI {
  80982. /**
  80983. * Class used to create a container panel deployed on the surface of a cylinder
  80984. */
  80985. export class CylinderPanel extends VolumeBasedPanel {
  80986. private _radius;
  80987. /**
  80988. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80989. */
  80990. get radius(): BABYLON.float;
  80991. set radius(value: BABYLON.float);
  80992. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80993. private _cylindricalMapping;
  80994. }
  80995. }
  80996. declare module BABYLON.GUI {
  80997. /** @hidden */
  80998. export var fluentVertexShader: {
  80999. name: string;
  81000. shader: string;
  81001. };
  81002. }
  81003. declare module BABYLON.GUI {
  81004. /** @hidden */
  81005. export var fluentPixelShader: {
  81006. name: string;
  81007. shader: string;
  81008. };
  81009. }
  81010. declare module BABYLON.GUI {
  81011. /** @hidden */
  81012. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81013. INNERGLOW: boolean;
  81014. BORDER: boolean;
  81015. HOVERLIGHT: boolean;
  81016. TEXTURE: boolean;
  81017. constructor();
  81018. }
  81019. /**
  81020. * Class used to render controls with fluent desgin
  81021. */
  81022. export class FluentMaterial extends BABYLON.PushMaterial {
  81023. /**
  81024. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81025. */
  81026. innerGlowColorIntensity: number;
  81027. /**
  81028. * Gets or sets the inner glow color (white by default)
  81029. */
  81030. innerGlowColor: BABYLON.Color3;
  81031. /**
  81032. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81033. */
  81034. albedoColor: BABYLON.Color3;
  81035. /**
  81036. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81037. */
  81038. renderBorders: boolean;
  81039. /**
  81040. * Gets or sets border width (default is 0.5)
  81041. */
  81042. borderWidth: number;
  81043. /**
  81044. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81045. */
  81046. edgeSmoothingValue: number;
  81047. /**
  81048. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81049. */
  81050. borderMinValue: number;
  81051. /**
  81052. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81053. */
  81054. renderHoverLight: boolean;
  81055. /**
  81056. * Gets or sets the radius used to render the hover light (default is 1.0)
  81057. */
  81058. hoverRadius: number;
  81059. /**
  81060. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81061. */
  81062. hoverColor: BABYLON.Color4;
  81063. /**
  81064. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81065. */
  81066. hoverPosition: BABYLON.Vector3;
  81067. private _albedoTexture;
  81068. /** Gets or sets the texture to use for albedo color */
  81069. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81070. /**
  81071. * Creates a new Fluent material
  81072. * @param name defines the name of the material
  81073. * @param scene defines the hosting scene
  81074. */
  81075. constructor(name: string, scene: BABYLON.Scene);
  81076. needAlphaBlending(): boolean;
  81077. needAlphaTesting(): boolean;
  81078. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81081. getActiveTextures(): BABYLON.BaseTexture[];
  81082. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81083. dispose(forceDisposeEffect?: boolean): void;
  81084. clone(name: string): FluentMaterial;
  81085. serialize(): any;
  81086. getClassName(): string;
  81087. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81088. }
  81089. }
  81090. declare module BABYLON.GUI {
  81091. /**
  81092. * Class used to create a holographic button in 3D
  81093. */
  81094. export class HolographicButton extends Button3D {
  81095. private _backPlate;
  81096. private _textPlate;
  81097. private _frontPlate;
  81098. private _text;
  81099. private _imageUrl;
  81100. private _shareMaterials;
  81101. private _frontMaterial;
  81102. private _backMaterial;
  81103. private _plateMaterial;
  81104. private _pickedPointObserver;
  81105. private _tooltipFade;
  81106. private _tooltipTextBlock;
  81107. private _tooltipTexture;
  81108. private _tooltipMesh;
  81109. private _tooltipHoverObserver;
  81110. private _tooltipOutObserver;
  81111. private _disposeTooltip;
  81112. /**
  81113. * Rendering ground id of all the mesh in the button
  81114. */
  81115. set renderingGroupId(id: number);
  81116. get renderingGroupId(): number;
  81117. /**
  81118. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81119. */
  81120. set tooltipText(text: BABYLON.Nullable<string>);
  81121. get tooltipText(): BABYLON.Nullable<string>;
  81122. /**
  81123. * Gets or sets text for the button
  81124. */
  81125. get text(): string;
  81126. set text(value: string);
  81127. /**
  81128. * Gets or sets the image url for the button
  81129. */
  81130. get imageUrl(): string;
  81131. set imageUrl(value: string);
  81132. /**
  81133. * Gets the back material used by this button
  81134. */
  81135. get backMaterial(): FluentMaterial;
  81136. /**
  81137. * Gets the front material used by this button
  81138. */
  81139. get frontMaterial(): FluentMaterial;
  81140. /**
  81141. * Gets the plate material used by this button
  81142. */
  81143. get plateMaterial(): BABYLON.StandardMaterial;
  81144. /**
  81145. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81146. */
  81147. get shareMaterials(): boolean;
  81148. /**
  81149. * Creates a new button
  81150. * @param name defines the control name
  81151. */
  81152. constructor(name?: string, shareMaterials?: boolean);
  81153. protected _getTypeName(): string;
  81154. private _rebuildContent;
  81155. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81156. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81157. private _createBackMaterial;
  81158. private _createFrontMaterial;
  81159. private _createPlateMaterial;
  81160. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81161. /**
  81162. * Releases all associated resources
  81163. */
  81164. dispose(): void;
  81165. }
  81166. }
  81167. declare module BABYLON.GUI {
  81168. /**
  81169. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81170. */
  81171. export class MeshButton3D extends Button3D {
  81172. /** @hidden */
  81173. protected _currentMesh: BABYLON.Mesh;
  81174. /**
  81175. * Creates a new 3D button based on a mesh
  81176. * @param mesh mesh to become a 3D button
  81177. * @param name defines the control name
  81178. */
  81179. constructor(mesh: BABYLON.Mesh, name?: string);
  81180. protected _getTypeName(): string;
  81181. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81182. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81183. }
  81184. }
  81185. declare module BABYLON.GUI {
  81186. /**
  81187. * Class used to create a container panel deployed on the surface of a plane
  81188. */
  81189. export class PlanePanel extends VolumeBasedPanel {
  81190. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81191. }
  81192. }
  81193. declare module BABYLON.GUI {
  81194. /**
  81195. * Class used to create a container panel where items get randomized planar mapping
  81196. */
  81197. export class ScatterPanel extends VolumeBasedPanel {
  81198. private _iteration;
  81199. /**
  81200. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81201. */
  81202. get iteration(): BABYLON.float;
  81203. set iteration(value: BABYLON.float);
  81204. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81205. private _scatterMapping;
  81206. protected _finalProcessing(): void;
  81207. }
  81208. }
  81209. declare module BABYLON.GUI {
  81210. /**
  81211. * Class used to create a container panel deployed on the surface of a sphere
  81212. */
  81213. export class SpherePanel extends VolumeBasedPanel {
  81214. private _radius;
  81215. /**
  81216. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81217. */
  81218. get radius(): BABYLON.float;
  81219. set radius(value: BABYLON.float);
  81220. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81221. private _sphericalMapping;
  81222. }
  81223. }
  81224. declare module BABYLON.GUI {
  81225. /**
  81226. * Class used to create a stack panel in 3D on XY plane
  81227. */
  81228. export class StackPanel3D extends Container3D {
  81229. private _isVertical;
  81230. /**
  81231. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81232. */
  81233. get isVertical(): boolean;
  81234. set isVertical(value: boolean);
  81235. /**
  81236. * Gets or sets the distance between elements
  81237. */
  81238. margin: number;
  81239. /**
  81240. * Creates new StackPanel
  81241. * @param isVertical
  81242. */
  81243. constructor(isVertical?: boolean);
  81244. protected _arrangeChildren(): void;
  81245. }
  81246. }
  81247. declare module BABYLON {
  81248. /**
  81249. * Configuration for glTF validation
  81250. */
  81251. export interface IGLTFValidationConfiguration {
  81252. /**
  81253. * The url of the glTF validator.
  81254. */
  81255. url: string;
  81256. }
  81257. /**
  81258. * glTF validation
  81259. */
  81260. export class GLTFValidation {
  81261. /**
  81262. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81263. */
  81264. static Configuration: IGLTFValidationConfiguration;
  81265. private static _LoadScriptPromise;
  81266. /**
  81267. * Validate a glTF asset using the glTF-Validator.
  81268. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81269. * @param rootUrl The root url for the glTF
  81270. * @param fileName The file name for the glTF
  81271. * @param getExternalResource The callback to get external resources for the glTF validator
  81272. * @returns A promise that resolves with the glTF validation results once complete
  81273. */
  81274. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81275. }
  81276. }
  81277. declare module BABYLON {
  81278. /**
  81279. * Mode that determines the coordinate system to use.
  81280. */
  81281. export enum GLTFLoaderCoordinateSystemMode {
  81282. /**
  81283. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81284. */
  81285. AUTO = 0,
  81286. /**
  81287. * Sets the useRightHandedSystem flag on the scene.
  81288. */
  81289. FORCE_RIGHT_HANDED = 1
  81290. }
  81291. /**
  81292. * Mode that determines what animations will start.
  81293. */
  81294. export enum GLTFLoaderAnimationStartMode {
  81295. /**
  81296. * No animation will start.
  81297. */
  81298. NONE = 0,
  81299. /**
  81300. * The first animation will start.
  81301. */
  81302. FIRST = 1,
  81303. /**
  81304. * All animations will start.
  81305. */
  81306. ALL = 2
  81307. }
  81308. /**
  81309. * Interface that contains the data for the glTF asset.
  81310. */
  81311. export interface IGLTFLoaderData {
  81312. /**
  81313. * The object that represents the glTF JSON.
  81314. */
  81315. json: Object;
  81316. /**
  81317. * The BIN chunk of a binary glTF.
  81318. */
  81319. bin: Nullable<IDataBuffer>;
  81320. }
  81321. /**
  81322. * Interface for extending the loader.
  81323. */
  81324. export interface IGLTFLoaderExtension {
  81325. /**
  81326. * The name of this extension.
  81327. */
  81328. readonly name: string;
  81329. /**
  81330. * Defines whether this extension is enabled.
  81331. */
  81332. enabled: boolean;
  81333. /**
  81334. * Defines the order of this extension.
  81335. * The loader sorts the extensions using these values when loading.
  81336. */
  81337. order?: number;
  81338. }
  81339. /**
  81340. * Loader state.
  81341. */
  81342. export enum GLTFLoaderState {
  81343. /**
  81344. * The asset is loading.
  81345. */
  81346. LOADING = 0,
  81347. /**
  81348. * The asset is ready for rendering.
  81349. */
  81350. READY = 1,
  81351. /**
  81352. * The asset is completely loaded.
  81353. */
  81354. COMPLETE = 2
  81355. }
  81356. /** @hidden */
  81357. export interface IImportMeshAsyncOutput {
  81358. meshes: AbstractMesh[];
  81359. geometries: Geometry[];
  81360. particleSystems: IParticleSystem[];
  81361. skeletons: Skeleton[];
  81362. animationGroups: AnimationGroup[];
  81363. lights: Light[];
  81364. transformNodes: TransformNode[];
  81365. }
  81366. /** @hidden */
  81367. export interface IGLTFLoader extends IDisposable {
  81368. readonly state: Nullable<GLTFLoaderState>;
  81369. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81370. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81371. }
  81372. /**
  81373. * File loader for loading glTF files into a scene.
  81374. */
  81375. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81376. /** @hidden */
  81377. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81378. /** @hidden */
  81379. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81380. /**
  81381. * Raised when the asset has been parsed
  81382. */
  81383. onParsedObservable: Observable<IGLTFLoaderData>;
  81384. private _onParsedObserver;
  81385. /**
  81386. * Raised when the asset has been parsed
  81387. */
  81388. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81389. /**
  81390. * 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.
  81391. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81392. * Defaults to true.
  81393. * @hidden
  81394. */
  81395. static IncrementalLoading: boolean;
  81396. /**
  81397. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81398. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81399. * @hidden
  81400. */
  81401. static HomogeneousCoordinates: boolean;
  81402. /**
  81403. * The coordinate system mode. Defaults to AUTO.
  81404. */
  81405. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81406. /**
  81407. * The animation start mode. Defaults to FIRST.
  81408. */
  81409. animationStartMode: GLTFLoaderAnimationStartMode;
  81410. /**
  81411. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81412. */
  81413. compileMaterials: boolean;
  81414. /**
  81415. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81416. */
  81417. useClipPlane: boolean;
  81418. /**
  81419. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81420. */
  81421. compileShadowGenerators: boolean;
  81422. /**
  81423. * Defines if the Alpha blended materials are only applied as coverage.
  81424. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81425. * If true, no extra effects are applied to transparent pixels.
  81426. */
  81427. transparencyAsCoverage: boolean;
  81428. /**
  81429. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81430. * Enabling will disable offline support and glTF validator.
  81431. * Defaults to false.
  81432. */
  81433. useRangeRequests: boolean;
  81434. /**
  81435. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81436. */
  81437. createInstances: boolean;
  81438. /**
  81439. * 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.
  81440. */
  81441. alwaysComputeBoundingBox: boolean;
  81442. /**
  81443. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81444. */
  81445. loadAllMaterials: boolean;
  81446. /**
  81447. * Function called before loading a url referenced by the asset.
  81448. */
  81449. preprocessUrlAsync: (url: string) => Promise<string>;
  81450. /**
  81451. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81452. * 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, ...)
  81453. */
  81454. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81455. private _onMeshLoadedObserver;
  81456. /**
  81457. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81458. * 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, ...)
  81459. */
  81460. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81461. /**
  81462. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81463. */
  81464. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81465. private _onTextureLoadedObserver;
  81466. /**
  81467. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81468. */
  81469. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81470. /**
  81471. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81472. */
  81473. readonly onMaterialLoadedObservable: Observable<Material>;
  81474. private _onMaterialLoadedObserver;
  81475. /**
  81476. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81477. */
  81478. set onMaterialLoaded(callback: (material: Material) => void);
  81479. /**
  81480. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81481. */
  81482. readonly onCameraLoadedObservable: Observable<Camera>;
  81483. private _onCameraLoadedObserver;
  81484. /**
  81485. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81486. */
  81487. set onCameraLoaded(callback: (camera: Camera) => void);
  81488. /**
  81489. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81490. * For assets with LODs, raised when all of the LODs are complete.
  81491. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81492. */
  81493. readonly onCompleteObservable: Observable<void>;
  81494. private _onCompleteObserver;
  81495. /**
  81496. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81497. * For assets with LODs, raised when all of the LODs are complete.
  81498. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81499. */
  81500. set onComplete(callback: () => void);
  81501. /**
  81502. * Observable raised when an error occurs.
  81503. */
  81504. readonly onErrorObservable: Observable<any>;
  81505. private _onErrorObserver;
  81506. /**
  81507. * Callback raised when an error occurs.
  81508. */
  81509. set onError(callback: (reason: any) => void);
  81510. /**
  81511. * Observable raised after the loader is disposed.
  81512. */
  81513. readonly onDisposeObservable: Observable<void>;
  81514. private _onDisposeObserver;
  81515. /**
  81516. * Callback raised after the loader is disposed.
  81517. */
  81518. set onDispose(callback: () => void);
  81519. /**
  81520. * Observable raised after a loader extension is created.
  81521. * Set additional options for a loader extension in this event.
  81522. */
  81523. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81524. private _onExtensionLoadedObserver;
  81525. /**
  81526. * Callback raised after a loader extension is created.
  81527. */
  81528. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81529. /**
  81530. * Defines if the loader logging is enabled.
  81531. */
  81532. get loggingEnabled(): boolean;
  81533. set loggingEnabled(value: boolean);
  81534. /**
  81535. * Defines if the loader should capture performance counters.
  81536. */
  81537. get capturePerformanceCounters(): boolean;
  81538. set capturePerformanceCounters(value: boolean);
  81539. /**
  81540. * Defines if the loader should validate the asset.
  81541. */
  81542. validate: boolean;
  81543. /**
  81544. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81545. */
  81546. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81547. private _onValidatedObserver;
  81548. /**
  81549. * Callback raised after a loader extension is created.
  81550. */
  81551. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81552. private _loader;
  81553. private _progressCallback?;
  81554. private _requests;
  81555. private static magicBase64Encoded;
  81556. /**
  81557. * Name of the loader ("gltf")
  81558. */
  81559. name: string;
  81560. /** @hidden */
  81561. extensions: ISceneLoaderPluginExtensions;
  81562. /**
  81563. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81564. */
  81565. dispose(): void;
  81566. /** @hidden */
  81567. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81568. /** @hidden */
  81569. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81570. /** @hidden */
  81571. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81572. meshes: AbstractMesh[];
  81573. particleSystems: IParticleSystem[];
  81574. skeletons: Skeleton[];
  81575. animationGroups: AnimationGroup[];
  81576. }>;
  81577. /** @hidden */
  81578. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81579. /** @hidden */
  81580. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81581. /** @hidden */
  81582. canDirectLoad(data: string): boolean;
  81583. /** @hidden */
  81584. directLoad(scene: Scene, data: string): Promise<any>;
  81585. /**
  81586. * The callback that allows custom handling of the root url based on the response url.
  81587. * @param rootUrl the original root url
  81588. * @param responseURL the response url if available
  81589. * @returns the new root url
  81590. */
  81591. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81592. /** @hidden */
  81593. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81594. /**
  81595. * The loader state or null if the loader is not active.
  81596. */
  81597. get loaderState(): Nullable<GLTFLoaderState>;
  81598. /**
  81599. * Returns a promise that resolves when the asset is completely loaded.
  81600. * @returns a promise that resolves when the asset is completely loaded.
  81601. */
  81602. whenCompleteAsync(): Promise<void>;
  81603. /** @hidden */
  81604. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81605. /** @hidden */
  81606. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81607. private _onProgress;
  81608. private _validate;
  81609. private _getLoader;
  81610. private _parseJson;
  81611. private _unpackBinaryAsync;
  81612. private _unpackBinaryV1Async;
  81613. private _unpackBinaryV2Async;
  81614. private static _parseVersion;
  81615. private static _compareVersion;
  81616. private static readonly _logSpaces;
  81617. private _logIndentLevel;
  81618. private _loggingEnabled;
  81619. /** @hidden */
  81620. _log: (message: string) => void;
  81621. /** @hidden */
  81622. _logOpen(message: string): void;
  81623. /** @hidden */
  81624. _logClose(): void;
  81625. private _logEnabled;
  81626. private _logDisabled;
  81627. private _capturePerformanceCounters;
  81628. /** @hidden */
  81629. _startPerformanceCounter: (counterName: string) => void;
  81630. /** @hidden */
  81631. _endPerformanceCounter: (counterName: string) => void;
  81632. private _startPerformanceCounterEnabled;
  81633. private _startPerformanceCounterDisabled;
  81634. private _endPerformanceCounterEnabled;
  81635. private _endPerformanceCounterDisabled;
  81636. }
  81637. }
  81638. declare module BABYLON.GLTF1 {
  81639. /**
  81640. * Enums
  81641. * @hidden
  81642. */
  81643. export enum EComponentType {
  81644. BYTE = 5120,
  81645. UNSIGNED_BYTE = 5121,
  81646. SHORT = 5122,
  81647. UNSIGNED_SHORT = 5123,
  81648. FLOAT = 5126
  81649. }
  81650. /** @hidden */
  81651. export enum EShaderType {
  81652. FRAGMENT = 35632,
  81653. VERTEX = 35633
  81654. }
  81655. /** @hidden */
  81656. export enum EParameterType {
  81657. BYTE = 5120,
  81658. UNSIGNED_BYTE = 5121,
  81659. SHORT = 5122,
  81660. UNSIGNED_SHORT = 5123,
  81661. INT = 5124,
  81662. UNSIGNED_INT = 5125,
  81663. FLOAT = 5126,
  81664. FLOAT_VEC2 = 35664,
  81665. FLOAT_VEC3 = 35665,
  81666. FLOAT_VEC4 = 35666,
  81667. INT_VEC2 = 35667,
  81668. INT_VEC3 = 35668,
  81669. INT_VEC4 = 35669,
  81670. BOOL = 35670,
  81671. BOOL_VEC2 = 35671,
  81672. BOOL_VEC3 = 35672,
  81673. BOOL_VEC4 = 35673,
  81674. FLOAT_MAT2 = 35674,
  81675. FLOAT_MAT3 = 35675,
  81676. FLOAT_MAT4 = 35676,
  81677. SAMPLER_2D = 35678
  81678. }
  81679. /** @hidden */
  81680. export enum ETextureWrapMode {
  81681. CLAMP_TO_EDGE = 33071,
  81682. MIRRORED_REPEAT = 33648,
  81683. REPEAT = 10497
  81684. }
  81685. /** @hidden */
  81686. export enum ETextureFilterType {
  81687. NEAREST = 9728,
  81688. LINEAR = 9728,
  81689. NEAREST_MIPMAP_NEAREST = 9984,
  81690. LINEAR_MIPMAP_NEAREST = 9985,
  81691. NEAREST_MIPMAP_LINEAR = 9986,
  81692. LINEAR_MIPMAP_LINEAR = 9987
  81693. }
  81694. /** @hidden */
  81695. export enum ETextureFormat {
  81696. ALPHA = 6406,
  81697. RGB = 6407,
  81698. RGBA = 6408,
  81699. LUMINANCE = 6409,
  81700. LUMINANCE_ALPHA = 6410
  81701. }
  81702. /** @hidden */
  81703. export enum ECullingType {
  81704. FRONT = 1028,
  81705. BACK = 1029,
  81706. FRONT_AND_BACK = 1032
  81707. }
  81708. /** @hidden */
  81709. export enum EBlendingFunction {
  81710. ZERO = 0,
  81711. ONE = 1,
  81712. SRC_COLOR = 768,
  81713. ONE_MINUS_SRC_COLOR = 769,
  81714. DST_COLOR = 774,
  81715. ONE_MINUS_DST_COLOR = 775,
  81716. SRC_ALPHA = 770,
  81717. ONE_MINUS_SRC_ALPHA = 771,
  81718. DST_ALPHA = 772,
  81719. ONE_MINUS_DST_ALPHA = 773,
  81720. CONSTANT_COLOR = 32769,
  81721. ONE_MINUS_CONSTANT_COLOR = 32770,
  81722. CONSTANT_ALPHA = 32771,
  81723. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81724. SRC_ALPHA_SATURATE = 776
  81725. }
  81726. /** @hidden */
  81727. export interface IGLTFProperty {
  81728. extensions?: {
  81729. [key: string]: any;
  81730. };
  81731. extras?: Object;
  81732. }
  81733. /** @hidden */
  81734. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81735. name?: string;
  81736. }
  81737. /** @hidden */
  81738. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81739. bufferView: string;
  81740. byteOffset: number;
  81741. byteStride: number;
  81742. count: number;
  81743. type: string;
  81744. componentType: EComponentType;
  81745. max?: number[];
  81746. min?: number[];
  81747. name?: string;
  81748. }
  81749. /** @hidden */
  81750. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81751. buffer: string;
  81752. byteOffset: number;
  81753. byteLength: number;
  81754. byteStride: number;
  81755. target?: number;
  81756. }
  81757. /** @hidden */
  81758. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81759. uri: string;
  81760. byteLength?: number;
  81761. type?: string;
  81762. }
  81763. /** @hidden */
  81764. export interface IGLTFShader extends IGLTFChildRootProperty {
  81765. uri: string;
  81766. type: EShaderType;
  81767. }
  81768. /** @hidden */
  81769. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81770. attributes: string[];
  81771. fragmentShader: string;
  81772. vertexShader: string;
  81773. }
  81774. /** @hidden */
  81775. export interface IGLTFTechniqueParameter {
  81776. type: number;
  81777. count?: number;
  81778. semantic?: string;
  81779. node?: string;
  81780. value?: number | boolean | string | Array<any>;
  81781. source?: string;
  81782. babylonValue?: any;
  81783. }
  81784. /** @hidden */
  81785. export interface IGLTFTechniqueCommonProfile {
  81786. lightingModel: string;
  81787. texcoordBindings: Object;
  81788. parameters?: Array<any>;
  81789. }
  81790. /** @hidden */
  81791. export interface IGLTFTechniqueStatesFunctions {
  81792. blendColor?: number[];
  81793. blendEquationSeparate?: number[];
  81794. blendFuncSeparate?: number[];
  81795. colorMask: boolean[];
  81796. cullFace: number[];
  81797. }
  81798. /** @hidden */
  81799. export interface IGLTFTechniqueStates {
  81800. enable: number[];
  81801. functions: IGLTFTechniqueStatesFunctions;
  81802. }
  81803. /** @hidden */
  81804. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81805. parameters: {
  81806. [key: string]: IGLTFTechniqueParameter;
  81807. };
  81808. program: string;
  81809. attributes: {
  81810. [key: string]: string;
  81811. };
  81812. uniforms: {
  81813. [key: string]: string;
  81814. };
  81815. states: IGLTFTechniqueStates;
  81816. }
  81817. /** @hidden */
  81818. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81819. technique?: string;
  81820. values: string[];
  81821. }
  81822. /** @hidden */
  81823. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81824. attributes: {
  81825. [key: string]: string;
  81826. };
  81827. indices: string;
  81828. material: string;
  81829. mode?: number;
  81830. }
  81831. /** @hidden */
  81832. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81833. primitives: IGLTFMeshPrimitive[];
  81834. }
  81835. /** @hidden */
  81836. export interface IGLTFImage extends IGLTFChildRootProperty {
  81837. uri: string;
  81838. }
  81839. /** @hidden */
  81840. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81841. magFilter?: number;
  81842. minFilter?: number;
  81843. wrapS?: number;
  81844. wrapT?: number;
  81845. }
  81846. /** @hidden */
  81847. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81848. sampler: string;
  81849. source: string;
  81850. format?: ETextureFormat;
  81851. internalFormat?: ETextureFormat;
  81852. target?: number;
  81853. type?: number;
  81854. babylonTexture?: Texture;
  81855. }
  81856. /** @hidden */
  81857. export interface IGLTFAmbienLight {
  81858. color?: number[];
  81859. }
  81860. /** @hidden */
  81861. export interface IGLTFDirectionalLight {
  81862. color?: number[];
  81863. }
  81864. /** @hidden */
  81865. export interface IGLTFPointLight {
  81866. color?: number[];
  81867. constantAttenuation?: number;
  81868. linearAttenuation?: number;
  81869. quadraticAttenuation?: number;
  81870. }
  81871. /** @hidden */
  81872. export interface IGLTFSpotLight {
  81873. color?: number[];
  81874. constantAttenuation?: number;
  81875. fallOfAngle?: number;
  81876. fallOffExponent?: number;
  81877. linearAttenuation?: number;
  81878. quadraticAttenuation?: number;
  81879. }
  81880. /** @hidden */
  81881. export interface IGLTFLight extends IGLTFChildRootProperty {
  81882. type: string;
  81883. }
  81884. /** @hidden */
  81885. export interface IGLTFCameraOrthographic {
  81886. xmag: number;
  81887. ymag: number;
  81888. zfar: number;
  81889. znear: number;
  81890. }
  81891. /** @hidden */
  81892. export interface IGLTFCameraPerspective {
  81893. aspectRatio: number;
  81894. yfov: number;
  81895. zfar: number;
  81896. znear: number;
  81897. }
  81898. /** @hidden */
  81899. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81900. type: string;
  81901. }
  81902. /** @hidden */
  81903. export interface IGLTFAnimationChannelTarget {
  81904. id: string;
  81905. path: string;
  81906. }
  81907. /** @hidden */
  81908. export interface IGLTFAnimationChannel {
  81909. sampler: string;
  81910. target: IGLTFAnimationChannelTarget;
  81911. }
  81912. /** @hidden */
  81913. export interface IGLTFAnimationSampler {
  81914. input: string;
  81915. output: string;
  81916. interpolation?: string;
  81917. }
  81918. /** @hidden */
  81919. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81920. channels?: IGLTFAnimationChannel[];
  81921. parameters?: {
  81922. [key: string]: string;
  81923. };
  81924. samplers?: {
  81925. [key: string]: IGLTFAnimationSampler;
  81926. };
  81927. }
  81928. /** @hidden */
  81929. export interface IGLTFNodeInstanceSkin {
  81930. skeletons: string[];
  81931. skin: string;
  81932. meshes: string[];
  81933. }
  81934. /** @hidden */
  81935. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81936. bindShapeMatrix: number[];
  81937. inverseBindMatrices: string;
  81938. jointNames: string[];
  81939. babylonSkeleton?: Skeleton;
  81940. }
  81941. /** @hidden */
  81942. export interface IGLTFNode extends IGLTFChildRootProperty {
  81943. camera?: string;
  81944. children: string[];
  81945. skin?: string;
  81946. jointName?: string;
  81947. light?: string;
  81948. matrix: number[];
  81949. mesh?: string;
  81950. meshes?: string[];
  81951. rotation?: number[];
  81952. scale?: number[];
  81953. translation?: number[];
  81954. babylonNode?: Node;
  81955. }
  81956. /** @hidden */
  81957. export interface IGLTFScene extends IGLTFChildRootProperty {
  81958. nodes: string[];
  81959. }
  81960. /** @hidden */
  81961. export interface IGLTFRuntime {
  81962. extensions: {
  81963. [key: string]: any;
  81964. };
  81965. accessors: {
  81966. [key: string]: IGLTFAccessor;
  81967. };
  81968. buffers: {
  81969. [key: string]: IGLTFBuffer;
  81970. };
  81971. bufferViews: {
  81972. [key: string]: IGLTFBufferView;
  81973. };
  81974. meshes: {
  81975. [key: string]: IGLTFMesh;
  81976. };
  81977. lights: {
  81978. [key: string]: IGLTFLight;
  81979. };
  81980. cameras: {
  81981. [key: string]: IGLTFCamera;
  81982. };
  81983. nodes: {
  81984. [key: string]: IGLTFNode;
  81985. };
  81986. images: {
  81987. [key: string]: IGLTFImage;
  81988. };
  81989. textures: {
  81990. [key: string]: IGLTFTexture;
  81991. };
  81992. shaders: {
  81993. [key: string]: IGLTFShader;
  81994. };
  81995. programs: {
  81996. [key: string]: IGLTFProgram;
  81997. };
  81998. samplers: {
  81999. [key: string]: IGLTFSampler;
  82000. };
  82001. techniques: {
  82002. [key: string]: IGLTFTechnique;
  82003. };
  82004. materials: {
  82005. [key: string]: IGLTFMaterial;
  82006. };
  82007. animations: {
  82008. [key: string]: IGLTFAnimation;
  82009. };
  82010. skins: {
  82011. [key: string]: IGLTFSkins;
  82012. };
  82013. currentScene?: Object;
  82014. scenes: {
  82015. [key: string]: IGLTFScene;
  82016. };
  82017. extensionsUsed: string[];
  82018. extensionsRequired?: string[];
  82019. buffersCount: number;
  82020. shaderscount: number;
  82021. scene: Scene;
  82022. rootUrl: string;
  82023. loadedBufferCount: number;
  82024. loadedBufferViews: {
  82025. [name: string]: ArrayBufferView;
  82026. };
  82027. loadedShaderCount: number;
  82028. importOnlyMeshes: boolean;
  82029. importMeshesNames?: string[];
  82030. dummyNodes: Node[];
  82031. forAssetContainer: boolean;
  82032. }
  82033. /** @hidden */
  82034. export interface INodeToRoot {
  82035. bone: Bone;
  82036. node: IGLTFNode;
  82037. id: string;
  82038. }
  82039. /** @hidden */
  82040. export interface IJointNode {
  82041. node: IGLTFNode;
  82042. id: string;
  82043. }
  82044. }
  82045. declare module BABYLON.GLTF1 {
  82046. /**
  82047. * Utils functions for GLTF
  82048. * @hidden
  82049. */
  82050. export class GLTFUtils {
  82051. /**
  82052. * Sets the given "parameter" matrix
  82053. * @param scene: the Scene object
  82054. * @param source: the source node where to pick the matrix
  82055. * @param parameter: the GLTF technique parameter
  82056. * @param uniformName: the name of the shader's uniform
  82057. * @param shaderMaterial: the shader material
  82058. */
  82059. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82060. /**
  82061. * Sets the given "parameter" matrix
  82062. * @param shaderMaterial: the shader material
  82063. * @param uniform: the name of the shader's uniform
  82064. * @param value: the value of the uniform
  82065. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82066. */
  82067. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82068. /**
  82069. * Returns the wrap mode of the texture
  82070. * @param mode: the mode value
  82071. */
  82072. static GetWrapMode(mode: number): number;
  82073. /**
  82074. * Returns the byte stride giving an accessor
  82075. * @param accessor: the GLTF accessor objet
  82076. */
  82077. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82078. /**
  82079. * Returns the texture filter mode giving a mode value
  82080. * @param mode: the filter mode value
  82081. */
  82082. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82083. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82084. /**
  82085. * Returns a buffer from its accessor
  82086. * @param gltfRuntime: the GLTF runtime
  82087. * @param accessor: the GLTF accessor
  82088. */
  82089. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82090. /**
  82091. * Decodes a buffer view into a string
  82092. * @param view: the buffer view
  82093. */
  82094. static DecodeBufferToText(view: ArrayBufferView): string;
  82095. /**
  82096. * Returns the default material of gltf. Related to
  82097. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82098. * @param scene: the Babylon.js scene
  82099. */
  82100. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82101. private static _DefaultMaterial;
  82102. }
  82103. }
  82104. declare module BABYLON.GLTF1 {
  82105. /**
  82106. * Implementation of the base glTF spec
  82107. * @hidden
  82108. */
  82109. export class GLTFLoaderBase {
  82110. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82111. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82112. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82113. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82114. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82115. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82116. }
  82117. /**
  82118. * glTF V1 Loader
  82119. * @hidden
  82120. */
  82121. export class GLTFLoader implements IGLTFLoader {
  82122. static Extensions: {
  82123. [name: string]: GLTFLoaderExtension;
  82124. };
  82125. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82126. state: Nullable<GLTFLoaderState>;
  82127. dispose(): void;
  82128. private _importMeshAsync;
  82129. /**
  82130. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82131. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82132. * @param scene the scene the meshes should be added to
  82133. * @param forAssetContainer defines if the entities must be stored in the scene
  82134. * @param data gltf data containing information of the meshes in a loaded file
  82135. * @param rootUrl root url to load from
  82136. * @param onProgress event that fires when loading progress has occured
  82137. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82138. */
  82139. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82140. private _loadAsync;
  82141. /**
  82142. * Imports all objects from a loaded gltf file and adds them to the scene
  82143. * @param scene the scene the objects should be added to
  82144. * @param data gltf data containing information of the meshes in a loaded file
  82145. * @param rootUrl root url to load from
  82146. * @param onProgress event that fires when loading progress has occured
  82147. * @returns a promise which completes when objects have been loaded to the scene
  82148. */
  82149. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82150. private _loadShadersAsync;
  82151. private _loadBuffersAsync;
  82152. private _createNodes;
  82153. }
  82154. /** @hidden */
  82155. export abstract class GLTFLoaderExtension {
  82156. private _name;
  82157. constructor(name: string);
  82158. get name(): string;
  82159. /**
  82160. * Defines an override for loading the runtime
  82161. * Return true to stop further extensions from loading the runtime
  82162. */
  82163. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82164. /**
  82165. * Defines an onverride for creating gltf runtime
  82166. * Return true to stop further extensions from creating the runtime
  82167. */
  82168. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82169. /**
  82170. * Defines an override for loading buffers
  82171. * Return true to stop further extensions from loading this buffer
  82172. */
  82173. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82174. /**
  82175. * Defines an override for loading texture buffers
  82176. * Return true to stop further extensions from loading this texture data
  82177. */
  82178. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82179. /**
  82180. * Defines an override for creating textures
  82181. * Return true to stop further extensions from loading this texture
  82182. */
  82183. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82184. /**
  82185. * Defines an override for loading shader strings
  82186. * Return true to stop further extensions from loading this shader data
  82187. */
  82188. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82189. /**
  82190. * Defines an override for loading materials
  82191. * Return true to stop further extensions from loading this material
  82192. */
  82193. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82194. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82195. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82196. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82197. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82198. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82199. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82200. private static LoadTextureBufferAsync;
  82201. private static CreateTextureAsync;
  82202. private static ApplyExtensions;
  82203. }
  82204. }
  82205. declare module BABYLON.GLTF1 {
  82206. /** @hidden */
  82207. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82208. private _bin;
  82209. constructor();
  82210. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82211. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82212. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82213. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82214. }
  82215. }
  82216. declare module BABYLON.GLTF1 {
  82217. /** @hidden */
  82218. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82219. constructor();
  82220. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82221. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82222. private _loadTexture;
  82223. }
  82224. }
  82225. declare module BABYLON.GLTF2.Loader {
  82226. /**
  82227. * Loader interface with an index field.
  82228. */
  82229. export interface IArrayItem {
  82230. /**
  82231. * The index of this item in the array.
  82232. */
  82233. index: number;
  82234. }
  82235. /**
  82236. * Loader interface with additional members.
  82237. */
  82238. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82239. /** @hidden */
  82240. _data?: Promise<ArrayBufferView>;
  82241. /** @hidden */
  82242. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82243. }
  82244. /**
  82245. * Loader interface with additional members.
  82246. */
  82247. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82248. }
  82249. /** @hidden */
  82250. export interface _IAnimationSamplerData {
  82251. input: Float32Array;
  82252. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82253. output: Float32Array;
  82254. }
  82255. /**
  82256. * Loader interface with additional members.
  82257. */
  82258. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82259. /** @hidden */
  82260. _data?: Promise<_IAnimationSamplerData>;
  82261. }
  82262. /**
  82263. * Loader interface with additional members.
  82264. */
  82265. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82266. channels: IAnimationChannel[];
  82267. samplers: IAnimationSampler[];
  82268. /** @hidden */
  82269. _babylonAnimationGroup?: AnimationGroup;
  82270. }
  82271. /**
  82272. * Loader interface with additional members.
  82273. */
  82274. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82275. /** @hidden */
  82276. _data?: Promise<ArrayBufferView>;
  82277. }
  82278. /**
  82279. * Loader interface with additional members.
  82280. */
  82281. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82282. /** @hidden */
  82283. _data?: Promise<ArrayBufferView>;
  82284. /** @hidden */
  82285. _babylonBuffer?: Promise<Buffer>;
  82286. }
  82287. /**
  82288. * Loader interface with additional members.
  82289. */
  82290. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82291. }
  82292. /**
  82293. * Loader interface with additional members.
  82294. */
  82295. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82296. /** @hidden */
  82297. _data?: Promise<ArrayBufferView>;
  82298. }
  82299. /**
  82300. * Loader interface with additional members.
  82301. */
  82302. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82303. }
  82304. /**
  82305. * Loader interface with additional members.
  82306. */
  82307. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82308. }
  82309. /**
  82310. * Loader interface with additional members.
  82311. */
  82312. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82313. baseColorTexture?: ITextureInfo;
  82314. metallicRoughnessTexture?: ITextureInfo;
  82315. }
  82316. /**
  82317. * Loader interface with additional members.
  82318. */
  82319. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82320. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82321. normalTexture?: IMaterialNormalTextureInfo;
  82322. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82323. emissiveTexture?: ITextureInfo;
  82324. /** @hidden */
  82325. _data?: {
  82326. [babylonDrawMode: number]: {
  82327. babylonMaterial: Material;
  82328. babylonMeshes: AbstractMesh[];
  82329. promise: Promise<void>;
  82330. };
  82331. };
  82332. }
  82333. /**
  82334. * Loader interface with additional members.
  82335. */
  82336. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82337. primitives: IMeshPrimitive[];
  82338. }
  82339. /**
  82340. * Loader interface with additional members.
  82341. */
  82342. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82343. /** @hidden */
  82344. _instanceData?: {
  82345. babylonSourceMesh: Mesh;
  82346. promise: Promise<any>;
  82347. };
  82348. }
  82349. /**
  82350. * Loader interface with additional members.
  82351. */
  82352. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82353. /**
  82354. * The parent glTF node.
  82355. */
  82356. parent?: INode;
  82357. /** @hidden */
  82358. _babylonTransformNode?: TransformNode;
  82359. /** @hidden */
  82360. _primitiveBabylonMeshes?: AbstractMesh[];
  82361. /** @hidden */
  82362. _babylonBones?: Bone[];
  82363. /** @hidden */
  82364. _numMorphTargets?: number;
  82365. }
  82366. /** @hidden */
  82367. export interface _ISamplerData {
  82368. noMipMaps: boolean;
  82369. samplingMode: number;
  82370. wrapU: number;
  82371. wrapV: number;
  82372. }
  82373. /**
  82374. * Loader interface with additional members.
  82375. */
  82376. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82377. /** @hidden */
  82378. _data?: _ISamplerData;
  82379. }
  82380. /**
  82381. * Loader interface with additional members.
  82382. */
  82383. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82384. }
  82385. /**
  82386. * Loader interface with additional members.
  82387. */
  82388. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82389. /** @hidden */
  82390. _data?: {
  82391. babylonSkeleton: Skeleton;
  82392. promise: Promise<void>;
  82393. };
  82394. }
  82395. /**
  82396. * Loader interface with additional members.
  82397. */
  82398. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82399. }
  82400. /**
  82401. * Loader interface with additional members.
  82402. */
  82403. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82404. }
  82405. /**
  82406. * Loader interface with additional members.
  82407. */
  82408. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82409. accessors?: IAccessor[];
  82410. animations?: IAnimation[];
  82411. buffers?: IBuffer[];
  82412. bufferViews?: IBufferView[];
  82413. cameras?: ICamera[];
  82414. images?: IImage[];
  82415. materials?: IMaterial[];
  82416. meshes?: IMesh[];
  82417. nodes?: INode[];
  82418. samplers?: ISampler[];
  82419. scenes?: IScene[];
  82420. skins?: ISkin[];
  82421. textures?: ITexture[];
  82422. }
  82423. }
  82424. declare module BABYLON.GLTF2 {
  82425. /**
  82426. * Interface for a glTF loader extension.
  82427. */
  82428. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82429. /**
  82430. * Called after the loader state changes to LOADING.
  82431. */
  82432. onLoading?(): void;
  82433. /**
  82434. * Called after the loader state changes to READY.
  82435. */
  82436. onReady?(): void;
  82437. /**
  82438. * Define this method to modify the default behavior when loading scenes.
  82439. * @param context The context when loading the asset
  82440. * @param scene The glTF scene property
  82441. * @returns A promise that resolves when the load is complete or null if not handled
  82442. */
  82443. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82444. /**
  82445. * Define this method to modify the default behavior when loading nodes.
  82446. * @param context The context when loading the asset
  82447. * @param node The glTF node property
  82448. * @param assign A function called synchronously after parsing the glTF properties
  82449. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82450. */
  82451. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82452. /**
  82453. * Define this method to modify the default behavior when loading cameras.
  82454. * @param context The context when loading the asset
  82455. * @param camera The glTF camera property
  82456. * @param assign A function called synchronously after parsing the glTF properties
  82457. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82458. */
  82459. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82460. /**
  82461. * @hidden
  82462. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82463. * @param context The context when loading the asset
  82464. * @param primitive The glTF mesh primitive property
  82465. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82466. */
  82467. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82468. /**
  82469. * @hidden
  82470. * Define this method to modify the default behavior when loading data for mesh primitives.
  82471. * @param context The context when loading the asset
  82472. * @param name The mesh name when loading the asset
  82473. * @param node The glTF node when loading the asset
  82474. * @param mesh The glTF mesh when loading the asset
  82475. * @param primitive The glTF mesh primitive property
  82476. * @param assign A function called synchronously after parsing the glTF properties
  82477. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82478. */
  82479. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82480. /**
  82481. * @hidden
  82482. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82483. * @param context The context when loading the asset
  82484. * @param material The glTF material property
  82485. * @param assign A function called synchronously after parsing the glTF properties
  82486. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82487. */
  82488. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82489. /**
  82490. * Define this method to modify the default behavior when creating materials.
  82491. * @param context The context when loading the asset
  82492. * @param material The glTF material property
  82493. * @param babylonDrawMode The draw mode for the Babylon material
  82494. * @returns The Babylon material or null if not handled
  82495. */
  82496. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82497. /**
  82498. * Define this method to modify the default behavior when loading material properties.
  82499. * @param context The context when loading the asset
  82500. * @param material The glTF material property
  82501. * @param babylonMaterial The Babylon material
  82502. * @returns A promise that resolves when the load is complete or null if not handled
  82503. */
  82504. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82505. /**
  82506. * Define this method to modify the default behavior when loading texture infos.
  82507. * @param context The context when loading the asset
  82508. * @param textureInfo The glTF texture info property
  82509. * @param assign A function called synchronously after parsing the glTF properties
  82510. * @param textureDataType type of data held by the texture
  82511. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82512. */
  82513. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, textureDataType: TextureDataType): Nullable<Promise<BaseTexture>>;
  82514. /**
  82515. * @hidden
  82516. * Define this method to modify the default behavior when loading textures.
  82517. * @param context The context when loading the asset
  82518. * @param texture The glTF texture property
  82519. * @param assign A function called synchronously after parsing the glTF properties
  82520. * @param textureDataType type of data held by the texture
  82521. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82522. */
  82523. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, textureDataType: TextureDataType): Nullable<Promise<BaseTexture>>;
  82524. /**
  82525. * Define this method to modify the default behavior when loading animations.
  82526. * @param context The context when loading the asset
  82527. * @param animation The glTF animation property
  82528. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82529. */
  82530. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82531. /**
  82532. * @hidden
  82533. * Define this method to modify the default behavior when loading skins.
  82534. * @param context The context when loading the asset
  82535. * @param node The glTF node property
  82536. * @param skin The glTF skin property
  82537. * @returns A promise that resolves when the load is complete or null if not handled
  82538. */
  82539. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82540. /**
  82541. * @hidden
  82542. * Define this method to modify the default behavior when loading uris.
  82543. * @param context The context when loading the asset
  82544. * @param property The glTF property associated with the uri
  82545. * @param uri The uri to load
  82546. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82547. */
  82548. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82549. /**
  82550. * Define this method to modify the default behavior when loading buffer views.
  82551. * @param context The context when loading the asset
  82552. * @param bufferView The glTF buffer view property
  82553. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82554. */
  82555. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82556. /**
  82557. * Define this method to modify the default behavior when loading buffers.
  82558. * @param context The context when loading the asset
  82559. * @param buffer The glTF buffer property
  82560. * @param byteOffset The byte offset to load
  82561. * @param byteLength The byte length to load
  82562. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82563. */
  82564. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82565. }
  82566. }
  82567. declare module BABYLON.GLTF2 {
  82568. /**
  82569. * Type of data held by a texture
  82570. * @hidden
  82571. */
  82572. export enum TextureDataType {
  82573. /** color data (albedo, emissive, ...) */
  82574. Color = 0,
  82575. /** roughness data */
  82576. Roughness = 1,
  82577. /** normal map */
  82578. Normal = 2,
  82579. /** glossiness data */
  82580. Glossiness = 3,
  82581. /** specular map */
  82582. Specular = 4,
  82583. /** transmission map (thickness) */
  82584. Transmission = 5,
  82585. /** metallic/roughness data */
  82586. MetallicRoughness = 6,
  82587. /** occlusion data */
  82588. Occlusion = 7
  82589. }
  82590. /**
  82591. * Helper class for working with arrays when loading the glTF asset
  82592. */
  82593. export class ArrayItem {
  82594. /**
  82595. * Gets an item from the given array.
  82596. * @param context The context when loading the asset
  82597. * @param array The array to get the item from
  82598. * @param index The index to the array
  82599. * @returns The array item
  82600. */
  82601. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82602. /**
  82603. * Assign an `index` field to each item of the given array.
  82604. * @param array The array of items
  82605. */
  82606. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82607. }
  82608. /**
  82609. * The glTF 2.0 loader
  82610. */
  82611. export class GLTFLoader implements IGLTFLoader {
  82612. /** @hidden */
  82613. _completePromises: Promise<any>[];
  82614. /** @hidden */
  82615. _forAssetContainer: boolean;
  82616. /** Storage */
  82617. _babylonLights: Light[];
  82618. /** @hidden */
  82619. _disableInstancedMesh: number;
  82620. private _disposed;
  82621. private _parent;
  82622. private _state;
  82623. private _extensions;
  82624. private _rootUrl;
  82625. private _fileName;
  82626. private _uniqueRootUrl;
  82627. private _gltf;
  82628. private _bin;
  82629. private _babylonScene;
  82630. private _rootBabylonMesh;
  82631. private _defaultBabylonMaterialData;
  82632. private static _RegisteredExtensions;
  82633. /**
  82634. * The default glTF sampler.
  82635. */
  82636. static readonly DefaultSampler: ISampler;
  82637. /**
  82638. * Registers a loader extension.
  82639. * @param name The name of the loader extension.
  82640. * @param factory The factory function that creates the loader extension.
  82641. */
  82642. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82643. /**
  82644. * Unregisters a loader extension.
  82645. * @param name The name of the loader extension.
  82646. * @returns A boolean indicating whether the extension has been unregistered
  82647. */
  82648. static UnregisterExtension(name: string): boolean;
  82649. /**
  82650. * The loader state.
  82651. */
  82652. get state(): Nullable<GLTFLoaderState>;
  82653. /**
  82654. * The object that represents the glTF JSON.
  82655. */
  82656. get gltf(): IGLTF;
  82657. /**
  82658. * The BIN chunk of a binary glTF.
  82659. */
  82660. get bin(): Nullable<IDataBuffer>;
  82661. /**
  82662. * The parent file loader.
  82663. */
  82664. get parent(): GLTFFileLoader;
  82665. /**
  82666. * The Babylon scene when loading the asset.
  82667. */
  82668. get babylonScene(): Scene;
  82669. /**
  82670. * The root Babylon mesh when loading the asset.
  82671. */
  82672. get rootBabylonMesh(): Mesh;
  82673. /** @hidden */
  82674. constructor(parent: GLTFFileLoader);
  82675. /** @hidden */
  82676. dispose(): void;
  82677. /** @hidden */
  82678. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82679. /** @hidden */
  82680. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82681. private _loadAsync;
  82682. private _loadData;
  82683. private _setupData;
  82684. private _loadExtensions;
  82685. private _checkExtensions;
  82686. private _setState;
  82687. private _createRootNode;
  82688. /**
  82689. * Loads a glTF scene.
  82690. * @param context The context when loading the asset
  82691. * @param scene The glTF scene property
  82692. * @returns A promise that resolves when the load is complete
  82693. */
  82694. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82695. private _forEachPrimitive;
  82696. private _getGeometries;
  82697. private _getMeshes;
  82698. private _getTransformNodes;
  82699. private _getSkeletons;
  82700. private _getAnimationGroups;
  82701. private _startAnimations;
  82702. /**
  82703. * Loads a glTF node.
  82704. * @param context The context when loading the asset
  82705. * @param node The glTF node property
  82706. * @param assign A function called synchronously after parsing the glTF properties
  82707. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82708. */
  82709. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82710. private _loadMeshAsync;
  82711. /**
  82712. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82713. * @param context The context when loading the asset
  82714. * @param name The mesh name when loading the asset
  82715. * @param node The glTF node when loading the asset
  82716. * @param mesh The glTF mesh when loading the asset
  82717. * @param primitive The glTF mesh primitive property
  82718. * @param assign A function called synchronously after parsing the glTF properties
  82719. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82720. */
  82721. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82722. private _loadVertexDataAsync;
  82723. private _createMorphTargets;
  82724. private _loadMorphTargetsAsync;
  82725. private _loadMorphTargetVertexDataAsync;
  82726. private static _LoadTransform;
  82727. private _loadSkinAsync;
  82728. private _loadBones;
  82729. private _loadBone;
  82730. private _loadSkinInverseBindMatricesDataAsync;
  82731. private _updateBoneMatrices;
  82732. private _getNodeMatrix;
  82733. /**
  82734. * Loads a glTF camera.
  82735. * @param context The context when loading the asset
  82736. * @param camera The glTF camera property
  82737. * @param assign A function called synchronously after parsing the glTF properties
  82738. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82739. */
  82740. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82741. private _loadAnimationsAsync;
  82742. /**
  82743. * Loads a glTF animation.
  82744. * @param context The context when loading the asset
  82745. * @param animation The glTF animation property
  82746. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82747. */
  82748. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82749. /**
  82750. * @hidden Loads a glTF animation channel.
  82751. * @param context The context when loading the asset
  82752. * @param animationContext The context of the animation when loading the asset
  82753. * @param animation The glTF animation property
  82754. * @param channel The glTF animation channel property
  82755. * @param babylonAnimationGroup The babylon animation group property
  82756. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82757. * @returns A void promise when the channel load is complete
  82758. */
  82759. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82760. private _loadAnimationSamplerAsync;
  82761. private _loadBufferAsync;
  82762. /**
  82763. * Loads a glTF buffer view.
  82764. * @param context The context when loading the asset
  82765. * @param bufferView The glTF buffer view property
  82766. * @returns A promise that resolves with the loaded data when the load is complete
  82767. */
  82768. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82769. private _loadAccessorAsync;
  82770. /** @hidden */
  82771. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82772. private _loadIndicesAccessorAsync;
  82773. private _loadVertexBufferViewAsync;
  82774. private _loadVertexAccessorAsync;
  82775. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82776. /** @hidden */
  82777. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82778. private _createDefaultMaterial;
  82779. /**
  82780. * Creates a Babylon material from a glTF material.
  82781. * @param context The context when loading the asset
  82782. * @param material The glTF material property
  82783. * @param babylonDrawMode The draw mode for the Babylon material
  82784. * @returns The Babylon material
  82785. */
  82786. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82787. /**
  82788. * Loads properties from a glTF material into a Babylon material.
  82789. * @param context The context when loading the asset
  82790. * @param material The glTF material property
  82791. * @param babylonMaterial The Babylon material
  82792. * @returns A promise that resolves when the load is complete
  82793. */
  82794. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82795. /**
  82796. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82797. * @param context The context when loading the asset
  82798. * @param material The glTF material property
  82799. * @param babylonMaterial The Babylon material
  82800. * @returns A promise that resolves when the load is complete
  82801. */
  82802. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82803. /**
  82804. * Loads the alpha properties from a glTF material into a Babylon material.
  82805. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82806. * @param context The context when loading the asset
  82807. * @param material The glTF material property
  82808. * @param babylonMaterial The Babylon material
  82809. */
  82810. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82811. /**
  82812. * Loads a glTF texture info.
  82813. * @param context The context when loading the asset
  82814. * @param textureInfo The glTF texture info property
  82815. * @param assign A function called synchronously after parsing the glTF properties
  82816. * @param textureDataType type of data held by the texture
  82817. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82818. */
  82819. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void, textureDataType?: TextureDataType): Promise<BaseTexture>;
  82820. /** @hidden */
  82821. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void, textureDataType?: TextureDataType): Promise<BaseTexture>;
  82822. /** @hidden */
  82823. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  82824. private _loadSampler;
  82825. /**
  82826. * Loads a glTF image.
  82827. * @param context The context when loading the asset
  82828. * @param image The glTF image property
  82829. * @returns A promise that resolves with the loaded data when the load is complete
  82830. */
  82831. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82832. /**
  82833. * Loads a glTF uri.
  82834. * @param context The context when loading the asset
  82835. * @param property The glTF property associated with the uri
  82836. * @param uri The base64 or relative uri
  82837. * @returns A promise that resolves with the loaded data when the load is complete
  82838. */
  82839. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82840. /**
  82841. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82842. * @param babylonObject the Babylon object with metadata
  82843. * @param pointer the JSON pointer
  82844. */
  82845. static AddPointerMetadata(babylonObject: {
  82846. metadata: any;
  82847. }, pointer: string): void;
  82848. private static _GetTextureWrapMode;
  82849. private static _GetTextureSamplingMode;
  82850. private static _GetTypedArrayConstructor;
  82851. private static _GetTypedArray;
  82852. private static _GetNumComponents;
  82853. private static _ValidateUri;
  82854. /** @hidden */
  82855. static _GetDrawMode(context: string, mode: number | undefined): number;
  82856. private _compileMaterialsAsync;
  82857. private _compileShadowGeneratorsAsync;
  82858. private _forEachExtensions;
  82859. private _applyExtensions;
  82860. private _extensionsOnLoading;
  82861. private _extensionsOnReady;
  82862. private _extensionsLoadSceneAsync;
  82863. private _extensionsLoadNodeAsync;
  82864. private _extensionsLoadCameraAsync;
  82865. private _extensionsLoadVertexDataAsync;
  82866. private _extensionsLoadMeshPrimitiveAsync;
  82867. private _extensionsLoadMaterialAsync;
  82868. private _extensionsCreateMaterial;
  82869. private _extensionsLoadMaterialPropertiesAsync;
  82870. private _extensionsLoadTextureInfoAsync;
  82871. private _extensionsLoadTextureAsync;
  82872. private _extensionsLoadAnimationAsync;
  82873. private _extensionsLoadSkinAsync;
  82874. private _extensionsLoadUriAsync;
  82875. private _extensionsLoadBufferViewAsync;
  82876. private _extensionsLoadBufferAsync;
  82877. /**
  82878. * Helper method called by a loader extension to load an glTF extension.
  82879. * @param context The context when loading the asset
  82880. * @param property The glTF property to load the extension from
  82881. * @param extensionName The name of the extension to load
  82882. * @param actionAsync The action to run
  82883. * @returns The promise returned by actionAsync or null if the extension does not exist
  82884. */
  82885. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82886. /**
  82887. * Helper method called by a loader extension to load a glTF extra.
  82888. * @param context The context when loading the asset
  82889. * @param property The glTF property to load the extra from
  82890. * @param extensionName The name of the extension to load
  82891. * @param actionAsync The action to run
  82892. * @returns The promise returned by actionAsync or null if the extra does not exist
  82893. */
  82894. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82895. /**
  82896. * Checks for presence of an extension.
  82897. * @param name The name of the extension to check
  82898. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82899. */
  82900. isExtensionUsed(name: string): boolean;
  82901. /**
  82902. * Increments the indentation level and logs a message.
  82903. * @param message The message to log
  82904. */
  82905. logOpen(message: string): void;
  82906. /**
  82907. * Decrements the indentation level.
  82908. */
  82909. logClose(): void;
  82910. /**
  82911. * Logs a message
  82912. * @param message The message to log
  82913. */
  82914. log(message: string): void;
  82915. /**
  82916. * Starts a performance counter.
  82917. * @param counterName The name of the performance counter
  82918. */
  82919. startPerformanceCounter(counterName: string): void;
  82920. /**
  82921. * Ends a performance counter.
  82922. * @param counterName The name of the performance counter
  82923. */
  82924. endPerformanceCounter(counterName: string): void;
  82925. }
  82926. }
  82927. declare module BABYLON.GLTF2.Loader.Extensions {
  82928. /** @hidden */
  82929. interface IEXTLightsImageBased_LightImageBased {
  82930. _babylonTexture?: BaseTexture;
  82931. _loaded?: Promise<void>;
  82932. }
  82933. /**
  82934. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82935. */
  82936. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82937. /**
  82938. * The name of this extension.
  82939. */
  82940. readonly name: string;
  82941. /**
  82942. * Defines whether this extension is enabled.
  82943. */
  82944. enabled: boolean;
  82945. private _loader;
  82946. private _lights?;
  82947. /** @hidden */
  82948. constructor(loader: GLTFLoader);
  82949. /** @hidden */
  82950. dispose(): void;
  82951. /** @hidden */
  82952. onLoading(): void;
  82953. /** @hidden */
  82954. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82955. private _loadLightAsync;
  82956. }
  82957. }
  82958. declare module BABYLON.GLTF2.Loader.Extensions {
  82959. /**
  82960. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82961. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82962. * !!! Experimental Extension Subject to Changes !!!
  82963. */
  82964. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82965. /**
  82966. * The name of this extension.
  82967. */
  82968. readonly name: string;
  82969. /**
  82970. * Defines whether this extension is enabled.
  82971. */
  82972. enabled: boolean;
  82973. private _loader;
  82974. /** @hidden */
  82975. constructor(loader: GLTFLoader);
  82976. /** @hidden */
  82977. dispose(): void;
  82978. /** @hidden */
  82979. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82980. }
  82981. }
  82982. declare module BABYLON.GLTF2.Loader.Extensions {
  82983. /**
  82984. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82985. */
  82986. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82987. /** The name of this extension. */
  82988. readonly name: string;
  82989. /** Defines whether this extension is enabled. */
  82990. enabled: boolean;
  82991. private _loader;
  82992. /** @hidden */
  82993. constructor(loader: GLTFLoader);
  82994. /** @hidden */
  82995. dispose(): void;
  82996. /** @hidden */
  82997. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82998. }
  82999. }
  83000. declare module BABYLON.GLTF2.Loader.Extensions {
  83001. /**
  83002. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83003. */
  83004. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83005. /**
  83006. * The name of this extension.
  83007. */
  83008. readonly name: string;
  83009. /**
  83010. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83011. */
  83012. dracoCompression?: DracoCompression;
  83013. /**
  83014. * Defines whether this extension is enabled.
  83015. */
  83016. enabled: boolean;
  83017. private _loader;
  83018. /** @hidden */
  83019. constructor(loader: GLTFLoader);
  83020. /** @hidden */
  83021. dispose(): void;
  83022. /** @hidden */
  83023. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83024. }
  83025. }
  83026. declare module BABYLON.GLTF2.Loader.Extensions {
  83027. /**
  83028. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83029. */
  83030. export class KHR_lights implements IGLTFLoaderExtension {
  83031. /**
  83032. * The name of this extension.
  83033. */
  83034. readonly name: string;
  83035. /**
  83036. * Defines whether this extension is enabled.
  83037. */
  83038. enabled: boolean;
  83039. private _loader;
  83040. private _lights?;
  83041. /** @hidden */
  83042. constructor(loader: GLTFLoader);
  83043. /** @hidden */
  83044. dispose(): void;
  83045. /** @hidden */
  83046. onLoading(): void;
  83047. /** @hidden */
  83048. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83049. }
  83050. }
  83051. declare module BABYLON.GLTF2.Loader.Extensions {
  83052. /**
  83053. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83054. */
  83055. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83056. /**
  83057. * The name of this extension.
  83058. */
  83059. readonly name: string;
  83060. /**
  83061. * Defines whether this extension is enabled.
  83062. */
  83063. enabled: boolean;
  83064. /**
  83065. * Defines a number that determines the order the extensions are applied.
  83066. */
  83067. order: number;
  83068. private _loader;
  83069. /** @hidden */
  83070. constructor(loader: GLTFLoader);
  83071. /** @hidden */
  83072. dispose(): void;
  83073. /** @hidden */
  83074. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83075. private _loadSpecularGlossinessPropertiesAsync;
  83076. }
  83077. }
  83078. declare module BABYLON.GLTF2.Loader.Extensions {
  83079. /**
  83080. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83081. */
  83082. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83083. /**
  83084. * The name of this extension.
  83085. */
  83086. readonly name: string;
  83087. /**
  83088. * Defines whether this extension is enabled.
  83089. */
  83090. enabled: boolean;
  83091. /**
  83092. * Defines a number that determines the order the extensions are applied.
  83093. */
  83094. order: number;
  83095. private _loader;
  83096. /** @hidden */
  83097. constructor(loader: GLTFLoader);
  83098. /** @hidden */
  83099. dispose(): void;
  83100. /** @hidden */
  83101. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83102. private _loadUnlitPropertiesAsync;
  83103. }
  83104. }
  83105. declare module BABYLON.GLTF2.Loader.Extensions {
  83106. /**
  83107. * [Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  83108. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83109. */
  83110. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83111. /**
  83112. * The name of this extension.
  83113. */
  83114. readonly name: string;
  83115. /**
  83116. * Defines whether this extension is enabled.
  83117. */
  83118. enabled: boolean;
  83119. /**
  83120. * Defines a number that determines the order the extensions are applied.
  83121. */
  83122. order: number;
  83123. private _loader;
  83124. /** @hidden */
  83125. constructor(loader: GLTFLoader);
  83126. /** @hidden */
  83127. dispose(): void;
  83128. /** @hidden */
  83129. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83130. private _loadClearCoatPropertiesAsync;
  83131. }
  83132. }
  83133. declare module BABYLON.GLTF2.Loader.Extensions {
  83134. /**
  83135. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83136. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83137. * !!! Experimental Extension Subject to Changes !!!
  83138. */
  83139. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83140. /**
  83141. * The name of this extension.
  83142. */
  83143. readonly name: string;
  83144. /**
  83145. * Defines whether this extension is enabled.
  83146. */
  83147. enabled: boolean;
  83148. /**
  83149. * Defines a number that determines the order the extensions are applied.
  83150. */
  83151. order: number;
  83152. private _loader;
  83153. /** @hidden */
  83154. constructor(loader: GLTFLoader);
  83155. /** @hidden */
  83156. dispose(): void;
  83157. /** @hidden */
  83158. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83159. private _loadSheenPropertiesAsync;
  83160. }
  83161. }
  83162. declare module BABYLON.GLTF2.Loader.Extensions {
  83163. /**
  83164. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83165. * !!! Experimental Extension Subject to Changes !!!
  83166. */
  83167. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83168. /**
  83169. * The name of this extension.
  83170. */
  83171. readonly name: string;
  83172. /**
  83173. * Defines whether this extension is enabled.
  83174. */
  83175. enabled: boolean;
  83176. /**
  83177. * Defines a number that determines the order the extensions are applied.
  83178. */
  83179. order: number;
  83180. private _loader;
  83181. /** @hidden */
  83182. constructor(loader: GLTFLoader);
  83183. /** @hidden */
  83184. dispose(): void;
  83185. /** @hidden */
  83186. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83187. private _loadSpecularPropertiesAsync;
  83188. }
  83189. }
  83190. declare module BABYLON.GLTF2.Loader.Extensions {
  83191. /**
  83192. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83193. * !!! Experimental Extension Subject to Changes !!!
  83194. */
  83195. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83196. /**
  83197. * Default ior Value from the spec.
  83198. */
  83199. private static readonly _DEFAULT_IOR;
  83200. /**
  83201. * The name of this extension.
  83202. */
  83203. readonly name: string;
  83204. /**
  83205. * Defines whether this extension is enabled.
  83206. */
  83207. enabled: boolean;
  83208. /**
  83209. * Defines a number that determines the order the extensions are applied.
  83210. */
  83211. order: number;
  83212. private _loader;
  83213. /** @hidden */
  83214. constructor(loader: GLTFLoader);
  83215. /** @hidden */
  83216. dispose(): void;
  83217. /** @hidden */
  83218. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83219. private _loadIorPropertiesAsync;
  83220. }
  83221. }
  83222. declare module BABYLON.GLTF2.Loader.Extensions {
  83223. /**
  83224. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83225. * !!! Experimental Extension Subject to Changes !!!
  83226. */
  83227. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83228. /**
  83229. * The name of this extension.
  83230. */
  83231. readonly name: string;
  83232. /**
  83233. * Defines whether this extension is enabled.
  83234. */
  83235. enabled: boolean;
  83236. private _loader;
  83237. private _variants?;
  83238. /** @hidden */
  83239. constructor(loader: GLTFLoader);
  83240. /** @hidden */
  83241. dispose(): void;
  83242. /**
  83243. * Gets the list of available variant names for this asset.
  83244. * @param rootMesh The glTF root mesh
  83245. * @returns the list of all the variant names for this model
  83246. */
  83247. static GetAvailableVariants(rootMesh: Mesh): string[];
  83248. /**
  83249. * Gets the list of available variant names for this asset.
  83250. * @param rootMesh The glTF root mesh
  83251. * @returns the list of all the variant names for this model
  83252. */
  83253. getAvailableVariants(rootMesh: Mesh): string[];
  83254. /**
  83255. * Select a variant given a variant name or a list of variant names.
  83256. * @param rootMesh The glTF root mesh
  83257. * @param variantName The variant name(s) to select.
  83258. */
  83259. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83260. /**
  83261. * Select a variant given a variant name or a list of variant names.
  83262. * @param rootMesh The glTF root mesh
  83263. * @param variantName The variant name(s) to select.
  83264. */
  83265. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83266. /**
  83267. * Reset back to the original before selecting a variant.
  83268. * @param rootMesh The glTF root mesh
  83269. */
  83270. static Reset(rootMesh: Mesh): void;
  83271. /**
  83272. * Reset back to the original before selecting a variant.
  83273. * @param rootMesh The glTF root mesh
  83274. */
  83275. reset(rootMesh: Mesh): void;
  83276. /**
  83277. * Gets the last selected variant name(s) or null if original.
  83278. * @param rootMesh The glTF root mesh
  83279. * @returns The selected variant name(s).
  83280. */
  83281. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83282. /**
  83283. * Gets the last selected variant name(s) or null if original.
  83284. * @param rootMesh The glTF root mesh
  83285. * @returns The selected variant name(s).
  83286. */
  83287. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83288. private static _GetExtensionMetadata;
  83289. /** @hidden */
  83290. onLoading(): void;
  83291. /** @hidden */
  83292. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83293. }
  83294. }
  83295. declare module BABYLON.GLTF2.Loader.Extensions {
  83296. /**
  83297. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83298. * !!! Experimental Extension Subject to Changes !!!
  83299. */
  83300. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83301. /**
  83302. * The name of this extension.
  83303. */
  83304. readonly name: string;
  83305. /**
  83306. * Defines whether this extension is enabled.
  83307. */
  83308. enabled: boolean;
  83309. /**
  83310. * Defines a number that determines the order the extensions are applied.
  83311. */
  83312. order: number;
  83313. private _loader;
  83314. /** @hidden */
  83315. constructor(loader: GLTFLoader);
  83316. /** @hidden */
  83317. dispose(): void;
  83318. /** @hidden */
  83319. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83320. private _loadTransparentPropertiesAsync;
  83321. }
  83322. }
  83323. declare module BABYLON.GLTF2.Loader.Extensions {
  83324. /**
  83325. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83326. */
  83327. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83328. /**
  83329. * The name of this extension.
  83330. */
  83331. readonly name: string;
  83332. /**
  83333. * Defines whether this extension is enabled.
  83334. */
  83335. enabled: boolean;
  83336. /** @hidden */
  83337. constructor(loader: GLTFLoader);
  83338. /** @hidden */
  83339. dispose(): void;
  83340. }
  83341. }
  83342. declare module BABYLON.GLTF2.Loader.Extensions {
  83343. /**
  83344. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83345. * !!! Experimental Extension Subject to Changes !!!
  83346. */
  83347. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83348. /** The name of this extension. */
  83349. readonly name: string;
  83350. /** Defines whether this extension is enabled. */
  83351. enabled: boolean;
  83352. private _loader;
  83353. /** @hidden */
  83354. constructor(loader: GLTFLoader);
  83355. /** @hidden */
  83356. dispose(): void;
  83357. /** @hidden */
  83358. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, textureDataType?: TextureDataType): Nullable<Promise<BaseTexture>>;
  83359. }
  83360. }
  83361. declare module BABYLON.GLTF2.Loader.Extensions {
  83362. /**
  83363. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83364. */
  83365. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83366. /**
  83367. * The name of this extension.
  83368. */
  83369. readonly name: string;
  83370. /**
  83371. * Defines whether this extension is enabled.
  83372. */
  83373. enabled: boolean;
  83374. private _loader;
  83375. /** @hidden */
  83376. constructor(loader: GLTFLoader);
  83377. /** @hidden */
  83378. dispose(): void;
  83379. /** @hidden */
  83380. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, textureDataType?: TextureDataType): Nullable<Promise<BaseTexture>>;
  83381. }
  83382. }
  83383. declare module BABYLON.GLTF2.Loader.Extensions {
  83384. /**
  83385. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83386. * !!! Experimental Extension Subject to Changes !!!
  83387. */
  83388. export class KHR_xmp implements IGLTFLoaderExtension {
  83389. /**
  83390. * The name of this extension.
  83391. */
  83392. readonly name: string;
  83393. /**
  83394. * Defines whether this extension is enabled.
  83395. */
  83396. enabled: boolean;
  83397. /**
  83398. * Defines a number that determines the order the extensions are applied.
  83399. */
  83400. order: number;
  83401. private _loader;
  83402. /** @hidden */
  83403. constructor(loader: GLTFLoader);
  83404. /** @hidden */
  83405. dispose(): void;
  83406. /**
  83407. * Called after the loader state changes to LOADING.
  83408. */
  83409. onLoading(): void;
  83410. }
  83411. }
  83412. declare module BABYLON.GLTF2.Loader.Extensions {
  83413. /**
  83414. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83415. */
  83416. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83417. /**
  83418. * The name of this extension.
  83419. */
  83420. readonly name: string;
  83421. /**
  83422. * Defines whether this extension is enabled.
  83423. */
  83424. enabled: boolean;
  83425. private _loader;
  83426. private _clips;
  83427. private _emitters;
  83428. /** @hidden */
  83429. constructor(loader: GLTFLoader);
  83430. /** @hidden */
  83431. dispose(): void;
  83432. /** @hidden */
  83433. onLoading(): void;
  83434. /** @hidden */
  83435. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83436. /** @hidden */
  83437. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83438. /** @hidden */
  83439. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83440. private _loadClipAsync;
  83441. private _loadEmitterAsync;
  83442. private _getEventAction;
  83443. private _loadAnimationEventAsync;
  83444. }
  83445. }
  83446. declare module BABYLON.GLTF2.Loader.Extensions {
  83447. /**
  83448. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83449. */
  83450. export class MSFT_lod implements IGLTFLoaderExtension {
  83451. /**
  83452. * The name of this extension.
  83453. */
  83454. readonly name: string;
  83455. /**
  83456. * Defines whether this extension is enabled.
  83457. */
  83458. enabled: boolean;
  83459. /**
  83460. * Defines a number that determines the order the extensions are applied.
  83461. */
  83462. order: number;
  83463. /**
  83464. * Maximum number of LODs to load, starting from the lowest LOD.
  83465. */
  83466. maxLODsToLoad: number;
  83467. /**
  83468. * Observable raised when all node LODs of one level are loaded.
  83469. * The event data is the index of the loaded LOD starting from zero.
  83470. * Dispose the loader to cancel the loading of the next level of LODs.
  83471. */
  83472. onNodeLODsLoadedObservable: Observable<number>;
  83473. /**
  83474. * Observable raised when all material LODs of one level are loaded.
  83475. * The event data is the index of the loaded LOD starting from zero.
  83476. * Dispose the loader to cancel the loading of the next level of LODs.
  83477. */
  83478. onMaterialLODsLoadedObservable: Observable<number>;
  83479. private _loader;
  83480. private _bufferLODs;
  83481. private _nodeIndexLOD;
  83482. private _nodeSignalLODs;
  83483. private _nodePromiseLODs;
  83484. private _nodeBufferLODs;
  83485. private _materialIndexLOD;
  83486. private _materialSignalLODs;
  83487. private _materialPromiseLODs;
  83488. private _materialBufferLODs;
  83489. /** @hidden */
  83490. constructor(loader: GLTFLoader);
  83491. /** @hidden */
  83492. dispose(): void;
  83493. /** @hidden */
  83494. onReady(): void;
  83495. /** @hidden */
  83496. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83497. /** @hidden */
  83498. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83499. /** @hidden */
  83500. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83501. /** @hidden */
  83502. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83503. /** @hidden */
  83504. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83505. private _loadBufferLOD;
  83506. /**
  83507. * Gets an array of LOD properties from lowest to highest.
  83508. */
  83509. private _getLODs;
  83510. private _disposeTransformNode;
  83511. private _disposeMaterials;
  83512. }
  83513. }
  83514. declare module BABYLON.GLTF2.Loader.Extensions {
  83515. /** @hidden */
  83516. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83517. readonly name: string;
  83518. enabled: boolean;
  83519. private _loader;
  83520. constructor(loader: GLTFLoader);
  83521. dispose(): void;
  83522. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83523. }
  83524. }
  83525. declare module BABYLON.GLTF2.Loader.Extensions {
  83526. /** @hidden */
  83527. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83528. readonly name: string;
  83529. enabled: boolean;
  83530. private _loader;
  83531. constructor(loader: GLTFLoader);
  83532. dispose(): void;
  83533. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83534. }
  83535. }
  83536. declare module BABYLON.GLTF2.Loader.Extensions {
  83537. /**
  83538. * Store glTF extras (if present) in BJS objects' metadata
  83539. */
  83540. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83541. /**
  83542. * The name of this extension.
  83543. */
  83544. readonly name: string;
  83545. /**
  83546. * Defines whether this extension is enabled.
  83547. */
  83548. enabled: boolean;
  83549. private _loader;
  83550. private _assignExtras;
  83551. /** @hidden */
  83552. constructor(loader: GLTFLoader);
  83553. /** @hidden */
  83554. dispose(): void;
  83555. /** @hidden */
  83556. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83557. /** @hidden */
  83558. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83559. /** @hidden */
  83560. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83561. }
  83562. }
  83563. declare module BABYLON {
  83564. /**
  83565. * Class reading and parsing the MTL file bundled with the obj file.
  83566. */
  83567. export class MTLFileLoader {
  83568. /**
  83569. * Invert Y-Axis of referenced textures on load
  83570. */
  83571. static INVERT_TEXTURE_Y: boolean;
  83572. /**
  83573. * All material loaded from the mtl will be set here
  83574. */
  83575. materials: StandardMaterial[];
  83576. /**
  83577. * This function will read the mtl file and create each material described inside
  83578. * This function could be improve by adding :
  83579. * -some component missing (Ni, Tf...)
  83580. * -including the specific options available
  83581. *
  83582. * @param scene defines the scene the material will be created in
  83583. * @param data defines the mtl data to parse
  83584. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83585. * @param forAssetContainer defines if the material should be registered in the scene
  83586. */
  83587. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83588. /**
  83589. * Gets the texture for the material.
  83590. *
  83591. * If the material is imported from input file,
  83592. * We sanitize the url to ensure it takes the textre from aside the material.
  83593. *
  83594. * @param rootUrl The root url to load from
  83595. * @param value The value stored in the mtl
  83596. * @return The Texture
  83597. */
  83598. private static _getTexture;
  83599. }
  83600. }
  83601. declare module BABYLON {
  83602. /**
  83603. * Options for loading OBJ/MTL files
  83604. */
  83605. type MeshLoadOptions = {
  83606. /**
  83607. * Defines if UVs are optimized by default during load.
  83608. */
  83609. OptimizeWithUV: boolean;
  83610. /**
  83611. * Defines custom scaling of UV coordinates of loaded meshes.
  83612. */
  83613. UVScaling: Vector2;
  83614. /**
  83615. * Invert model on y-axis (does a model scaling inversion)
  83616. */
  83617. InvertY: boolean;
  83618. /**
  83619. * Invert Y-Axis of referenced textures on load
  83620. */
  83621. InvertTextureY: boolean;
  83622. /**
  83623. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83624. */
  83625. ImportVertexColors: boolean;
  83626. /**
  83627. * Compute the normals for the model, even if normals are present in the file.
  83628. */
  83629. ComputeNormals: boolean;
  83630. /**
  83631. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83632. */
  83633. SkipMaterials: boolean;
  83634. /**
  83635. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83636. */
  83637. MaterialLoadingFailsSilently: boolean;
  83638. };
  83639. /**
  83640. * OBJ file type loader.
  83641. * This is a babylon scene loader plugin.
  83642. */
  83643. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83644. /**
  83645. * Defines if UVs are optimized by default during load.
  83646. */
  83647. static OPTIMIZE_WITH_UV: boolean;
  83648. /**
  83649. * Invert model on y-axis (does a model scaling inversion)
  83650. */
  83651. static INVERT_Y: boolean;
  83652. /**
  83653. * Invert Y-Axis of referenced textures on load
  83654. */
  83655. static get INVERT_TEXTURE_Y(): boolean;
  83656. static set INVERT_TEXTURE_Y(value: boolean);
  83657. /**
  83658. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83659. */
  83660. static IMPORT_VERTEX_COLORS: boolean;
  83661. /**
  83662. * Compute the normals for the model, even if normals are present in the file.
  83663. */
  83664. static COMPUTE_NORMALS: boolean;
  83665. /**
  83666. * Defines custom scaling of UV coordinates of loaded meshes.
  83667. */
  83668. static UV_SCALING: Vector2;
  83669. /**
  83670. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83671. */
  83672. static SKIP_MATERIALS: boolean;
  83673. /**
  83674. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83675. *
  83676. * Defaults to true for backwards compatibility.
  83677. */
  83678. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83679. /**
  83680. * Defines the name of the plugin.
  83681. */
  83682. name: string;
  83683. /**
  83684. * Defines the extension the plugin is able to load.
  83685. */
  83686. extensions: string;
  83687. /** @hidden */
  83688. obj: RegExp;
  83689. /** @hidden */
  83690. group: RegExp;
  83691. /** @hidden */
  83692. mtllib: RegExp;
  83693. /** @hidden */
  83694. usemtl: RegExp;
  83695. /** @hidden */
  83696. smooth: RegExp;
  83697. /** @hidden */
  83698. vertexPattern: RegExp;
  83699. /** @hidden */
  83700. normalPattern: RegExp;
  83701. /** @hidden */
  83702. uvPattern: RegExp;
  83703. /** @hidden */
  83704. facePattern1: RegExp;
  83705. /** @hidden */
  83706. facePattern2: RegExp;
  83707. /** @hidden */
  83708. facePattern3: RegExp;
  83709. /** @hidden */
  83710. facePattern4: RegExp;
  83711. /** @hidden */
  83712. facePattern5: RegExp;
  83713. private _forAssetContainer;
  83714. private _meshLoadOptions;
  83715. /**
  83716. * Creates loader for .OBJ files
  83717. *
  83718. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83719. */
  83720. constructor(meshLoadOptions?: MeshLoadOptions);
  83721. private static get currentMeshLoadOptions();
  83722. /**
  83723. * Calls synchronously the MTL file attached to this obj.
  83724. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83725. * Without this function materials are not displayed in the first frame (but displayed after).
  83726. * In consequence it is impossible to get material information in your HTML file
  83727. *
  83728. * @param url The URL of the MTL file
  83729. * @param rootUrl
  83730. * @param onSuccess Callback function to be called when the MTL file is loaded
  83731. * @private
  83732. */
  83733. private _loadMTL;
  83734. /**
  83735. * Instantiates a OBJ file loader plugin.
  83736. * @returns the created plugin
  83737. */
  83738. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83739. /**
  83740. * If the data string can be loaded directly.
  83741. *
  83742. * @param data string containing the file data
  83743. * @returns if the data can be loaded directly
  83744. */
  83745. canDirectLoad(data: string): boolean;
  83746. /**
  83747. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83748. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83749. * @param scene the scene the meshes should be added to
  83750. * @param data the OBJ data to load
  83751. * @param rootUrl root url to load from
  83752. * @param onProgress event that fires when loading progress has occured
  83753. * @param fileName Defines the name of the file to load
  83754. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83755. */
  83756. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83757. meshes: AbstractMesh[];
  83758. particleSystems: IParticleSystem[];
  83759. skeletons: Skeleton[];
  83760. animationGroups: AnimationGroup[];
  83761. }>;
  83762. /**
  83763. * Imports all objects from the loaded OBJ data and adds them to the scene
  83764. * @param scene the scene the objects should be added to
  83765. * @param data the OBJ data to load
  83766. * @param rootUrl root url to load from
  83767. * @param onProgress event that fires when loading progress has occured
  83768. * @param fileName Defines the name of the file to load
  83769. * @returns a promise which completes when objects have been loaded to the scene
  83770. */
  83771. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83772. /**
  83773. * Load into an asset container.
  83774. * @param scene The scene to load into
  83775. * @param data The data to import
  83776. * @param rootUrl The root url for scene and resources
  83777. * @param onProgress The callback when the load progresses
  83778. * @param fileName Defines the name of the file to load
  83779. * @returns The loaded asset container
  83780. */
  83781. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83782. /**
  83783. * Read the OBJ file and create an Array of meshes.
  83784. * Each mesh contains all information given by the OBJ and the MTL file.
  83785. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83786. *
  83787. * @param meshesNames
  83788. * @param scene Scene The scene where are displayed the data
  83789. * @param data String The content of the obj file
  83790. * @param rootUrl String The path to the folder
  83791. * @returns Array<AbstractMesh>
  83792. * @private
  83793. */
  83794. private _parseSolid;
  83795. }
  83796. }
  83797. declare module BABYLON {
  83798. /**
  83799. * STL file type loader.
  83800. * This is a babylon scene loader plugin.
  83801. */
  83802. export class STLFileLoader implements ISceneLoaderPlugin {
  83803. /** @hidden */
  83804. solidPattern: RegExp;
  83805. /** @hidden */
  83806. facetsPattern: RegExp;
  83807. /** @hidden */
  83808. normalPattern: RegExp;
  83809. /** @hidden */
  83810. vertexPattern: RegExp;
  83811. /**
  83812. * Defines the name of the plugin.
  83813. */
  83814. name: string;
  83815. /**
  83816. * Defines the extensions the stl loader is able to load.
  83817. * force data to come in as an ArrayBuffer
  83818. * we'll convert to string if it looks like it's an ASCII .stl
  83819. */
  83820. extensions: ISceneLoaderPluginExtensions;
  83821. /**
  83822. * Import meshes into a scene.
  83823. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83824. * @param scene The scene to import into
  83825. * @param data The data to import
  83826. * @param rootUrl The root url for scene and resources
  83827. * @param meshes The meshes array to import into
  83828. * @param particleSystems The particle systems array to import into
  83829. * @param skeletons The skeletons array to import into
  83830. * @param onError The callback when import fails
  83831. * @returns True if successful or false otherwise
  83832. */
  83833. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83834. /**
  83835. * Load into a scene.
  83836. * @param scene The scene to load into
  83837. * @param data The data to import
  83838. * @param rootUrl The root url for scene and resources
  83839. * @param onError The callback when import fails
  83840. * @returns true if successful or false otherwise
  83841. */
  83842. load(scene: Scene, data: any, rootUrl: string): boolean;
  83843. /**
  83844. * Load into an asset container.
  83845. * @param scene The scene to load into
  83846. * @param data The data to import
  83847. * @param rootUrl The root url for scene and resources
  83848. * @param onError The callback when import fails
  83849. * @returns The loaded asset container
  83850. */
  83851. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83852. private _isBinary;
  83853. private _parseBinary;
  83854. private _parseASCII;
  83855. }
  83856. }
  83857. declare module BABYLON {
  83858. /**
  83859. * Class for generating OBJ data from a Babylon scene.
  83860. */
  83861. export class OBJExport {
  83862. /**
  83863. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83864. * @param mesh defines the list of meshes to serialize
  83865. * @param materials defines if materials should be exported
  83866. * @param matlibname defines the name of the associated mtl file
  83867. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83868. * @returns the OBJ content
  83869. */
  83870. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83871. /**
  83872. * Exports the material(s) of a mesh in .MTL file format (text)
  83873. * @param mesh defines the mesh to extract the material from
  83874. * @returns the mtl content
  83875. */
  83876. static MTL(mesh: Mesh): string;
  83877. }
  83878. }
  83879. declare module BABYLON {
  83880. /** @hidden */
  83881. export var __IGLTFExporterExtension: number;
  83882. /**
  83883. * Interface for extending the exporter
  83884. * @hidden
  83885. */
  83886. export interface IGLTFExporterExtension {
  83887. /**
  83888. * The name of this extension
  83889. */
  83890. readonly name: string;
  83891. /**
  83892. * Defines whether this extension is enabled
  83893. */
  83894. enabled: boolean;
  83895. /**
  83896. * Defines whether this extension is required
  83897. */
  83898. required: boolean;
  83899. }
  83900. }
  83901. declare module BABYLON.GLTF2.Exporter {
  83902. /** @hidden */
  83903. export var __IGLTFExporterExtensionV2: number;
  83904. /**
  83905. * Interface for a glTF exporter extension
  83906. * @hidden
  83907. */
  83908. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83909. /**
  83910. * Define this method to modify the default behavior before exporting a texture
  83911. * @param context The context when loading the asset
  83912. * @param babylonTexture The Babylon.js texture
  83913. * @param mimeType The mime-type of the generated image
  83914. * @returns A promise that resolves with the exported texture
  83915. */
  83916. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83917. /**
  83918. * Define this method to get notified when a texture info is created
  83919. * @param context The context when loading the asset
  83920. * @param textureInfo The glTF texture info
  83921. * @param babylonTexture The Babylon.js texture
  83922. */
  83923. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83924. /**
  83925. * Define this method to modify the default behavior when exporting texture info
  83926. * @param context The context when loading the asset
  83927. * @param meshPrimitive glTF mesh primitive
  83928. * @param babylonSubMesh Babylon submesh
  83929. * @param binaryWriter glTF serializer binary writer instance
  83930. * @returns nullable IMeshPrimitive promise
  83931. */
  83932. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83933. /**
  83934. * Define this method to modify the default behavior when exporting a node
  83935. * @param context The context when exporting the node
  83936. * @param node glTF node
  83937. * @param babylonNode BabylonJS node
  83938. * @returns nullable INode promise
  83939. */
  83940. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83941. [key: number]: number;
  83942. }): Promise<Nullable<INode>>;
  83943. /**
  83944. * Define this method to modify the default behavior when exporting a material
  83945. * @param material glTF material
  83946. * @param babylonMaterial BabylonJS material
  83947. * @returns nullable IMaterial promise
  83948. */
  83949. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83950. /**
  83951. * Define this method to return additional textures to export from a material
  83952. * @param material glTF material
  83953. * @param babylonMaterial BabylonJS material
  83954. * @returns List of textures
  83955. */
  83956. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83957. /** Gets a boolean indicating that this extension was used */
  83958. wasUsed: boolean;
  83959. /** Gets a boolean indicating that this extension is required for the file to work */
  83960. required: boolean;
  83961. /**
  83962. * Called after the exporter state changes to EXPORTING
  83963. */
  83964. onExporting?(): void;
  83965. }
  83966. }
  83967. declare module BABYLON.GLTF2.Exporter {
  83968. /**
  83969. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83970. * @hidden
  83971. */
  83972. export class _GLTFMaterialExporter {
  83973. /**
  83974. * Represents the dielectric specular values for R, G and B
  83975. */
  83976. private static readonly _DielectricSpecular;
  83977. /**
  83978. * Allows the maximum specular power to be defined for material calculations
  83979. */
  83980. private static readonly _MaxSpecularPower;
  83981. /**
  83982. * Mapping to store textures
  83983. */
  83984. private _textureMap;
  83985. /**
  83986. * Numeric tolerance value
  83987. */
  83988. private static readonly _Epsilon;
  83989. /**
  83990. * Reference to the glTF Exporter
  83991. */
  83992. private _exporter;
  83993. constructor(exporter: _Exporter);
  83994. /**
  83995. * Specifies if two colors are approximately equal in value
  83996. * @param color1 first color to compare to
  83997. * @param color2 second color to compare to
  83998. * @param epsilon threshold value
  83999. */
  84000. private static FuzzyEquals;
  84001. /**
  84002. * Gets the materials from a Babylon scene and converts them to glTF materials
  84003. * @param scene babylonjs scene
  84004. * @param mimeType texture mime type
  84005. * @param images array of images
  84006. * @param textures array of textures
  84007. * @param materials array of materials
  84008. * @param imageData mapping of texture names to base64 textures
  84009. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84010. */
  84011. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84012. /**
  84013. * Makes a copy of the glTF material without the texture parameters
  84014. * @param originalMaterial original glTF material
  84015. * @returns glTF material without texture parameters
  84016. */
  84017. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84018. /**
  84019. * Specifies if the material has any texture parameters present
  84020. * @param material glTF Material
  84021. * @returns boolean specifying if texture parameters are present
  84022. */
  84023. _hasTexturesPresent(material: IMaterial): boolean;
  84024. /**
  84025. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84026. * @param babylonStandardMaterial
  84027. * @returns glTF Metallic Roughness Material representation
  84028. */
  84029. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84030. /**
  84031. * Computes the metallic factor
  84032. * @param diffuse diffused value
  84033. * @param specular specular value
  84034. * @param oneMinusSpecularStrength one minus the specular strength
  84035. * @returns metallic value
  84036. */
  84037. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84038. /**
  84039. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84040. * @param glTFMaterial glTF material
  84041. * @param babylonMaterial Babylon material
  84042. */
  84043. private static _SetAlphaMode;
  84044. /**
  84045. * Converts a Babylon Standard Material to a glTF Material
  84046. * @param babylonStandardMaterial BJS Standard Material
  84047. * @param mimeType mime type to use for the textures
  84048. * @param images array of glTF image interfaces
  84049. * @param textures array of glTF texture interfaces
  84050. * @param materials array of glTF material interfaces
  84051. * @param imageData map of image file name to data
  84052. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84053. */
  84054. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84055. private _finishMaterial;
  84056. /**
  84057. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84058. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84059. * @param mimeType mime type to use for the textures
  84060. * @param images array of glTF image interfaces
  84061. * @param textures array of glTF texture interfaces
  84062. * @param materials array of glTF material interfaces
  84063. * @param imageData map of image file name to data
  84064. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84065. */
  84066. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84067. /**
  84068. * Converts an image typed array buffer to a base64 image
  84069. * @param buffer typed array buffer
  84070. * @param width width of the image
  84071. * @param height height of the image
  84072. * @param mimeType mimetype of the image
  84073. * @returns base64 image string
  84074. */
  84075. private _createBase64FromCanvasAsync;
  84076. /**
  84077. * Generates a white texture based on the specified width and height
  84078. * @param width width of the texture in pixels
  84079. * @param height height of the texture in pixels
  84080. * @param scene babylonjs scene
  84081. * @returns white texture
  84082. */
  84083. private _createWhiteTexture;
  84084. /**
  84085. * 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
  84086. * @param texture1 first texture to resize
  84087. * @param texture2 second texture to resize
  84088. * @param scene babylonjs scene
  84089. * @returns resized textures or null
  84090. */
  84091. private _resizeTexturesToSameDimensions;
  84092. /**
  84093. * Converts an array of pixels to a Float32Array
  84094. * Throws an error if the pixel format is not supported
  84095. * @param pixels - array buffer containing pixel values
  84096. * @returns Float32 of pixels
  84097. */
  84098. private _convertPixelArrayToFloat32;
  84099. /**
  84100. * Convert Specular Glossiness Textures to Metallic Roughness
  84101. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84102. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84103. * @param diffuseTexture texture used to store diffuse information
  84104. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84105. * @param factors specular glossiness material factors
  84106. * @param mimeType the mime type to use for the texture
  84107. * @returns pbr metallic roughness interface or null
  84108. */
  84109. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84110. /**
  84111. * Converts specular glossiness material properties to metallic roughness
  84112. * @param specularGlossiness interface with specular glossiness material properties
  84113. * @returns interface with metallic roughness material properties
  84114. */
  84115. private _convertSpecularGlossinessToMetallicRoughness;
  84116. /**
  84117. * Calculates the surface reflectance, independent of lighting conditions
  84118. * @param color Color source to calculate brightness from
  84119. * @returns number representing the perceived brightness, or zero if color is undefined
  84120. */
  84121. private _getPerceivedBrightness;
  84122. /**
  84123. * Returns the maximum color component value
  84124. * @param color
  84125. * @returns maximum color component value, or zero if color is null or undefined
  84126. */
  84127. private _getMaxComponent;
  84128. /**
  84129. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84130. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84131. * @param mimeType mime type to use for the textures
  84132. * @param images array of glTF image interfaces
  84133. * @param textures array of glTF texture interfaces
  84134. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84135. * @param imageData map of image file name to data
  84136. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84137. * @returns glTF PBR Metallic Roughness factors
  84138. */
  84139. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84140. private _getGLTFTextureSampler;
  84141. private _getGLTFTextureWrapMode;
  84142. private _getGLTFTextureWrapModesSampler;
  84143. /**
  84144. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84145. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84146. * @param mimeType mime type to use for the textures
  84147. * @param images array of glTF image interfaces
  84148. * @param textures array of glTF texture interfaces
  84149. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84150. * @param imageData map of image file name to data
  84151. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84152. * @returns glTF PBR Metallic Roughness factors
  84153. */
  84154. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84155. /**
  84156. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84157. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84158. * @param mimeType mime type to use for the textures
  84159. * @param images array of glTF image interfaces
  84160. * @param textures array of glTF texture interfaces
  84161. * @param materials array of glTF material interfaces
  84162. * @param imageData map of image file name to data
  84163. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84164. */
  84165. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84166. private setMetallicRoughnessPbrMaterial;
  84167. private getPixelsFromTexture;
  84168. /**
  84169. * Extracts a texture from a Babylon texture into file data and glTF data
  84170. * @param babylonTexture Babylon texture to extract
  84171. * @param mimeType Mime Type of the babylonTexture
  84172. * @return glTF texture info, or null if the texture format is not supported
  84173. */
  84174. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84175. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84176. /**
  84177. * Builds a texture from base64 string
  84178. * @param base64Texture base64 texture string
  84179. * @param baseTextureName Name to use for the texture
  84180. * @param mimeType image mime type for the texture
  84181. * @param images array of images
  84182. * @param textures array of textures
  84183. * @param imageData map of image data
  84184. * @returns glTF texture info, or null if the texture format is not supported
  84185. */
  84186. private _getTextureInfoFromBase64;
  84187. }
  84188. }
  84189. declare module BABYLON {
  84190. /**
  84191. * Class for holding and downloading glTF file data
  84192. */
  84193. export class GLTFData {
  84194. /**
  84195. * Object which contains the file name as the key and its data as the value
  84196. */
  84197. glTFFiles: {
  84198. [fileName: string]: string | Blob;
  84199. };
  84200. /**
  84201. * Initializes the glTF file object
  84202. */
  84203. constructor();
  84204. /**
  84205. * Downloads the glTF data as files based on their names and data
  84206. */
  84207. downloadFiles(): void;
  84208. }
  84209. }
  84210. declare module BABYLON {
  84211. /**
  84212. * Holds a collection of exporter options and parameters
  84213. */
  84214. export interface IExportOptions {
  84215. /**
  84216. * Function which indicates whether a babylon node should be exported or not
  84217. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84218. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84219. */
  84220. shouldExportNode?(node: Node): boolean;
  84221. /**
  84222. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84223. * @param metadata source metadata to read from
  84224. * @returns the data to store to glTF node extras
  84225. */
  84226. metadataSelector?(metadata: any): any;
  84227. /**
  84228. * The sample rate to bake animation curves
  84229. */
  84230. animationSampleRate?: number;
  84231. /**
  84232. * Begin serialization without waiting for the scene to be ready
  84233. */
  84234. exportWithoutWaitingForScene?: boolean;
  84235. /**
  84236. * Indicates if coordinate system swapping root nodes should be included in export
  84237. */
  84238. includeCoordinateSystemConversionNodes?: boolean;
  84239. }
  84240. /**
  84241. * Class for generating glTF data from a Babylon scene.
  84242. */
  84243. export class GLTF2Export {
  84244. /**
  84245. * Exports the geometry of the scene to .gltf file format asynchronously
  84246. * @param scene Babylon scene with scene hierarchy information
  84247. * @param filePrefix File prefix to use when generating the glTF file
  84248. * @param options Exporter options
  84249. * @returns Returns an object with a .gltf file and associates texture names
  84250. * as keys and their data and paths as values
  84251. */
  84252. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84253. private static _PreExportAsync;
  84254. private static _PostExportAsync;
  84255. /**
  84256. * Exports the geometry of the scene to .glb file format asychronously
  84257. * @param scene Babylon scene with scene hierarchy information
  84258. * @param filePrefix File prefix to use when generating glb file
  84259. * @param options Exporter options
  84260. * @returns Returns an object with a .glb filename as key and data as value
  84261. */
  84262. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84263. }
  84264. }
  84265. declare module BABYLON.GLTF2.Exporter {
  84266. /**
  84267. * @hidden
  84268. */
  84269. export class _GLTFUtilities {
  84270. /**
  84271. * Creates a buffer view based on the supplied arguments
  84272. * @param bufferIndex index value of the specified buffer
  84273. * @param byteOffset byte offset value
  84274. * @param byteLength byte length of the bufferView
  84275. * @param byteStride byte distance between conequential elements
  84276. * @param name name of the buffer view
  84277. * @returns bufferView for glTF
  84278. */
  84279. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84280. /**
  84281. * Creates an accessor based on the supplied arguments
  84282. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84283. * @param name The name of the accessor
  84284. * @param type The type of the accessor
  84285. * @param componentType The datatype of components in the attribute
  84286. * @param count The number of attributes referenced by this accessor
  84287. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84288. * @param min Minimum value of each component in this attribute
  84289. * @param max Maximum value of each component in this attribute
  84290. * @returns accessor for glTF
  84291. */
  84292. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84293. /**
  84294. * Calculates the minimum and maximum values of an array of position floats
  84295. * @param positions Positions array of a mesh
  84296. * @param vertexStart Starting vertex offset to calculate min and max values
  84297. * @param vertexCount Number of vertices to check for min and max values
  84298. * @returns min number array and max number array
  84299. */
  84300. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84301. min: number[];
  84302. max: number[];
  84303. };
  84304. /**
  84305. * Converts a new right-handed Vector3
  84306. * @param vector vector3 array
  84307. * @returns right-handed Vector3
  84308. */
  84309. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84310. /**
  84311. * Converts a Vector3 to right-handed
  84312. * @param vector Vector3 to convert to right-handed
  84313. */
  84314. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84315. /**
  84316. * Converts a three element number array to right-handed
  84317. * @param vector number array to convert to right-handed
  84318. */
  84319. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84320. /**
  84321. * Converts a new right-handed Vector3
  84322. * @param vector vector3 array
  84323. * @returns right-handed Vector3
  84324. */
  84325. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84326. /**
  84327. * Converts a Vector3 to right-handed
  84328. * @param vector Vector3 to convert to right-handed
  84329. */
  84330. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84331. /**
  84332. * Converts a three element number array to right-handed
  84333. * @param vector number array to convert to right-handed
  84334. */
  84335. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84336. /**
  84337. * Converts a Vector4 to right-handed
  84338. * @param vector Vector4 to convert to right-handed
  84339. */
  84340. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84341. /**
  84342. * Converts a Vector4 to right-handed
  84343. * @param vector Vector4 to convert to right-handed
  84344. */
  84345. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84346. /**
  84347. * Converts a Quaternion to right-handed
  84348. * @param quaternion Source quaternion to convert to right-handed
  84349. */
  84350. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84351. /**
  84352. * Converts a Quaternion to right-handed
  84353. * @param quaternion Source quaternion to convert to right-handed
  84354. */
  84355. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84356. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84357. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84358. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84359. }
  84360. }
  84361. declare module BABYLON.GLTF2.Exporter {
  84362. /**
  84363. * Converts Babylon Scene into glTF 2.0.
  84364. * @hidden
  84365. */
  84366. export class _Exporter {
  84367. /**
  84368. * Stores the glTF to export
  84369. */
  84370. _glTF: IGLTF;
  84371. /**
  84372. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84373. */
  84374. _bufferViews: IBufferView[];
  84375. /**
  84376. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84377. */
  84378. _accessors: IAccessor[];
  84379. /**
  84380. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84381. */
  84382. _nodes: INode[];
  84383. /**
  84384. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84385. */
  84386. private _scenes;
  84387. /**
  84388. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84389. */
  84390. private _meshes;
  84391. /**
  84392. * Stores all the generated material information, which represents the appearance of each primitive
  84393. */
  84394. _materials: IMaterial[];
  84395. _materialMap: {
  84396. [materialID: number]: number;
  84397. };
  84398. /**
  84399. * Stores all the generated texture information, which is referenced by glTF materials
  84400. */
  84401. _textures: ITexture[];
  84402. /**
  84403. * Stores all the generated image information, which is referenced by glTF textures
  84404. */
  84405. _images: IImage[];
  84406. /**
  84407. * Stores all the texture samplers
  84408. */
  84409. _samplers: ISampler[];
  84410. /**
  84411. * Stores all the generated glTF skins
  84412. */
  84413. _skins: ISkin[];
  84414. /**
  84415. * Stores all the generated animation samplers, which is referenced by glTF animations
  84416. */
  84417. /**
  84418. * Stores the animations for glTF models
  84419. */
  84420. private _animations;
  84421. /**
  84422. * Stores the total amount of bytes stored in the glTF buffer
  84423. */
  84424. private _totalByteLength;
  84425. /**
  84426. * Stores a reference to the Babylon scene containing the source geometry and material information
  84427. */
  84428. _babylonScene: Scene;
  84429. /**
  84430. * Stores a map of the image data, where the key is the file name and the value
  84431. * is the image data
  84432. */
  84433. _imageData: {
  84434. [fileName: string]: {
  84435. data: Uint8Array;
  84436. mimeType: ImageMimeType;
  84437. };
  84438. };
  84439. protected _orderedImageData: Array<{
  84440. data: Uint8Array;
  84441. mimeType: ImageMimeType;
  84442. }>;
  84443. /**
  84444. * Stores a map of the unique id of a node to its index in the node array
  84445. */
  84446. _nodeMap: {
  84447. [key: number]: number;
  84448. };
  84449. /**
  84450. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84451. */
  84452. _convertToRightHandedSystem: boolean;
  84453. /**
  84454. * Specifies if a Babylon node should be converted to right-handed on export
  84455. */
  84456. _convertToRightHandedSystemMap: {
  84457. [nodeId: number]: boolean;
  84458. };
  84459. _includeCoordinateSystemConversionNodes: boolean;
  84460. /**
  84461. * Baked animation sample rate
  84462. */
  84463. private _animationSampleRate;
  84464. private _options;
  84465. private _localEngine;
  84466. _glTFMaterialExporter: _GLTFMaterialExporter;
  84467. private _extensions;
  84468. private static _ExtensionNames;
  84469. private static _ExtensionFactories;
  84470. private _applyExtension;
  84471. private _applyExtensions;
  84472. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84473. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84474. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84475. [key: number]: number;
  84476. }): Promise<Nullable<INode>>;
  84477. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84478. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84479. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84480. private _forEachExtensions;
  84481. private _extensionsOnExporting;
  84482. /**
  84483. * Load glTF serializer extensions
  84484. */
  84485. private _loadExtensions;
  84486. /**
  84487. * Creates a glTF Exporter instance, which can accept optional exporter options
  84488. * @param babylonScene Babylon scene object
  84489. * @param options Options to modify the behavior of the exporter
  84490. */
  84491. constructor(babylonScene: Scene, options?: IExportOptions);
  84492. dispose(): void;
  84493. /**
  84494. * Registers a glTF exporter extension
  84495. * @param name Name of the extension to export
  84496. * @param factory The factory function that creates the exporter extension
  84497. */
  84498. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84499. /**
  84500. * Un-registers an exporter extension
  84501. * @param name The name fo the exporter extension
  84502. * @returns A boolean indicating whether the extension has been un-registered
  84503. */
  84504. static UnregisterExtension(name: string): boolean;
  84505. /**
  84506. * Lazy load a local engine
  84507. */
  84508. _getLocalEngine(): Engine;
  84509. private reorderIndicesBasedOnPrimitiveMode;
  84510. /**
  84511. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84512. * clock-wise during export to glTF
  84513. * @param submesh BabylonJS submesh
  84514. * @param primitiveMode Primitive mode of the mesh
  84515. * @param sideOrientation the winding order of the submesh
  84516. * @param vertexBufferKind The type of vertex attribute
  84517. * @param meshAttributeArray The vertex attribute data
  84518. * @param byteOffset The offset to the binary data
  84519. * @param binaryWriter The binary data for the glTF file
  84520. * @param convertToRightHandedSystem Converts the values to right-handed
  84521. */
  84522. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84523. /**
  84524. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84525. * clock-wise during export to glTF
  84526. * @param submesh BabylonJS submesh
  84527. * @param primitiveMode Primitive mode of the mesh
  84528. * @param sideOrientation the winding order of the submesh
  84529. * @param vertexBufferKind The type of vertex attribute
  84530. * @param meshAttributeArray The vertex attribute data
  84531. * @param byteOffset The offset to the binary data
  84532. * @param binaryWriter The binary data for the glTF file
  84533. * @param convertToRightHandedSystem Converts the values to right-handed
  84534. */
  84535. private reorderTriangleFillMode;
  84536. /**
  84537. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84538. * clock-wise during export to glTF
  84539. * @param submesh BabylonJS submesh
  84540. * @param primitiveMode Primitive mode of the mesh
  84541. * @param sideOrientation the winding order of the submesh
  84542. * @param vertexBufferKind The type of vertex attribute
  84543. * @param meshAttributeArray The vertex attribute data
  84544. * @param byteOffset The offset to the binary data
  84545. * @param binaryWriter The binary data for the glTF file
  84546. * @param convertToRightHandedSystem Converts the values to right-handed
  84547. */
  84548. private reorderTriangleStripDrawMode;
  84549. /**
  84550. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84551. * clock-wise during export to glTF
  84552. * @param submesh BabylonJS submesh
  84553. * @param primitiveMode Primitive mode of the mesh
  84554. * @param sideOrientation the winding order of the submesh
  84555. * @param vertexBufferKind The type of vertex attribute
  84556. * @param meshAttributeArray The vertex attribute data
  84557. * @param byteOffset The offset to the binary data
  84558. * @param binaryWriter The binary data for the glTF file
  84559. * @param convertToRightHandedSystem Converts the values to right-handed
  84560. */
  84561. private reorderTriangleFanMode;
  84562. /**
  84563. * Writes the vertex attribute data to binary
  84564. * @param vertices The vertices to write to the binary writer
  84565. * @param byteOffset The offset into the binary writer to overwrite binary data
  84566. * @param vertexAttributeKind The vertex attribute type
  84567. * @param meshAttributeArray The vertex attribute data
  84568. * @param binaryWriter The writer containing the binary data
  84569. * @param convertToRightHandedSystem Converts the values to right-handed
  84570. */
  84571. private writeVertexAttributeData;
  84572. /**
  84573. * Writes mesh attribute data to a data buffer
  84574. * Returns the bytelength of the data
  84575. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84576. * @param meshAttributeArray Array containing the attribute data
  84577. * @param byteStride Specifies the space between data
  84578. * @param binaryWriter The buffer to write the binary data to
  84579. * @param convertToRightHandedSystem Converts the values to right-handed
  84580. */
  84581. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84582. /**
  84583. * Writes mesh attribute data to a data buffer
  84584. * Returns the bytelength of the data
  84585. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84586. * @param meshAttributeArray Array containing the attribute data
  84587. * @param byteStride Specifies the space between data
  84588. * @param binaryWriter The buffer to write the binary data to
  84589. * @param convertToRightHandedSystem Converts the values to right-handed
  84590. */
  84591. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84592. /**
  84593. * Generates glTF json data
  84594. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84595. * @param glTFPrefix Text to use when prefixing a glTF file
  84596. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84597. * @returns json data as string
  84598. */
  84599. private generateJSON;
  84600. /**
  84601. * Generates data for .gltf and .bin files based on the glTF prefix string
  84602. * @param glTFPrefix Text to use when prefixing a glTF file
  84603. * @param dispose Dispose the exporter
  84604. * @returns GLTFData with glTF file data
  84605. */
  84606. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84607. /**
  84608. * Creates a binary buffer for glTF
  84609. * @returns array buffer for binary data
  84610. */
  84611. private _generateBinaryAsync;
  84612. /**
  84613. * Pads the number to a multiple of 4
  84614. * @param num number to pad
  84615. * @returns padded number
  84616. */
  84617. private _getPadding;
  84618. /**
  84619. * @hidden
  84620. */
  84621. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84622. /**
  84623. * Sets the TRS for each node
  84624. * @param node glTF Node for storing the transformation data
  84625. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84626. * @param convertToRightHandedSystem Converts the values to right-handed
  84627. */
  84628. private setNodeTransformation;
  84629. private getVertexBufferFromMesh;
  84630. /**
  84631. * Creates a bufferview based on the vertices type for the Babylon mesh
  84632. * @param kind Indicates the type of vertices data
  84633. * @param componentType Indicates the numerical type used to store the data
  84634. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84635. * @param binaryWriter The buffer to write the bufferview data to
  84636. * @param convertToRightHandedSystem Converts the values to right-handed
  84637. */
  84638. private createBufferViewKind;
  84639. /**
  84640. * Creates a bufferview based on the vertices type for the Babylon mesh
  84641. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84642. * @param babylonMorphTarget the morph target to be exported
  84643. * @param binaryWriter The buffer to write the bufferview data to
  84644. * @param convertToRightHandedSystem Converts the values to right-handed
  84645. */
  84646. private setMorphTargetAttributes;
  84647. /**
  84648. * The primitive mode of the Babylon mesh
  84649. * @param babylonMesh The BabylonJS mesh
  84650. */
  84651. private getMeshPrimitiveMode;
  84652. /**
  84653. * Sets the primitive mode of the glTF mesh primitive
  84654. * @param meshPrimitive glTF mesh primitive
  84655. * @param primitiveMode The primitive mode
  84656. */
  84657. private setPrimitiveMode;
  84658. /**
  84659. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84660. * @param meshPrimitive glTF mesh primitive
  84661. * @param attributeKind vertex attribute
  84662. * @returns boolean specifying if uv coordinates are present
  84663. */
  84664. private setAttributeKind;
  84665. /**
  84666. * Sets data for the primitive attributes of each submesh
  84667. * @param mesh glTF Mesh object to store the primitive attribute information
  84668. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84669. * @param binaryWriter Buffer to write the attribute data to
  84670. * @param convertToRightHandedSystem Converts the values to right-handed
  84671. */
  84672. private setPrimitiveAttributesAsync;
  84673. /**
  84674. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84675. * @param node The node to check
  84676. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84677. */
  84678. private isBabylonCoordinateSystemConvertingNode;
  84679. /**
  84680. * Creates a glTF scene based on the array of meshes
  84681. * Returns the the total byte offset
  84682. * @param babylonScene Babylon scene to get the mesh data from
  84683. * @param binaryWriter Buffer to write binary data to
  84684. */
  84685. private createSceneAsync;
  84686. /**
  84687. * Creates a mapping of Node unique id to node index and handles animations
  84688. * @param babylonScene Babylon Scene
  84689. * @param nodes Babylon transform nodes
  84690. * @param binaryWriter Buffer to write binary data to
  84691. * @returns Node mapping of unique id to index
  84692. */
  84693. private createNodeMapAndAnimationsAsync;
  84694. /**
  84695. * Creates a glTF node from a Babylon mesh
  84696. * @param babylonMesh Source Babylon mesh
  84697. * @param binaryWriter Buffer for storing geometry data
  84698. * @param convertToRightHandedSystem Converts the values to right-handed
  84699. * @param nodeMap Node mapping of unique id to glTF node index
  84700. * @returns glTF node
  84701. */
  84702. private createNodeAsync;
  84703. /**
  84704. * Creates a glTF skin from a Babylon skeleton
  84705. * @param babylonScene Babylon Scene
  84706. * @param nodes Babylon transform nodes
  84707. * @param binaryWriter Buffer to write binary data to
  84708. * @returns Node mapping of unique id to index
  84709. */
  84710. private createSkinsAsync;
  84711. }
  84712. /**
  84713. * @hidden
  84714. *
  84715. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84716. */
  84717. export class _BinaryWriter {
  84718. /**
  84719. * Array buffer which stores all binary data
  84720. */
  84721. private _arrayBuffer;
  84722. /**
  84723. * View of the array buffer
  84724. */
  84725. private _dataView;
  84726. /**
  84727. * byte offset of data in array buffer
  84728. */
  84729. private _byteOffset;
  84730. /**
  84731. * Initialize binary writer with an initial byte length
  84732. * @param byteLength Initial byte length of the array buffer
  84733. */
  84734. constructor(byteLength: number);
  84735. /**
  84736. * Resize the array buffer to the specified byte length
  84737. * @param byteLength
  84738. */
  84739. private resizeBuffer;
  84740. /**
  84741. * Get an array buffer with the length of the byte offset
  84742. * @returns ArrayBuffer resized to the byte offset
  84743. */
  84744. getArrayBuffer(): ArrayBuffer;
  84745. /**
  84746. * Get the byte offset of the array buffer
  84747. * @returns byte offset
  84748. */
  84749. getByteOffset(): number;
  84750. /**
  84751. * Stores an UInt8 in the array buffer
  84752. * @param entry
  84753. * @param byteOffset If defined, specifies where to set the value as an offset.
  84754. */
  84755. setUInt8(entry: number, byteOffset?: number): void;
  84756. /**
  84757. * Stores an UInt16 in the array buffer
  84758. * @param entry
  84759. * @param byteOffset If defined, specifies where to set the value as an offset.
  84760. */
  84761. setUInt16(entry: number, byteOffset?: number): void;
  84762. /**
  84763. * Gets an UInt32 in the array buffer
  84764. * @param entry
  84765. * @param byteOffset If defined, specifies where to set the value as an offset.
  84766. */
  84767. getUInt32(byteOffset: number): number;
  84768. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84769. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84770. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84771. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84772. /**
  84773. * Stores a Float32 in the array buffer
  84774. * @param entry
  84775. */
  84776. setFloat32(entry: number, byteOffset?: number): void;
  84777. /**
  84778. * Stores an UInt32 in the array buffer
  84779. * @param entry
  84780. * @param byteOffset If defined, specifies where to set the value as an offset.
  84781. */
  84782. setUInt32(entry: number, byteOffset?: number): void;
  84783. }
  84784. }
  84785. declare module BABYLON.GLTF2.Exporter {
  84786. /**
  84787. * @hidden
  84788. * Interface to store animation data.
  84789. */
  84790. export interface _IAnimationData {
  84791. /**
  84792. * Keyframe data.
  84793. */
  84794. inputs: number[];
  84795. /**
  84796. * Value data.
  84797. */
  84798. outputs: number[][];
  84799. /**
  84800. * Animation interpolation data.
  84801. */
  84802. samplerInterpolation: AnimationSamplerInterpolation;
  84803. /**
  84804. * Minimum keyframe value.
  84805. */
  84806. inputsMin: number;
  84807. /**
  84808. * Maximum keyframe value.
  84809. */
  84810. inputsMax: number;
  84811. }
  84812. /**
  84813. * @hidden
  84814. */
  84815. export interface _IAnimationInfo {
  84816. /**
  84817. * The target channel for the animation
  84818. */
  84819. animationChannelTargetPath: AnimationChannelTargetPath;
  84820. /**
  84821. * The glTF accessor type for the data.
  84822. */
  84823. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84824. /**
  84825. * Specifies if quaternions should be used.
  84826. */
  84827. useQuaternion: boolean;
  84828. }
  84829. /**
  84830. * @hidden
  84831. * Utility class for generating glTF animation data from BabylonJS.
  84832. */
  84833. export class _GLTFAnimation {
  84834. /**
  84835. * @ignore
  84836. *
  84837. * Creates glTF channel animation from BabylonJS animation.
  84838. * @param babylonTransformNode - BabylonJS mesh.
  84839. * @param animation - animation.
  84840. * @param animationChannelTargetPath - The target animation channel.
  84841. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84842. * @param useQuaternion - Specifies if quaternions are used.
  84843. * @returns nullable IAnimationData
  84844. */
  84845. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84846. private static _DeduceAnimationInfo;
  84847. /**
  84848. * @ignore
  84849. * Create node animations from the transform node animations
  84850. * @param babylonNode
  84851. * @param runtimeGLTFAnimation
  84852. * @param idleGLTFAnimations
  84853. * @param nodeMap
  84854. * @param nodes
  84855. * @param binaryWriter
  84856. * @param bufferViews
  84857. * @param accessors
  84858. * @param convertToRightHandedSystem
  84859. * @param animationSampleRate
  84860. */
  84861. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84862. [key: number]: number;
  84863. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84864. /**
  84865. * @ignore
  84866. * Create individual morph animations from the mesh's morph target animation tracks
  84867. * @param babylonNode
  84868. * @param runtimeGLTFAnimation
  84869. * @param idleGLTFAnimations
  84870. * @param nodeMap
  84871. * @param nodes
  84872. * @param binaryWriter
  84873. * @param bufferViews
  84874. * @param accessors
  84875. * @param convertToRightHandedSystem
  84876. * @param animationSampleRate
  84877. */
  84878. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84879. [key: number]: number;
  84880. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84881. /**
  84882. * @ignore
  84883. * Create node and morph animations from the animation groups
  84884. * @param babylonScene
  84885. * @param glTFAnimations
  84886. * @param nodeMap
  84887. * @param nodes
  84888. * @param binaryWriter
  84889. * @param bufferViews
  84890. * @param accessors
  84891. * @param convertToRightHandedSystemMap
  84892. * @param animationSampleRate
  84893. */
  84894. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84895. [key: number]: number;
  84896. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84897. [nodeId: number]: boolean;
  84898. }, animationSampleRate: number): void;
  84899. private static AddAnimation;
  84900. /**
  84901. * Create a baked animation
  84902. * @param babylonTransformNode BabylonJS mesh
  84903. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84904. * @param animationChannelTargetPath animation target channel
  84905. * @param minFrame minimum animation frame
  84906. * @param maxFrame maximum animation frame
  84907. * @param fps frames per second of the animation
  84908. * @param inputs input key frames of the animation
  84909. * @param outputs output key frame data of the animation
  84910. * @param convertToRightHandedSystem converts the values to right-handed
  84911. * @param useQuaternion specifies if quaternions should be used
  84912. */
  84913. private static _CreateBakedAnimation;
  84914. private static _ConvertFactorToVector3OrQuaternion;
  84915. private static _SetInterpolatedValue;
  84916. /**
  84917. * Creates linear animation from the animation key frames
  84918. * @param babylonTransformNode BabylonJS mesh
  84919. * @param animation BabylonJS animation
  84920. * @param animationChannelTargetPath The target animation channel
  84921. * @param frameDelta The difference between the last and first frame of the animation
  84922. * @param inputs Array to store the key frame times
  84923. * @param outputs Array to store the key frame data
  84924. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84925. * @param useQuaternion Specifies if quaternions are used in the animation
  84926. */
  84927. private static _CreateLinearOrStepAnimation;
  84928. /**
  84929. * Creates cubic spline animation from the animation key frames
  84930. * @param babylonTransformNode BabylonJS mesh
  84931. * @param animation BabylonJS animation
  84932. * @param animationChannelTargetPath The target animation channel
  84933. * @param frameDelta The difference between the last and first frame of the animation
  84934. * @param inputs Array to store the key frame times
  84935. * @param outputs Array to store the key frame data
  84936. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84937. * @param useQuaternion Specifies if quaternions are used in the animation
  84938. */
  84939. private static _CreateCubicSplineAnimation;
  84940. private static _GetBasePositionRotationOrScale;
  84941. /**
  84942. * Adds a key frame value
  84943. * @param keyFrame
  84944. * @param animation
  84945. * @param outputs
  84946. * @param animationChannelTargetPath
  84947. * @param basePositionRotationOrScale
  84948. * @param convertToRightHandedSystem
  84949. * @param useQuaternion
  84950. */
  84951. private static _AddKeyframeValue;
  84952. /**
  84953. * Determine the interpolation based on the key frames
  84954. * @param keyFrames
  84955. * @param animationChannelTargetPath
  84956. * @param useQuaternion
  84957. */
  84958. private static _DeduceInterpolation;
  84959. /**
  84960. * Adds an input tangent or output tangent to the output data
  84961. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84962. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84963. * @param outputs The animation data by keyframe
  84964. * @param animationChannelTargetPath The target animation channel
  84965. * @param interpolation The interpolation type
  84966. * @param keyFrame The key frame with the animation data
  84967. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84968. * @param useQuaternion Specifies if quaternions are used
  84969. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84970. */
  84971. private static AddSplineTangent;
  84972. /**
  84973. * Get the minimum and maximum key frames' frame values
  84974. * @param keyFrames animation key frames
  84975. * @returns the minimum and maximum key frame value
  84976. */
  84977. private static calculateMinMaxKeyFrames;
  84978. }
  84979. }
  84980. declare module BABYLON.GLTF2.Exporter {
  84981. /** @hidden */
  84982. export var textureTransformPixelShader: {
  84983. name: string;
  84984. shader: string;
  84985. };
  84986. }
  84987. declare module BABYLON.GLTF2.Exporter.Extensions {
  84988. /**
  84989. * @hidden
  84990. */
  84991. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84992. private _recordedTextures;
  84993. /** Name of this extension */
  84994. readonly name: string;
  84995. /** Defines whether this extension is enabled */
  84996. enabled: boolean;
  84997. /** Defines whether this extension is required */
  84998. required: boolean;
  84999. /** Reference to the glTF exporter */
  85000. private _wasUsed;
  85001. constructor(exporter: _Exporter);
  85002. dispose(): void;
  85003. /** @hidden */
  85004. get wasUsed(): boolean;
  85005. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85006. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85007. /**
  85008. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85009. * @param babylonTexture
  85010. * @param offset
  85011. * @param rotation
  85012. * @param scale
  85013. * @param scene
  85014. */
  85015. private _textureTransformTextureAsync;
  85016. }
  85017. }
  85018. declare module BABYLON.GLTF2.Exporter.Extensions {
  85019. /**
  85020. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85021. */
  85022. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85023. /** The name of this extension. */
  85024. readonly name: string;
  85025. /** Defines whether this extension is enabled. */
  85026. enabled: boolean;
  85027. /** Defines whether this extension is required */
  85028. required: boolean;
  85029. /** Reference to the glTF exporter */
  85030. private _exporter;
  85031. private _lights;
  85032. /** @hidden */
  85033. constructor(exporter: _Exporter);
  85034. /** @hidden */
  85035. dispose(): void;
  85036. /** @hidden */
  85037. get wasUsed(): boolean;
  85038. /** @hidden */
  85039. onExporting(): void;
  85040. /**
  85041. * Define this method to modify the default behavior when exporting a node
  85042. * @param context The context when exporting the node
  85043. * @param node glTF node
  85044. * @param babylonNode BabylonJS node
  85045. * @param nodeMap Node mapping of unique id to glTF node index
  85046. * @returns nullable INode promise
  85047. */
  85048. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85049. [key: number]: number;
  85050. }): Promise<Nullable<INode>>;
  85051. }
  85052. }
  85053. declare module BABYLON.GLTF2.Exporter.Extensions {
  85054. /**
  85055. * @hidden
  85056. */
  85057. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85058. /** Name of this extension */
  85059. readonly name: string;
  85060. /** Defines whether this extension is enabled */
  85061. enabled: boolean;
  85062. /** Defines whether this extension is required */
  85063. required: boolean;
  85064. /** Reference to the glTF exporter */
  85065. private _textureInfos;
  85066. private _exportedTextures;
  85067. private _wasUsed;
  85068. constructor(exporter: _Exporter);
  85069. dispose(): void;
  85070. /** @hidden */
  85071. get wasUsed(): boolean;
  85072. private _getTextureIndex;
  85073. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85074. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85075. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85076. }
  85077. }
  85078. declare module BABYLON.GLTF2.Exporter.Extensions {
  85079. /**
  85080. * @hidden
  85081. */
  85082. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85083. /** Name of this extension */
  85084. readonly name: string;
  85085. /** Defines whether this extension is enabled */
  85086. enabled: boolean;
  85087. /** Defines whether this extension is required */
  85088. required: boolean;
  85089. private _wasUsed;
  85090. constructor(exporter: _Exporter);
  85091. /** @hidden */
  85092. get wasUsed(): boolean;
  85093. dispose(): void;
  85094. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85095. }
  85096. }
  85097. declare module BABYLON {
  85098. /**
  85099. * Class for generating STL data from a Babylon scene.
  85100. */
  85101. export class STLExport {
  85102. /**
  85103. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85104. * @param meshes list defines the mesh to serialize
  85105. * @param download triggers the automatic download of the file.
  85106. * @param fileName changes the downloads fileName.
  85107. * @param binary changes the STL to a binary type.
  85108. * @param isLittleEndian toggle for binary type exporter.
  85109. * @returns the STL as UTF8 string
  85110. */
  85111. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85112. }
  85113. }
  85114. declare module "babylonjs-gltf2interface" {
  85115. export = BABYLON.GLTF2;
  85116. }
  85117. /**
  85118. * Module for glTF 2.0 Interface
  85119. */
  85120. declare module BABYLON.GLTF2 {
  85121. /**
  85122. * The datatype of the components in the attribute
  85123. */
  85124. const enum AccessorComponentType {
  85125. /**
  85126. * Byte
  85127. */
  85128. BYTE = 5120,
  85129. /**
  85130. * Unsigned Byte
  85131. */
  85132. UNSIGNED_BYTE = 5121,
  85133. /**
  85134. * Short
  85135. */
  85136. SHORT = 5122,
  85137. /**
  85138. * Unsigned Short
  85139. */
  85140. UNSIGNED_SHORT = 5123,
  85141. /**
  85142. * Unsigned Int
  85143. */
  85144. UNSIGNED_INT = 5125,
  85145. /**
  85146. * Float
  85147. */
  85148. FLOAT = 5126,
  85149. }
  85150. /**
  85151. * Specifies if the attirbute is a scalar, vector, or matrix
  85152. */
  85153. const enum AccessorType {
  85154. /**
  85155. * Scalar
  85156. */
  85157. SCALAR = "SCALAR",
  85158. /**
  85159. * Vector2
  85160. */
  85161. VEC2 = "VEC2",
  85162. /**
  85163. * Vector3
  85164. */
  85165. VEC3 = "VEC3",
  85166. /**
  85167. * Vector4
  85168. */
  85169. VEC4 = "VEC4",
  85170. /**
  85171. * Matrix2x2
  85172. */
  85173. MAT2 = "MAT2",
  85174. /**
  85175. * Matrix3x3
  85176. */
  85177. MAT3 = "MAT3",
  85178. /**
  85179. * Matrix4x4
  85180. */
  85181. MAT4 = "MAT4",
  85182. }
  85183. /**
  85184. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85185. */
  85186. const enum AnimationChannelTargetPath {
  85187. /**
  85188. * Translation
  85189. */
  85190. TRANSLATION = "translation",
  85191. /**
  85192. * Rotation
  85193. */
  85194. ROTATION = "rotation",
  85195. /**
  85196. * Scale
  85197. */
  85198. SCALE = "scale",
  85199. /**
  85200. * Weights
  85201. */
  85202. WEIGHTS = "weights",
  85203. }
  85204. /**
  85205. * Interpolation algorithm
  85206. */
  85207. const enum AnimationSamplerInterpolation {
  85208. /**
  85209. * The animated values are linearly interpolated between keyframes
  85210. */
  85211. LINEAR = "LINEAR",
  85212. /**
  85213. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85214. */
  85215. STEP = "STEP",
  85216. /**
  85217. * The animation's interpolation is computed using a cubic spline with specified tangents
  85218. */
  85219. CUBICSPLINE = "CUBICSPLINE",
  85220. }
  85221. /**
  85222. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85223. */
  85224. const enum CameraType {
  85225. /**
  85226. * A perspective camera containing properties to create a perspective projection matrix
  85227. */
  85228. PERSPECTIVE = "perspective",
  85229. /**
  85230. * An orthographic camera containing properties to create an orthographic projection matrix
  85231. */
  85232. ORTHOGRAPHIC = "orthographic",
  85233. }
  85234. /**
  85235. * The mime-type of the image
  85236. */
  85237. const enum ImageMimeType {
  85238. /**
  85239. * JPEG Mime-type
  85240. */
  85241. JPEG = "image/jpeg",
  85242. /**
  85243. * PNG Mime-type
  85244. */
  85245. PNG = "image/png",
  85246. }
  85247. /**
  85248. * The alpha rendering mode of the material
  85249. */
  85250. const enum MaterialAlphaMode {
  85251. /**
  85252. * The alpha value is ignored and the rendered output is fully opaque
  85253. */
  85254. OPAQUE = "OPAQUE",
  85255. /**
  85256. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85257. */
  85258. MASK = "MASK",
  85259. /**
  85260. * 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)
  85261. */
  85262. BLEND = "BLEND",
  85263. }
  85264. /**
  85265. * The type of the primitives to render
  85266. */
  85267. const enum MeshPrimitiveMode {
  85268. /**
  85269. * Points
  85270. */
  85271. POINTS = 0,
  85272. /**
  85273. * Lines
  85274. */
  85275. LINES = 1,
  85276. /**
  85277. * Line Loop
  85278. */
  85279. LINE_LOOP = 2,
  85280. /**
  85281. * Line Strip
  85282. */
  85283. LINE_STRIP = 3,
  85284. /**
  85285. * Triangles
  85286. */
  85287. TRIANGLES = 4,
  85288. /**
  85289. * Triangle Strip
  85290. */
  85291. TRIANGLE_STRIP = 5,
  85292. /**
  85293. * Triangle Fan
  85294. */
  85295. TRIANGLE_FAN = 6,
  85296. }
  85297. /**
  85298. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85299. */
  85300. const enum TextureMagFilter {
  85301. /**
  85302. * Nearest
  85303. */
  85304. NEAREST = 9728,
  85305. /**
  85306. * Linear
  85307. */
  85308. LINEAR = 9729,
  85309. }
  85310. /**
  85311. * Minification filter. All valid values correspond to WebGL enums
  85312. */
  85313. const enum TextureMinFilter {
  85314. /**
  85315. * Nearest
  85316. */
  85317. NEAREST = 9728,
  85318. /**
  85319. * Linear
  85320. */
  85321. LINEAR = 9729,
  85322. /**
  85323. * Nearest Mip-Map Nearest
  85324. */
  85325. NEAREST_MIPMAP_NEAREST = 9984,
  85326. /**
  85327. * Linear Mipmap Nearest
  85328. */
  85329. LINEAR_MIPMAP_NEAREST = 9985,
  85330. /**
  85331. * Nearest Mipmap Linear
  85332. */
  85333. NEAREST_MIPMAP_LINEAR = 9986,
  85334. /**
  85335. * Linear Mipmap Linear
  85336. */
  85337. LINEAR_MIPMAP_LINEAR = 9987,
  85338. }
  85339. /**
  85340. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85341. */
  85342. const enum TextureWrapMode {
  85343. /**
  85344. * Clamp to Edge
  85345. */
  85346. CLAMP_TO_EDGE = 33071,
  85347. /**
  85348. * Mirrored Repeat
  85349. */
  85350. MIRRORED_REPEAT = 33648,
  85351. /**
  85352. * Repeat
  85353. */
  85354. REPEAT = 10497,
  85355. }
  85356. /**
  85357. * glTF Property
  85358. */
  85359. interface IProperty {
  85360. /**
  85361. * Dictionary object with extension-specific objects
  85362. */
  85363. extensions?: {
  85364. [key: string]: any;
  85365. };
  85366. /**
  85367. * Application-Specific data
  85368. */
  85369. extras?: any;
  85370. }
  85371. /**
  85372. * glTF Child of Root Property
  85373. */
  85374. interface IChildRootProperty extends IProperty {
  85375. /**
  85376. * The user-defined name of this object
  85377. */
  85378. name?: string;
  85379. }
  85380. /**
  85381. * Indices of those attributes that deviate from their initialization value
  85382. */
  85383. interface IAccessorSparseIndices extends IProperty {
  85384. /**
  85385. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85386. */
  85387. bufferView: number;
  85388. /**
  85389. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85390. */
  85391. byteOffset?: number;
  85392. /**
  85393. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85394. */
  85395. componentType: AccessorComponentType;
  85396. }
  85397. /**
  85398. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85399. */
  85400. interface IAccessorSparseValues extends IProperty {
  85401. /**
  85402. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85403. */
  85404. bufferView: number;
  85405. /**
  85406. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85407. */
  85408. byteOffset?: number;
  85409. }
  85410. /**
  85411. * Sparse storage of attributes that deviate from their initialization value
  85412. */
  85413. interface IAccessorSparse extends IProperty {
  85414. /**
  85415. * The number of attributes encoded in this sparse accessor
  85416. */
  85417. count: number;
  85418. /**
  85419. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85420. */
  85421. indices: IAccessorSparseIndices;
  85422. /**
  85423. * 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
  85424. */
  85425. values: IAccessorSparseValues;
  85426. }
  85427. /**
  85428. * 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
  85429. */
  85430. interface IAccessor extends IChildRootProperty {
  85431. /**
  85432. * The index of the bufferview
  85433. */
  85434. bufferView?: number;
  85435. /**
  85436. * The offset relative to the start of the bufferView in bytes
  85437. */
  85438. byteOffset?: number;
  85439. /**
  85440. * The datatype of components in the attribute
  85441. */
  85442. componentType: AccessorComponentType;
  85443. /**
  85444. * Specifies whether integer data values should be normalized
  85445. */
  85446. normalized?: boolean;
  85447. /**
  85448. * The number of attributes referenced by this accessor
  85449. */
  85450. count: number;
  85451. /**
  85452. * Specifies if the attribute is a scalar, vector, or matrix
  85453. */
  85454. type: AccessorType;
  85455. /**
  85456. * Maximum value of each component in this attribute
  85457. */
  85458. max?: number[];
  85459. /**
  85460. * Minimum value of each component in this attribute
  85461. */
  85462. min?: number[];
  85463. /**
  85464. * Sparse storage of attributes that deviate from their initialization value
  85465. */
  85466. sparse?: IAccessorSparse;
  85467. }
  85468. /**
  85469. * Targets an animation's sampler at a node's property
  85470. */
  85471. interface IAnimationChannel extends IProperty {
  85472. /**
  85473. * The index of a sampler in this animation used to compute the value for the target
  85474. */
  85475. sampler: number;
  85476. /**
  85477. * The index of the node and TRS property to target
  85478. */
  85479. target: IAnimationChannelTarget;
  85480. }
  85481. /**
  85482. * The index of the node and TRS property that an animation channel targets
  85483. */
  85484. interface IAnimationChannelTarget extends IProperty {
  85485. /**
  85486. * The index of the node to target
  85487. */
  85488. node: number;
  85489. /**
  85490. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85491. */
  85492. path: AnimationChannelTargetPath;
  85493. }
  85494. /**
  85495. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85496. */
  85497. interface IAnimationSampler extends IProperty {
  85498. /**
  85499. * The index of an accessor containing keyframe input values, e.g., time
  85500. */
  85501. input: number;
  85502. /**
  85503. * Interpolation algorithm
  85504. */
  85505. interpolation?: AnimationSamplerInterpolation;
  85506. /**
  85507. * The index of an accessor, containing keyframe output values
  85508. */
  85509. output: number;
  85510. }
  85511. /**
  85512. * A keyframe animation
  85513. */
  85514. interface IAnimation extends IChildRootProperty {
  85515. /**
  85516. * An array of channels, each of which targets an animation's sampler at a node's property
  85517. */
  85518. channels: IAnimationChannel[];
  85519. /**
  85520. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85521. */
  85522. samplers: IAnimationSampler[];
  85523. }
  85524. /**
  85525. * Metadata about the glTF asset
  85526. */
  85527. interface IAsset extends IChildRootProperty {
  85528. /**
  85529. * A copyright message suitable for display to credit the content creator
  85530. */
  85531. copyright?: string;
  85532. /**
  85533. * Tool that generated this glTF model. Useful for debugging
  85534. */
  85535. generator?: string;
  85536. /**
  85537. * The glTF version that this asset targets
  85538. */
  85539. version: string;
  85540. /**
  85541. * The minimum glTF version that this asset targets
  85542. */
  85543. minVersion?: string;
  85544. }
  85545. /**
  85546. * A buffer points to binary geometry, animation, or skins
  85547. */
  85548. interface IBuffer extends IChildRootProperty {
  85549. /**
  85550. * 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
  85551. */
  85552. uri?: string;
  85553. /**
  85554. * The length of the buffer in bytes
  85555. */
  85556. byteLength: number;
  85557. }
  85558. /**
  85559. * A view into a buffer generally representing a subset of the buffer
  85560. */
  85561. interface IBufferView extends IChildRootProperty {
  85562. /**
  85563. * The index of the buffer
  85564. */
  85565. buffer: number;
  85566. /**
  85567. * The offset into the buffer in bytes
  85568. */
  85569. byteOffset?: number;
  85570. /**
  85571. * The lenth of the bufferView in bytes
  85572. */
  85573. byteLength: number;
  85574. /**
  85575. * The stride, in bytes
  85576. */
  85577. byteStride?: number;
  85578. }
  85579. /**
  85580. * An orthographic camera containing properties to create an orthographic projection matrix
  85581. */
  85582. interface ICameraOrthographic extends IProperty {
  85583. /**
  85584. * The floating-point horizontal magnification of the view. Must not be zero
  85585. */
  85586. xmag: number;
  85587. /**
  85588. * The floating-point vertical magnification of the view. Must not be zero
  85589. */
  85590. ymag: number;
  85591. /**
  85592. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85593. */
  85594. zfar: number;
  85595. /**
  85596. * The floating-point distance to the near clipping plane
  85597. */
  85598. znear: number;
  85599. }
  85600. /**
  85601. * A perspective camera containing properties to create a perspective projection matrix
  85602. */
  85603. interface ICameraPerspective extends IProperty {
  85604. /**
  85605. * The floating-point aspect ratio of the field of view
  85606. */
  85607. aspectRatio?: number;
  85608. /**
  85609. * The floating-point vertical field of view in radians
  85610. */
  85611. yfov: number;
  85612. /**
  85613. * The floating-point distance to the far clipping plane
  85614. */
  85615. zfar?: number;
  85616. /**
  85617. * The floating-point distance to the near clipping plane
  85618. */
  85619. znear: number;
  85620. }
  85621. /**
  85622. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85623. */
  85624. interface ICamera extends IChildRootProperty {
  85625. /**
  85626. * An orthographic camera containing properties to create an orthographic projection matrix
  85627. */
  85628. orthographic?: ICameraOrthographic;
  85629. /**
  85630. * A perspective camera containing properties to create a perspective projection matrix
  85631. */
  85632. perspective?: ICameraPerspective;
  85633. /**
  85634. * Specifies if the camera uses a perspective or orthographic projection
  85635. */
  85636. type: CameraType;
  85637. }
  85638. /**
  85639. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85640. */
  85641. interface IImage extends IChildRootProperty {
  85642. /**
  85643. * 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
  85644. */
  85645. uri?: string;
  85646. /**
  85647. * The image's MIME type
  85648. */
  85649. mimeType?: ImageMimeType;
  85650. /**
  85651. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85652. */
  85653. bufferView?: number;
  85654. }
  85655. /**
  85656. * Material Normal Texture Info
  85657. */
  85658. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85659. /**
  85660. * The scalar multiplier applied to each normal vector of the normal texture
  85661. */
  85662. scale?: number;
  85663. }
  85664. /**
  85665. * Material Occlusion Texture Info
  85666. */
  85667. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85668. /**
  85669. * A scalar multiplier controlling the amount of occlusion applied
  85670. */
  85671. strength?: number;
  85672. }
  85673. /**
  85674. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85675. */
  85676. interface IMaterialPbrMetallicRoughness {
  85677. /**
  85678. * The material's base color factor
  85679. */
  85680. baseColorFactor?: number[];
  85681. /**
  85682. * The base color texture
  85683. */
  85684. baseColorTexture?: ITextureInfo;
  85685. /**
  85686. * The metalness of the material
  85687. */
  85688. metallicFactor?: number;
  85689. /**
  85690. * The roughness of the material
  85691. */
  85692. roughnessFactor?: number;
  85693. /**
  85694. * The metallic-roughness texture
  85695. */
  85696. metallicRoughnessTexture?: ITextureInfo;
  85697. }
  85698. /**
  85699. * The material appearance of a primitive
  85700. */
  85701. interface IMaterial extends IChildRootProperty {
  85702. /**
  85703. * 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
  85704. */
  85705. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85706. /**
  85707. * The normal map texture
  85708. */
  85709. normalTexture?: IMaterialNormalTextureInfo;
  85710. /**
  85711. * The occlusion map texture
  85712. */
  85713. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85714. /**
  85715. * The emissive map texture
  85716. */
  85717. emissiveTexture?: ITextureInfo;
  85718. /**
  85719. * 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
  85720. */
  85721. emissiveFactor?: number[];
  85722. /**
  85723. * The alpha rendering mode of the material
  85724. */
  85725. alphaMode?: MaterialAlphaMode;
  85726. /**
  85727. * The alpha cutoff value of the material
  85728. */
  85729. alphaCutoff?: number;
  85730. /**
  85731. * Specifies whether the material is double sided
  85732. */
  85733. doubleSided?: boolean;
  85734. }
  85735. /**
  85736. * Geometry to be rendered with the given material
  85737. */
  85738. interface IMeshPrimitive extends IProperty {
  85739. /**
  85740. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85741. */
  85742. attributes: {
  85743. [name: string]: number;
  85744. };
  85745. /**
  85746. * The index of the accessor that contains the indices
  85747. */
  85748. indices?: number;
  85749. /**
  85750. * The index of the material to apply to this primitive when rendering
  85751. */
  85752. material?: number;
  85753. /**
  85754. * The type of primitives to render. All valid values correspond to WebGL enums
  85755. */
  85756. mode?: MeshPrimitiveMode;
  85757. /**
  85758. * 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
  85759. */
  85760. targets?: {
  85761. [name: string]: number;
  85762. }[];
  85763. }
  85764. /**
  85765. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85766. */
  85767. interface IMesh extends IChildRootProperty {
  85768. /**
  85769. * An array of primitives, each defining geometry to be rendered with a material
  85770. */
  85771. primitives: IMeshPrimitive[];
  85772. /**
  85773. * Array of weights to be applied to the Morph Targets
  85774. */
  85775. weights?: number[];
  85776. }
  85777. /**
  85778. * A node in the node hierarchy
  85779. */
  85780. interface INode extends IChildRootProperty {
  85781. /**
  85782. * The index of the camera referenced by this node
  85783. */
  85784. camera?: number;
  85785. /**
  85786. * The indices of this node's children
  85787. */
  85788. children?: number[];
  85789. /**
  85790. * The index of the skin referenced by this node
  85791. */
  85792. skin?: number;
  85793. /**
  85794. * A floating-point 4x4 transformation matrix stored in column-major order
  85795. */
  85796. matrix?: number[];
  85797. /**
  85798. * The index of the mesh in this node
  85799. */
  85800. mesh?: number;
  85801. /**
  85802. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85803. */
  85804. rotation?: number[];
  85805. /**
  85806. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85807. */
  85808. scale?: number[];
  85809. /**
  85810. * The node's translation along the x, y, and z axes
  85811. */
  85812. translation?: number[];
  85813. /**
  85814. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85815. */
  85816. weights?: number[];
  85817. }
  85818. /**
  85819. * Texture sampler properties for filtering and wrapping modes
  85820. */
  85821. interface ISampler extends IChildRootProperty {
  85822. /**
  85823. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85824. */
  85825. magFilter?: TextureMagFilter;
  85826. /**
  85827. * Minification filter. All valid values correspond to WebGL enums
  85828. */
  85829. minFilter?: TextureMinFilter;
  85830. /**
  85831. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85832. */
  85833. wrapS?: TextureWrapMode;
  85834. /**
  85835. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85836. */
  85837. wrapT?: TextureWrapMode;
  85838. }
  85839. /**
  85840. * The root nodes of a scene
  85841. */
  85842. interface IScene extends IChildRootProperty {
  85843. /**
  85844. * The indices of each root node
  85845. */
  85846. nodes: number[];
  85847. }
  85848. /**
  85849. * Joints and matrices defining a skin
  85850. */
  85851. interface ISkin extends IChildRootProperty {
  85852. /**
  85853. * 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
  85854. */
  85855. inverseBindMatrices?: number;
  85856. /**
  85857. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85858. */
  85859. skeleton?: number;
  85860. /**
  85861. * 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)
  85862. */
  85863. joints: number[];
  85864. }
  85865. /**
  85866. * A texture and its sampler
  85867. */
  85868. interface ITexture extends IChildRootProperty {
  85869. /**
  85870. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85871. */
  85872. sampler?: number;
  85873. /**
  85874. * The index of the image used by this texture
  85875. */
  85876. source: number;
  85877. }
  85878. /**
  85879. * Reference to a texture
  85880. */
  85881. interface ITextureInfo extends IProperty {
  85882. /**
  85883. * The index of the texture
  85884. */
  85885. index: number;
  85886. /**
  85887. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85888. */
  85889. texCoord?: number;
  85890. }
  85891. /**
  85892. * The root object for a glTF asset
  85893. */
  85894. interface IGLTF extends IProperty {
  85895. /**
  85896. * An array of accessors. An accessor is a typed view into a bufferView
  85897. */
  85898. accessors?: IAccessor[];
  85899. /**
  85900. * An array of keyframe animations
  85901. */
  85902. animations?: IAnimation[];
  85903. /**
  85904. * Metadata about the glTF asset
  85905. */
  85906. asset: IAsset;
  85907. /**
  85908. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85909. */
  85910. buffers?: IBuffer[];
  85911. /**
  85912. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85913. */
  85914. bufferViews?: IBufferView[];
  85915. /**
  85916. * An array of cameras
  85917. */
  85918. cameras?: ICamera[];
  85919. /**
  85920. * Names of glTF extensions used somewhere in this asset
  85921. */
  85922. extensionsUsed?: string[];
  85923. /**
  85924. * Names of glTF extensions required to properly load this asset
  85925. */
  85926. extensionsRequired?: string[];
  85927. /**
  85928. * An array of images. An image defines data used to create a texture
  85929. */
  85930. images?: IImage[];
  85931. /**
  85932. * An array of materials. A material defines the appearance of a primitive
  85933. */
  85934. materials?: IMaterial[];
  85935. /**
  85936. * An array of meshes. A mesh is a set of primitives to be rendered
  85937. */
  85938. meshes?: IMesh[];
  85939. /**
  85940. * An array of nodes
  85941. */
  85942. nodes?: INode[];
  85943. /**
  85944. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85945. */
  85946. samplers?: ISampler[];
  85947. /**
  85948. * The index of the default scene
  85949. */
  85950. scene?: number;
  85951. /**
  85952. * An array of scenes
  85953. */
  85954. scenes?: IScene[];
  85955. /**
  85956. * An array of skins. A skin is defined by joints and matrices
  85957. */
  85958. skins?: ISkin[];
  85959. /**
  85960. * An array of textures
  85961. */
  85962. textures?: ITexture[];
  85963. }
  85964. /**
  85965. * The glTF validation results
  85966. * @ignore
  85967. */
  85968. interface IGLTFValidationResults {
  85969. info: {
  85970. generator: string;
  85971. hasAnimations: boolean;
  85972. hasDefaultScene: boolean;
  85973. hasMaterials: boolean;
  85974. hasMorphTargets: boolean;
  85975. hasSkins: boolean;
  85976. hasTextures: boolean;
  85977. maxAttributesUsed: number;
  85978. primitivesCount: number
  85979. };
  85980. issues: {
  85981. messages: Array<string>;
  85982. numErrors: number;
  85983. numHints: number;
  85984. numInfos: number;
  85985. numWarnings: number;
  85986. truncated: boolean
  85987. };
  85988. mimeType: string;
  85989. uri: string;
  85990. validatedAt: string;
  85991. validatorVersion: string;
  85992. }
  85993. /**
  85994. * The glTF validation options
  85995. */
  85996. interface IGLTFValidationOptions {
  85997. /** Uri to use */
  85998. uri?: string;
  85999. /** Function used to load external resources */
  86000. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86001. /** Boolean indicating that we need to validate accessor data */
  86002. validateAccessorData?: boolean;
  86003. /** max number of issues allowed */
  86004. maxIssues?: number;
  86005. /** Ignored issues */
  86006. ignoredIssues?: Array<string>;
  86007. /** Value to override severy settings */
  86008. severityOverrides?: Object;
  86009. }
  86010. /**
  86011. * The glTF validator object
  86012. * @ignore
  86013. */
  86014. interface IGLTFValidator {
  86015. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86016. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86017. }
  86018. /**
  86019. * Interfaces from the EXT_lights_image_based extension
  86020. */
  86021. /** @hidden */
  86022. interface IEXTLightsImageBased_LightReferenceImageBased {
  86023. light: number;
  86024. }
  86025. /** @hidden */
  86026. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86027. intensity: number;
  86028. rotation: number[];
  86029. specularImageSize: number;
  86030. specularImages: number[][];
  86031. irradianceCoefficients: number[][];
  86032. }
  86033. /** @hidden */
  86034. interface IEXTLightsImageBased {
  86035. lights: IEXTLightsImageBased_LightImageBased[];
  86036. }
  86037. /**
  86038. * Interfaces from the EXT_mesh_gpu_instancing extension
  86039. * !!! Experimental Extension Subject to Changes !!!
  86040. */
  86041. /** @hidden */
  86042. interface IEXTMeshGpuInstancing {
  86043. mesh?: number;
  86044. attributes: { [name: string]: number };
  86045. }
  86046. /**
  86047. * Interfaces from the KHR_draco_mesh_compression extension
  86048. */
  86049. /** @hidden */
  86050. interface IKHRDracoMeshCompression {
  86051. bufferView: number;
  86052. attributes: { [name: string]: number };
  86053. }
  86054. /**
  86055. * Interfaces from the KHR_lights_punctual extension
  86056. */
  86057. /** @hidden */
  86058. const enum IKHRLightsPunctual_LightType {
  86059. DIRECTIONAL = "directional",
  86060. POINT = "point",
  86061. SPOT = "spot"
  86062. }
  86063. /** @hidden */
  86064. interface IKHRLightsPunctual_LightReference {
  86065. light: number;
  86066. }
  86067. /** @hidden */
  86068. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86069. type: IKHRLightsPunctual_LightType;
  86070. color?: number[];
  86071. intensity?: number;
  86072. range?: number;
  86073. spot?: {
  86074. innerConeAngle?: number;
  86075. outerConeAngle?: number;
  86076. };
  86077. }
  86078. /** @hidden */
  86079. interface IKHRLightsPunctual {
  86080. lights: IKHRLightsPunctual_Light[];
  86081. }
  86082. /**
  86083. * Interfaces from the KHR_materials_clearcoat extension
  86084. * !!! Experimental Extension Subject to Changes !!!
  86085. */
  86086. /** @hidden */
  86087. interface IKHRMaterialsClearcoat {
  86088. clearcoatFactor: number;
  86089. clearcoatTexture: ITextureInfo;
  86090. clearcoatRoughnessFactor: number;
  86091. clearcoatRoughnessTexture: ITextureInfo;
  86092. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86093. }
  86094. /**
  86095. * Interfaces from the KHR_materials_ior extension
  86096. * !!! Experimental Extension Subject to Changes !!!
  86097. */
  86098. /** @hidden */
  86099. interface IKHRMaterialsIor {
  86100. ior: number;
  86101. }
  86102. /**
  86103. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86104. */
  86105. /** @hidden */
  86106. interface IKHRMaterialsPbrSpecularGlossiness {
  86107. diffuseFactor: number[];
  86108. diffuseTexture: ITextureInfo;
  86109. specularFactor: number[];
  86110. glossinessFactor: number;
  86111. specularGlossinessTexture: ITextureInfo;
  86112. }
  86113. /**
  86114. * Interfaces from the KHR_materials_sheen extension
  86115. * !!! Experimental Extension Subject to Changes !!!
  86116. */
  86117. /** @hidden */
  86118. interface IKHRMaterialsSheen {
  86119. sheenColorFactor?: number[];
  86120. sheenColorTexture?: ITextureInfo;
  86121. sheenRoughnessFactor?: number;
  86122. sheenRoughnessTexture?: ITextureInfo;
  86123. }
  86124. /**
  86125. * Interfaces from the KHR_materials_specular extension
  86126. * !!! Experimental Extension Subject to Changes !!!
  86127. */
  86128. /** @hidden */
  86129. interface IKHRMaterialsSpecular {
  86130. specularFactor: number;
  86131. specularColorFactor: number[];
  86132. specularTexture: ITextureInfo;
  86133. }
  86134. /**
  86135. * Interfaces from the KHR_materials_transmission extension
  86136. * !!! Experimental Extension Subject to Changes !!!
  86137. */
  86138. /** @hidden */
  86139. interface IKHRMaterialsTransmission {
  86140. transmissionFactor?: number;
  86141. transmissionTexture?: ITextureInfo;
  86142. }
  86143. /**
  86144. * Interfaces from the KHR_materials_variants extension
  86145. * !!! Experimental Extension Subject to Changes !!!
  86146. */
  86147. /** @hidden */
  86148. interface IKHRMaterialVariants_Mapping extends IProperty {
  86149. mappings: Array<{
  86150. variants: number[];
  86151. material: number;
  86152. }>;
  86153. }
  86154. /** @hidden */
  86155. interface IKHRMaterialVariants_Variant extends IProperty {
  86156. name: string;
  86157. }
  86158. /** @hidden */
  86159. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86160. variants: Array<IKHRMaterialVariants_Variant>;
  86161. }
  86162. /**
  86163. * Interfaces from the KHR_texture_basisu extension
  86164. * !!! Experimental Extension Subject to Changes !!!
  86165. */
  86166. /** @hidden */
  86167. interface IKHRTextureBasisU {
  86168. source: number;
  86169. }
  86170. /**
  86171. * Interfaces from the EXT_texture_webp extension
  86172. */
  86173. /** @hidden */
  86174. interface IEXTTextureWebP {
  86175. source: number;
  86176. }
  86177. /**
  86178. * Interfaces from the KHR_texture_transform extension
  86179. */
  86180. /** @hidden */
  86181. interface IKHRTextureTransform {
  86182. offset?: number[];
  86183. rotation?: number;
  86184. scale?: number[];
  86185. texCoord?: number;
  86186. }
  86187. /**
  86188. * Interfaces from the KHR_xmp extension
  86189. * !!! Experimental Extension Subject to Changes !!!
  86190. */
  86191. /** @hidden */
  86192. interface IKHRXmp_Data {
  86193. [key: string]: unknown;
  86194. }
  86195. /** @hidden */
  86196. interface IKHRXmp_Gltf {
  86197. packets: IKHRXmp_Data[];
  86198. }
  86199. /** @hidden */
  86200. interface IKHRXmp_Node {
  86201. packet: number;
  86202. }
  86203. /**
  86204. * Interfaces from the MSFT_audio_emitter extension
  86205. */
  86206. /** @hidden */
  86207. interface IMSFTAudioEmitter_ClipReference {
  86208. clip: number;
  86209. weight?: number;
  86210. }
  86211. /** @hidden */
  86212. interface IMSFTAudioEmitter_EmittersReference {
  86213. emitters: number[];
  86214. }
  86215. /** @hidden */
  86216. const enum IMSFTAudioEmitter_DistanceModel {
  86217. linear = "linear",
  86218. inverse = "inverse",
  86219. exponential = "exponential",
  86220. }
  86221. /** @hidden */
  86222. interface IMSFTAudioEmitter_Emitter {
  86223. name?: string;
  86224. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86225. refDistance?: number;
  86226. maxDistance?: number;
  86227. rolloffFactor?: number;
  86228. innerAngle?: number;
  86229. outerAngle?: number;
  86230. loop?: boolean;
  86231. volume?: number;
  86232. clips: IMSFTAudioEmitter_ClipReference[];
  86233. }
  86234. /** @hidden */
  86235. const enum IMSFTAudioEmitter_AudioMimeType {
  86236. WAV = "audio/wav",
  86237. }
  86238. /** @hidden */
  86239. interface IMSFTAudioEmitter_Clip extends IProperty {
  86240. uri?: string;
  86241. bufferView?: number;
  86242. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86243. }
  86244. /** @hidden */
  86245. const enum IMSFTAudioEmitter_AnimationEventAction {
  86246. play = "play",
  86247. pause = "pause",
  86248. stop = "stop",
  86249. }
  86250. /** @hidden */
  86251. interface IMSFTAudioEmitter_AnimationEvent {
  86252. action: IMSFTAudioEmitter_AnimationEventAction;
  86253. emitter: number;
  86254. time: number;
  86255. startOffset?: number;
  86256. }
  86257. /**
  86258. * Interfaces from the MSFT_lod extension
  86259. */
  86260. /** @hidden */
  86261. interface IMSFTLOD {
  86262. ids: number[];
  86263. }
  86264. }
  86265. declare module BABYLON {
  86266. /** @hidden */
  86267. export var cellPixelShader: {
  86268. name: string;
  86269. shader: string;
  86270. };
  86271. }
  86272. declare module BABYLON {
  86273. /** @hidden */
  86274. export var cellVertexShader: {
  86275. name: string;
  86276. shader: string;
  86277. };
  86278. }
  86279. declare module BABYLON {
  86280. export class CellMaterial extends BABYLON.PushMaterial {
  86281. private _diffuseTexture;
  86282. diffuseTexture: BABYLON.BaseTexture;
  86283. diffuseColor: BABYLON.Color3;
  86284. _computeHighLevel: boolean;
  86285. computeHighLevel: boolean;
  86286. private _disableLighting;
  86287. disableLighting: boolean;
  86288. private _maxSimultaneousLights;
  86289. maxSimultaneousLights: number;
  86290. constructor(name: string, scene: BABYLON.Scene);
  86291. needAlphaBlending(): boolean;
  86292. needAlphaTesting(): boolean;
  86293. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86294. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86295. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86296. getAnimatables(): BABYLON.IAnimatable[];
  86297. getActiveTextures(): BABYLON.BaseTexture[];
  86298. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86299. dispose(forceDisposeEffect?: boolean): void;
  86300. getClassName(): string;
  86301. clone(name: string): CellMaterial;
  86302. serialize(): any;
  86303. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86304. }
  86305. }
  86306. declare module BABYLON {
  86307. export class CustomShaderStructure {
  86308. FragmentStore: string;
  86309. VertexStore: string;
  86310. constructor();
  86311. }
  86312. export class ShaderSpecialParts {
  86313. constructor();
  86314. Fragment_Begin: string;
  86315. Fragment_Definitions: string;
  86316. Fragment_MainBegin: string;
  86317. Fragment_Custom_Diffuse: string;
  86318. Fragment_Before_Lights: string;
  86319. Fragment_Before_Fog: string;
  86320. Fragment_Custom_Alpha: string;
  86321. Fragment_Before_FragColor: string;
  86322. Vertex_Begin: string;
  86323. Vertex_Definitions: string;
  86324. Vertex_MainBegin: string;
  86325. Vertex_Before_PositionUpdated: string;
  86326. Vertex_Before_NormalUpdated: string;
  86327. Vertex_After_WorldPosComputed: string;
  86328. Vertex_MainEnd: string;
  86329. }
  86330. export class CustomMaterial extends BABYLON.StandardMaterial {
  86331. static ShaderIndexer: number;
  86332. CustomParts: ShaderSpecialParts;
  86333. _isCreatedShader: boolean;
  86334. _createdShaderName: string;
  86335. _customUniform: string[];
  86336. _newUniforms: string[];
  86337. _newUniformInstances: {
  86338. [name: string]: any;
  86339. };
  86340. _newSamplerInstances: {
  86341. [name: string]: BABYLON.Texture;
  86342. };
  86343. _customAttributes: string[];
  86344. FragmentShader: string;
  86345. VertexShader: string;
  86346. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86347. ReviewUniform(name: string, arr: string[]): string[];
  86348. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86349. constructor(name: string, scene: BABYLON.Scene);
  86350. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86351. AddAttribute(name: string): CustomMaterial;
  86352. Fragment_Begin(shaderPart: string): CustomMaterial;
  86353. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86354. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86355. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86356. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86357. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86358. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86359. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86360. Vertex_Begin(shaderPart: string): CustomMaterial;
  86361. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86362. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86363. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86364. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86365. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86366. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86367. }
  86368. }
  86369. declare module BABYLON {
  86370. export class ShaderAlebdoParts {
  86371. constructor();
  86372. Fragment_Begin: string;
  86373. Fragment_Definitions: string;
  86374. Fragment_MainBegin: string;
  86375. Fragment_Custom_Albedo: string;
  86376. Fragment_Before_Lights: string;
  86377. Fragment_Custom_MetallicRoughness: string;
  86378. Fragment_Custom_MicroSurface: string;
  86379. Fragment_Before_Fog: string;
  86380. Fragment_Custom_Alpha: string;
  86381. Fragment_Before_FragColor: string;
  86382. Vertex_Begin: string;
  86383. Vertex_Definitions: string;
  86384. Vertex_MainBegin: string;
  86385. Vertex_Before_PositionUpdated: string;
  86386. Vertex_Before_NormalUpdated: string;
  86387. Vertex_After_WorldPosComputed: string;
  86388. Vertex_MainEnd: string;
  86389. }
  86390. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86391. static ShaderIndexer: number;
  86392. CustomParts: ShaderAlebdoParts;
  86393. _isCreatedShader: boolean;
  86394. _createdShaderName: string;
  86395. _customUniform: string[];
  86396. _newUniforms: string[];
  86397. _newUniformInstances: {
  86398. [name: string]: any;
  86399. };
  86400. _newSamplerInstances: {
  86401. [name: string]: BABYLON.Texture;
  86402. };
  86403. _customAttributes: string[];
  86404. FragmentShader: string;
  86405. VertexShader: string;
  86406. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86407. ReviewUniform(name: string, arr: string[]): string[];
  86408. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86409. constructor(name: string, scene: BABYLON.Scene);
  86410. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86411. AddAttribute(name: string): PBRCustomMaterial;
  86412. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86413. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86414. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86415. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86416. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86417. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86418. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86419. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86420. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86421. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86422. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86423. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86424. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86425. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86426. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86427. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86428. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86429. }
  86430. }
  86431. declare module BABYLON {
  86432. /** @hidden */
  86433. export var firePixelShader: {
  86434. name: string;
  86435. shader: string;
  86436. };
  86437. }
  86438. declare module BABYLON {
  86439. /** @hidden */
  86440. export var fireVertexShader: {
  86441. name: string;
  86442. shader: string;
  86443. };
  86444. }
  86445. declare module BABYLON {
  86446. export class FireMaterial extends BABYLON.PushMaterial {
  86447. private _diffuseTexture;
  86448. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86449. private _distortionTexture;
  86450. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86451. private _opacityTexture;
  86452. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86453. diffuseColor: BABYLON.Color3;
  86454. speed: number;
  86455. private _scaledDiffuse;
  86456. private _lastTime;
  86457. constructor(name: string, scene: BABYLON.Scene);
  86458. needAlphaBlending(): boolean;
  86459. needAlphaTesting(): boolean;
  86460. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86461. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86462. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86463. getAnimatables(): BABYLON.IAnimatable[];
  86464. getActiveTextures(): BABYLON.BaseTexture[];
  86465. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86466. getClassName(): string;
  86467. dispose(forceDisposeEffect?: boolean): void;
  86468. clone(name: string): FireMaterial;
  86469. serialize(): any;
  86470. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86471. }
  86472. }
  86473. declare module BABYLON {
  86474. /** @hidden */
  86475. export var furPixelShader: {
  86476. name: string;
  86477. shader: string;
  86478. };
  86479. }
  86480. declare module BABYLON {
  86481. /** @hidden */
  86482. export var furVertexShader: {
  86483. name: string;
  86484. shader: string;
  86485. };
  86486. }
  86487. declare module BABYLON {
  86488. export class FurMaterial extends BABYLON.PushMaterial {
  86489. private _diffuseTexture;
  86490. diffuseTexture: BABYLON.BaseTexture;
  86491. private _heightTexture;
  86492. heightTexture: BABYLON.BaseTexture;
  86493. diffuseColor: BABYLON.Color3;
  86494. furLength: number;
  86495. furAngle: number;
  86496. furColor: BABYLON.Color3;
  86497. furOffset: number;
  86498. furSpacing: number;
  86499. furGravity: BABYLON.Vector3;
  86500. furSpeed: number;
  86501. furDensity: number;
  86502. furOcclusion: number;
  86503. furTexture: BABYLON.DynamicTexture;
  86504. private _disableLighting;
  86505. disableLighting: boolean;
  86506. private _maxSimultaneousLights;
  86507. maxSimultaneousLights: number;
  86508. highLevelFur: boolean;
  86509. _meshes: BABYLON.AbstractMesh[];
  86510. private _furTime;
  86511. constructor(name: string, scene: BABYLON.Scene);
  86512. get furTime(): number;
  86513. set furTime(furTime: number);
  86514. needAlphaBlending(): boolean;
  86515. needAlphaTesting(): boolean;
  86516. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86517. updateFur(): void;
  86518. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86519. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86520. getAnimatables(): BABYLON.IAnimatable[];
  86521. getActiveTextures(): BABYLON.BaseTexture[];
  86522. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86523. dispose(forceDisposeEffect?: boolean): void;
  86524. clone(name: string): FurMaterial;
  86525. serialize(): any;
  86526. getClassName(): string;
  86527. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86528. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86529. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86530. }
  86531. }
  86532. declare module BABYLON {
  86533. /** @hidden */
  86534. export var gradientPixelShader: {
  86535. name: string;
  86536. shader: string;
  86537. };
  86538. }
  86539. declare module BABYLON {
  86540. /** @hidden */
  86541. export var gradientVertexShader: {
  86542. name: string;
  86543. shader: string;
  86544. };
  86545. }
  86546. declare module BABYLON {
  86547. export class GradientMaterial extends BABYLON.PushMaterial {
  86548. private _maxSimultaneousLights;
  86549. maxSimultaneousLights: number;
  86550. topColor: BABYLON.Color3;
  86551. topColorAlpha: number;
  86552. bottomColor: BABYLON.Color3;
  86553. bottomColorAlpha: number;
  86554. offset: number;
  86555. scale: number;
  86556. smoothness: number;
  86557. private _disableLighting;
  86558. disableLighting: boolean;
  86559. constructor(name: string, scene: BABYLON.Scene);
  86560. needAlphaBlending(): boolean;
  86561. needAlphaTesting(): boolean;
  86562. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86563. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86564. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86565. getAnimatables(): BABYLON.IAnimatable[];
  86566. dispose(forceDisposeEffect?: boolean): void;
  86567. clone(name: string): GradientMaterial;
  86568. serialize(): any;
  86569. getClassName(): string;
  86570. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86571. }
  86572. }
  86573. declare module BABYLON {
  86574. /** @hidden */
  86575. export var gridPixelShader: {
  86576. name: string;
  86577. shader: string;
  86578. };
  86579. }
  86580. declare module BABYLON {
  86581. /** @hidden */
  86582. export var gridVertexShader: {
  86583. name: string;
  86584. shader: string;
  86585. };
  86586. }
  86587. declare module BABYLON {
  86588. /**
  86589. * The grid materials allows you to wrap any shape with a grid.
  86590. * Colors are customizable.
  86591. */
  86592. export class GridMaterial extends BABYLON.PushMaterial {
  86593. /**
  86594. * Main color of the grid (e.g. between lines)
  86595. */
  86596. mainColor: BABYLON.Color3;
  86597. /**
  86598. * Color of the grid lines.
  86599. */
  86600. lineColor: BABYLON.Color3;
  86601. /**
  86602. * The scale of the grid compared to unit.
  86603. */
  86604. gridRatio: number;
  86605. /**
  86606. * Allows setting an offset for the grid lines.
  86607. */
  86608. gridOffset: BABYLON.Vector3;
  86609. /**
  86610. * The frequency of thicker lines.
  86611. */
  86612. majorUnitFrequency: number;
  86613. /**
  86614. * The visibility of minor units in the grid.
  86615. */
  86616. minorUnitVisibility: number;
  86617. /**
  86618. * The grid opacity outside of the lines.
  86619. */
  86620. opacity: number;
  86621. /**
  86622. * Determine RBG output is premultiplied by alpha value.
  86623. */
  86624. preMultiplyAlpha: boolean;
  86625. private _opacityTexture;
  86626. opacityTexture: BABYLON.BaseTexture;
  86627. private _gridControl;
  86628. /**
  86629. * constructor
  86630. * @param name The name given to the material in order to identify it afterwards.
  86631. * @param scene The scene the material is used in.
  86632. */
  86633. constructor(name: string, scene: BABYLON.Scene);
  86634. /**
  86635. * Returns wehter or not the grid requires alpha blending.
  86636. */
  86637. needAlphaBlending(): boolean;
  86638. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86639. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86640. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86641. /**
  86642. * Dispose the material and its associated resources.
  86643. * @param forceDisposeEffect will also dispose the used effect when true
  86644. */
  86645. dispose(forceDisposeEffect?: boolean): void;
  86646. clone(name: string): GridMaterial;
  86647. serialize(): any;
  86648. getClassName(): string;
  86649. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86650. }
  86651. }
  86652. declare module BABYLON {
  86653. /** @hidden */
  86654. export var lavaPixelShader: {
  86655. name: string;
  86656. shader: string;
  86657. };
  86658. }
  86659. declare module BABYLON {
  86660. /** @hidden */
  86661. export var lavaVertexShader: {
  86662. name: string;
  86663. shader: string;
  86664. };
  86665. }
  86666. declare module BABYLON {
  86667. export class LavaMaterial extends BABYLON.PushMaterial {
  86668. private _diffuseTexture;
  86669. diffuseTexture: BABYLON.BaseTexture;
  86670. noiseTexture: BABYLON.BaseTexture;
  86671. fogColor: BABYLON.Color3;
  86672. speed: number;
  86673. movingSpeed: number;
  86674. lowFrequencySpeed: number;
  86675. fogDensity: number;
  86676. private _lastTime;
  86677. diffuseColor: BABYLON.Color3;
  86678. private _disableLighting;
  86679. disableLighting: boolean;
  86680. private _unlit;
  86681. unlit: boolean;
  86682. private _maxSimultaneousLights;
  86683. maxSimultaneousLights: number;
  86684. private _scaledDiffuse;
  86685. constructor(name: string, scene: BABYLON.Scene);
  86686. needAlphaBlending(): boolean;
  86687. needAlphaTesting(): boolean;
  86688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86691. getAnimatables(): BABYLON.IAnimatable[];
  86692. getActiveTextures(): BABYLON.BaseTexture[];
  86693. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86694. dispose(forceDisposeEffect?: boolean): void;
  86695. clone(name: string): LavaMaterial;
  86696. serialize(): any;
  86697. getClassName(): string;
  86698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. /** @hidden */
  86703. export var mixPixelShader: {
  86704. name: string;
  86705. shader: string;
  86706. };
  86707. }
  86708. declare module BABYLON {
  86709. /** @hidden */
  86710. export var mixVertexShader: {
  86711. name: string;
  86712. shader: string;
  86713. };
  86714. }
  86715. declare module BABYLON {
  86716. export class MixMaterial extends BABYLON.PushMaterial {
  86717. /**
  86718. * Mix textures
  86719. */
  86720. private _mixTexture1;
  86721. mixTexture1: BABYLON.BaseTexture;
  86722. private _mixTexture2;
  86723. mixTexture2: BABYLON.BaseTexture;
  86724. /**
  86725. * Diffuse textures
  86726. */
  86727. private _diffuseTexture1;
  86728. diffuseTexture1: BABYLON.Texture;
  86729. private _diffuseTexture2;
  86730. diffuseTexture2: BABYLON.Texture;
  86731. private _diffuseTexture3;
  86732. diffuseTexture3: BABYLON.Texture;
  86733. private _diffuseTexture4;
  86734. diffuseTexture4: BABYLON.Texture;
  86735. private _diffuseTexture5;
  86736. diffuseTexture5: BABYLON.Texture;
  86737. private _diffuseTexture6;
  86738. diffuseTexture6: BABYLON.Texture;
  86739. private _diffuseTexture7;
  86740. diffuseTexture7: BABYLON.Texture;
  86741. private _diffuseTexture8;
  86742. diffuseTexture8: BABYLON.Texture;
  86743. /**
  86744. * Uniforms
  86745. */
  86746. diffuseColor: BABYLON.Color3;
  86747. specularColor: BABYLON.Color3;
  86748. specularPower: number;
  86749. private _disableLighting;
  86750. disableLighting: boolean;
  86751. private _maxSimultaneousLights;
  86752. maxSimultaneousLights: number;
  86753. constructor(name: string, scene: BABYLON.Scene);
  86754. needAlphaBlending(): boolean;
  86755. needAlphaTesting(): boolean;
  86756. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86757. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86758. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86759. getAnimatables(): BABYLON.IAnimatable[];
  86760. getActiveTextures(): BABYLON.BaseTexture[];
  86761. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86762. dispose(forceDisposeEffect?: boolean): void;
  86763. clone(name: string): MixMaterial;
  86764. serialize(): any;
  86765. getClassName(): string;
  86766. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86767. }
  86768. }
  86769. declare module BABYLON {
  86770. /** @hidden */
  86771. export var normalPixelShader: {
  86772. name: string;
  86773. shader: string;
  86774. };
  86775. }
  86776. declare module BABYLON {
  86777. /** @hidden */
  86778. export var normalVertexShader: {
  86779. name: string;
  86780. shader: string;
  86781. };
  86782. }
  86783. declare module BABYLON {
  86784. export class NormalMaterial extends BABYLON.PushMaterial {
  86785. private _diffuseTexture;
  86786. diffuseTexture: BABYLON.BaseTexture;
  86787. diffuseColor: BABYLON.Color3;
  86788. private _disableLighting;
  86789. disableLighting: boolean;
  86790. private _maxSimultaneousLights;
  86791. maxSimultaneousLights: number;
  86792. constructor(name: string, scene: BABYLON.Scene);
  86793. needAlphaBlending(): boolean;
  86794. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86795. needAlphaTesting(): boolean;
  86796. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86799. getAnimatables(): BABYLON.IAnimatable[];
  86800. getActiveTextures(): BABYLON.BaseTexture[];
  86801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86802. dispose(forceDisposeEffect?: boolean): void;
  86803. clone(name: string): NormalMaterial;
  86804. serialize(): any;
  86805. getClassName(): string;
  86806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86807. }
  86808. }
  86809. declare module BABYLON {
  86810. /** @hidden */
  86811. export var shadowOnlyPixelShader: {
  86812. name: string;
  86813. shader: string;
  86814. };
  86815. }
  86816. declare module BABYLON {
  86817. /** @hidden */
  86818. export var shadowOnlyVertexShader: {
  86819. name: string;
  86820. shader: string;
  86821. };
  86822. }
  86823. declare module BABYLON {
  86824. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86825. private _activeLight;
  86826. private _needAlphaBlending;
  86827. constructor(name: string, scene: BABYLON.Scene);
  86828. shadowColor: BABYLON.Color3;
  86829. needAlphaBlending(): boolean;
  86830. needAlphaTesting(): boolean;
  86831. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86832. get activeLight(): BABYLON.IShadowLight;
  86833. set activeLight(light: BABYLON.IShadowLight);
  86834. private _getFirstShadowLightForMesh;
  86835. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86836. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86837. clone(name: string): ShadowOnlyMaterial;
  86838. serialize(): any;
  86839. getClassName(): string;
  86840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86841. }
  86842. }
  86843. declare module BABYLON {
  86844. /** @hidden */
  86845. export var simplePixelShader: {
  86846. name: string;
  86847. shader: string;
  86848. };
  86849. }
  86850. declare module BABYLON {
  86851. /** @hidden */
  86852. export var simpleVertexShader: {
  86853. name: string;
  86854. shader: string;
  86855. };
  86856. }
  86857. declare module BABYLON {
  86858. export class SimpleMaterial extends BABYLON.PushMaterial {
  86859. private _diffuseTexture;
  86860. diffuseTexture: BABYLON.BaseTexture;
  86861. diffuseColor: BABYLON.Color3;
  86862. private _disableLighting;
  86863. disableLighting: boolean;
  86864. private _maxSimultaneousLights;
  86865. maxSimultaneousLights: number;
  86866. constructor(name: string, scene: BABYLON.Scene);
  86867. needAlphaBlending(): boolean;
  86868. needAlphaTesting(): boolean;
  86869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86872. getAnimatables(): BABYLON.IAnimatable[];
  86873. getActiveTextures(): BABYLON.BaseTexture[];
  86874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86875. dispose(forceDisposeEffect?: boolean): void;
  86876. clone(name: string): SimpleMaterial;
  86877. serialize(): any;
  86878. getClassName(): string;
  86879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86880. }
  86881. }
  86882. declare module BABYLON {
  86883. /** @hidden */
  86884. export var skyPixelShader: {
  86885. name: string;
  86886. shader: string;
  86887. };
  86888. }
  86889. declare module BABYLON {
  86890. /** @hidden */
  86891. export var skyVertexShader: {
  86892. name: string;
  86893. shader: string;
  86894. };
  86895. }
  86896. declare module BABYLON {
  86897. /**
  86898. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86899. * @see https://doc.babylonjs.com/extensions/sky
  86900. */
  86901. export class SkyMaterial extends BABYLON.PushMaterial {
  86902. /**
  86903. * Defines the overall luminance of sky in interval ]0, 1[.
  86904. */
  86905. luminance: number;
  86906. /**
  86907. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86908. */
  86909. turbidity: number;
  86910. /**
  86911. * Defines the sky appearance (light intensity).
  86912. */
  86913. rayleigh: number;
  86914. /**
  86915. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86916. */
  86917. mieCoefficient: number;
  86918. /**
  86919. * Defines the amount of haze particles following the Mie scattering theory.
  86920. */
  86921. mieDirectionalG: number;
  86922. /**
  86923. * Defines the distance of the sun according to the active scene camera.
  86924. */
  86925. distance: number;
  86926. /**
  86927. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86928. * "inclined".
  86929. */
  86930. inclination: number;
  86931. /**
  86932. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86933. * an object direction and a reference direction.
  86934. */
  86935. azimuth: number;
  86936. /**
  86937. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86938. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86939. */
  86940. sunPosition: BABYLON.Vector3;
  86941. /**
  86942. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86943. * .sunPosition property.
  86944. */
  86945. useSunPosition: boolean;
  86946. /**
  86947. * Defines an offset vector used to get a horizon offset.
  86948. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86949. */
  86950. cameraOffset: BABYLON.Vector3;
  86951. private _cameraPosition;
  86952. /**
  86953. * Instantiates a new sky material.
  86954. * This material allows to create dynamic and texture free
  86955. * effects for skyboxes by taking care of the atmosphere state.
  86956. * @see https://doc.babylonjs.com/extensions/sky
  86957. * @param name Define the name of the material in the scene
  86958. * @param scene Define the scene the material belong to
  86959. */
  86960. constructor(name: string, scene: BABYLON.Scene);
  86961. /**
  86962. * Specifies if the material will require alpha blending
  86963. * @returns a boolean specifying if alpha blending is needed
  86964. */
  86965. needAlphaBlending(): boolean;
  86966. /**
  86967. * Specifies if this material should be rendered in alpha test mode
  86968. * @returns false as the sky material doesn't need alpha testing.
  86969. */
  86970. needAlphaTesting(): boolean;
  86971. /**
  86972. * Get the texture used for alpha test purpose.
  86973. * @returns null as the sky material has no texture.
  86974. */
  86975. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86976. /**
  86977. * Get if the submesh is ready to be used and all its information available.
  86978. * Child classes can use it to update shaders
  86979. * @param mesh defines the mesh to check
  86980. * @param subMesh defines which submesh to check
  86981. * @param useInstances specifies that instances should be used
  86982. * @returns a boolean indicating that the submesh is ready or not
  86983. */
  86984. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86985. /**
  86986. * Binds the submesh to this material by preparing the effect and shader to draw
  86987. * @param world defines the world transformation matrix
  86988. * @param mesh defines the mesh containing the submesh
  86989. * @param subMesh defines the submesh to bind the material to
  86990. */
  86991. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86992. /**
  86993. * Get the list of animatables in the material.
  86994. * @returns the list of animatables object used in the material
  86995. */
  86996. getAnimatables(): BABYLON.IAnimatable[];
  86997. /**
  86998. * Disposes the material
  86999. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87000. */
  87001. dispose(forceDisposeEffect?: boolean): void;
  87002. /**
  87003. * Makes a duplicate of the material, and gives it a new name
  87004. * @param name defines the new name for the duplicated material
  87005. * @returns the cloned material
  87006. */
  87007. clone(name: string): SkyMaterial;
  87008. /**
  87009. * Serializes this material in a JSON representation
  87010. * @returns the serialized material object
  87011. */
  87012. serialize(): any;
  87013. /**
  87014. * Gets the current class name of the material e.g. "SkyMaterial"
  87015. * Mainly use in serialization.
  87016. * @returns the class name
  87017. */
  87018. getClassName(): string;
  87019. /**
  87020. * Creates a sky material from parsed material data
  87021. * @param source defines the JSON representation of the material
  87022. * @param scene defines the hosting scene
  87023. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87024. * @returns a new sky material
  87025. */
  87026. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87027. }
  87028. }
  87029. declare module BABYLON {
  87030. /** @hidden */
  87031. export var terrainPixelShader: {
  87032. name: string;
  87033. shader: string;
  87034. };
  87035. }
  87036. declare module BABYLON {
  87037. /** @hidden */
  87038. export var terrainVertexShader: {
  87039. name: string;
  87040. shader: string;
  87041. };
  87042. }
  87043. declare module BABYLON {
  87044. export class TerrainMaterial extends BABYLON.PushMaterial {
  87045. private _mixTexture;
  87046. mixTexture: BABYLON.BaseTexture;
  87047. private _diffuseTexture1;
  87048. diffuseTexture1: BABYLON.Texture;
  87049. private _diffuseTexture2;
  87050. diffuseTexture2: BABYLON.Texture;
  87051. private _diffuseTexture3;
  87052. diffuseTexture3: BABYLON.Texture;
  87053. private _bumpTexture1;
  87054. bumpTexture1: BABYLON.Texture;
  87055. private _bumpTexture2;
  87056. bumpTexture2: BABYLON.Texture;
  87057. private _bumpTexture3;
  87058. bumpTexture3: BABYLON.Texture;
  87059. diffuseColor: BABYLON.Color3;
  87060. specularColor: BABYLON.Color3;
  87061. specularPower: number;
  87062. private _disableLighting;
  87063. disableLighting: boolean;
  87064. private _maxSimultaneousLights;
  87065. maxSimultaneousLights: number;
  87066. constructor(name: string, scene: BABYLON.Scene);
  87067. needAlphaBlending(): boolean;
  87068. needAlphaTesting(): boolean;
  87069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87070. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87071. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87072. getAnimatables(): BABYLON.IAnimatable[];
  87073. getActiveTextures(): BABYLON.BaseTexture[];
  87074. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87075. dispose(forceDisposeEffect?: boolean): void;
  87076. clone(name: string): TerrainMaterial;
  87077. serialize(): any;
  87078. getClassName(): string;
  87079. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87080. }
  87081. }
  87082. declare module BABYLON {
  87083. /** @hidden */
  87084. export var triplanarPixelShader: {
  87085. name: string;
  87086. shader: string;
  87087. };
  87088. }
  87089. declare module BABYLON {
  87090. /** @hidden */
  87091. export var triplanarVertexShader: {
  87092. name: string;
  87093. shader: string;
  87094. };
  87095. }
  87096. declare module BABYLON {
  87097. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87098. mixTexture: BABYLON.BaseTexture;
  87099. private _diffuseTextureX;
  87100. diffuseTextureX: BABYLON.BaseTexture;
  87101. private _diffuseTextureY;
  87102. diffuseTextureY: BABYLON.BaseTexture;
  87103. private _diffuseTextureZ;
  87104. diffuseTextureZ: BABYLON.BaseTexture;
  87105. private _normalTextureX;
  87106. normalTextureX: BABYLON.BaseTexture;
  87107. private _normalTextureY;
  87108. normalTextureY: BABYLON.BaseTexture;
  87109. private _normalTextureZ;
  87110. normalTextureZ: BABYLON.BaseTexture;
  87111. tileSize: number;
  87112. diffuseColor: BABYLON.Color3;
  87113. specularColor: BABYLON.Color3;
  87114. specularPower: number;
  87115. private _disableLighting;
  87116. disableLighting: boolean;
  87117. private _maxSimultaneousLights;
  87118. maxSimultaneousLights: number;
  87119. constructor(name: string, scene: BABYLON.Scene);
  87120. needAlphaBlending(): boolean;
  87121. needAlphaTesting(): boolean;
  87122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87123. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87124. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87125. getAnimatables(): BABYLON.IAnimatable[];
  87126. getActiveTextures(): BABYLON.BaseTexture[];
  87127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87128. dispose(forceDisposeEffect?: boolean): void;
  87129. clone(name: string): TriPlanarMaterial;
  87130. serialize(): any;
  87131. getClassName(): string;
  87132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87133. }
  87134. }
  87135. declare module BABYLON {
  87136. /** @hidden */
  87137. export var waterPixelShader: {
  87138. name: string;
  87139. shader: string;
  87140. };
  87141. }
  87142. declare module BABYLON {
  87143. /** @hidden */
  87144. export var waterVertexShader: {
  87145. name: string;
  87146. shader: string;
  87147. };
  87148. }
  87149. declare module BABYLON {
  87150. export class WaterMaterial extends BABYLON.PushMaterial {
  87151. renderTargetSize: BABYLON.Vector2;
  87152. private _bumpTexture;
  87153. bumpTexture: BABYLON.BaseTexture;
  87154. diffuseColor: BABYLON.Color3;
  87155. specularColor: BABYLON.Color3;
  87156. specularPower: number;
  87157. private _disableLighting;
  87158. disableLighting: boolean;
  87159. private _maxSimultaneousLights;
  87160. maxSimultaneousLights: number;
  87161. /**
  87162. * Defines the wind force.
  87163. */
  87164. windForce: number;
  87165. /**
  87166. * Defines the direction of the wind in the plane (X, Z).
  87167. */
  87168. windDirection: BABYLON.Vector2;
  87169. /**
  87170. * Defines the height of the waves.
  87171. */
  87172. waveHeight: number;
  87173. /**
  87174. * Defines the bump height related to the bump map.
  87175. */
  87176. bumpHeight: number;
  87177. /**
  87178. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87179. */
  87180. private _bumpSuperimpose;
  87181. bumpSuperimpose: boolean;
  87182. /**
  87183. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87184. */
  87185. private _fresnelSeparate;
  87186. fresnelSeparate: boolean;
  87187. /**
  87188. * Defines wether or not bump Wwves modify the reflection.
  87189. */
  87190. private _bumpAffectsReflection;
  87191. bumpAffectsReflection: boolean;
  87192. /**
  87193. * Defines the water color blended with the refraction (near).
  87194. */
  87195. waterColor: BABYLON.Color3;
  87196. /**
  87197. * Defines the blend factor related to the water color.
  87198. */
  87199. colorBlendFactor: number;
  87200. /**
  87201. * Defines the water color blended with the reflection (far).
  87202. */
  87203. waterColor2: BABYLON.Color3;
  87204. /**
  87205. * Defines the blend factor related to the water color (reflection, far).
  87206. */
  87207. colorBlendFactor2: number;
  87208. /**
  87209. * Defines the maximum length of a wave.
  87210. */
  87211. waveLength: number;
  87212. /**
  87213. * Defines the waves speed.
  87214. */
  87215. waveSpeed: number;
  87216. /**
  87217. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  87218. */
  87219. waveCount: number;
  87220. /**
  87221. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87222. * will avoid calculating useless pixels in the pixel shader of the water material.
  87223. */
  87224. disableClipPlane: boolean;
  87225. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87226. private _mesh;
  87227. private _refractionRTT;
  87228. private _reflectionRTT;
  87229. private _reflectionTransform;
  87230. private _lastTime;
  87231. private _lastDeltaTime;
  87232. private _useLogarithmicDepth;
  87233. private _waitingRenderList;
  87234. private _imageProcessingConfiguration;
  87235. private _imageProcessingObserver;
  87236. /**
  87237. * Gets a boolean indicating that current material needs to register RTT
  87238. */
  87239. get hasRenderTargetTextures(): boolean;
  87240. /**
  87241. * Constructor
  87242. */
  87243. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87244. get useLogarithmicDepth(): boolean;
  87245. set useLogarithmicDepth(value: boolean);
  87246. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87247. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87248. addToRenderList(node: any): void;
  87249. enableRenderTargets(enable: boolean): void;
  87250. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87251. get renderTargetsEnabled(): boolean;
  87252. needAlphaBlending(): boolean;
  87253. needAlphaTesting(): boolean;
  87254. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87255. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87256. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87257. private _createRenderTargets;
  87258. getAnimatables(): BABYLON.IAnimatable[];
  87259. getActiveTextures(): BABYLON.BaseTexture[];
  87260. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87261. dispose(forceDisposeEffect?: boolean): void;
  87262. clone(name: string): WaterMaterial;
  87263. serialize(): any;
  87264. getClassName(): string;
  87265. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87266. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87267. }
  87268. }
  87269. declare module BABYLON {
  87270. /** @hidden */
  87271. export var asciiartPixelShader: {
  87272. name: string;
  87273. shader: string;
  87274. };
  87275. }
  87276. declare module BABYLON {
  87277. /**
  87278. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87279. *
  87280. * It basically takes care rendering the font front the given font size to a texture.
  87281. * This is used later on in the postprocess.
  87282. */
  87283. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87284. private _font;
  87285. private _text;
  87286. private _charSize;
  87287. /**
  87288. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87289. */
  87290. get charSize(): number;
  87291. /**
  87292. * Create a new instance of the Ascii Art FontTexture class
  87293. * @param name the name of the texture
  87294. * @param font the font to use, use the W3C CSS notation
  87295. * @param text the caracter set to use in the rendering.
  87296. * @param scene the scene that owns the texture
  87297. */
  87298. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87299. /**
  87300. * Gets the max char width of a font.
  87301. * @param font the font to use, use the W3C CSS notation
  87302. * @return the max char width
  87303. */
  87304. private getFontWidth;
  87305. /**
  87306. * Gets the max char height of a font.
  87307. * @param font the font to use, use the W3C CSS notation
  87308. * @return the max char height
  87309. */
  87310. private getFontHeight;
  87311. /**
  87312. * Clones the current AsciiArtTexture.
  87313. * @return the clone of the texture.
  87314. */
  87315. clone(): AsciiArtFontTexture;
  87316. /**
  87317. * Parses a json object representing the texture and returns an instance of it.
  87318. * @param source the source JSON representation
  87319. * @param scene the scene to create the texture for
  87320. * @return the parsed texture
  87321. */
  87322. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87323. }
  87324. /**
  87325. * Option available in the Ascii Art Post Process.
  87326. */
  87327. export interface IAsciiArtPostProcessOptions {
  87328. /**
  87329. * The font to use following the w3c font definition.
  87330. */
  87331. font?: string;
  87332. /**
  87333. * The character set to use in the postprocess.
  87334. */
  87335. characterSet?: string;
  87336. /**
  87337. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87338. * This number is defined between 0 and 1;
  87339. */
  87340. mixToTile?: number;
  87341. /**
  87342. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87343. * This number is defined between 0 and 1;
  87344. */
  87345. mixToNormal?: number;
  87346. }
  87347. /**
  87348. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87349. *
  87350. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87351. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87352. */
  87353. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87354. /**
  87355. * The font texture used to render the char in the post process.
  87356. */
  87357. private _asciiArtFontTexture;
  87358. /**
  87359. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87360. * This number is defined between 0 and 1;
  87361. */
  87362. mixToTile: number;
  87363. /**
  87364. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87365. * This number is defined between 0 and 1;
  87366. */
  87367. mixToNormal: number;
  87368. /**
  87369. * Instantiates a new Ascii Art Post Process.
  87370. * @param name the name to give to the postprocess
  87371. * @camera the camera to apply the post process to.
  87372. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87373. */
  87374. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87375. }
  87376. }
  87377. declare module BABYLON {
  87378. /** @hidden */
  87379. export var digitalrainPixelShader: {
  87380. name: string;
  87381. shader: string;
  87382. };
  87383. }
  87384. declare module BABYLON {
  87385. /**
  87386. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87387. *
  87388. * It basically takes care rendering the font front the given font size to a texture.
  87389. * This is used later on in the postprocess.
  87390. */
  87391. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87392. private _font;
  87393. private _text;
  87394. private _charSize;
  87395. /**
  87396. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87397. */
  87398. get charSize(): number;
  87399. /**
  87400. * Create a new instance of the Digital Rain FontTexture class
  87401. * @param name the name of the texture
  87402. * @param font the font to use, use the W3C CSS notation
  87403. * @param text the caracter set to use in the rendering.
  87404. * @param scene the scene that owns the texture
  87405. */
  87406. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87407. /**
  87408. * Gets the max char width of a font.
  87409. * @param font the font to use, use the W3C CSS notation
  87410. * @return the max char width
  87411. */
  87412. private getFontWidth;
  87413. /**
  87414. * Gets the max char height of a font.
  87415. * @param font the font to use, use the W3C CSS notation
  87416. * @return the max char height
  87417. */
  87418. private getFontHeight;
  87419. /**
  87420. * Clones the current DigitalRainFontTexture.
  87421. * @return the clone of the texture.
  87422. */
  87423. clone(): DigitalRainFontTexture;
  87424. /**
  87425. * Parses a json object representing the texture and returns an instance of it.
  87426. * @param source the source JSON representation
  87427. * @param scene the scene to create the texture for
  87428. * @return the parsed texture
  87429. */
  87430. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87431. }
  87432. /**
  87433. * Option available in the Digital Rain Post Process.
  87434. */
  87435. export interface IDigitalRainPostProcessOptions {
  87436. /**
  87437. * The font to use following the w3c font definition.
  87438. */
  87439. font?: string;
  87440. /**
  87441. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87442. * This number is defined between 0 and 1;
  87443. */
  87444. mixToTile?: number;
  87445. /**
  87446. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87447. * This number is defined between 0 and 1;
  87448. */
  87449. mixToNormal?: number;
  87450. }
  87451. /**
  87452. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87453. *
  87454. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87455. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87456. */
  87457. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87458. /**
  87459. * The font texture used to render the char in the post process.
  87460. */
  87461. private _digitalRainFontTexture;
  87462. /**
  87463. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87464. * This number is defined between 0 and 1;
  87465. */
  87466. mixToTile: number;
  87467. /**
  87468. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87469. * This number is defined between 0 and 1;
  87470. */
  87471. mixToNormal: number;
  87472. /**
  87473. * Instantiates a new Digital Rain Post Process.
  87474. * @param name the name to give to the postprocess
  87475. * @camera the camera to apply the post process to.
  87476. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87477. */
  87478. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87479. }
  87480. }
  87481. declare module BABYLON {
  87482. /** @hidden */
  87483. export var brickProceduralTexturePixelShader: {
  87484. name: string;
  87485. shader: string;
  87486. };
  87487. }
  87488. declare module BABYLON {
  87489. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87490. private _numberOfBricksHeight;
  87491. private _numberOfBricksWidth;
  87492. private _jointColor;
  87493. private _brickColor;
  87494. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87495. updateShaderUniforms(): void;
  87496. get numberOfBricksHeight(): number;
  87497. set numberOfBricksHeight(value: number);
  87498. get numberOfBricksWidth(): number;
  87499. set numberOfBricksWidth(value: number);
  87500. get jointColor(): BABYLON.Color3;
  87501. set jointColor(value: BABYLON.Color3);
  87502. get brickColor(): BABYLON.Color3;
  87503. set brickColor(value: BABYLON.Color3);
  87504. /**
  87505. * Serializes this brick procedural texture
  87506. * @returns a serialized brick procedural texture object
  87507. */
  87508. serialize(): any;
  87509. /**
  87510. * Creates a Brick Procedural BABYLON.Texture from parsed brick 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 brick procedural texture information
  87514. * @returns a parsed Brick Procedural BABYLON.Texture
  87515. */
  87516. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87517. }
  87518. }
  87519. declare module BABYLON {
  87520. /** @hidden */
  87521. export var cloudProceduralTexturePixelShader: {
  87522. name: string;
  87523. shader: string;
  87524. };
  87525. }
  87526. declare module BABYLON {
  87527. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87528. private _skyColor;
  87529. private _cloudColor;
  87530. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87531. updateShaderUniforms(): void;
  87532. get skyColor(): BABYLON.Color4;
  87533. set skyColor(value: BABYLON.Color4);
  87534. get cloudColor(): BABYLON.Color4;
  87535. set cloudColor(value: BABYLON.Color4);
  87536. /**
  87537. * Serializes this cloud procedural texture
  87538. * @returns a serialized cloud procedural texture object
  87539. */
  87540. serialize(): any;
  87541. /**
  87542. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87543. * @param parsedTexture defines parsed texture data
  87544. * @param scene defines the current scene
  87545. * @param rootUrl defines the root URL containing cloud procedural texture information
  87546. * @returns a parsed Cloud Procedural BABYLON.Texture
  87547. */
  87548. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87549. }
  87550. }
  87551. declare module BABYLON {
  87552. /** @hidden */
  87553. export var fireProceduralTexturePixelShader: {
  87554. name: string;
  87555. shader: string;
  87556. };
  87557. }
  87558. declare module BABYLON {
  87559. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87560. private _time;
  87561. private _speed;
  87562. private _autoGenerateTime;
  87563. private _fireColors;
  87564. private _alphaThreshold;
  87565. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87566. updateShaderUniforms(): void;
  87567. render(useCameraPostProcess?: boolean): void;
  87568. static get PurpleFireColors(): BABYLON.Color3[];
  87569. static get GreenFireColors(): BABYLON.Color3[];
  87570. static get RedFireColors(): BABYLON.Color3[];
  87571. static get BlueFireColors(): BABYLON.Color3[];
  87572. get autoGenerateTime(): boolean;
  87573. set autoGenerateTime(value: boolean);
  87574. get fireColors(): BABYLON.Color3[];
  87575. set fireColors(value: BABYLON.Color3[]);
  87576. get time(): number;
  87577. set time(value: number);
  87578. get speed(): BABYLON.Vector2;
  87579. set speed(value: BABYLON.Vector2);
  87580. get alphaThreshold(): number;
  87581. set alphaThreshold(value: number);
  87582. /**
  87583. * Serializes this fire procedural texture
  87584. * @returns a serialized fire procedural texture object
  87585. */
  87586. serialize(): any;
  87587. /**
  87588. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87589. * @param parsedTexture defines parsed texture data
  87590. * @param scene defines the current scene
  87591. * @param rootUrl defines the root URL containing fire procedural texture information
  87592. * @returns a parsed Fire Procedural BABYLON.Texture
  87593. */
  87594. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87595. }
  87596. }
  87597. declare module BABYLON {
  87598. /** @hidden */
  87599. export var grassProceduralTexturePixelShader: {
  87600. name: string;
  87601. shader: string;
  87602. };
  87603. }
  87604. declare module BABYLON {
  87605. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87606. private _grassColors;
  87607. private _groundColor;
  87608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87609. updateShaderUniforms(): void;
  87610. get grassColors(): BABYLON.Color3[];
  87611. set grassColors(value: BABYLON.Color3[]);
  87612. get groundColor(): BABYLON.Color3;
  87613. set groundColor(value: BABYLON.Color3);
  87614. /**
  87615. * Serializes this grass procedural texture
  87616. * @returns a serialized grass procedural texture object
  87617. */
  87618. serialize(): any;
  87619. /**
  87620. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87621. * @param parsedTexture defines parsed texture data
  87622. * @param scene defines the current scene
  87623. * @param rootUrl defines the root URL containing grass procedural texture information
  87624. * @returns a parsed Grass Procedural BABYLON.Texture
  87625. */
  87626. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87627. }
  87628. }
  87629. declare module BABYLON {
  87630. /** @hidden */
  87631. export var marbleProceduralTexturePixelShader: {
  87632. name: string;
  87633. shader: string;
  87634. };
  87635. }
  87636. declare module BABYLON {
  87637. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87638. private _numberOfTilesHeight;
  87639. private _numberOfTilesWidth;
  87640. private _amplitude;
  87641. private _jointColor;
  87642. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87643. updateShaderUniforms(): void;
  87644. get numberOfTilesHeight(): number;
  87645. set numberOfTilesHeight(value: number);
  87646. get amplitude(): number;
  87647. set amplitude(value: number);
  87648. get numberOfTilesWidth(): number;
  87649. set numberOfTilesWidth(value: number);
  87650. get jointColor(): BABYLON.Color3;
  87651. set jointColor(value: BABYLON.Color3);
  87652. /**
  87653. * Serializes this marble procedural texture
  87654. * @returns a serialized marble procedural texture object
  87655. */
  87656. serialize(): any;
  87657. /**
  87658. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87659. * @param parsedTexture defines parsed texture data
  87660. * @param scene defines the current scene
  87661. * @param rootUrl defines the root URL containing marble procedural texture information
  87662. * @returns a parsed Marble Procedural BABYLON.Texture
  87663. */
  87664. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87665. }
  87666. }
  87667. declare module BABYLON {
  87668. /** @hidden */
  87669. export var normalMapProceduralTexturePixelShader: {
  87670. name: string;
  87671. shader: string;
  87672. };
  87673. }
  87674. declare module BABYLON {
  87675. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87676. private _baseTexture;
  87677. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87678. updateShaderUniforms(): void;
  87679. render(useCameraPostProcess?: boolean): void;
  87680. resize(size: any, generateMipMaps: any): void;
  87681. get baseTexture(): BABYLON.Texture;
  87682. set baseTexture(texture: BABYLON.Texture);
  87683. /**
  87684. * Serializes this normal map procedural texture
  87685. * @returns a serialized normal map procedural texture object
  87686. */
  87687. serialize(): any;
  87688. /**
  87689. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87690. * @param parsedTexture defines parsed texture data
  87691. * @param scene defines the current scene
  87692. * @param rootUrl defines the root URL containing normal map procedural texture information
  87693. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87694. */
  87695. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87696. }
  87697. }
  87698. declare module BABYLON {
  87699. /** @hidden */
  87700. export var perlinNoiseProceduralTexturePixelShader: {
  87701. name: string;
  87702. shader: string;
  87703. };
  87704. }
  87705. declare module BABYLON {
  87706. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87707. time: number;
  87708. timeScale: number;
  87709. translationSpeed: number;
  87710. private _currentTranslation;
  87711. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87712. updateShaderUniforms(): void;
  87713. render(useCameraPostProcess?: boolean): void;
  87714. resize(size: any, generateMipMaps: any): void;
  87715. /**
  87716. * Serializes this perlin noise procedural texture
  87717. * @returns a serialized perlin noise procedural texture object
  87718. */
  87719. serialize(): any;
  87720. /**
  87721. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87722. * @param parsedTexture defines parsed texture data
  87723. * @param scene defines the current scene
  87724. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87725. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87726. */
  87727. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87728. }
  87729. }
  87730. declare module BABYLON {
  87731. /** @hidden */
  87732. export var roadProceduralTexturePixelShader: {
  87733. name: string;
  87734. shader: string;
  87735. };
  87736. }
  87737. declare module BABYLON {
  87738. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87739. private _roadColor;
  87740. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87741. updateShaderUniforms(): void;
  87742. get roadColor(): BABYLON.Color3;
  87743. set roadColor(value: BABYLON.Color3);
  87744. /**
  87745. * Serializes this road procedural texture
  87746. * @returns a serialized road procedural texture object
  87747. */
  87748. serialize(): any;
  87749. /**
  87750. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87751. * @param parsedTexture defines parsed texture data
  87752. * @param scene defines the current scene
  87753. * @param rootUrl defines the root URL containing road procedural texture information
  87754. * @returns a parsed Road Procedural BABYLON.Texture
  87755. */
  87756. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87757. }
  87758. }
  87759. declare module BABYLON {
  87760. /** @hidden */
  87761. export var starfieldProceduralTexturePixelShader: {
  87762. name: string;
  87763. shader: string;
  87764. };
  87765. }
  87766. declare module BABYLON {
  87767. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87768. private _time;
  87769. private _alpha;
  87770. private _beta;
  87771. private _zoom;
  87772. private _formuparam;
  87773. private _stepsize;
  87774. private _tile;
  87775. private _brightness;
  87776. private _darkmatter;
  87777. private _distfading;
  87778. private _saturation;
  87779. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87780. updateShaderUniforms(): void;
  87781. get time(): number;
  87782. set time(value: number);
  87783. get alpha(): number;
  87784. set alpha(value: number);
  87785. get beta(): number;
  87786. set beta(value: number);
  87787. get formuparam(): number;
  87788. set formuparam(value: number);
  87789. get stepsize(): number;
  87790. set stepsize(value: number);
  87791. get zoom(): number;
  87792. set zoom(value: number);
  87793. get tile(): number;
  87794. set tile(value: number);
  87795. get brightness(): number;
  87796. set brightness(value: number);
  87797. get darkmatter(): number;
  87798. set darkmatter(value: number);
  87799. get distfading(): number;
  87800. set distfading(value: number);
  87801. get saturation(): number;
  87802. set saturation(value: number);
  87803. /**
  87804. * Serializes this starfield procedural texture
  87805. * @returns a serialized starfield procedural texture object
  87806. */
  87807. serialize(): any;
  87808. /**
  87809. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87810. * @param parsedTexture defines parsed texture data
  87811. * @param scene defines the current scene
  87812. * @param rootUrl defines the root URL containing startfield procedural texture information
  87813. * @returns a parsed Starfield Procedural BABYLON.Texture
  87814. */
  87815. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87816. }
  87817. }
  87818. declare module BABYLON {
  87819. /** @hidden */
  87820. export var woodProceduralTexturePixelShader: {
  87821. name: string;
  87822. shader: string;
  87823. };
  87824. }
  87825. declare module BABYLON {
  87826. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87827. private _ampScale;
  87828. private _woodColor;
  87829. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87830. updateShaderUniforms(): void;
  87831. get ampScale(): number;
  87832. set ampScale(value: number);
  87833. get woodColor(): BABYLON.Color3;
  87834. set woodColor(value: BABYLON.Color3);
  87835. /**
  87836. * Serializes this wood procedural texture
  87837. * @returns a serialized wood procedural texture object
  87838. */
  87839. serialize(): any;
  87840. /**
  87841. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87842. * @param parsedTexture defines parsed texture data
  87843. * @param scene defines the current scene
  87844. * @param rootUrl defines the root URL containing wood procedural texture information
  87845. * @returns a parsed Wood Procedural BABYLON.Texture
  87846. */
  87847. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87848. }
  87849. }